- added ability to completely disable explorecells caching if required

This commit is contained in:
Mark Vejvoda 2010-07-17 06:33:40 +00:00
parent 94ce234787
commit ed67b16aba

View File

@ -40,6 +40,7 @@ namespace Glest{ namespace Game{
const float World::airHeight= 5.f;
// This limit is to keep RAM use under control while offering better performance.
int MaxExploredCellsLookupItemCache = 5000;
time_t ExploredCellsLookupItem::lastDebug = 0;
// ===================== PUBLIC ========================
@ -752,13 +753,12 @@ void World::initMap(){
// ==================== exploration ====================
time_t ExploredCellsLookupItem::lastDebug = 0;
void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex){
// Experimental cache lookup of previously calculated cells + sight range
if(MaxExploredCellsLookupItemCache > 0) {
if(difftime(time(NULL),ExploredCellsLookupItem::lastDebug) >= 10) {
ExploredCellsLookupItem::lastDebug = time(NULL);
printf("In [%s::%s Line: %d] ExploredCellsLookupItemCache.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,ExploredCellsLookupItemCache.size());
//printf("In [%s::%s Line: %d] ExploredCellsLookupItemCache.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,ExploredCellsLookupItemCache.size());
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ExploredCellsLookupItemCache.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,ExploredCellsLookupItemCache.size());
}
@ -821,6 +821,7 @@ void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex){
}
}
}
}
Vec2i newSurfPos= Map::toSurfCoords(newPos);
int surfSightRange= sightRange/Map::cellScale+1;
@ -853,6 +854,7 @@ void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex){
}
// Ok update our caches with the latest info for this position, sight and team
if(MaxExploredCellsLookupItemCache > 0) {
if(item.exploredCellList.size() > 0 || item.visibleCellList.size() > 0) {
//ExploredCellsLookupItemCache.push_back(item);
item.ExploredCellsLookupItemCacheTimerCountIndex = ExploredCellsLookupItemCacheTimerCount++;
@ -864,6 +866,7 @@ void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex){
lookupKey.teamIndex = teamIndex;
ExploredCellsLookupItemCacheTimer[item.ExploredCellsLookupItemCacheTimerCountIndex] = lookupKey;
}
}
}
//computes the fog of war texture, contained in the minimap