From 6c9ba8bea4b157d051dc17dd8e41aa8b15076cc4 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 22 Mar 2011 17:55:11 +0000 Subject: [PATCH] - added more error details when some errors are generated --- source/glest_game/type_instances/faction.cpp | 15 +++++++-------- source/glest_game/world/surface_atlas.cpp | 7 +++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index c14b2669..491160e4 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -483,19 +483,18 @@ void Faction::applyDiscount(const ProducibleType *p, int discount) } //apply static production (for starting units) -void Faction::applyStaticCosts(const ProducibleType *p) -{ +void Faction::applyStaticCosts(const ProducibleType *p) { assert(p != NULL); //decrease static resources - for(int i=0; igetCostCount(); ++i) - { + for(int i=0; igetCostCount(); ++i) { const ResourceType *rt= p->getCost(i)->getType(); 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(); - if(cost > 0) - { + if(cost > 0) { incResourceAmount(rt, -cost); } } diff --git a/source/glest_game/world/surface_atlas.cpp b/source/glest_game/world/surface_atlas.cpp index 15541d1f..f3d6c6d9 100644 --- a/source/glest_game/world/surface_atlas.cpp +++ b/source/glest_game/world/surface_atlas.cpp @@ -119,11 +119,14 @@ void SurfaceAtlas::checkDimensions(const Pixmap2D *p) { if(p == NULL) { throw runtime_error("Bad surface texture pixmap (NULL)"); } - else if(surfaceSize == -1){ + else if(surfaceSize == -1) { surfaceSize= p->getW(); + //printf("Setting surfaceSize = %d for pixmap [%s]\n",surfaceSize,p->getPath().c_str()); } 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); } }