Now water buildings are supported properly

This commit is contained in:
mathusummut
2019-04-06 01:11:36 +02:00
parent f85d7f322e
commit 5e2b48ee98
2 changed files with 4 additions and 3 deletions

View File

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

View File

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