- bugfix for multiple consumable resources applying incorrectly during the update interval. (thanks silnarm)

This commit is contained in:
Mark Vejvoda 2010-10-22 22:52:37 +00:00
parent c4c812dd15
commit e53e6b49a9
3 changed files with 4 additions and 4 deletions

View File

@ -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()) {

View File

@ -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

View File

@ -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; i<getFactionCount(); ++i){
getFaction(i)->applyCostsOnInterval();
getFaction(i)->applyCostsOnInterval(rt);
}
}
}