home *** CD-ROM | disk | FTP | other *** search
- 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;
- 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);
- for s := 1 to maxSector do
- if distances[s].d = -1 then distances[s].d := maxint;
- FixPath := distances[ finish ].d;
- end; {FixPath}
-