{ Part one will parse a log file, and store explored sectors; then
create a text file that you can feed to the computer that will give you
a map of the universe.  Part two will take a log file generated from
feeding the first to the computer, and create a data file that can
be fed into something else.

Well, this has been expanded a bit since the first note.  It now does
a variety of conversion tasks, from fighter clouds to major space lane stuff.
But that is always the problem with programs -- they always outstrip the
documentation, eh?  Program begun Dec 1990 by woody.
}

{ I keep forgetting to turn off 286 instruction set.  So, better force it
  off here, before I confuse any more 286 people. }
{$A+}        { speed up us 80x86 guys }
{$B-}        { I dig short circuits }
{$I+}        { pisses people off when they hit a letter, but its better than
               gigo. }
{$G-}        { turn OFF 286 instruction set }


program converter;

uses DOS;

{$I headers.inc}


var
  upl,
  ext,
  mss       : string;
  othername,
  BBSName   : string;
  ch        : char;
  n         : integer;
  f, g      : text;
  space     : TheVoid;

{$I QUEUE.INC }
{$I status.inc }
{$I misc.inc }
{$I PortStat.inc }
{$I gsdata.inc }
{$I part13.inc}
{$I part2.inc}
{$I part4.inc}
{$I part5.inc}
{$I part6.inc}
{$I part89.inc}
{$I editbase.inc}

begin {main}
  writeln('Tradewars Data Base generator: ', Version);
  writeln( author );
  writeln( source );
  writeln;
  InitSpace( Space );
  if paramcount > 0 then
    BBSName := paramstr( 1 )
  else
    BBSName := '';
  GetData( space, BBSName, true );
  repeat
    repeat
      writeln('Choices:');
      writeln('  (0)  Let me out of here!');
      writeln('  (1)  Read "Explored/Unexplored Sectors"',
              'for newly scanned sectors');
      writeln('  (2)  Read log files for inter-warp and port information');
      writeln('  (3)  Read "Fighter Display" list for fighter clouds');
      writeln('  (4)  Generate upload file for determining Major Space Lanes');
      writeln('  (5)  Read "Major Space Lanes" downloaded file into database');
      writeln('  (6)  Add some other explorer''s data into database');
      writeln('  (7)  Perform editing on data base');
      writeln('  (8)  Read "Interrogation Mode" sector report');
      writeln('  (9)  Read "Interrogation Mode" port report');
      writeln;
      write('(', BBSname, ')  Your choice?  (0, 1, ..., 9) ');
      readln( ch );
    until ch in ['0'..'9'];
    n := ord( ch ) - ord( '0' );
    if n = 0 then halt;
    upl := 'dat';
    case n of
      1 : begin
            mss := '"Explored/Unexplored Sectors"';
            ext := 'exp';
            upl := 'upl';
          end;
      2 : begin
            mss := 'log';
            ext := 'log';
          end;
      3 : begin
            mss := '"Deployed Fighter Scan"';
            ext := 'ftr';
          end;
      4 : upl := 'upl';
      5 : begin
            mss := '"Major Space Lanes"';
            ext := 'msl';
          end;
      6 : begin
            mss :='other database';
            ext := 'unk';
          end;
      7 : ;
      8 : begin
            mss := 'sector report file';
            ext := 'sct';
          end;
      9 : begin
            mss := 'port report file';
            ext := 'prt';
          end;
    end; {case}
    if not (n in [4,7]) then
      begin
        othername := GetOldFileName( 'Name of ' + mss + ' file?  ',
                                     bbsname + '.' + ext );
        if n <> 6 then
          begin
            assign( f, othername);
            reset( f );
          end; {if}
      end; {if}
    assign( g, GetNewFileName('Name of file to generate? ',
                                bbsname + '.' + upl) );
    rewrite( g );
    case n of
      1 : partOneThree;
      2 : partII( space);
      3 : partIV( space );
      4 : partV;
      5 : partVI( space );
      6 : begin GetData( space, othername, false ); SaveData( g, space ); end;
      7 : begin EditMenu; SaveData( g, space ); end;
      8 : partVIII( f, Space );
      9 : partIX( f, Space );
    end; {case}
    if n in [1, 2, 3, 8, 9] then
      close( f );
  until n = 0;
end.
