mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
wrap && conditions in parentheses when near ||
This commit is contained in:
parent
2ce78ba8c9
commit
1d57c40740
@ -63,7 +63,7 @@ void DangerHitMapAnalyzer::updateHitMap()
|
||||
auto & node = hitMap[pos.x][pos.y][pos.z];
|
||||
|
||||
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.turn = turn;
|
||||
@ -71,7 +71,7 @@ void DangerHitMapAnalyzer::updateHitMap()
|
||||
}
|
||||
|
||||
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.turn = turn;
|
||||
@ -101,8 +101,8 @@ uint64_t DangerHitMapAnalyzer::enemyCanKillOurHeroesAlongThePath(const AIPath &
|
||||
int turn = path.turn();
|
||||
const HitMapNode & info = hitMap[tile.x][tile.y][tile.z];
|
||||
|
||||
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);
|
||||
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));
|
||||
}
|
||||
|
||||
const HitMapNode & DangerHitMapAnalyzer::getObjectTreat(const CGObjectInstance * obj) const
|
||||
|
@ -149,7 +149,7 @@ bool ObjectClusterizer::shouldVisitObject(const CGObjectInstance * obj) const
|
||||
|
||||
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))
|
||||
{
|
||||
return false;
|
||||
|
@ -106,10 +106,10 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
{
|
||||
if(path.getHeroStrength() > 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
|
||||
if((path.turn() <= treat.turn && dayOfWeek + treat.turn < 6 && isSafeToVisit(path.targetHero, path.heroArmy, treat.danger))
|
||||
|| (path.exchangeCount == 1 && path.turn() < treat.turn)
|
||||
|| path.turn() < treat.turn - 1
|
||||
|| path.turn() < treat.turn && treat.turn >= 2)
|
||||
|| (path.turn() < treat.turn && treat.turn >= 2))
|
||||
{
|
||||
logAi->debug(
|
||||
"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
|
||||
if(town->garrisonHero
|
||||
|| town->getUpperArmy()->stacksCount() == 0
|
||||
|| town->getUpperArmy()->getArmyStrength() < 500 && town->fortLevel() >= CGTownInstance::CITADEL)
|
||||
|| (town->getUpperArmy()->getArmyStrength() < 500 && town->fortLevel() >= CGTownInstance::CITADEL))
|
||||
{
|
||||
tasks.push_back(
|
||||
Goals::sptr(Composition()
|
||||
@ -228,7 +228,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
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))
|
||||
{
|
||||
@ -294,4 +294,4 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
}
|
||||
|
||||
logAi->debug("Found %d tasks", tasks.size());
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ const CGHeroInstance * getNearestHero(const CGTownInstance * town)
|
||||
if(shortestPath.nodes.size() > 1
|
||||
|| shortestPath.turn() != 0
|
||||
|| shortestPath.targetHero->visitablePos().dist2dSQ(town->visitablePos()) > 4
|
||||
|| town->garrisonHero && shortestPath.targetHero == town->garrisonHero.get())
|
||||
|| (town->garrisonHero && shortestPath.targetHero == town->garrisonHero.get()))
|
||||
return nullptr;
|
||||
|
||||
return shortestPath.targetHero;
|
||||
@ -76,7 +76,7 @@ bool needToRecruitHero(const CGTownInstance * startupTown)
|
||||
|
||||
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::CAMPFIRE
|
||||
|| obj->ID == Obj::WATER_WHEEL)
|
||||
@ -162,7 +162,7 @@ Goals::TGoalVec StartupBehavior::decompose() const
|
||||
auto garrisonHeroScore = ai->nullkiller->heroManager->evaluateHero(garrisonHero);
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -558,7 +558,7 @@ bool AINodeStorage::selectNextActor()
|
||||
for(auto actor = actors.begin(); actor != actors.end(); actor++)
|
||||
{
|
||||
if(actor->get()->armyValue > currentActor->get()->armyValue
|
||||
|| actor->get()->armyValue == currentActor->get()->armyValue && actor <= currentActor)
|
||||
|| (actor->get()->armyValue == currentActor->get()->armyValue && actor <= currentActor))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -5585,7 +5585,7 @@ bool CGameHandler::isAllowedExchange(ObjectInstanceID id1, ObjectInstanceID id2)
|
||||
auto topArmy = dialog->exchangingArmies.at(0);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user