Skip to content

Commit

Permalink
Fix some stylistic logic display
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1arm committed Aug 20, 2024
1 parent 4e86df3 commit ec18c88
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 29 deletions.
16 changes: 12 additions & 4 deletions src/game/Server/WorldSocketMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ WorldSocketMgr::WorldSocketMgr()

WorldSocketMgr::~WorldSocketMgr()
{
if (reactor_) delete reactor_;
if (reactor_)
{
if (acceptor_) delete acceptor_;
delete reactor_;
}
if (acceptor_)
{
delete acceptor_;
}
}

Expand Down Expand Up @@ -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();
}
Expand Down
24 changes: 18 additions & 6 deletions src/modules/Bots/ahbot/AhBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
24 changes: 16 additions & 8 deletions src/modules/Bots/playerbot/PlayerbotSecurity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand 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;
}
}
Expand 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;
}
}
Expand All @@ -72,17 +76,19 @@ 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;
}
}
}

if (bot->IsDead())
{
if (reason) *reason = PLAYERBOT_DENY_DEAD;
if (reason)
{
*reason = PLAYERBOT_DENY_DEAD;
return PLAYERBOT_SECURITY_TALK;
}
}
Expand All @@ -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;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 10 additions & 5 deletions src/modules/Bots/playerbot/strategy/actions/AttackAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/modules/Bots/playerbot/strategy/actions/WhoAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit ec18c88

Please sign in to comment.