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

wrap && conditions in parentheses when near ||

This commit is contained in:
Andrey Filipenkov 2022-09-22 11:22:14 +03:00
parent 2ce78ba8c9
commit 1d57c40740
6 changed files with 16 additions and 16 deletions

View File

@ -63,7 +63,7 @@ void DangerHitMapAnalyzer::updateHitMap()
auto & node = hitMap[pos.x][pos.y][pos.z]; auto & node = hitMap[pos.x][pos.y][pos.z];
if(tileDanger > node.maximumDanger.danger if(tileDanger > node.maximumDanger.danger
|| tileDanger == node.maximumDanger.danger && node.maximumDanger.turn > turn) || (tileDanger == node.maximumDanger.danger && node.maximumDanger.turn > turn))
{ {
node.maximumDanger.danger = tileDanger; node.maximumDanger.danger = tileDanger;
node.maximumDanger.turn = turn; node.maximumDanger.turn = turn;
@ -71,7 +71,7 @@ void DangerHitMapAnalyzer::updateHitMap()
} }
if(turn < node.fastestDanger.turn if(turn < node.fastestDanger.turn
|| turn == node.fastestDanger.turn && node.fastestDanger.danger < tileDanger) || (turn == node.fastestDanger.turn && node.fastestDanger.danger < tileDanger))
{ {
node.fastestDanger.danger = tileDanger; node.fastestDanger.danger = tileDanger;
node.fastestDanger.turn = turn; node.fastestDanger.turn = turn;
@ -101,8 +101,8 @@ uint64_t DangerHitMapAnalyzer::enemyCanKillOurHeroesAlongThePath(const AIPath &
int turn = path.turn(); int turn = path.turn();
const HitMapNode & info = hitMap[tile.x][tile.y][tile.z]; const HitMapNode & info = hitMap[tile.x][tile.y][tile.z];
return info.fastestDanger.turn <= turn && !isSafeToVisit(path.targetHero, path.heroArmy, info.fastestDanger.danger) return (info.fastestDanger.turn <= turn && !isSafeToVisit(path.targetHero, path.heroArmy, info.fastestDanger.danger))
|| info.maximumDanger.turn <= turn && !isSafeToVisit(path.targetHero, path.heroArmy, info.maximumDanger.danger); || (info.maximumDanger.turn <= turn && !isSafeToVisit(path.targetHero, path.heroArmy, info.maximumDanger.danger));
} }
const HitMapNode & DangerHitMapAnalyzer::getObjectTreat(const CGObjectInstance * obj) const const HitMapNode & DangerHitMapAnalyzer::getObjectTreat(const CGObjectInstance * obj) const

View File

@ -149,7 +149,7 @@ bool ObjectClusterizer::shouldVisitObject(const CGObjectInstance * obj) const
const int3 pos = obj->visitablePos(); const int3 pos = obj->visitablePos();
if(obj->ID != Obj::CREATURE_GENERATOR1 && vstd::contains(ai->memory->alreadyVisited, obj) if((obj->ID != Obj::CREATURE_GENERATOR1 && vstd::contains(ai->memory->alreadyVisited, obj))
|| obj->wasVisited(ai->playerID)) || obj->wasVisited(ai->playerID))
{ {
return false; return false;

View File

@ -106,10 +106,10 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
{ {
if(path.getHeroStrength() > treat.danger) if(path.getHeroStrength() > treat.danger)
{ {
if(path.turn() <= treat.turn && dayOfWeek + treat.turn < 6 && isSafeToVisit(path.targetHero, path.heroArmy, treat.danger) if((path.turn() <= treat.turn && dayOfWeek + treat.turn < 6 && isSafeToVisit(path.targetHero, path.heroArmy, treat.danger))
|| path.exchangeCount == 1 && path.turn() < treat.turn || (path.exchangeCount == 1 && path.turn() < treat.turn)
|| path.turn() < treat.turn - 1 || path.turn() < treat.turn - 1
|| path.turn() < treat.turn && treat.turn >= 2) || (path.turn() < treat.turn && treat.turn >= 2))
{ {
logAi->debug( logAi->debug(
"Hero %s can eliminate danger for town %s using path %s.", "Hero %s can eliminate danger for town %s using path %s.",
@ -217,7 +217,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
// dismiss creatures we are not able to pick to be able to hide in garrison // dismiss creatures we are not able to pick to be able to hide in garrison
if(town->garrisonHero if(town->garrisonHero
|| town->getUpperArmy()->stacksCount() == 0 || town->getUpperArmy()->stacksCount() == 0
|| town->getUpperArmy()->getArmyStrength() < 500 && town->fortLevel() >= CGTownInstance::CITADEL) || (town->getUpperArmy()->getArmyStrength() < 500 && town->fortLevel() >= CGTownInstance::CITADEL))
{ {
tasks.push_back( tasks.push_back(
Goals::sptr(Composition() Goals::sptr(Composition()
@ -228,7 +228,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
continue; continue;
} }
if(treat.turn == 0 || path.turn() <= treat.turn && path.getHeroStrength() * SAFE_ATTACK_CONSTANT >= treat.danger) if(treat.turn == 0 || (path.turn() <= treat.turn && path.getHeroStrength() * SAFE_ATTACK_CONSTANT >= treat.danger))
{ {
if(ai->nullkiller->arePathHeroesLocked(path)) if(ai->nullkiller->arePathHeroesLocked(path))
{ {

View File

@ -55,7 +55,7 @@ const CGHeroInstance * getNearestHero(const CGTownInstance * town)
if(shortestPath.nodes.size() > 1 if(shortestPath.nodes.size() > 1
|| shortestPath.turn() != 0 || shortestPath.turn() != 0
|| shortestPath.targetHero->visitablePos().dist2dSQ(town->visitablePos()) > 4 || shortestPath.targetHero->visitablePos().dist2dSQ(town->visitablePos()) > 4
|| town->garrisonHero && shortestPath.targetHero == town->garrisonHero.get()) || (town->garrisonHero && shortestPath.targetHero == town->garrisonHero.get()))
return nullptr; return nullptr;
return shortestPath.targetHero; return shortestPath.targetHero;
@ -76,7 +76,7 @@ bool needToRecruitHero(const CGTownInstance * startupTown)
for(auto obj : ai->nullkiller->objectClusterizer->getNearbyObjects()) for(auto obj : ai->nullkiller->objectClusterizer->getNearbyObjects())
{ {
if(obj->ID == Obj::RESOURCE && obj->subID == Res::GOLD if((obj->ID == Obj::RESOURCE && obj->subID == Res::GOLD)
|| obj->ID == Obj::TREASURE_CHEST || obj->ID == Obj::TREASURE_CHEST
|| obj->ID == Obj::CAMPFIRE || obj->ID == Obj::CAMPFIRE
|| obj->ID == Obj::WATER_WHEEL) || obj->ID == Obj::WATER_WHEEL)
@ -162,7 +162,7 @@ Goals::TGoalVec StartupBehavior::decompose() const
auto garrisonHeroScore = ai->nullkiller->heroManager->evaluateHero(garrisonHero); auto garrisonHeroScore = ai->nullkiller->heroManager->evaluateHero(garrisonHero);
if(visitingHeroScore > garrisonHeroScore if(visitingHeroScore > garrisonHeroScore
|| ai->nullkiller->heroManager->getHeroRole(garrisonHero) == HeroRole::SCOUT && ai->nullkiller->heroManager->getHeroRole(visitingHero) == HeroRole::MAIN) || (ai->nullkiller->heroManager->getHeroRole(garrisonHero) == HeroRole::SCOUT && ai->nullkiller->heroManager->getHeroRole(visitingHero) == HeroRole::MAIN))
{ {
if(canRecruitHero || ai->nullkiller->armyManager->howManyReinforcementsCanGet(visitingHero, garrisonHero) > 200) if(canRecruitHero || ai->nullkiller->armyManager->howManyReinforcementsCanGet(visitingHero, garrisonHero) > 200)
{ {

View File

@ -558,7 +558,7 @@ bool AINodeStorage::selectNextActor()
for(auto actor = actors.begin(); actor != actors.end(); actor++) for(auto actor = actors.begin(); actor != actors.end(); actor++)
{ {
if(actor->get()->armyValue > currentActor->get()->armyValue if(actor->get()->armyValue > currentActor->get()->armyValue
|| actor->get()->armyValue == currentActor->get()->armyValue && actor <= currentActor) || (actor->get()->armyValue == currentActor->get()->armyValue && actor <= currentActor))
{ {
continue; continue;
} }

View File

@ -5585,7 +5585,7 @@ bool CGameHandler::isAllowedExchange(ObjectInstanceID id1, ObjectInstanceID id2)
auto topArmy = dialog->exchangingArmies.at(0); auto topArmy = dialog->exchangingArmies.at(0);
auto bottomArmy = dialog->exchangingArmies.at(1); auto bottomArmy = dialog->exchangingArmies.at(1);
if (topArmy == o1 && bottomArmy == o2 || bottomArmy == o1 && topArmy == o2) if ((topArmy == o1 && bottomArmy == o2) || (bottomArmy == o1 && topArmy == o2))
return true; return true;
} }
} }