@echo off
rem                                 Sound setup v1.1
rem
rem                                        for
rem
rem                              THE CONQUEST OF MEXICO   
rem
rem                      by Jesús Balsinde (jbalsinde@ucsd.edu)
rem
rem
rem                          This batch file was created by
rem
rem                     Christian Schlobach (uzsn8y@uni-bonn.de)
rem
rem
rem This file can be adapted and used by anybody who wishes to do so. I'd be happy
rem about a credit though ;-) Comments and questions are always welcome! If you have
rem a problem with this file please contact me and I will try to solve it.
rem
rem This batch file really does nothing else but copying the appropriate sound files
rem from the main Civ2 sound directory (or from the original Civ2 CD) to the sound
rem directory of the scenario. However, I can't be held responsible for any damages
rem which this file might cause (especially if improperly used). So, if your computer
rem blows up don't blame me!
rem (Well, don't worry though! Batch files don't blow up computers!)

if exist mexico.scn goto parametercheck
echo Please make sure that SNDSETUP.BAT is located in the same directory as the
echo scenario file of THE CONQUEST OF MEXICO (MEXICO.SCN).
goto end

:parametercheck
if "%1"=="" goto check
set source=%1
if "%2"=="" goto step0
set target=%2
goto step1

:check
if exist ..\civ2.exe set source=..\sound\
if exist ...\civ2.exe set source=...\sound\
if exist ....\civ2.exe set source=....\sound\
if exist .....\civ2.exe set source=.....\sound\
if exist ......\civ2.exe set source=......\sound\
if exist .......\civ2.exe set source=.......\sound\
if exist ........\civ2.exe set source=........\sound\
if exist .........\civ2.exe set source=.........\sound\
if "%source%"=="" goto default
set target=sound\
goto step1

:default
echo Your main Civ2 sound directory could not be located. Please use either the
echo default settings or rerun SNDSETUP.BAT with the source path as parameter.
echo.
echo Do you want to use the default source and target paths?
echo (source:  c:\mps\civ2\sound\)
echo (target:  sound\)    [This is the scenario's default sound subdirectory.]
echo.
choice /c:yn Yes or No?
if errorlevel 2 goto error1
call sndsetup c:\mps\civ2\sound\ sound\
goto end

:step0
set target=sound\

:step1
echo Is this correct?
echo The source directory is:
echo.
dir %source%..\s?und
echo.
echo Ignore "file not found" if the source directory is not called "sound".
echo In this case the relevant directory is displayed above it.
echo.
choice /c:yn Yes or No?
if errorlevel 2 goto error1
echo.
echo The target directory is:
echo.
dir %target%..\s?und
echo.
choice /c:yn Yes or No?
if errorlevel 2 goto error1
if not exist %target%extra5.wav goto error2
echo Commence copying ...
copy %target%extra5.wav %target%extra2.wav
copy %target%extra5.wav %target%medgun.wav

:step2
if not exist %source%infantry.wav goto error3
if not exist %source%swordfgt.wav goto error3
if not exist %source%navbttle.wav goto error3
if not exist %source%smallexp.wav goto error3
if not exist %source%largexpl.wav goto error3
copy %source%infantry.wav %target%cavalry.wav
copy %source%navbttle.wav %target%extra3.wav
copy %source%swordfgt.wav %target%fire---.wav
copy %source%swordfgt.wav %target%extra7.wav
copy %source%swordfgt.wav %target%extra8.wav
copy %source%swordfgt.wav %target%elephant.wav
copy %source%swordfgt.wav %target%swordfgt.wav
copy %source%swordfgt.wav %target%catapult.wav
copy %source%swordfgt.wav %target%infantry.wav
copy %source%swordfgt.wav %target%mchnguns.wav
copy %source%smallexp.wav %target%extra4.wav
copy %source%largexpl.wav %target%extra6.wav
echo.
echo Sound effects for "THE CONQUEST OF MEXICO" successfully installed!
goto end

:error1
echo.
echo Please rerun SNDSETUP.BAT and specify the source and (if necessary) the
echo target directory.
echo.
goto syntax

:error2
echo The sound file extra5.wav was not found. Possible reasons for this are:
echo a) You have not extracted it from mexico.zip to the scenario sound directory.
echo b) You have specified the wrong target directory.
echo c) The default target directory doesn't correspond to the actual target
echo    directory. In this case specify the source *and* target directory.
echo.
echo Please identify the problem, solve it and rerun SNDSETUP.BAT!
pause
goto syntax

:error3
echo At least one of the sound files from the Civ2 sound directory was not found.
echo Possible reasons for this are:
echo a) You have specified the wrong source directory.
echo b) The default source directory doesn't correspond to the actual source
echo    directory. 
echo    In case of a) or b) specify the correct directory when running sndsetup.bat.
echo c) There are sound files missing in the specified directory.
echo    The required sound files are: navbttle.wav
echo                                  swordfgt.wav
echo                                  infantry.wav
echo                                  smallexp.wav
echo                                  largexpl.wav
echo.
echo Please identify the problem, solve it and rerun SNDSETUP.BAT!
pause
goto syntax

:syntax
echo Please use the following syntax:
echo.
echo [path]sndsetup [source dir] [target dir]
echo.
echo [path]              If necessary specify the path for SNDSETUP.BAT.
echo [source dir]        The path of the main Civ2 sound directory.
echo [target dir]        The path of the sound directory for this scenario.
echo.
echo Don't forget the backslash at the end of the source and target path.
echo.
echo If running SNDSETUP.BAT without any parameters doesn't work try running 
echo SNDSETUP.BAT with the above mentioned parameters.
echo.
echo Example:
echo c:\civ2\scenario\mexico\sndsetup c:\civ2\sound\ c:\civ2\scenario\mexico\sound\
echo.
echo SNDSETUP.BAT was terminated. Please rerun.
goto end

:end
set source=
set target=
