- disallow air units to morph back to land if unwalkable objects or water terrain are below

This commit is contained in:
Mark Vejvoda 2010-10-30 04:49:49 +00:00
parent f897884321
commit 060a9d3fe6
1 changed files with 14 additions and 3 deletions

View File

@ -315,10 +315,21 @@ bool Map::isFreeCell(const Vec2i &pos, Field field) const {
(field!=fLand || getDeepSubmerged(getCell(pos)) == false);
}
bool Map::isFreeCellOrHasUnit(const Vec2i &pos, Field field, const Unit *unit) const{
if(isInside(pos)){
bool Map::isFreeCellOrHasUnit(const Vec2i &pos, Field field, const Unit *unit) const {
if(isInside(pos)) {
Cell *c= getCell(pos);
if(c->getUnit(unit->getCurrField())==unit){
if(c->getUnit(unit->getCurrField()) == unit) {
if(unit->getCurrField() == fAir) {
const SurfaceCell *sc= getSurfaceCell(toSurfCoords(pos));
if(sc != NULL) {
if(getDeepSubmerged(sc) == true) {
return false;
}
else if(field == fLand) {
return sc->isFree();
}
}
}
return true;
}
else{