@echo off
echo TW2TOOLS Version 1.00 SHAREWARE copyright (c) Jim Gast, Naperville, IL.

if "%1" == "" goto usage

if "%2" == "" goto findlog

if not exist %1.%2 goto nologext

echo Copying the log . . .
copy %1.%2 %1.log

:findlog

if not exist %1.log goto nolog

if exist %1.num goto analyze

: Try to create a file to make sure he specified a good %1
echo > %1.xxx
if not exist %1.xxx goto badarg1
del %1.xxx

echo Analyzing your first log file to see where you went . . .
echo 0 > %1.num
goto analyze

: analyze the log to find sectors, planets, and warps
echo Adding new discoveries from %1.log to the %1.num . . .
:analyze
tw2read %1 log

: If you do not have hdiff *AND* you want to avoid the error message
: remove the colon from the beginning of the next line
: if not exist hdiff.exe goto RenameFiles
echo Net differences - - -
hdiff %1.num %1.new

:RenameFiles
if exist %1.old del %1.old
rename %1.num %1.old
rename %1.new %1.num

ngc %1.RTE

echo !name:  %1  - Trade Wars 2002 data   >  %1.ML
echo !menu:                               >> %1.ML
echo  Routes by Sector    %1.NGO          >> %1.ML

ngml %1.ML

if exist %1.NG echo Your finished NG file is %1.NG
goto done

:nolog
echo I cannot find a log file named %1.LOG
echo To use this program, you will need to capture your TW2002 session
echo to a disk file.  Name this file %1.LOG.
goto done

:nologext
echo I cannot find a log file named %1.%2
echo To use this program, you will need to capture your TW2002 session
echo to a disk file.  I did not understand the "%2" you specified.
goto done

:badarg1
echo I cannot create the files I need using the gamename you specified.
echo ú
goto usage

:usage
echo To make a TradeWars 2002 NG file for a particular game use:
echo           TW2TOOLS gamename logextension
echo If you are just starting, choose a gamename that is up to 7
echo characters long.
echo ú
echo Then you will need to capture each TW2002 session to a disk file.
echo You may want to name your logs based on dates, or you can simply
echo name each one gamename.LOG.  Then run this TW2TOOLS batch file after
echo each session.
echo ú
echo If you want to keep multiple logs, you can use the optional logextension.
echo For example:
echo           TW2TOOLS RACER 924
echo would analyze the log named RACER.924, add the results into the
echo accumulated knowledge in files named RACER.NUM, RACER.RTE and make a
echo Norton Guides file named RACER.NG.
echo ú
echo This program is copyrighted SHAREWARE, Comments welcome. Register Free on
echo THE RACER'S EDGE BBS (708) 983-9708.  Leave message for Jim Gast.
goto done

:done
