@echo off
rem ===================================================
rem BGAME PRODUCTION TC BAT INSTALLER AND LAUNCHER v4.0
rem COPYRIGHT MOLOCH, BGAME PRODUCTIONS,     1998/2000.
rem ===================================================
rem       STARSHIP TROOPERS TOTAL CONVERSION UMP
rem ===================================================

:inilogic
if "%1"=="/tcdetect" goto tcdetect
if exist sst_ump.ins goto installed

:inisetup
if not exist sst_full.ins goto snotc

:setupgo
cls
if not exist RESOURCE.001 goto whoops
goto okgo

:whoops
echo =============================================================================
echo         STARSHIP TROOPERS TC USERMAP PACKAGE, BGAME PRODUCTIONS 2000.
echo =============================================================================
echo.
echo Resource files not found, please copy all UMP data files into this directory.
echo.
echo [ I have read the above and I understand it completely ]
pause > nul
goto exit

:okgo
echo =============================================================================
echo         STARSHIP TROOPERS TC USERMAP PACKAGE, BGAME PRODUCTIONS 2000.
echo =============================================================================
echo DISCLAIMER:
echo.
echo Following software is called the Starship Troopers TC UserMap Package. This 
echo enables building of the SST TC user maps using the Duke Nukem BUILD editor.
echo.
echo UMP requires installed version of BUILD (any version) to function!
echo.
echo By installing the SST TC UMP, you hereby agree with the terms and you are
echo installing this software at your own risk. Starship Troopers TC UserMap
echo Package is provided "as-is" and there are no guarantees of any kind.
echo.
echo [ CTRL+BREAK to cancel the installation, or any other key to continue... ]
pause > nul

:secpage
cls
if not exist build.exe goto nobuild
goto step1


:nobuild
echo =============================================================================
echo         STARSHIP TROOPERS TC USERMAP PACKAGE, BGAME PRODUCTIONS 2000.
echo =============================================================================
echo INSTALLATION STOPPED; BUILD IS NOT PRESENT
echo.
echo SST TC UserMap Package Installation consists of several steps. Everything,
echo except for one thing, is handled by this setup program. This one thing is the
echo BUILD editor.                                                                 
echo.
echo Before this setup can proceed, BUILD has to be installed into this directory.
echo Since you are reading this, I presume you know how to install BUILD. Please
echo copy all BUILD files in here and then continue the installation.
echo.
echo [ I have read the above and I understand it completely ]
pause >nul
goto exit

:step1
echo =============================================================================
echo         STARSHIP TROOPERS TC USERMAP PACKAGE, BGAME PRODUCTIONS 2000.
echo =============================================================================
echo.
echo This setup will now extract the UMP art files. To edit SST TC maps, you need
echo a different set of art files, and that's exactly what this art pack does.
echo.
echo However, you cannot use UMP art files to play the game because some special
echo sprites that are normally invisible will appear in the game and look, well, 
echo ugly. ;)
echo Thus, you will have to use this batch file to load the BUILD editor. Usage
echo is very simple, just run it and it will backup game art files and install the
echo BUILD art, then undo the process when you exit the BUILD. Don't worry, it's
echo very fast, doesn't require any extra disk space and is designed to cope with
echo the regular BUILD crashes. :)
echo.
echo [ I have read the above and I understand it completely ]
pause >nul

md STMAPFAQ
if exist names.h del names.h
ren RESOURCE.001 UMP001.ART
ren RESOURCE.002 UMP003.ART
ren RESOURCE.003 UMP004.ART
ren RESOURCE.004 UMP005.ART
ren RESOURCE.005 UMP006.ART
ren RESOURCE.006 UMP007.ART
ren RESOURCE.007 UMP008.ART
ren RESOURCE.008 UMP009.ART
ren RESOURCE.009 UMP013.ART
ren RESOURCE.010 NAMES.H
move RESOURCE.011 STMAPFAQ\SSTSound.exe
move RESOURCE.012 STMAPFAQ\STMapFAQ.txt
move RESOURCE.013 STMAPFAQ\Ar.map
move RESOURCE.014 STMAPFAQ\Bugholes.map
move RESOURCE.015 STMAPFAQ\Ladders.map
move RESOURCE.016 STMAPFAQ\Sparks.map
move RESOURCE.017 STMAPFAQ\Template.txt
move RESOURCE.018 STMAPFAQ\TCMaps.txt
cls


:finished
echo DO NOT DELETE!!!  > sst_ump.ins
echo =============================================================================
echo         STARSHIP TROOPERS TC USERMAP PACKAGE, BGAME PRODUCTIONS 2000.
echo =============================================================================
echo INSTALLATION COMPLETED
echo.
echo This directory now contains several new art files, all with the name format
echo UMPxxx.ART where xxx is a number. These are the UMP art files, so leave them
echo alone. They are required.
echo.
echo Also installed is SST TC MapFAQ, (you can view it in NotePad or any other
echo text viewer), several tutorial maps, TC levels credits and a new template. 
echo Everything is tucked away nicely in the subdirectory STMAPFAQ.
echo.
echo To uninstall UMP, simply delete all UMPxxx.ART files and the directory
echo STMAPFAQ.
echo.
echo Press a key... or die waiting. ;-)
pause > nul
cls

