From 5e2b48ee987f07b9da4fc9268b24df70ca49410d Mon Sep 17 00:00:00 2001 From: mathusummut Date: Sat, 6 Apr 2019 01:11:36 +0200 Subject: [PATCH] Now water buildings are supported properly --- source/game/world/map.cpp | 5 +++-- source/game/world/unit_updater.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/game/world/map.cpp b/source/game/world/map.cpp index f97d10ec5..dc9d4d34b 100644 --- a/source/game/world/map.cpp +++ b/source/game/world/map.cpp @@ -772,8 +772,9 @@ namespace Game { isInside(pos) && isInsideSurface(toSurfCoords(pos)) && (getCell(pos)->isFree(field) ? true : (buildingsOnly && !getCell(pos)->getUnit(field)->getType()->hasSkillClass(scBeBuilt))) && - (SkillType::toActualField(field) == fAir || getSurfaceCell(toSurfCoords(pos))->isFree()) && - (SkillType::toActualField(field) == fAir || ((field & fWater) == fWater ? ((field & fLand) == fLand ? true : getDeepSubmerged(getCell(pos))) : !getDeepSubmerged(getCell(pos)))); + (SkillType::toActualField(field) == fAir || + (getSurfaceCell(toSurfCoords(pos))->isFree() && + ((field & fWater) == fWater ? ((field & fLand) == fLand ? true : getDeepSubmerged(getCell(pos))) : !getDeepSubmerged(getCell(pos))))); } diff --git a/source/game/world/unit_updater.cpp b/source/game/world/unit_updater.cpp index aca5b2ae0..9c1ce4f7c 100644 --- a/source/game/world/unit_updater.cpp +++ b/source/game/world/unit_updater.cpp @@ -1064,7 +1064,7 @@ namespace Game { Unit *builtUnit = new Unit(world->getNextUnitId(unit->getFaction()), newpath, buildPos, builtUnitType, unit->getFaction(), world->getMap(), facing); if (toleratePos) builtUnit->setPos(pathFinder->computeNearestFreePos(builtUnit, buildPos, false, true)); - if (world->getMap()->isFreeCells(builtUnit->getPos(), builtUnit->getType()->getSize(), builtUnit->getCurrField(), true)) { + if (world->getMap()->isFreeCells(builtUnit->getPos(), builtUnit->getType()->getSize(), (builtUnit->getCurrField() & fAir) == fAir ? fAir : fLandWater, true)) { if (SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands, "In [%s::%s Line: %d]\n", __FILE__, __FUNCTION__, __LINE__); builtUnit->create();