rem This is the install script
rem Don't forget to update the gamePt script!

echo Setting up the directory for ImagiNation
godir %1:%6 CantCreate
del *.so
del *.to
del *.p56
del *.v56
del *.snd
del resource.*
del *.drv
del *.dll
del *.exe
del hostaddr.tim
del landaddr.tim
del landcfg.tim
del *.prf
rem delete old 2.3 BBS indexes because of new format.
del *.bbs

godir %1:%6\CC CantCC
godir %1:%6\CC\VMF CantCC
godir %1:%6\CC
rem Get the player data from the main directory if it's not already in cc
if not exist player.dir copy ..\*.dta /q
rem Ooops! We copied the password file too!  Get rid of it!
if exist pass_set.dta del pass_set.dta
if not exist player.dir del ..\*.dta
if not exist player.dir copy ..\player.dir /q
del ..\player.dir
del *.so
del *.to
del *.p56
del *.v56
del *.snd
del *.pbm
del resource.*
del *.drv
del *.dll
del *.exe
del *.CFG
del *.prf

godir %1:%6\SL CantSL
godir %1:%6\SL\VMF CantSL
godir %1:%6\SL
del *.so
del *.to
del *.p56
del *.v56
del *.snd
del *.pbm
del resource.*
del *.drv
del *.dll
del *.exe
del *.CFG
del *.prf

godir %1:%6\LL CantLL
godir %1:%6\LL\VMF CantLL
godir %1:%6\LL
rem Try to keep any old personal ads so that people can still match
rem personalities with profiles submitted from previous installations
if exist *.pad rename *.pad *._pa > NUL
del *.so
del *.to
del *.p56
del *.v56
del *.snd
del resource.*
del *.drv
del *.dll
del *.exe
del *.CFG                                 
del *.prf
if exist *._pa rename *._pa *.pad > NUL

godir %1:%6\ARENA CantARENA
godir %1:%6\ARENA\VMF CantARENA
godir %1:%6\ARENA
rem do not delete 912.so - 941.so, or 12.v56 - 25.v56!
rem There are no 942-949 patches or 26-29 views in Arena 
rem so this technique should not fail to delete unneeded 
rem things either.
if exist 91?.so rename 91?.so *._so > NUL
if exist 92?.so rename 92?.so *._so > NUL
if exist 93?.so rename 93?.so *._so > NUL
if exist 94?.so rename 94?.so *._so > NUL
if exist 1?.v56 rename 1?.v56 *._v5 > NUL
if exist 2?.v56 rename 2?.v56 *._v5 > NUL
del *.so
del *.to
del *.p56
del *.v56
del *.snd
del resource.*
del *.drv
del *.dll
del *.exe
if exist 91?._so rename 91?._so 91?.so > NUL 
if exist 92?._so rename 92?._so 92?.so > NUL 
if exist 93?._so rename 93?._so 93?.so > NUL 
if exist 94?._so rename 94?._so 94?.so > NUL 
if exist 1?._v5  rename 1?._v5  1?.v56 > NUL 
if exist 2?._v5  rename 2?._v5  2?.v56 > NUL 
rem  don't nuke *.cfg so gamelist.cfg doesn't get wiped
del gameinfo.tim
del *.prf

REM  Kill any CUC stuff lying around
godir %1:%6\SHOPADV CantCUC
del *.*
godir %1:%6\SHOPADV\VMF CantCUC
del *.*
godir %1:%6\SHOPADV
rd VMF > NUL
godir %1:%6
rd SHOPADV > NUL

godir %1:%6\BARON CantBaron
del volume.*
del *.exe

godir %1:%6\GOLF CantGolf
del *.*

