added a detailed error message to try to hunt down a bug discovered by Elimnator

This commit is contained in:
Mark Vejvoda 2011-11-10 21:00:50 +00:00
parent 9f316bef08
commit 1e34bc66c1
1 changed files with 13 additions and 4 deletions

View File

@ -660,10 +660,19 @@ bool Faction::applyCosts(const ProducibleType *p){
assert(p != NULL);
//for each unit cost spend it
//pass 2, decrease resources, except negative static costs (ie: farms)
for(int i=0; i<p->getCostCount(); ++i)
{
const ResourceType *rt= p->getCost(i)->getType();
int cost= p->getCost(i)->getAmount();
for(int i=0; i<p->getCostCount(); ++i) {
const Resource *r= p->getCost(i);
if(r == NULL) {
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)
{
incResourceAmount(rt, -(cost));