- more performance improvements for resource cache logic (try to avoid repetitive caching logic when it was already done once)
This commit is contained in:
parent
d07cd76459
commit
8bbbe403ad
|
@ -359,7 +359,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
}
|
}
|
||||||
}//while
|
}//while
|
||||||
|
|
||||||
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld, openNodes.empty() = %d, pathFound = %d, nodeLimitReached = %d, unit = %s\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),openNodes.empty(),pathFound,nodeLimitReached,unit->getFullName().c_str());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld, openNodes.size() = %d, pathFound = %d, nodeLimitReached = %d, unit = %s\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),openNodes.size(),pathFound,nodeLimitReached,unit->getFullName().c_str());
|
||||||
|
|
||||||
Node *lastNode= node;
|
Node *lastNode= node;
|
||||||
|
|
||||||
|
|
|
@ -700,6 +700,7 @@ void Faction::removeResourceTargetFromCache(const Vec2i &pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Faction::addCloseResourceTargetToCache(const Vec2i &pos) {
|
void Faction::addCloseResourceTargetToCache(const Vec2i &pos) {
|
||||||
|
if(cachedCloseResourceTargetLookupList.find(pos) == cachedCloseResourceTargetLookupList.end()) {
|
||||||
const Map *map = world->getMap();
|
const Map *map = world->getMap();
|
||||||
const int harvestDistance = 5;
|
const int harvestDistance = 5;
|
||||||
for(int j = -harvestDistance; j <= harvestDistance; ++j) {
|
for(int j = -harvestDistance; j <= harvestDistance; ++j) {
|
||||||
|
@ -716,6 +717,9 @@ void Faction::addCloseResourceTargetToCache(const Vec2i &pos) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cachedCloseResourceTargetLookupList[pos] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2i Faction::getClosestResourceTypeTargetFromCache(Unit *unit, const ResourceType *type) {
|
Vec2i Faction::getClosestResourceTypeTargetFromCache(Unit *unit, const ResourceType *type) {
|
||||||
|
|
|
@ -85,6 +85,7 @@ private:
|
||||||
|
|
||||||
std::map<Vec2i, std::vector<FactionPathSuccessCache> > successfulPathFinderTargetList;
|
std::map<Vec2i, std::vector<FactionPathSuccessCache> > successfulPathFinderTargetList;
|
||||||
std::map<Vec2i,int> cacheResourceTargetList;
|
std::map<Vec2i,int> cacheResourceTargetList;
|
||||||
|
std::map<Vec2i,bool> cachedCloseResourceTargetLookupList;
|
||||||
time_t lastResourceTargettListPurge;
|
time_t lastResourceTargettListPurge;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user