mirror of
https://github.com/glest/glest-source.git
synced 2025-02-26 04:32:22 +01:00
- some optimizations for performance logging
This commit is contained in:
parent
b0b775dc49
commit
64705aa786
@ -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; i<getFactionCount(); ++i){
|
||||
@ -196,7 +199,7 @@ void World::update(){
|
||||
unitUpdater.updateUnit(getFaction(i)->getUnit(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<getFactionCount(); ++i){
|
||||
@ -210,7 +213,7 @@ 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());
|
||||
|
||||
//food costs
|
||||
for(int i=0; i<techTree->getResourceTypeCount(); ++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<float>(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<map.getSurfaceW()-2 && surfPos.y<map.getSurfaceH()-2){
|
||||
|
@ -91,6 +91,8 @@ private:
|
||||
int fogOfWarSmoothingFrameSkip;
|
||||
bool fogOfWarSmoothing;
|
||||
Game *game;
|
||||
Chrono chronoPerfTimer;
|
||||
bool perfTimerEnabled;
|
||||
|
||||
public:
|
||||
World();
|
||||
|
Loading…
x
Reference in New Issue
Block a user