- added more error details when some errors are generated

This commit is contained in:
Mark Vejvoda 2011-03-22 17:55:11 +00:00
parent 14bd71c250
commit 6c9ba8bea4
2 changed files with 12 additions and 10 deletions

View File

@ -483,19 +483,18 @@ void Faction::applyDiscount(const ProducibleType *p, int discount)
} }
//apply static production (for starting units) //apply static production (for starting units)
void Faction::applyStaticCosts(const ProducibleType *p) void Faction::applyStaticCosts(const ProducibleType *p) {
{
assert(p != NULL); assert(p != NULL);
//decrease static resources //decrease static resources
for(int i=0; i<p->getCostCount(); ++i) for(int i=0; i<p->getCostCount(); ++i) {
{
const ResourceType *rt= p->getCost(i)->getType(); const ResourceType *rt= p->getCost(i)->getType();
assert(rt != NULL); assert(rt != NULL);
if(rt->getClass() == rcStatic) if(rt == NULL) {
{ throw runtime_error("rt == NULL");
}
if(rt->getClass() == rcStatic) {
int cost= p->getCost(i)->getAmount(); int cost= p->getCost(i)->getAmount();
if(cost > 0) if(cost > 0) {
{
incResourceAmount(rt, -cost); incResourceAmount(rt, -cost);
} }
} }

View File

@ -119,11 +119,14 @@ void SurfaceAtlas::checkDimensions(const Pixmap2D *p) {
if(p == NULL) { if(p == NULL) {
throw runtime_error("Bad surface texture pixmap (NULL)"); throw runtime_error("Bad surface texture pixmap (NULL)");
} }
else if(surfaceSize == -1){ else if(surfaceSize == -1) {
surfaceSize= p->getW(); surfaceSize= p->getW();
//printf("Setting surfaceSize = %d for pixmap [%s]\n",surfaceSize,p->getPath().c_str());
} }
else if(p->getW() != surfaceSize || p->getH() != surfaceSize) { else if(p->getW() != surfaceSize || p->getH() != surfaceSize) {
throw runtime_error("Bad surface texture dimensions"); char szBuf[1024]="";
sprintf(szBuf,"Bad surface texture dimensions, expected surfaceSize = %d, texture w = %d, h = %d",surfaceSize,p->getW(),p->getH());
throw runtime_error(szBuf);
} }
} }