From e53e6b49a9b857b1b0185c11dcc10a2544b75494 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Fri, 22 Oct 2010 22:52:37 +0000 Subject: [PATCH] - bugfix for multiple consumable resources applying incorrectly during the update interval. (thanks silnarm) --- source/glest_game/type_instances/faction.cpp | 4 ++-- source/glest_game/type_instances/faction.h | 2 +- source/glest_game/world/world.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index 84f0ff20..4098acb9 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -364,7 +364,7 @@ void Faction::deApplyStaticConsumption(const ProducibleType *p) } //apply resource on interval (cosumable resouces) -void Faction::applyCostsOnInterval(){ +void Faction::applyCostsOnInterval(const ResourceType *rtApply) { // For each Resource type we store in the int a total consumed value, then // a vector of units that consume the resource type @@ -376,7 +376,7 @@ void Faction::applyCostsOnInterval(){ if(unit->isOperative() == true) { 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() == rtApply && resource->getType()->getClass() == rcConsumable && resource->getAmount() != 0) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] resource->getType() [%s] store = %d, unit cost = %d\n",__FILE__,__FUNCTION__,__LINE__,resource->getType()->getName().c_str(), getResource(resource->getType())->getAmount(),resource->getAmount()); if(resourceIntervalUsage.find(resource->getType()) == resourceIntervalUsage.end()) { diff --git a/source/glest_game/type_instances/faction.h b/source/glest_game/type_instances/faction.h index 240032f5..9d6b920a 100644 --- a/source/glest_game/type_instances/faction.h +++ b/source/glest_game/type_instances/faction.h @@ -128,7 +128,7 @@ public: void deApplyCosts(const ProducibleType *p); void deApplyStaticCosts(const ProducibleType *p); void deApplyStaticConsumption(const ProducibleType *p); - void applyCostsOnInterval(); + void applyCostsOnInterval(const ResourceType *rtApply); bool checkCosts(const ProducibleType *pt); //reqs diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index a94cecaf..21ab511f 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -288,7 +288,7 @@ void World::updateAllFactionConsumableCosts() { const ResourceType *rt= techTree->getResourceType(i); if(rt->getClass() == rcConsumable && frameCount % (rt->getInterval() * GameConstants::updateFps)==0){ for(int i=0; iapplyCostsOnInterval(); + getFaction(i)->applyCostsOnInterval(rt); } } }