- added map cell checks back but output to error log only (and assert for debug mode)

This commit is contained in:
Mark Vejvoda 2010-11-28 03:21:20 +00:00
parent 128b98b619
commit ab966d7872
1 changed files with 8 additions and 6 deletions

View File

@ -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);