[Tool] Self Cleaning Side Builder

Started by tirpider, September 15, 2013, 05:26:23 PM

Previous topic - Next topic
September 15, 2013, 05:26:23 PM Last Edit: October 02, 2013, 09:57:41 PM by tirpider
This may be redundant and/or silly, but I find it useful.

It's a batch file that builds a side.lvl and cleans up after itself.

It is inspired by the side builders released by Bamdur and the revised ones in Phobos's toolbox.  But I based the actual contents on the various munge.bat files in BFBuilder. Not sure if the commands are different across the versions.  Didn't check.

I did this cause the side builders are un-necessarily complex and redistribute the exe's from the BFBuilder folder.
Why do that when the tools are already there?

This doesn't change any of the known things about building a side. You still need the MSH, ODF, munged, folders and such, as well as all the properly named and set up REQ files. All this does is put the build process into a single, no-download, batch file.

FEATURES:
- puts all the side munging steps into one file so you don't have to follow threads through bat files to see what's happening.
- creates it's own _build and _output folders as needed.
- Operates exactly like the BFBuilder munge.bat without having to build an entire map to test/build a single unit/side
- doesn't care where you run it. It sets it's own path so you don't have to put it in a particular place.
- 0 size download. Just paste into your bat from the code tag below.

REQUIREMENTS:
- Must have the SWBF1 mod tools installed somewhere
- Must be able to edit the bat file. (any text editor will work.)
- A side folder setup exactly like you would for BFBuilder or any of the other builders.

USAGE:
- Put the bat file in a folder
- Put your side folder in there with it. (see the pic attached to this post.)
- edit the top of the batch file
- run it.
- the side.lvl will be in the _OUTPUT folder waiting for you.

ISSUES:
- I have yet to munge a FPM with BFBuilder or any of the side builders. So this probably won't either. The commands for it are in place, but it fails to create the FPM\side.lvl.  If anyone knows how to get them munging, let me know and I'll update this bat.
- It doesn't include the soundmunge lines. This may come in the future.


There are 3 lines at the top of the bat file to edit.

@set SIDETAG=TUS
Change TUS to the name of your side.

@set TOOLSFOLDER=C:\Lucasarts\BFBuilder\ToolsFL\Bin
Change C:\Lucasarts\BFBuilder\ToolsFL\Bin to the location of your ToolsFL\Bin folder.
If it contains spaces, you should put quotes around it.

@set KEEPBUILDFOLDER=false
When set to false it will remove all the files in it's _build folder. Just like running clean.bat.
When set to true it will leave it all.


So here it is:

@ECHO off
@ECHO ------------------------------------------------------
@ECHO INITIAL SETUP
@ECHO ------------------------------------------------------

@REM  ******************************************************
@REM  change sidetag to indicate the filename of your side
@REM  ******************************************************
@set SIDETAG=TUS

@REM  ******************************************************
@REM  change TOOLSFOLDER to the location of
@REM  ToolsFL\Bin so it can find the mungers
@REM  Enclose it in quotes if it contains a space.
@REM  ******************************************************
@set TOOLSFOLDER=C:\Lucasarts\BFBuilder\ToolsFL\Bin

@REM  ******************************************************
@REM  set to FALSE to delete the _BUILD folder
@REM  TRUE will leave it
@REM  ******************************************************
@set KEEPBUILDFOLDER=false

@REM **** don't chnge anything below this line *********************************

@REM  ******************************************************
@REM  set up the variables
@REM  ******************************************************
@set SOURCEFOLDER=%CD%\%SIDETAG%

@set BUILDFOLDER=%CD%\_BUILD\%SIDETAG%
if NOT EXIST %BUILDFOLDER% md %BUILDFOLDER%

@set OUTPUTFOLDER=%CD%\_OUTPUT\%SIDETAG%\SIDE
if NOT EXIST %OUTPUTFOLDER% md %OUTPUTFOLDER%

@REM  ******************************************************
@rem  not sure FPM is set up right
@REM  ******************************************************
@set FPMREQFOLDER=%CD%\%SIDETAG%\REQ\FPM
@set FPMOUTPUTFOLDER=%CD%\_OUTPUT\%SIDETAG%\FPM
if NOT EXIST %FPMOUTPUTFOLDER% md %FPMOUTPUTFOLDER%

@REM  ******************************************************
@REM  check the tools folder
@REM  ******************************************************
if NOT EXIST %TOOLSFOLDER% goto ERRORTOOLS
if NOT EXIST %TOOLSFOLDER%\odfmunge.exe goto ERRORTOOLS
if NOT EXIST %TOOLSFOLDER%\modelmunge.exe goto ERRORTOOLS
if NOT EXIST %TOOLSFOLDER%\texturemunge.exe goto ERRORTOOLS
if NOT EXIST %TOOLSFOLDER%\configmunge.exe goto ERRORTOOLS
if NOT EXIST %TOOLSFOLDER%\levelpack.exe goto ERRORTOOLS

