home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Game Killer
/
Game_Killer.bin
/
271.TEXTDISP.INC
< prev
next >
Wrap
Text File
|
1991-07-08
|
5KB
|
161 lines
function DisplayPort( WhichPort : PortPtr ) : string;
begin
if WhichPort = 0 then
DisplayPort := 'Port data not found!'
else
with space.ports.data[ WhichPort ] do
DisplayPort := ' F:' + str(amts[fuel], 5) + ' ' + str(usage[fuel],3) +
'% O:' + str( amts[ organics], 5) + ' ' + str(usage[organics],3) +
'% E:' + str( amts[ equipment ], 5 )+ ' ' + str(usage[equipment],3) + '%';
end; {DisplayPort}
function DisplayNote( s : sector ) : string;
{ print the note associated with sector s }
var
n : 0..MaxNote;
begin
n := NoteNumber( s );
if n = 0 then
Displaynote := ' Missing note! '
else
Displaynote := ' ' + space.notes.data[n].info;
end; {write note}
procedure DisplaySector( s : sector; whatIs : string; dist : integer;
ToFile : boolean; var TheFile : text);
var
line : string;
begin
with space.sectors[s] do
begin
line := 'Sctr:' + str( s, 3);
if dist <> Error then
line := line + WhatIs + str( dist, 2 );
if number = UnExplored then
line := line + ' Unexplored sector';
if portType <> NotAPort then
begin
line := line + ' port ' + status( portType );
if portType <> Class0 then
line := line + DisplayPort( portnumber( s ) );
end; {if port}
if (etc and SpaceLane) <> Nothing then
line := line + ' space lane';
if (etc and StarDock) <> Nothing then
line := line + ' Star Dock';
if (etc and HasFighters) <> Nothing then
line := line + ' has fighters';
if (etc and NoteExists) <> Nothing then
line := line + DisplayNote( s );
if number = 1 then
if AppearanceCount(s) = 1 then
line := line + ' dead end (' + str(HowFar( s ),1) + ')';
writeln( line);
if ToFile then
writeln( TheFile, line );
end; {with}
end; {DisplaySector}
type
WhichStuff = (any, PortOnly, NoteOnly, UnExpOnly );
procedure EliminateUnwanted( var distances : distanceArray;
keepMe : WhichStuff;
var HowManyLeft : integer );
{ Remove the sectors you don't want in the list by pushing them to the back}
var
whichSector : sector;
keep : boolean;
begin
HowManyLeft := 0;
for whichSector := 1 to MaxSector do
begin
case keepMe of
any : keep := distances[ whichSector ].d <> maxint;
PortOnly : keep := space.sectors[whichSector].porttype <> NotAPort;
NoteOnly : keep := space.sectors[whichSector].etc and NoteExists
<> Nothing;
UnExpOnly: keep := (space.sectors[whichSector].number = UnExplored)
and (distances[ whichSector ].d <> maxint);
end; {case}
if keep then
begin
HowManyLeft := HowManyLeft + 1;
distances[ howManyLeft ] := distances[ whichSector ];
end; {if}
end; {for}
write('Total of ', HowManyLeft );
case keepMe of
any : writeln(' sectors from base sector');
PortOnly : writeln(' known ports');
NoteOnly : writeln(' sectors with notes');
UnExpOnly: writeln(' unexplored sectors with known position');
end; {case}
end; {EliminateUnwanted}
procedure FindSmallest( var distances : DistanceArray;
lowest, highest : sector );
{ Examine the distance array from lowest to highest, and move the
sector at smallest distance into the "lowest" slot. }
var
temp : dist;
s,
smallest : sector;
begin
Smallest := lowest;
for s := lowest to highest do
if distances[ s ].d < distances[ smallest ].d then
smallest := s;
temp := distances[ smallest ];
distances[ smallest ] := distances[ lowest ];
distances[ lowest ] := temp;
end; {FindSmallest}
procedure nearestStuff( Filter : WhichStuff );
var
Number,
s, n : integer;
log : boolean;
f : text;
begin
if SetUpDistances then
begin
EliminateUnwanted( distances, filter, Number );
log := prompt( 'Log to disk? ');
if log then
begin
assign( f, GetNewFileName('File name for report? ', 'report.txt') );
rewrite( f );
end;
if Number <> 0 then
begin
for n := 1 to Number do
begin
FindSmallest( distances, n, Number );
DisplaySector( distances[ n ].s, ' Dist:', distances[n].d, log, f );
if n mod 20 = 0 then
if not prompt( 'more? ') then
begin
if log then
close( f );
exit;
end;
end; {for}
end; {if}
if log then
close( f );
end; {if}
end; {nearport}
procedure SortPorts( var NumPorts : integer );
var
s, n : integer;
begin
NumPorts := 0;
if SetUpDistances then
begin
EliminateUnwanted( distances, PortOnly, NumPorts );
writeln('Sorting...');
SortDistances( distances, NumPorts )
end; {if}
end; {SortPorts}