diff --git a/AI/BattleAI/AttackPossibility.cpp b/AI/BattleAI/AttackPossibility.cpp index 7693c5768..b54007dbe 100644 --- a/AI/BattleAI/AttackPossibility.cpp +++ b/AI/BattleAI/AttackPossibility.cpp @@ -86,10 +86,8 @@ AttackPossibility AttackPossibility::evaluate(const BattleAttackInfo & attackInf for(BattleHex defHex : defenderHex) { - if(defHex == hex) { - // should be impossible but check anyway + if(defHex == hex) // should be impossible but check anyway continue; - } AttackPossibility ap(hex, defHex, attackInfo); ap.attackerState = attacker->acquireState(); @@ -109,20 +107,22 @@ AttackPossibility AttackPossibility::evaluate(const BattleAttackInfo & attackInf // ensure the defender is also affected bool addDefender = true; - for(auto unit : units) { - if (unit->unitId() == defender->unitId()) { + for(auto unit : units) + { + if (unit->unitId() == defender->unitId()) + { addDefender = false; break; } } - if(addDefender) { - units.push_back(defender); - } - for(auto u : units) { - if(!ap.attackerState->alive()) { + if(addDefender) + units.push_back(defender); + + for(auto u : units) + { + if(!ap.attackerState->alive()) break; - } assert(u->unitId() != attacker->unitId()); diff --git a/lib/battle/CBattleInfoCallback.cpp b/lib/battle/CBattleInfoCallback.cpp index b15ce3df5..7e0f84636 100644 --- a/lib/battle/CBattleInfoCallback.cpp +++ b/lib/battle/CBattleInfoCallback.cpp @@ -1475,16 +1475,15 @@ std::vector CBattleInfoCallback::getAttackedBattleUnits(con units = battleGetUnitsIf([=](const battle::Unit * unit) { - if (unit->isGhost() || !unit->alive()) { + if (unit->isGhost() || !unit->alive()) return false; - } - for (BattleHex hex : battle::Unit::getHexes(unit->getPosition(), unit->doubleWide(), unit->unitSide())) { - if (vstd::contains(at.hostileCreaturePositions, hex)) { + + for (BattleHex hex : battle::Unit::getHexes(unit->getPosition(), unit->doubleWide(), unit->unitSide())) + { + if (vstd::contains(at.hostileCreaturePositions, hex)) return true; - } - if (vstd::contains(at.friendlyCreaturePositions, hex)) { + if (vstd::contains(at.friendlyCreaturePositions, hex)) return true; - } } return false; }); diff --git a/lib/logging/CBasicLogConfigurator.cpp b/lib/logging/CBasicLogConfigurator.cpp index 5000a4663..94e37b17d 100644 --- a/lib/logging/CBasicLogConfigurator.cpp +++ b/lib/logging/CBasicLogConfigurator.cpp @@ -141,9 +141,9 @@ EConsoleTextColor::EConsoleTextColor CBasicLogConfigurator::getConsoleColor(cons throw std::runtime_error("Color " + colorName + " unknown."); } -void CBasicLogConfigurator::deconfigure() { +void CBasicLogConfigurator::deconfigure() +{ auto l = CLogger::getGlobalLogger(); - if(l != nullptr) { + if(l != nullptr) l->clearTargets(); - } }