Skretzo / shortest-path

Pathfinding for Old School RuneScape
BSD 2-Clause "Simplified" License
14 stars 31 forks source link

Bug fixes and code reorganization #1

Closed beemerwt closed 2 years ago

beemerwt commented 2 years ago

Creating a new Pathfinder object every "scheduled update" is incredibly inefficient, so I created the "Path" class that encapsulates specifically the pathing methods, and now only create the pathfinder object once with all of the CollisionMap and Transports data. This also removes a lot of variables in creating/re-creating a path, which was previously a bug where the path wouldn't properly dispose when the user set a new target.

Additionally, there are a lot of null checks that I added for the sake of the linter and keeping each stack frame more consistent. Where this really mattered was inside each of the overlays where getting the path could so drastically change within each call.

Skretzo commented 2 years ago

Thanks, this looks nice! Any idea why it seems to take longer time to switch from the blue line (loading) to the red line (pathfinding is done) with your changes? (Edit: found the issue). I will add some fixes of my own too and then open a PR for the plugin hub.