godir %1:%6\YSERBIUS CantYserbius
rem Copy the characters and map to the root in case the whole 
rem directory structure gets blown away.
copy mychars.dat ..\ysrbchar.dat /q
copy automaps.dat ..\ysrbmaps.dat /q
godir %1:%6\YSERBIUS\SAVE CantYserbius
copy ..\mychars.dat /q
copy ..\automaps.dat /q
godir %1:%6\YSERBIUS CantYserbius
rem del *.*
rem  Changed to not kill off-line yserbius installations
del AD09.XMI
del AD10.XMI
del AD11.XMI
del AD12.XMI
del AD13.XMI
del AD14.XMI
del AD15.XMI
del AD16.XMI
del AD17.XMI
del AD18.XMI
del AD19.XMI
del AD20.XMI
del AD21.XMI
del AD22.XMI
del AD23.XMI
del AD24.XMI
del AD25.XMI
del AD26.XMI
del ADLIB.ADV
del ADTIMBRE.GTL
del ANIM_SEQ
del AUTOMAPS.NEW
del CGENN.EXE
del HELP.DAT
del IMAGES.DAT
del MAIN.TSU
del MT00.XMI
del MT01.XMI
del MT02.XMI
del MT04.XMI
del MT05.XMI
del MT06.XMI
del MT07.XMI
del MT08.XMI
del MT09.XMI
del MT10.XMI
del MT11.XMI
del MT12.XMI
del MT13.XMI
del MT14.XMI
del MT15.XMI
del MT16.XMI
del MT17.XMI
del RESOURCE.031
del RESOURCE.032
del RESOURCE.033
del RESOURCE.034
del RESOURCE.036
del RESOURCE.037
del RESOURCE.038
del RESOURCE.039
del RESOURCE.040
del WALLS.DAT
del DARKSTRT.EXE
del SBFM.ADV
del MT18.XMI
del MT19.XMI
del MT20.XMI
del MT21.XMI
del MT22.XMI
del MT23.XMI
del MT24.XMI
del MT25.XMI
del MT26.XMI
del MT32MPU.ADV
del MYCHARS.NEW
del PALETTE.DAT
del RESOURCE.003
del RESOURCE.004
del RESOURCE.005
del RESOURCE.006
del RESOURCE.008
del RESOURCE.009
del RESOURCE.010
del RESOURCE.011
del RESOURCE.012
del RESOURCE.014
del RESOURCE.015
del RESOURCE.019
del RESOURCE.020
del RESOURCE.022
del RESOURCE.024
del RESOURCE.025
del RESOURCE.026
del RESOURCE.027
del RESOURCE.028
del RESOURCE.030
del RESOURCE.035
del RESOURCE.029
del RESOURCE.016
del RESOURCE.002
del RESOURCE.023
del RESOURCE.021
del RESOURCE.018
del RESOURCE.017
del RESOURCE.013
del RESOURCE.007
del RESOURCE.001
del MYCHARS .DAT
del AUTOMAPS.DAT
del AD00.XMI
del AD01.XMI
del AD02.XMI
del AD04.XMI
del AD05.XMI
del AD06.XMI
del AD07.XMI
del AD08.XMI
godir %1:%6


rem  Is there space?
space %1: %7 NoSpace
if errorlevel 1 goto NoSpace

echo Copying files...

copy    %2:READ.ME /q
echo    Installing Re-Installation Files
copy    %2:INSTTSN.EXE
copy    %2:BOOTDISK.EXE
copy    %2:NEWPHONE.EXE
rem copy        %2:puff.exe
copy    %2:REINST.BAT INSTALL.BAT
rem copy        %2:LSCIGET.EXE
copy    %2:INSTALL.TXT
copy    %2:DRIVERS.TXT
copy    %2:INSTALL.HLP
copy    %2:INSTTSN.TXT
copy    %2:INSTTSN.HLP
copy    %2:MODEM.TXT
copy    %2:PHONE.TXT
copy    %2:RBJOY.EXE
copy    %2:ID.EXE /q
copy    %2:W31READ.TXT
copy    %2:W95READ.TXT
copy    %2:OS2READ.TXT


rem Moved into volumes
rem echo    Installing ImagiNation executive
rem copy    %2:TSNEXEC.EXE
rem echo Decompressing executive
rem puff        /D _SNEXEC.EXE

rem Only overwrite TSN.PRG file for no version or lesser version
overExistingVer NoExVer SameExVer LessExVer GreatExVer
:NoExVer
copy %2:TSN.PRG
goto DoneTSNPrgCopy
:SameExVer
rem Don't copy over TSN.PRG file.
if not exist TSN.PRG copy %2:TSN.PRG
goto DoneTSNPrgCopy
:LessExVer
copy %2:TSN.PRG
goto DoneTSNPrgCopy
:GreatExVer
rem Don't copy over TSN.PRG file.  Assume format will not change.
if not exist TSN.PRG copy %2:TSN.PRG
goto DoneTSNPrgCopy
:DoneTSNPrgCopy


copy    %2:MODEM.DRV
rem remove this after AIT conversion
copy    %2:NOBRK.DRV
copy    %2:EASYLNK.DRV
copy    %2:INN.ICO
copy    %2:INN.PIF
copy    %2:PATCHPIF.EXE
patchpif %1 %6 > nul
copy    %2:HOSTADDR
copy    %2:tsnver
echo @echo off>INN.BAT
echo tsnexec DEFAULT>>INN.BAT

rem Moved into volumes
rem echo    Installing SCI and Drivers
rem copy    %2:LSCITV.EXE
rem echo Decompressing interpreter
rem puff        /D _SCITV.EXE

copy    %2:GAME.CFG
copy    %2:LAND.CFG
copy    %2:LLSYSTEM.DAT
copy    %2:TWEAKER.DRV
copy    %2:MT32.DRV
copy    %2:MT32.NL
copy    %2:ADL.DRV
copy    %2:SNDBLAST.DRV
rem copy    %2:TANDYXL.DRV
copy    %2:IBMKBD.DRV
copy    %2:_LNULL.DLL
rem echo Decompressing null-dll
puff    /D _LNULL.DLL
copy    %2:VGA320.DRV /q
copy    %2:_RAPH256.DLL /q
rem echo Decompressing graph256 dll
puff    /D _RAPH256.DLL
copy    %2:EGA640.DRV /q

echo %3>lsci.cfg
echo %4>%1:%6\tsn.cfg
echo %5>%1:%6\PASS_SET.DTA

