From 736bfcf7eb2b943f9d8c722120193f9584df1175 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 18 Sep 2015 21:54:17 +0100 Subject: [PATCH] Fix RV pathfinder performance regression caused by map size increase. The YAPF road vehicle pathfinder previously limited the path length to the map size (previously 2048). The extra large maps path increases this to 1M, nearly 3 orders of magnitude, and this can result in a major performance penalty due to excessively long pathfinder paths. Instead limit the RV pathfinder length to a hard-coded 2048. --- src/pathfinder/yapf/yapf_road.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp index 4c26d7b095..a7caa7b953 100644 --- a/src/pathfinder/yapf/yapf_road.cpp +++ b/src/pathfinder/yapf/yapf_road.cpp @@ -16,6 +16,14 @@ #include "../../safeguards.h" +/** + * This used to be MAX_MAP_SIZE, but is now its own constant. + * This is due to the addition of the extra-large maps patch, + * which increases MAX_MAP_SIZE by several orders of magnitude. + * This is no longer a sensible value for pathfinding as it + * leads to major performace issues if a path is not found. + */ +const uint MAX_RV_PF_TILES = 1 << 11; template class CYapfCostRoadT @@ -152,7 +160,7 @@ public: /* move to the next tile */ tile = F.m_new_tile; trackdir = new_td; - if (tiles > MAX_MAP_SIZE) break; + if (tiles > MAX_RV_PF_TILES) break; } /* save end of segment back to the node */