@echo off

@echo ===----------------------------------------------
@echo === Deathball Launcher
@echo ===----------------------------------------------


@echo === Environment Check ===


IF NOT EXIST "..\Deathball" (
	echo 'Play Deathball.cmd' is missing from your UT2004\Deathball Deathball folder. Please reinstall Deathball.
	pause
	goto end
)

IF EXIST ..\System\Deathball.u (
	echo Deathball package found in Ut2004\system folder! You have installed Deathball into wrong directory. Please remove any Deathball files from Ut2004\System folder or reinstall UT2004 and Deathball!
	pause
	goto end
)



IF NOT EXIST ..\System\Default.ini (
	echo UT2004\System\Default.ini is missing! Please reinstall UT2004!
	pause
	goto end
)

IF NOT EXIST System\Deathball.u (
	echo Deathball Package missing! Please reinstall.
	pause
	goto end
)

IF NOT EXIST System\DeathballAI.u (
	echo DeathballAI Package missing! Please reinstall.
	pause
	goto end
)

IF NOT EXIST System\Deathball_rc.u (
	echo DeathballAI Package missing! Please reinstall.
	pause
	goto end
)

IF NOT EXIST Maps\Entry.ut2 (
	echo Deathball\Maps\Entry.ut2 missing. Using UT2k4 default Entry map.
	copy ..\Maps\Entry.ut2 Maps\Entry.ut2 > NUL
)

IF NOT EXIST System\Deathball.ucl (
	echo === Exporting Deathball.ucl ===
	..\System\ucc exportcache -Mod=Deathball -v Deathball.u Deathball_rc.u DeathballAI.u Deathball.ucl
	IF NOT %ERRORLEVEL%==0 (
		echo ERROR! Unable to run UCC.
		pause			
		goto end
	)
	IF NOT EXIST System\Deathball.ucl (
		echo ERROR! Unable to export Deathball.ucl! 
		pause			
		goto end
	)
)

@echo === Checking for updates ===
AutoUpdate.exe /S /D=%CD%

@echo === Starting Deathball ===

@REM Use START always when possible!
IF DEFINED OS (
	IF %OS%==Windows_NT (
@echo %OS%
cd..
cd system
start ut2004.exe -Mod=Deathball
	)
)
	IF %OS%!=Windows_NT (
..\System\ut2004.exe -Mod=Deathball	)


:end

