home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Game Killer
/
Game_Killer.bin
/
104.BASEPATH.INC
< prev
next >
Wrap
Text File
|
1992-07-12
|
1KB
|
44 lines
function FixPath( start, finish : sectorindex; max : integer ) : integer;
{ Adjusts Distances from start up to point were finish is entered or we reach
a distance of max. Returns length of path, or max + 1. }
var
s : sector;
breadth : queue;
daddy, sonny : sector;
i : warpindex;
done : boolean;
begin
for s := 1 to maxSector do
Distances[s].d := -1;
breadth.front := 0;
enqueue( breadth, start, start );
repeat
serve( breadth, daddy, sonny );
if (Distances[ sonny ].d = -1) then {haven't hit him before:}
begin
distances[ sonny ].d := distances[ daddy ].d + 1;
distances[ sonny ].s := daddy;
if (space.sectors[sonny].etc and avoid) = Nothing then
with space.sectors[ sonny ] do if number > 0 then
for i := 1 to number do
enqueue( breadth, sonny, data[ i ] );
done := sonny = finish;
end; {if}
until done or (breadth.front = 0) or (distances[sonny].d = max);
for s := 1 to maxSector do
if distances[s].d = -1 then distances[s].d := maxint;
if done then
FixPath := distances[ finish ].d
else
FixPath := max + 1;
end; {FixPath}
procedure PrintPath( var home : sectorindex; sec : sectorindex );
var
dummy : text;
begin
if home <> sec then
PrintPath( home, distances[ sec ].s );
displaySector( sec, 'Dist', error, false, dummy )
end;