Skip to content

Commit ed62fab

Browse files
committed
fix(webgraphgen): improved time complexity
slightly slower on very small graphs for a huge speed boost on large ones. door graphing is now joined into the main loop, there's still room for further improvements in the future
1 parent 92f75c7 commit ed62fab

File tree

2 files changed

+217
-122
lines changed

2 files changed

+217
-122
lines changed

osrs/map/maploader.simba

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Credits: Torwent
1717
{$I SRLT/osrs.simba}
1818
{$ENDIF}
1919

20+
{.$DEFINE SRLT_GENERATE_GRAPH_ALWAYS}
21+
22+
2023
type
2124
(*
2225
## TMapLoader Enums
@@ -393,7 +396,10 @@ function TRSMapLoader.GetGraph(name: String; plane: Integer; map: TImage): TWebG
393396
var
394397
path: String;
395398
begin
396-
path := Self.CacheDir + 'graphs' + PATH_SEP + ToStr(plane) + PATH_SEP + name + '-' + GENERATED_GRAPH.Hash() + PATH_SEP;
399+
{$IFDEF SRLT_GENERATE_GRAPH_ALWAYS}
400+
Exit(WebGraphGenerator.BuildGraph(name, map));
401+
{$ENDIF}
402+
path := Self.CacheDir + 'graphs' + PATH_SEP + ToStr(plane) + PATH_SEP + name + '-' + WebGraphGenerator.Hash() + PATH_SEP;
397403

398404
if
399405
not FileExists(path + 'nodes.txt') or
@@ -407,7 +413,7 @@ begin
407413
if not DirCreate(path) then
408414
raise GetDebugLn('MapLoader', 'Failed to create cache directory: ' + path);
409415

410-
Result := TWebGraph.BuildGraph(name, map);
416+
Result := WebGraphGenerator.BuildGraph(name, map);
411417

412418
if (Result.Nodes <> []) then
413419
if not FileWriteBytes(path + 'nodes.txt', CompressBytes(Result.Nodes.ToBytes())) then
@@ -574,7 +580,7 @@ begin
574580

575581
collisionmaps += Self.GetMap(s, f, chunks[i].Planes[j], ERSMap.COLLISION);
576582

577-
if not GENERATED_GRAPH.Disabled then
583+
if not WebGraphGenerator.Disabled then
578584
graphs += Self.SetupGraph(name, idx, chunks[i].Planes[j], padding, collisionmaps[idx]);
579585

580586
collisionmaps[idx].Pad(padding);
@@ -603,7 +609,7 @@ begin
603609
Self.Heightmap := Self._InternalLoad(heightmaps);
604610
Self.Collision := Self._InternalLoad(collisionmaps);
605611

606-
if not GENERATED_GRAPH.Disabled then
612+
if not WebGraphGenerator.Disabled then
607613
Self.Graph := Self.InternalGraphLoad(graphs);
608614

609615
(* TODO

0 commit comments

Comments
 (0)