@echo off
rem  *   If you knew how to write batch files, this wouldn't look so
rem  *   difficult to you :)
if "%1"=="" goto showfiles
if "%1"=="/?" goto helpme
if "%2"=="" goto regular
if "%3"=="" goto regular

:custom
if exist e%2l%3.map goto oopscust
if not exist %1.map goto irk
ren %1.map e%2l%3.map
duke3d /v%2 /l%3
ren e%2l%3.map %1.map
goto end

:regular
if exist e1l8.map goto oopsreg
if not exist %1.map goto irk
ren %1.map e1l8.map
duke3d /v1 /l8
ren e1l8.map %1.map
goto end

:showfiles
dir *.map /p /on
goto end

:oopsreg
echo.
echo Sorry. There is already a file named e1l8.map in your directory
echo and thus your map file cannot be run as e1l8.map. Either move this file
echo to another directory or try typing something
echo like "run %1 2 1" This will run %1.map as e2l1.map
echo.
goto end


:oopscust
echo.
echo Sorry. There is already a file named e%2l%3.map in your directory
echo and thus your map file cannot be run as e%2l%3.map. Either move
echo this file to another directory or try typing something like :
echo  "run %1 x y"  where x is not = %2 and y is not = %3
echo.
goto end

:irk
echo.
echo There is no map with the filename %1.map.
echo.
goto end

:helpme
echo.
echo  Usage: run (mapname) (volume to use) (level to use)
echo  examples:  run bigboom       (runs bigboom.map using e1l8)
echo             run bigboom 1 1   (runs bigboom.map using e1l1)
echo             run               (lists .map files)
echo.
echo Renames given map file to e1l8 or chosen level/volume, runs Duke
echo Nukem with /vx /lx parameter and then renames it back again.
echo Only possible problem is when you already have a file named e1l8
echo or you choose to run a map using a level and volume that are already
echo occupied by a a file in your directory (for example, you type
echo "run bigboom 1 1" and there is a file e1l1.map in your directory).
echo If the game crashes before it gets back to dos, your map file
echo will have been renamed e1l8.map or exlx.map. Nothing fatal can
echo happen. Won't pass parameters. (You're welcome to modify it, though).
echo.
echo Note that there is already a map e1l8 in the game (surprised?)
echo You can get to this level by typing duke3d /v1 /l8.
echo (Probably have to extract it using kextract to use it
echo  in multiplayer).
echo.
echo Getting REALLY sick of the music from e1l1?
echo Try "run yourmapname 2 1"
echo.

:end
