Code: Select all
@echo off & @rem based on XNT.kex script template version 2016-03-05
setlocal enableextensions & prompt @
for %%x in (2.4 2.5 2.6 3.0 3.1) do if "%~1" == "%%x" goto USER
echo/
goto HELP
:USER --------------------------------------------------------------
::: Find [home]/.freeciv/x.y or fail :::::::::::::::::::::::::::::::
set USER=%APPDATA%\.freeciv\%~1
set NEED=%USER%
if not exist "%USER%\*" goto NEED
::: Find [prog]/freeciv-x.y.* or fail ::::::::::::::::::::::::::::::
set PROG=%ProgramFiles(x86)%
set NEED=%%ProgramFiles%%
if "%PROG%" == "" set PROG=%ProgramFiles%
if "%PROG%" == "" goto NEED
::: FIXME: will not find future 64bit installations ::::::::::::::::
set INST=
set NEED=%PROG%\Freeciv-%~1.*-*
for /D %%x in ("%NEED%") do set INST=%%x
if "%INST%" == "" goto NEED
:OPTS --------------------------------------------------------------
::: Find [home]/.freeciv/x.y/civtest.log for --log :::::::::::::::::
set OPTS=%USER%\%~n0.log
if exist "%OPTS%" del /P "%OPTS%"
if exist "%OPTS%" set OPTS=
if not "%OPTS%" == "" set OPTS=--log "%OPTS%"
::: Force --warning for 2.6 or later :::::::::::::::::::::::::::::::
if "%~1" GTR "2.5" set OPTS=--warning %OPTS%
::: Skip 1st argument x.y for the options ::::::::::::::::::::::::::
for /F "usebackq tokens=1*" %%x in ('%*') do set OPTS=%OPTS% %%y
set FREECIV_DATA_PATH=.;%INST%\data;%USER%
::: FIXME: freeciv-?t*.exe (qT or GTK*) kludge fails for SDL client:
set FCIV=freeciv-?t*.exe
set NEED=%INST%\%FCIV%
for /R "%INST%" %%x in (%FCIV%) do set FCIV=%%x
if not exist "%FCIV%" goto NEED
::: Show constructed FREECIV_DATA_PATH and run :::::::::::::::::::::
echo FREECIV_DATA_PATH=%FREECIV_DATA_PATH%
if "%LANG%" == "" set LANG=C
echo LANG=%LANG%
echo start "%~n0" "%FCIV%" %OPTS%
start "%~n0" "%FCIV%" %OPTS%
goto WAIT
:NEED --------------------------------------------------------------
echo/
echo Error: %0 found no "%NEED%"
:HELP --------------------------------------------------------------
echo Usage: %0 2.4^|2.5^|2.6^|3.0^|3.1 [opts]
echo/
echo %~n0 starts a 32bit qT or GTK freeciv-?t*.exe
echo for quick command line experiments with different
echo Freeciv clients. It uses the newest _installed_
echo freeciv-x.y.*-* and sets a FREECIV_DATA_PATH for
echo %APPDATA%\.freeciv\x.y
echo/
echo Adds --warning --log ~\.freeciv\x.y\%~n0.log
echo before any [opts], e.g., -d 3 (debug verbose).
echo CAVEAT: Options -h and -v do not (more) work in
echo _started_ clients, stdout/stderr end up nowhere.
echo/
:WAIT --------------------------------------------------------------
set NEED=usebackq tokens=2 delims=/
for /F "%NEED% " %%c in ('%CMDCMDLINE%') do if /I "%%c" == "c" pause