- bugfix for multiple consumable resources applying incorrectly during the update interval. (thanks silnarm)
This commit is contained in:
parent
c4c812dd15
commit
e53e6b49a9
|
@ -364,7 +364,7 @@ void Faction::deApplyStaticConsumption(const ProducibleType *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
//apply resource on interval (cosumable resouces)
|
//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
|
// For each Resource type we store in the int a total consumed value, then
|
||||||
// a vector of units that consume the resource type
|
// a vector of units that consume the resource type
|
||||||
|
@ -376,7 +376,7 @@ void Faction::applyCostsOnInterval(){
|
||||||
if(unit->isOperative() == true) {
|
if(unit->isOperative() == true) {
|
||||||
for(int k = 0; k < unit->getType()->getCostCount(); ++k) {
|
for(int k = 0; k < unit->getType()->getCostCount(); ++k) {
|
||||||
const Resource *resource = unit->getType()->getCost(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());
|
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()) {
|
if(resourceIntervalUsage.find(resource->getType()) == resourceIntervalUsage.end()) {
|
||||||
|
|
|
@ -128,7 +128,7 @@ public:
|
||||||
void deApplyCosts(const ProducibleType *p);
|
void deApplyCosts(const ProducibleType *p);
|
||||||
void deApplyStaticCosts(const ProducibleType *p);
|
void deApplyStaticCosts(const ProducibleType *p);
|
||||||
void deApplyStaticConsumption(const ProducibleType *p);
|
void deApplyStaticConsumption(const ProducibleType *p);
|
||||||
void applyCostsOnInterval();
|
void applyCostsOnInterval(const ResourceType *rtApply);
|
||||||
bool checkCosts(const ProducibleType *pt);
|
bool checkCosts(const ProducibleType *pt);
|
||||||
|
|
||||||
//reqs
|
//reqs
|
||||||
|
|
|
@ -288,7 +288,7 @@ void World::updateAllFactionConsumableCosts() {
|
||||||
const ResourceType *rt= techTree->getResourceType(i);
|
const ResourceType *rt= techTree->getResourceType(i);
|
||||||
if(rt->getClass() == rcConsumable && frameCount % (rt->getInterval() * GameConstants::updateFps)==0){
|
if(rt->getClass() == rcConsumable && frameCount % (rt->getInterval() * GameConstants::updateFps)==0){
|
||||||
for(int i=0; i<getFactionCount(); ++i){
|
for(int i=0; i<getFactionCount(); ++i){
|
||||||
getFaction(i)->applyCostsOnInterval();
|
getFaction(i)->applyCostsOnInterval(rt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user