diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index f59222a2..9c5b46e6 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -48,6 +48,8 @@ World::World(){ fogOfWarSmoothing= config.getBool("FogOfWarSmoothing"); fogOfWarSmoothingFrameSkip= config.getInt("FogOfWarSmoothingFrameSkip"); + bool perfTimerEnabled = SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled; + frameCount= 0; //nextUnitId= 0; @@ -177,18 +179,19 @@ void World::loadScenario(const string &path, Checksum *checksum){ // ==================== misc ==================== void World::update(){ - Chrono chrono; - chrono.start(); + if(perfTimerEnabled == true) { + chronoPerfTimer.start(); + } ++frameCount; //time timeFlow.update(); - if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis()); //water effects waterEffects.update(); - if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis()); //units for(int i=0; igetUnit(j)); } } - if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis()); //undertake the dead for(int i=0; i 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis()); //food costs for(int i=0; igetResourceTypeCount(); ++i){ @@ -221,21 +224,21 @@ void World::update(){ } } } - if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis()); //fow smoothing if(fogOfWarSmoothing && ((frameCount+1) % (fogOfWarSmoothingFrameSkip+1))==0){ float fogFactor= static_cast(frameCount%GameConstants::updateFps)/GameConstants::updateFps; minimap.updateFowTex(clamp(fogFactor, 0.f, 1.f)); } - if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis()); //tick if(frameCount%GameConstants::updateFps==0){ computeFow(); tick(); } - if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis()); } void World::tick(){ @@ -793,10 +796,9 @@ void World::computeFow(){ //iterate through all cells PosCircularIterator pci(&map, unit->getPos(), sightRange+indirectSightRange); while(pci.next()){ - Vec2i pos= pci.getPos(); + const Vec2i &pos= pci.getPos(); Vec2i surfPos= Map::toSurfCoords(pos); - //compute max alpha float maxAlpha; if(surfPos.x>1 && surfPos.y>1 && surfPos.x