added a detailed error message to try to hunt down a bug discovered by Elimnator
This commit is contained in:
parent
9f316bef08
commit
1e34bc66c1
|
@ -660,10 +660,19 @@ bool Faction::applyCosts(const ProducibleType *p){
|
||||||
assert(p != NULL);
|
assert(p != NULL);
|
||||||
//for each unit cost spend it
|
//for each unit cost spend it
|
||||||
//pass 2, decrease resources, except negative static costs (ie: farms)
|
//pass 2, decrease resources, except negative static costs (ie: farms)
|
||||||
for(int i=0; i<p->getCostCount(); ++i)
|
for(int i=0; i<p->getCostCount(); ++i) {
|
||||||
{
|
const Resource *r= p->getCost(i);
|
||||||
const ResourceType *rt= p->getCost(i)->getType();
|
if(r == NULL) {
|
||||||
int cost= p->getCost(i)->getAmount();
|
char szBuf[1024]="";
|
||||||
|
sprintf(szBuf,"cannot apply costs for p [%s] %d of %d costs resource is null",p->getName().c_str(),i,p->getCostCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
const ResourceType *rt= r->getType();
|
||||||
|
if(rt == NULL) {
|
||||||
|
char szBuf[1024]="";
|
||||||
|
sprintf(szBuf,"cannot apply costs for p [%s] %d of %d costs resourcetype [%s] is null",p->getName().c_str(),i,p->getCostCount(),r->getDescription().c_str());
|
||||||
|
}
|
||||||
|
int cost= r->getAmount();
|
||||||
if((cost > 0 || (rt->getClass() != rcStatic)) && rt->getClass() != rcConsumable)
|
if((cost > 0 || (rt->getClass() != rcStatic)) && rt->getClass() != rcConsumable)
|
||||||
{
|
{
|
||||||
incResourceAmount(rt, -(cost));
|
incResourceAmount(rt, -(cost));
|
||||||
|
|
Loading…
Reference in New Issue