procedure LoadData( var TheSector : SectorInfo ); var ch : char; begin with TheSector do begin number := 0; repeat read( f, ch ); until ch = ':'; ch := '-'; while ch = '-' do begin number := number + 1; data[ number ] := ReadNumber(f); read( f, ch ); end; {while} readln( f ); end; {with} end; {LoadData} procedure CheckData( var TheSector : SectorInfo ); var t : warpIndex; ch : char; begin repeat read( f, ch ); until ch = ':'; for t := 1 to TheSector.number do begin if TheSector.data[ t ] <> ReadNumber(f) then begin write('Log data doesn''t match input data! Exiting without save!'); halt; end; {if} read( f, ch ); end; {for} readln( f ); end; {Data} procedure ProcessWarps( var space : TheVoid ); var s : integer; line : string; begin skip( f, 6); s := ReadNumber(f); writeln('Processing sector ', s ); if s = 0 then begin writeln('Something is screwy. Exiting.'); readln; writeln('Screwup after line:'); writeln( line ); readln; SaveData( g, space ); readln; halt; end; if space.sectors[s].number > 0 then CheckData( space.sectors[ s ] ) else LoadData( space.sectors[ s ] ); end; {ProcessWarps} procedure ProcessPorts( var space : TheVoid; line : string ); var LeftBrack, s : integer; ch : char; err : string; begin LeftBrack := pos( ']', line ); delete( line, 1, LeftBrack ); if bval( line, s ) then writeln('error parsing sector ', line ) else if (s<1) or (s>maxSector) then writeln('sector value', s, ' out of bounds ') else if not eof( f ) then begin readln( f ); { next line is blank } if not eof( f ) then begin readln( f, line ); if (copy( line, 1, 8) = 'Commerce') and (not eof( f )) then begin if pos( 'Stargate Alpha', line ) > 0 then begin writeln('StarDock found in sector ', s); space.dock := s; space.sectors[ s ].etc := space.sectors[ s ].etc or StarDock; end; space.sectors[ s ].etc := space.sectors[ s ].etc or IsPort; GetPortStatus( s, space.sectors[ s ].portType, line, space.Ports ); writeln('Status on port ', s, ' : ', status(space.sectors[s].portType) ); end {if} else space.sectors[s].portType := NotAPort; end; {if} end; {eof} end; {ProcessPorts} procedure PartII( var space : TheVoid ); var line : string; ch : char; s, i : integer; finished : boolean; begin while not eof( f ) do begin readln( f, line ); if pos( 'examine?', line ) > 0 then processWarps( space ) else if pos( 'What sector is the port in?', line) > 0 then processPorts( space, line ); end; {while} writeln('Log processed... updating now.'); SaveData( g, space ); end; {PartII}