home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Game Killer
/
Game_Killer.bin
/
259.BASEPATH.INC
< prev
next >
Wrap
Text File
|
1991-07-08
|
996b
|
31 lines
function FixPath( start, finish : sector ) : integer;
{ Adjusts Distances from start up to point were finish is entered;
returns length of path. }
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;
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);
FixPath := distances[ finish ].d;
for s := 1 to maxSector do
if distances[s].d = -1 then distances[s].d := maxint;
end; {FixPath}