re-fix titi's morph when no space available

This commit is contained in:
Mark Vejvoda 2013-06-19 00:19:29 +00:00
parent c9c5d9aa8f
commit aceb9aec0a

View File

@ -1332,24 +1332,23 @@ void Map::putUnitCellsPrivate(Unit *unit, const Vec2i &pos, const UnitType *ut,
// }
}
if(canPutInCell == true) {
if(getCell(currPos)->getUnit(field) == NULL ||
getCell(currPos)->getUnit(field) == unit) {
if(isMorph) {
// unit is beeing morphed to another unit with maybe other field.
getCell(currPos)->setUnit(field, unit);
canPutInCell = false;
}
if(canPutInCell == true) {
getCell(currPos)->setUnit(unit->getCurrField(), unit);
}
if(getCell(currPos)->getUnit(field) == NULL ||
getCell(currPos)->getUnit(field) == unit) {
if(isMorph) {
// unit is beeing morphed to another unit with maybe other field.
getCell(currPos)->setUnit(field, unit);
canPutInCell = false;
}
else {
char szBuf[8096]="";
snprintf(szBuf,8096,"Trying to move unit [%d - %s] into occupied cell [%s] and field = %d, unit already in cell [%d - %s] ",unit->getId(),unit->getType()->getName(false).c_str(),pos.getString().c_str(),field,getCell(currPos)->getUnit(field)->getId(),getCell(currPos)->getUnit(field)->getType()->getName(false).c_str());
throw megaglest_runtime_error(szBuf);
if(canPutInCell == true) {
getCell(currPos)->setUnit(unit->getCurrField(), unit);
}
}
else if(canPutInCell == true) {
char szBuf[8096]="";
snprintf(szBuf,8096,"Trying to move unit [%d - %s] into occupied cell [%s] and field = %d, unit already in cell [%d - %s] ",unit->getId(),unit->getType()->getName(false).c_str(),pos.getString().c_str(),field,getCell(currPos)->getUnit(field)->getId(),getCell(currPos)->getUnit(field)->getType()->getName(false).c_str());
throw megaglest_runtime_error(szBuf);
}
}
else if(ut->hasCellMap() == true &&
ut->getAllowEmptyCellMap() == true &&