From b836bf0039800989643b72645772a36824a323f1 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Fri, 17 Sep 2010 04:00:48 +0000 Subject: [PATCH] - turned off staggered faction updates (can toggle via ini setting: StaggeredFactionUpdates) - added more debug info for resource depletion --- source/glest_game/type_instances/faction.cpp | 26 +++++++++++++++----- source/glest_game/world/world.cpp | 3 ++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index dca61a6a0..cb6eba76f 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -375,8 +375,12 @@ void Faction::applyCostsOnInterval(){ if(unit->isOperative()){ for(int k=0; kgetType()->getCostCount(); ++k){ const Resource *resource= unit->getType()->getCost(k); - if(resource->getType()->getClass()==rcConsumable && resource->getAmount()<0){ + if(resource->getType()->getClass() == rcConsumable && resource->getAmount() < 0) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] getResource(resource->getType())->getAmount() = %d\n",__FILE__,__FUNCTION__,__LINE__,getResource(resource->getType())->getAmount()); + incResourceAmount(resource->getType(), -resource->getAmount()); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] getResource(resource->getType())->getAmount() = %d\n",__FILE__,__FUNCTION__,__LINE__,getResource(resource->getType())->getAmount()); } } } @@ -386,20 +390,30 @@ void Faction::applyCostsOnInterval(){ for(int j=0; jisOperative()){ - for(int k=0; kgetType()->getCostCount(); ++k){ + if(unit->isOperative()) { + for(int k = 0; k < unit->getType()->getCostCount(); ++k) { const Resource *resource= unit->getType()->getCost(k); - if(resource->getType()->getClass()==rcConsumable && resource->getAmount()>0){ + if(resource->getType()->getClass() == rcConsumable && resource->getAmount() > 0){ + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] getResource(resource->getType())->getAmount() = %d\n",__FILE__,__FUNCTION__,__LINE__,getResource(resource->getType())->getAmount()); + incResourceAmount(resource->getType(), -resource->getAmount()); - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] consume setting for faction index = %d, consume = %d, getResource(resource->getType())->getAmount() = %d\n",__FILE__,__FUNCTION__,__LINE__,this->index,scriptManager->getPlayerModifiers(this->index)->getConsumeEnabled(),getResource(resource->getType())->getAmount()); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] getResource(resource->getType())->getAmount() = %d\n",__FILE__,__FUNCTION__,__LINE__,getResource(resource->getType())->getAmount()); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] consume setting for faction index = %d, consume = %d, getResource(resource->getType())->getAmount() = %d, Unit = [%s] - [%d]\n",__FILE__,__FUNCTION__,__LINE__,this->index,scriptManager->getPlayerModifiers(this->index)->getConsumeEnabled(),getResource(resource->getType())->getAmount(),unit->getFullName().c_str(),unit->getId()); //decrease unit hp if(scriptManager->getPlayerModifiers(this->index)->getConsumeEnabled() == true && getResource(resource->getType())->getAmount() < 0) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + resetResourceAmount(resource->getType()); bool decHpResult=unit->decHp(unit->getType()->getMaxHp()/3); - if(decHpResult){ + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] decHpResult = %d, unit->getType()->getMaxHp() = %d, hp = %d\n",__FILE__,__FUNCTION__,__LINE__,decHpResult,unit->getType()->getMaxHp(),unit->getHp()); + + if(decHpResult) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + world->getStats()->die(unit->getFactionIndex()); scriptManager->onUnitDied(unit); } diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index 3175c2453..a3d6576fb 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -48,7 +48,8 @@ World::World(){ SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); Config &config= Config::getInstance(); - staggeredFactionUpdates = true; + staggeredFactionUpdates = config.getBool("StaggeredFactionUpdates","false"); + ExploredCellsLookupItemCache.clear(); ExploredCellsLookupItemCacheTimer.clear(); ExploredCellsLookupItemCacheTimerCount = 0;