echo =============================================================================
echo         STARSHIP TROOPERS TC USERMAP PACKAGE, BGAME PRODUCTIONS 2000.
echo =============================================================================
echo QUICK START
echo.
echo To run UMP BUILD, type "UMP" and press enter. You can also supply a map file
echo as an argument, i.e., any of following will start BUILD
echo.
echo    UMP usermap.map
echo    UMP.BAT
echo    UMP
echo.
echo EXTREMELY IMPORTANT * EXTREMELY IMPORTANT * EXTREMELY IMPORTANT * READ!!!
echo EXTREMELY IMPORTANT * EXTREMELY IMPORTANT * EXTREMELY IMPORTANT * READ!!!
echo. 
echo If (beter said, when) BUILD crashes on you, DON'T DO ANYTHING before you
echo run UMP.BAT again. This program will detect if BUILD has crashed and react
echo accordingly. Deleting and removing files will just result in a mess and
echo you will have to reinstall both the TC and the UMP, so don't do it!
echo Running the TC after a BUILD crash will also result in the incorrect art
echo files to be loaded, so once again, run the UMP.BAT again after each crash.
echo
echo.
pause > nul
goto exit


:snotc
cls
echo =============================================================================
echo         STARSHIP TROOPERS TC USERMAP PACKAGE, BGAME PRODUCTIONS 2000.
echo =============================================================================
echo INSTALLATION ERROR; NO SST TC FOUND
echo.
echo UserMap Package requires installed full version of Starship Troopers TC.
echo The SST TC is either not installed, or it was installed incorrectly.
echo.
echo Setup cannot continue.
echo.
echo [ Press any key to exit ]
pause > nul
goto exit

:installed
if exist sstbuild.tmp goto crashed
goto run

:crashed
echo BUILD crash was detected and fixed...
echo Hit a key.
pause > nul
cls
goto runbuild

:run
echo DO NOT DELETE!!! > sstbuild.tmp

rem Backup TC art
ren TILES001.ART UMPTMP1.ART
ren TILES003.ART UMPTMP2.ART
ren TILES004.ART UMPTMP3.ART
ren TILES005.ART UMPTMP4.ART
ren TILES006.ART UMPTMP5.ART
ren TILES007.ART UMPTMP6.ART
ren TILES008.ART UMPTMP7.ART
ren TILES009.ART UMPTMP8.ART
ren TILES013.ART UMPTMP9.ART

rem Do the stuff
echo UMP is preparing Build...
copy UMP001.ART TILES001.ART >nul
copy UMP003.ART TILES003.ART >nul
copy UMP004.ART TILES004.ART >nul
copy UMP005.ART TILES005.ART >nul
copy UMP006.ART TILES006.ART >nul
copy UMP007.ART TILES007.ART >nul
copy UMP008.ART TILES008.ART >nul
copy UMP009.ART TILES009.ART >nul
copy UMP013.ART TILES013.ART >nul
echo.
echo Done.
cls
:runbuild
build %1
echo.
echo UMP hibernated Build until next use.
rem Remove UMP art
del TILES001.ART
del TILES003.ART
del TILES004.ART
del TILES005.ART
del TILES006.ART
del TILES007.ART
del TILES008.ART
del TILES009.ART
del TILES013.ART

rem Get the TC working again
ren UMPTMP1.ART TILES001.ART 
ren UMPTMP2.ART TILES003.ART
ren UMPTMP3.ART TILES004.ART
ren UMPTMP4.ART TILES005.ART
ren UMPTMP5.ART TILES006.ART
ren UMPTMP6.ART TILES007.ART
ren UMPTMP7.ART TILES008.ART
ren UMPTMP8.ART TILES009.ART
ren UMPTMP9.ART TILES013.ART
del sstbuild.tmp
goto exit

:tcdetect
echo TC launcher call detected, trying to fix...
rem Remove UMP art
if exist UMPTMP1.ART del TILES001.ART
if exist UMPTMP2.ART del TILES003.ART
if exist UMPTMP3.ART del TILES004.ART
if exist UMPTMP4.ART del TILES005.ART
if exist UMPTMP5.ART del TILES006.ART
if exist UMPTMP6.ART del TILES007.ART
if exist UMPTMP7.ART del TILES008.ART
if exist UMPTMP8.ART del TILES009.ART
if exist UMPTMP9.ART del TILES013.ART

rem Get the TC working again
ren UMPTMP1.ART TILES001.ART 
ren UMPTMP2.ART TILES003.ART
ren UMPTMP3.ART TILES004.ART
ren UMPTMP4.ART TILES005.ART
ren UMPTMP5.ART TILES006.ART
ren UMPTMP6.ART TILES007.ART
ren UMPTMP7.ART TILES008.ART
ren UMPTMP8.ART TILES009.ART
ren UMPTMP9.ART TILES013.ART
del sstbuild.tmp
goto hardexit

:exit
echo.
echo SST TC UMP Patcher v1.0

:hardexit