@REM  ******************************************************
@REM  check the side source folder
@REM  ******************************************************
if NOT EXIST %SOURCEFOLDER% goto ERRORSIDETAG

@setlocal
@set PATH=%TOOLSFOLDER%;%PATH%

@ECHO ------------------------------------------------------
@ECHO copy pre-munged files
@ECHO ------------------------------------------------------
copy %SOURCEFOLDER%\munged\*.*  %BUILDFOLDER%\

@ECHO ------------------------------------------------------
@ECHO munge ODF files
@ECHO ------------------------------------------------------
odfmunge -sourcedir %SOURCEFOLDER% -platform pc -inputfile !*.odf -outputdir %BUILDFOLDER%\ -checkdate -continue

@ECHO ------------------------------------------------------
@ECHO munge models
@ECHO ------------------------------------------------------
modelmunge -sourcedir %SOURCEFOLDER% -platform pc -inputfile !*.msh -outputdir %BUILDFOLDER%\ -checkdate -maxbones 16 -keep collision -continue -righthanded

@ECHO ------------------------------------------------------
@ECHO munge Textures
@ECHO ------------------------------------------------------
texturemunge -sourcedir %SOURCEFOLDER% -platform pc -inputfile !*.tga !*.pic -outputdir %BUILDFOLDER%\ -checkdate -continue

@ECHO ------------------------------------------------------
@ECHO munge Effects
@ECHO ------------------------------------------------------
configmunge -sourcedir %SOURCEFOLDER% -platform pc -inputfile effects\*.fx -outputdir %BUILDFOLDER%\ -checkdate -continue

@ECHO ------------------------------------------------------
@ECHO pack LVLs based on the \REQ folder
@ECHO ------------------------------------------------------
levelpack -sourcedir %SOURCEFOLDER% -platform pc -inputdir %BUILDFOLDER%\ -outputdir %BUILDFOLDER%\ -inputfile REQ\*.req -continue -checkdate

@ECHO ------------------------------------------------------
@ECHO pack the side LVL
@ECHO ------------------------------------------------------
levelpack -sourcedir %SOURCEFOLDER% -platform pc -inputdir %BUILDFOLDER%\ -outputdir %OUTPUTFOLDER%\ -inputfile %SIDETAG%.req -continue -checkdate

@ECHO ------------------------------------------------------
@ECHO pack the FPM LVLs
@ECHO ------------------------------------------------------
@rem  not sure FPM is set up right
for /D %%A in (%FPMREQFOLDER%\*) do levelpack -sourcedir %SOURCEFOLDER% -platform pc -inputdir %BUILDFOLDER%\ -outputdir %FPMOUTPUTFOLDER%\%%~nxA\ -inputfile %%A\*.req -continue -checkdate

endlocal

@ECHO ------------------------------------------------------
@ECHO Cleanup the useless mess and
@ECHO Show MungeLog if it exists
@ECHO ------------------------------------------------------
@if /i %KEEPBUILDFOLDER%==FALSE rd /s /q %BUILDFOLDER%
@del/s/q *.log
if EXIST MungeLog.txt Notepad.exe Mungelog.txt

@ECHO ------------------------------------------------------
@ECHO Done Munging, Potential errors can be found in Mungelog.txt
@ECHO ------------------------------------------------------
@goto END

@REM  ******************************************************
@REM  error reports
@REM  ******************************************************
:ERRORSIDETAG
@ECHO ------------------------------------------------------
@ECHO %SOURCEFOLDER% does not exist.
@ECHO
@ECHO Edit the set SIDETAG= line of this file.
@ECHO ------------------------------------------------------
@goto END

:ERRORTOOLS
@ECHO ------------------------------------------------------
@ECHO %TOOLSFOLDER%
@ECHO does not exist or does not contain all the mungers.
@ECHO
@ECHO Edit the set TOOLSFOLDER= line of this file.
@ECHO ------------------------------------------------------
@goto END

:END
PAUSE


If you have any questions/issues/internet cats, please post them below.

-edit
- fixed :ERRORSIDETAG message. does not affect how the bat file works.
- Changed a comment from: @ECHO pre-pack munged files into LVLs based on REQs created by the mungers
    to: @ECHO pack LVLs based on the \REQ folder
- Just noticed SK already had self cleaning in some mungers. So this isn't a new thing, but here it is anyway.

nice work i will add this feature to the next modders toolbox

Just going to say that cleaning your textures and models each time you munge is going to increase your munge time quite drastically. (That is what this does right? Auto-Cleans your sides?)

Yep, that's what it does.

The reason for including the cleaning bit is that I wanted a discrete, one-file solution.
You can set the KEEPBUILDFOLDER to true, and it will keep it.
Then to clean, just manually delete the side folder from _build.

I generally like to use a fresh munge every time (regardless of the time it takes).  If I have files I know I won't change, I move them from the build folder to the \munged folder with the animations. But that's mainly to reduce the clutter on the screen during the munge to make identifying modelmunge errors easier.