rem  Get the volumes installed from their blender file
rem  ALSO round-about method for finding out installed video config

echo    Setting Up Video Drivers
echo  dll = ..\graph256.dll>>lsci.cfg
echo  dll = ..\nlnull.dll>>lsci.cfg
echo  pathStr = ..\>>lsci.cfg
rem   echo  hostID = 311083420303>>lsci.cfg
echo  virtualDir = VMF>>lsci.cfg
echo  swapSize = 100>>lsci.cfg
echo  resource = .\;..\>>lsci.cfg

rem  copy the gamelist.cfg from disk one to the arena directory
shouldInstall ARENA dontcopyGamelist
if not exist %1:%6\ARENA\GAMELIST.CFG copy %2:GAMELIST.CFG %1:%6\ARENA\GAMELIST.CFG /q
:dontcopyGamelist


rem echo  Installing the License Agreement
copy %2:license.txt

rem  start the de-archiver
defuse %2 %1 part %6

rem Copy any patches which have found their way onto the final disk
godir %1:%6
copy    %2:allPatch\*.* /q
if exist _*.* puff /D _*.*

godir %1:%6\CC
copy    %2:ccPatch\*.* /q
if exist _*.* puff /D _*.*

shouldInstall SL dontSL
godir %1:%6\SL
copy    %2:slPatch\*.* /q
if exist _*.* puff /D _*.*
:dontSL

shouldInstall LL dontLL
godir %1:%6\LL
copy    %2:llPatch\*.* /q
if exist _*.* puff /D _*.*
:dontLL

shouldInstall ARENA dontARENA
godir %1:%6\ARENA
copy    %2:arPatch\*.* /q
if exist _*.* puff /D _*.*
:dontARENA

shouldInstall BARON dontBARON
echo UnCompressing "Red Baron"
godir %1:%6\BARON
rem puff /D _*.*
rem  Copy RBJOY.EXE from main directory to BARON directory
copy ..\rbjoy.exe /q

copy    %2:redpatch\*.* /q
if exist _*.* puff /D _*.*
:dontBARON

shouldInstall GOLF dontGOLF
echo UnCompressing "3-D Golf"
godir %1:%6\GOLF
rem puff /D _*.*

copy    %2:glfPatch\*.* /q
if exist _*.* puff /D _*.*
:dontGOLF

shouldInstall YSERBIUS dontYSERBIUS
echo UnCompressing "The Shadow of Yserbius"
godir %1:%6\YSERBIUS
rem puff /D _*.*
rem del _*.*

copy    %2:ysPatch\*.* /q
if exist _*.* puff /D _*.*
copy save\*.dat /q
:dontYSERBIUS

godir %1:%6

rem Delete the old documentation before replacing it with the new.
del General.doc
del Clubhous.doc
del Sierrlnd.doc
del Casland.doc
del Arena.doc
del Yserbius.doc
del RedBaron.doc
del 3-dGolf.doc
del PrsnlAds.doc

echo Installing ImagiNation Documentation
copy    %2:_ENERAL.DOC
copy    %2:_IERRLND.DOC
copy    %2:_ASLAND.DOC
copy    %2:_SERBIUS.DOC
copy    %2:_LUBHOUS.DOC
copy    %2:_RSNLADS.DOC
copy    %2:_RENA.DOC
copy    %2:_-DGOLF.DOC
copy    %2:_EDBARON.DOC
puff    /D _*.DOC

rem Use document list utility
%2:doclst doc.lst General.doc > NUL
%2:doclst doc.lst Clubhous.doc > NUL
%2:doclst doc.lst SierrLnd.doc > NUL
%2:doclst doc.lst CasLand.doc > NUL
%2:doclst doc.lst Arena.doc > NUL
%2:doclst doc.lst PrsnlAds.doc > NUL
%2:doclst doc.lst RedBaron.doc > NUL
%2:doclst doc.lst Yserbius.doc > NUL
%2:doclst doc.lst 3-DGolf.doc > NUL

cls
echo Installation complete.
echo 
echo 
echo Type "cd %6"
echo      "INN"
echo   to run The ImagiNation Network
echo 
end

:NoSpace
cls
echo There is not enough space on %1: to install ImagiNation!
echo %7 kilobytes are required. Delete some unused stuff.
pause
end

:CantCreate
Alert Unable to create %1:%6
cls
echo    There may already be a file called %1:%6.
echo
echo    If there is, rename it or install ImagiNation on another hard
echo    disk partition.
echo
pause
end

:CantCC
Alert Unable to create %1:%6\CC
end

:CantSL
Alert Unable to create %1:%6\SL
end

:CantLL
Alert Unable to create %1:%6\LL
end

:CantARENA
Alert Unable to create %1:%6\ARENA
end

rem Don't remove this in 2.4
:CantCUC
Alert Unable to create %1:%6\SHOPADV
end

:CantYserbius
Alert Unable to create %1:%6\YSERBIUS
end

:CantBaron
Alert Unable to create %1:%6\BARON
end

:CantGolf
Alert Unable to create %1:%6\GOLF
end

