From ab966d78723119798a4cd6baed6e7ab5a9b4011d Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sun, 28 Nov 2010 03:21:20 +0000 Subject: [PATCH] - added map cell checks back but output to error log only (and assert for debug mode) --- source/glest_game/world/map.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index a252fe1e..e04d65ed 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -822,10 +822,11 @@ void Map::putUnitCells(Unit *unit, const Vec2i &pos) { if( ut->hasCellMap() == false || ut->getCellMapCell(i, j, unit->getModelFacing())) { // NOT SURE UNDER WHAT CONDITIONS THIS COULD HAPPEN? - //assert(getCell(currPos)->getUnit(unit->getCurrField()) == NULL); - //if(getCell(currPos)->getUnit(unit->getCurrField()) != NULL) { + assert(getCell(currPos)->getUnit(unit->getCurrField()) == NULL); + if(getCell(currPos)->getUnit(unit->getCurrField()) != NULL) { // throw runtime_error("getCell(currPos)->getUnit(unit->getCurrField()) != NULL"); - //} + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] ERROR [getCell(currPos)->getUnit(unit->getCurrField()) != NULL] currPos [%s] unit [%s] cell unit [%s]\n",__FILE__,__FUNCTION__,__LINE__,currPos.getString().c_str(),unit->toString().c_str(),getCell(currPos)->getUnit(unit->getCurrField())->toString().c_str()); + } getCell(currPos)->setUnit(unit->getCurrField(), unit); @@ -864,10 +865,11 @@ void Map::clearUnitCells(Unit *unit, const Vec2i &pos) { // This seems to be a bad assert since you can clear the cell // for many reasons including a unit dieing. - //assert(getCell(currPos)->getUnit(unit->getCurrField())==unit); - //if(getCell(currPos)->getUnit(unit->getCurrField()) != unit) { + assert(getCell(currPos)->getUnit(unit->getCurrField())==unit); + if(getCell(currPos)->getUnit(unit->getCurrField()) != unit) { // throw runtime_error("getCell(currPos)->getUnit(unit->getCurrField()) != unit"); - //} + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] ERROR [getCell(currPos)->getUnit(unit->getCurrField()) != unit] currPos [%s] unit [%s] cell unit [%s]\n",__FILE__,__FUNCTION__,__LINE__,currPos.getString().c_str(),unit->toString().c_str(),(getCell(currPos)->getUnit(unit->getCurrField()) != NULL ? getCell(currPos)->getUnit(unit->getCurrField())->toString().c_str() : "NULL")); + } getCell(currPos)->setUnit(unit->getCurrField(), NULL);