1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

More formatting

This commit is contained in:
Victor Luchits 2020-05-16 16:14:58 +03:00
parent d4cc005882
commit b4025fa1d6
3 changed files with 20 additions and 21 deletions

View File

@ -86,10 +86,8 @@ AttackPossibility AttackPossibility::evaluate(const BattleAttackInfo & attackInf
for(BattleHex defHex : defenderHex) for(BattleHex defHex : defenderHex)
{ {
if(defHex == hex) { if(defHex == hex) // should be impossible but check anyway
// should be impossible but check anyway
continue; continue;
}
AttackPossibility ap(hex, defHex, attackInfo); AttackPossibility ap(hex, defHex, attackInfo);
ap.attackerState = attacker->acquireState(); ap.attackerState = attacker->acquireState();
@ -109,20 +107,22 @@ AttackPossibility AttackPossibility::evaluate(const BattleAttackInfo & attackInf
// ensure the defender is also affected // ensure the defender is also affected
bool addDefender = true; bool addDefender = true;
for(auto unit : units) { for(auto unit : units)
if (unit->unitId() == defender->unitId()) { {
if (unit->unitId() == defender->unitId())
{
addDefender = false; addDefender = false;
break; break;
} }
} }
if(addDefender) {
units.push_back(defender);
}
for(auto u : units) { if(addDefender)
if(!ap.attackerState->alive()) { units.push_back(defender);
for(auto u : units)
{
if(!ap.attackerState->alive())
break; break;
}
assert(u->unitId() != attacker->unitId()); assert(u->unitId() != attacker->unitId());

View File

@ -1475,16 +1475,15 @@ std::vector<const battle::Unit*> CBattleInfoCallback::getAttackedBattleUnits(con
units = battleGetUnitsIf([=](const battle::Unit * unit) units = battleGetUnitsIf([=](const battle::Unit * unit)
{ {
if (unit->isGhost() || !unit->alive()) { if (unit->isGhost() || !unit->alive())
return false; return false;
}
for (BattleHex hex : battle::Unit::getHexes(unit->getPosition(), unit->doubleWide(), unit->unitSide())) { for (BattleHex hex : battle::Unit::getHexes(unit->getPosition(), unit->doubleWide(), unit->unitSide()))
if (vstd::contains(at.hostileCreaturePositions, hex)) { {
if (vstd::contains(at.hostileCreaturePositions, hex))
return true; return true;
} if (vstd::contains(at.friendlyCreaturePositions, hex))
if (vstd::contains(at.friendlyCreaturePositions, hex)) {
return true; return true;
}
} }
return false; return false;
}); });

View File

@ -141,9 +141,9 @@ EConsoleTextColor::EConsoleTextColor CBasicLogConfigurator::getConsoleColor(cons
throw std::runtime_error("Color " + colorName + " unknown."); throw std::runtime_error("Color " + colorName + " unknown.");
} }
void CBasicLogConfigurator::deconfigure() { void CBasicLogConfigurator::deconfigure()
{
auto l = CLogger::getGlobalLogger(); auto l = CLogger::getGlobalLogger();
if(l != nullptr) { if(l != nullptr)
l->clearTargets(); l->clearTargets();
}
} }