From ec18c88424da67e104b7f4316c1e851fa070abc7 Mon Sep 17 00:00:00 2001 From: billy1arm Date: Tue, 20 Aug 2024 07:23:45 +0100 Subject: [PATCH] Fix some stylistic logic display --- src/game/Server/WorldSocketMgr.cpp | 16 +++++++++---- src/modules/Bots/ahbot/AhBot.cpp | 24 ++++++++++++++----- .../Bots/playerbot/PlayerbotSecurity.cpp | 24 ++++++++++++------- .../Bots/playerbot/RandomPlayerbotMgr.cpp | 5 ++-- .../strategy/actions/AttackAction.cpp | 15 ++++++++---- .../playerbot/strategy/actions/WhoAction.cpp | 10 ++++---- 6 files changed, 65 insertions(+), 29 deletions(-) diff --git a/src/game/Server/WorldSocketMgr.cpp b/src/game/Server/WorldSocketMgr.cpp index 07a1717e9..e20481962 100644 --- a/src/game/Server/WorldSocketMgr.cpp +++ b/src/game/Server/WorldSocketMgr.cpp @@ -50,9 +50,13 @@ WorldSocketMgr::WorldSocketMgr() WorldSocketMgr::~WorldSocketMgr() { - if (reactor_) delete reactor_; + if (reactor_) { - if (acceptor_) delete acceptor_; + delete reactor_; + } + if (acceptor_) + { + delete acceptor_; } } @@ -114,9 +118,13 @@ int WorldSocketMgr::StartNetwork(ACE_INET_Addr& addr) void WorldSocketMgr::StopNetwork() { - if (acceptor_) acceptor_->close(); + if (acceptor_) + { + acceptor_->close(); + } + if (reactor_) { - if (reactor_) reactor_->end_reactor_event_loop(); + reactor_->end_reactor_event_loop(); } wait(); } diff --git a/src/modules/Bots/ahbot/AhBot.cpp b/src/modules/Bots/ahbot/AhBot.cpp index 593ed0451..4c7ebfee6 100644 --- a/src/modules/Bots/ahbot/AhBot.cpp +++ b/src/modules/Bots/ahbot/AhBot.cpp @@ -341,9 +341,13 @@ int AhBot::Answer(int auction, Category* category, ItemBag* inAuctionItems) uint32 buyoutPrice = item->GetCount() * urand(price, 4 * price / 3); uint32 curPrice = entry->bid; - if (!curPrice) curPrice = entry->startbid; + if (!curPrice) { - if (!curPrice) curPrice = entry->buyout; + curPrice = entry->startbid; + } + if (!curPrice) + { + curPrice = entry->buyout; } if (curPrice > buyoutPrice) @@ -469,9 +473,13 @@ uint32 AhBot::GetBuyTime(uint32 entry, uint32 itemId, uint32 auctionHouse, Categ uint32 categoryTime = GetTime(categoryName, 0, auctionHouse, AHBOT_WON_DELAY); uint32 itemTime = GetTime("item", itemId, auctionHouse, AHBOT_WON_DELAY); - if (categoryTime < time(0)) categoryTime = time(0); + if (categoryTime < time(0)) + { + categoryTime = time(0); + } + if (itemTime < time(0)) { - if (itemTime < time(0)) itemTime = time(0); + itemTime = time(0); } double rarity = category->GetPricingStrategy()->GetRarityPriceMultiplier(itemId); @@ -504,9 +512,13 @@ uint32 AhBot::GetSellTime(uint32 itemId, uint32 auctionHouse, Category*& categor uint32 categoryBuyTime = GetTime(categoryName, 0, auctionHouse, AHBOT_WON_DELAY); uint32 categoryTime = max(categorySellTime, categoryBuyTime); - if (categoryTime < time(0)) categoryTime = time(0); + if (categoryTime < time(0)) + { + categoryTime = time(0); + } + if (itemTime < time(0)) { - if (itemTime < time(0)) itemTime = time(0); + itemTime = time(0); } double rarity = category->GetPricingStrategy()->GetRarityPriceMultiplier(itemId); diff --git a/src/modules/Bots/playerbot/PlayerbotSecurity.cpp b/src/modules/Bots/playerbot/PlayerbotSecurity.cpp index 45816e931..57e679f96 100644 --- a/src/modules/Bots/playerbot/PlayerbotSecurity.cpp +++ b/src/modules/Bots/playerbot/PlayerbotSecurity.cpp @@ -23,16 +23,18 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea if (from->GetPlayerbotAI()) { - if (reason) *reason = PLAYERBOT_DENY_IS_BOT; + if (reason) { + *reason = PLAYERBOT_DENY_IS_BOT; return PLAYERBOT_SECURITY_DENY_ALL; } } if (bot->GetPlayerbotAI()->IsOpposing(from)) { - if (reason) *reason = PLAYERBOT_DENY_OPPOSING; + if (reason) { + *reason = PLAYERBOT_DENY_OPPOSING; return PLAYERBOT_SECURITY_DENY_ALL; } } @@ -41,8 +43,9 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea { if (bot->GetPlayerbotAI()->IsOpposing(from)) { - if (reason) *reason = PLAYERBOT_DENY_OPPOSING; + if (reason) { + *reason = PLAYERBOT_DENY_OPPOSING; return PLAYERBOT_SECURITY_DENY_ALL; } } @@ -62,8 +65,9 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea if ((int)bot->getLevel() - (int)from->getLevel() > 5) { - if (reason) *reason = PLAYERBOT_DENY_LOW_LEVEL; + if (reason) { + *reason = PLAYERBOT_DENY_LOW_LEVEL; return PLAYERBOT_SECURITY_TALK; } } @@ -72,8 +76,9 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea { if (!bot->GetGuildId() || bot->GetGuildId() != from->GetGuildId()) { - if (reason) *reason = PLAYERBOT_DENY_FAR; + if (reason) { + *reason = PLAYERBOT_DENY_FAR; return PLAYERBOT_SECURITY_TALK; } } @@ -81,8 +86,9 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea if (bot->IsDead()) { - if (reason) *reason = PLAYERBOT_DENY_DEAD; + if (reason) { + *reason = PLAYERBOT_DENY_DEAD; return PLAYERBOT_SECURITY_TALK; } } @@ -107,14 +113,16 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea if (group->IsFull()) { - if (reason) *reason = PLAYERBOT_DENY_FULL_GROUP; + if (reason) { + *reason = PLAYERBOT_DENY_FULL_GROUP; return PLAYERBOT_SECURITY_TALK; } } - if (reason) *reason = PLAYERBOT_DENY_INVITE; + if (reason) { + *reason = PLAYERBOT_DENY_INVITE; return PLAYERBOT_SECURITY_INVITE; } } diff --git a/src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp b/src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp index 8a74531df..7af151771 100644 --- a/src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp +++ b/src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp @@ -892,10 +892,11 @@ void RandomPlayerbotMgr::PrintStats() uint32 from = i*10; uint32 to = min(from + 9, maxLevel); - if (!from) from = 1; + if (!from) { - sLog.outString(" %d..%d: %d alliance, %d horde", from, to, alliance[i], horde[i]); + from = 1; } + sLog.outString(" %d..%d: %d alliance, %d horde", from, to, alliance[i], horde[i]); } sLog.outString("Per race:"); for (uint8 race = RACE_HUMAN; race < MAX_RACES; ++race) diff --git a/src/modules/Bots/playerbot/strategy/actions/AttackAction.cpp b/src/modules/Bots/playerbot/strategy/actions/AttackAction.cpp index 2a3bee217..ef5710120 100644 --- a/src/modules/Bots/playerbot/strategy/actions/AttackAction.cpp +++ b/src/modules/Bots/playerbot/strategy/actions/AttackAction.cpp @@ -30,8 +30,9 @@ bool AttackMyTargetAction::Execute(Event event) ObjectGuid guid = master->GetSelectionGuid(); if (!guid) { - if (verbose) ai->TellMaster("You have no target"); + if (verbose) { + ai->TellMaster("You have no target"); return false; } } @@ -44,16 +45,18 @@ bool AttackAction::Attack(Unit* target) MotionMaster &mm = *bot->GetMotionMaster(); if (mm.GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE || bot->IsTaxiFlying()) { - if (verbose) ai->TellMaster("I cannot attack in flight"); + if (verbose) { + ai->TellMaster("I cannot attack in flight"); return false; } } if (!target) { - if (verbose) ai->TellMaster("I have no target"); + if (verbose) { + ai->TellMaster("I have no target"); return false; } } @@ -63,16 +66,18 @@ bool AttackAction::Attack(Unit* target) if (bot->IsFriendlyTo(target)) { msg << " is friendly to me"; - if (verbose) ai->TellMaster(msg.str()); + if (verbose) { + ai->TellMaster(msg.str()); return false; } } if (!bot->IsWithinLOSInMap(target)) { msg << " is not on my sight"; - if (verbose) ai->TellMaster(msg.str()); + if (verbose) { + ai->TellMaster(msg.str()); return false; } } diff --git a/src/modules/Bots/playerbot/strategy/actions/WhoAction.cpp b/src/modules/Bots/playerbot/strategy/actions/WhoAction.cpp index 25b476218..494d40058 100644 --- a/src/modules/Bots/playerbot/strategy/actions/WhoAction.cpp +++ b/src/modules/Bots/playerbot/strategy/actions/WhoAction.cpp @@ -129,19 +129,21 @@ string WhoAction::QuerySpec(string text) if (visitor.count[ITEM_QUALITY_RARE]) { - if (needSlash) out << "/"; + if (needSlash) { - out << "|h|cff8080ff" << visitor.count[ITEM_QUALITY_RARE] << "|h|cffffffff"; + out << "/"; } + out << "|h|cff8080ff" << visitor.count[ITEM_QUALITY_RARE] << "|h|cffffffff"; needSlash = true; } if (visitor.count[ITEM_QUALITY_UNCOMMON]) { - if (needSlash) out << "/"; + if (needSlash) { - out << "|h|cff00ff00" << visitor.count[ITEM_QUALITY_UNCOMMON] << "|h|cffffffff"; + out << "/"; } + out << "|h|cff00ff00" << visitor.count[ITEM_QUALITY_UNCOMMON] << "|h|cffffffff"; needSlash = true; }