REM CIVILIZATIONII SCENARIO EVENT-SWAPPING BATCH FILE
REM Created by Jorrit Vermeiren, jorrit_v@hotmail.com
REM
REM Any use of this file is encouraged as long as
REM I'm credited.
@ECHO OFF

IF NOT EXIST %0\..\Komnenai.scn GOTO error1
SET scenpath=%0\..

:paramcheck
IF "%1"=="/?" GOTO help
IF "%1"=="" GOTO change5to1
IF "%2"=="" GOTO find_delevent
SET DelEXE=%2
GOTO start


:find_delevent
IF EXIST C:\MPS\Civ2\delevent.exe SET DelEXE=C:\MPS\Civ2\delevent.exe
IF EXIST delevent.exe             SET DelEXE=delevent.exe
IF EXIST ..\delevent.exe          SET DelEXE=..\delevent.exe
IF EXIST ...\delevent.exe         SET DelEXE=...\delevent.exe
IF EXIST ....\delevent.exe        SET DelEXE=....\delevent.exe
IF EXIST .....\delevent.exe       SET DelEXE=.....\delevent.exe


:start
IF NOT EXIST %DelEXE% GOTO error2

IF NOT EXIST %scenpath%\events\events1.txt GOTO change1to2
IF NOT EXIST %scenpath%\events\events2.txt GOTO change2to3
IF NOT EXIST %scenpath%\events\events3.txt GOTO change3to4
IF NOT EXIST %scenpath%\events\events4.txt GOTO change4to5
IF NOT EXIST %scenpath%\events\events5.txt GOTO change5to1


:change1to2
IF NOT EXIST %scenpath%\events.txt GOTO error3
IF NOT EXIST %scenpath%\events\events2.txt GOTO error3
MOVE %scenpath%\events.txt %scenpath%\events\events1.txt
MOVE %scenpath%\events\events2.txt %scenpath%\events.txt
%DelEXE% %1
GOTO success


:change2to3
IF NOT EXIST %scenpath%\events.txt GOTO error3
IF NOT EXIST %scenpath%\events\events3.txt GOTO error3
MOVE %scenpath%\events.txt %scenpath%\events\events2.txt
MOVE %scenpath%\events\events3.txt %scenpath%\events.txt
%DelEXE% %1
GOTO success


:change3to4
IF NOT EXIST %scenpath%\events.txt GOTO error3
IF NOT EXIST %scenpath%\events\events4.txt GOTO error3
MOVE %scenpath%\events.txt %scenpath%\events\events3.txt
MOVE %scenpath%\events\events4.txt %scenpath%\events.txt
%DelEXE% %1
GOTO success

:change4to5
IF NOT EXIST %scenpath%\events.txt GOTO error3
IF NOT EXIST %scenpath%\events\events5.txt GOTO error3
MOVE %scenpath%\events.txt %scenpath%\events\events4.txt
MOVE %scenpath%\events\events5.txt %scenpath%\events.txt
%DelEXE% %1
GOTO success


:change5to1
IF NOT EXIST %scenpath%\events.txt GOTO error3
IF NOT EXIST %scenpath%\events\events1.txt GOTO back
IF NOT EXIST %scenpath%\events\events5.txt MOVE %scenpath%\events.txt %scenpath%\events\events5.txt
IF NOT EXIST %scenpath%\events\events4.txt MOVE %scenpath%\events.txt %scenpath%\events\events4.txt
IF NOT EXIST %scenpath%\events\events3.txt MOVE %scenpath%\events.txt %scenpath%\events\events3.txt
IF NOT EXIST %scenpath%\events\events2.txt MOVE %scenpath%\events.txt %scenpath%\events\events2.txt
MOVE %scenpath%\events\events1.txt %scenpath%\events.txt
%DelEXE% %1
GOTO back


:success
CLS
ECHO The event files have been swapped successfully!
ECHO Reload your savegame to continue the scenario.
ECHO.
GOTO end


:back
CLS
ECHO The event files have been put back to their original locations.
ECHO.
GOTO end


:error1
ECHO The scenario file could not be found. Please make sure this batch
ECHO file is located in the same directory as the scenario.
ECHO.
GOTO end


:error2
ECHO DELEVENT.EXE could not be found. Please specify the path to
ECHO DELEVENT.EXE (usually either the CivilizationII directory or
ECHO this scenario's directory).
ECHO.
PAUSE
GOTO help


:error3
ECHO One of the required event files could not be found! Please make
ECHO sure all files are in place.
ECHO.
GOTO end


:help
ECHO This file updates the events for a savegame of a Civilization II Scenario
ECHO that uses multiple event files.
ECHO Run this batch file without any arguments to reset the events files.
ECHO.
ECHO EVNTSWAP [drive1:][path1]savegame [[drive2:][path2]]
ECHO.
ECHO [drive1:][path1]savegame
ECHO			The name of your current savegame. The drive and path
ECHO			specifications are only required when this batch file isn't
ECHO			in the same directory of the savegame.
ECHO [drive2:][path2]
ECHO			The drive and path to DELEVENT.EXE. Only necessary if it can't
ECHO			be found automatically.
ECHO.
ECHO EXAMPLES:
ECHO evntswap caesar.sav C:\MPS\CIV2\SCENARIO\Rome
ECHO evntswap F:\Civ2\hannibal.sav
ECHO.
ECHO HINT: simply drag your savegame over this batch file in Windows Explorer to
ECHO avoid having to go to DOS. Of course, this doesn't work when you need to
ECHO specify the path to DELEVENT.EXE also.
GOTO end


:end
SET scenpath=
SET DelEXE=