From 1e104f0496c10290f08a57624d3cf7e9914835d5 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 26 Oct 2010 06:53:04 +0000 Subject: [PATCH] - attempt to further improve pathfinder performance when MANY units are on the map --- source/glest_game/ai/path_finder.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/glest_game/ai/path_finder.cpp b/source/glest_game/ai/path_finder.cpp index c2d0e093..31384a7c 100644 --- a/source/glest_game/ai/path_finder.cpp +++ b/source/glest_game/ai/path_finder.cpp @@ -143,7 +143,11 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld, ts = %d, unit = %s [size = %d]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),ts, unit->getFullName().c_str(),unit->getType()->getSize()); if(cachedPath.size() > 0) { - + path->clear(); + for(int i=0; i < cachedPath.size() && i < pathFindRefresh; ++i) { + path->add(cachedPath[i]); + } + ts = tsMoving; } else { //route cache miss