home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Game Killer
/
Game_Killer.bin
/
112.PATHSTUF.INC
< prev
next >
Wrap
Text File
|
1992-07-24
|
4KB
|
137 lines
procedure PathLength;
var
s1, s2 : sectorindex;
len : integer;
ch : char;
begin
write('Distance between which two sectors? ');
s1 := readNumberFromTerminal;
s2 := readNumberFromTerminal;
if (s1=0) or (s2=0) then
exit;
if space.sectors[ s1 ].number <> Unexplored then
begin
len := FixPath( s1, s2, maxint - 1 );
if len = Error then
writeln('You don''t know how to get to ', s2, ' from ', s1, '!' )
else
begin
writeln('Known shortest path from ', s1, ' to ', s2, ' is ');
PrintPath( s1, s2 );
writeln;
writeln('Path is of length ', len );
readln;
end; {if finite distance}
end {visited}
else
writeln('Never visited ', s1, ' so can''t tell distances leaving it.');
if space.sectors[ s1 ].number <> UnExplored then
begin
len := FixPath( s2, s1, maxint - 1 );
if len = Error then
writeln('You don''t know how to get to ', s1, ' from ', s2, '!' )
else
begin
writeln('Known shortest path from ', s2, ' to ', s1, ' is ');
PrintPath( s2, s1 );
writeln;
writeln('Path is of length ', len );
end; {if finite distance}
end
else
writeln('Never visited ', s2, ' so can''t tell distances leaving it.');
end;
procedure NearestFighters;
var
s : sectorIndex;
s1, Closest : sector;
begin
write('Current ');
s := GetSector;
if s = 0 then exit;
TwoWayDistances( s, distances, false, true );
Closest := 1;
for s1 := 1 to maxSector do
if (space.sectors[ s1 ].portType = Class0) or (s1=space.dock) then
if distances[ s1 ].d = maxint then
writeln('You don''t know how to get to ', s1 )
else
begin
writeln('Path to ', s1, ' is of length ', distances[ s1 ].d );
PrintPath( s, s1 );
writeln;
readln;
if distances[ s1 ].d < distances[ Closest ].d then
Closest := s1;
end; {for if else}
writeln('The closest target for fighters is ', closest );
end; {Nearest Fighters}
procedure GetBlockedPorts;
var
f : text;
fname : string;
p : portIndex;
begin
assign( f, GetNewFileName('Name of file to store list of blocked ports? ',
'avoids.upl'));
rewrite( f );
for p := 1 to space.ports.top do
begin
if space.ports.data[p].usage[Equipment] = 0 then
begin
writeln( f, 'V', space.ports.data[p].where);
writeln('sector ', space.ports.data[p].where, ' blocked.');
end;
end;
close( f );
end;
procedure StoreCurrentAvoids;
var
fname,
line : string;
f, g : text;
s : sectorindex;
begin
fname := GetOldFileName( 'File captured from avoid listing: ', 'avoids.log');
if fname = 'abort' then exit;
assign( g, fname);
{$I-}
reset( g );
{$I+}
if ioresult <> 0 then
exit;
assign( f, GetNewFileName( 'File to store current avoids: ', 'current.upl'));
rewrite( f );
repeat
readln( g, line );
until line = '<List Avoided Sectors>';
s := readNumber( g );
while s <> 0 do
begin
writeln( f, 'V', s );
s := readNumber( g );
end; {while}
close( f );
end;
procedure GetAvoidList;
var
choice : string;
begin
repeat
writeln('Store list of <B>locked ports to disk for upload');
writeln('Store <C>urrent avoids to disk for later upload');
writeln('<Q>uit' );
write( 'Your choice? [BCQ] ');
readln( choice );
if choice = '' then choice := 'Q';
until choice[1] in ['b','c','q','B','C','Q'];
case choice[1] of
'b','B' : GetBlockedPorts;
'c','C' : StoreCurrentAvoids;
'q','Q' : ;
end; {case}
end;