From 2f3f8d565ca141ef598d8f6ebe307fc01cd6d35e Mon Sep 17 00:00:00 2001 From: Yunfan Li <56597220+liyunfan1223@users.noreply.github.com> Date: Tue, 8 Apr 2025 10:11:03 +0800 Subject: [PATCH] Make battleground join / arena join / loot money session packet (#1178) * Make battleground / arena join session packet * Loot money * Avoid aoe crash --- .../actions/BattleGroundJoinAction.cpp | 18 +++++++++++------- src/strategy/actions/LootAction.cpp | 5 +++-- src/strategy/values/AoeValues.cpp | 4 ++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/strategy/actions/BattleGroundJoinAction.cpp b/src/strategy/actions/BattleGroundJoinAction.cpp index 541ce2a4..1bc71fe1 100644 --- a/src/strategy/actions/BattleGroundJoinAction.cpp +++ b/src/strategy/actions/BattleGroundJoinAction.cpp @@ -543,18 +543,22 @@ bool BGJoinAction::JoinQueue(uint32 type) } botAI->GetAiObjectContext()->GetValue("bg type")->Set(0); - + if (!isArena) { - WorldPacket packet(CMSG_BATTLEMASTER_JOIN, 20); - packet << bot->GetGUID() << bgTypeId_ << instanceId << joinAsGroup; - bot->GetSession()->HandleBattlemasterJoinOpcode(packet); + WorldPacket* packet = new WorldPacket(CMSG_BATTLEMASTER_JOIN, 20); + *packet << bot->GetGUID() << bgTypeId_ << instanceId << joinAsGroup; + /// FIX race condition + // bot->GetSession()->HandleBattlemasterJoinOpcode(packet); + bot->GetSession()->QueuePacket(packet); } else { - WorldPacket arena_packet(CMSG_BATTLEMASTER_JOIN_ARENA, 20); - arena_packet << unit->GetGUID() << arenaslot << asGroup << uint8(isRated); - bot->GetSession()->HandleBattlemasterJoinArena(arena_packet); + WorldPacket* arena_packet = new WorldPacket(CMSG_BATTLEMASTER_JOIN_ARENA, 20); + *arena_packet << unit->GetGUID() << arenaslot << asGroup << uint8(isRated); + /// FIX race condition + // bot->GetSession()->HandleBattlemasterJoinArena(arena_packet); + bot->GetSession()->QueuePacket(arena_packet); } return true; diff --git a/src/strategy/actions/LootAction.cpp b/src/strategy/actions/LootAction.cpp index c1724e17..95e4a744 100644 --- a/src/strategy/actions/LootAction.cpp +++ b/src/strategy/actions/LootAction.cpp @@ -356,8 +356,9 @@ bool StoreLootAction::Execute(Event event) if (gold > 0) { - WorldPacket packet(CMSG_LOOT_MONEY, 0); - bot->GetSession()->HandleLootMoneyOpcode(packet); + WorldPacket* packet = new WorldPacket(CMSG_LOOT_MONEY, 0); + bot->GetSession()->QueuePacket(packet); + // bot->GetSession()->HandleLootMoneyOpcode(packet); } for (uint8 i = 0; i < items; ++i) diff --git a/src/strategy/values/AoeValues.cpp b/src/strategy/values/AoeValues.cpp index 67508f66..4f8a94b1 100644 --- a/src/strategy/values/AoeValues.cpp +++ b/src/strategy/values/AoeValues.cpp @@ -135,7 +135,11 @@ Aura* AreaDebuffValue::Calculate() for (auto i = list.begin(); i != list.end(); ++i) { AuraEffect* aurEff = *i; + if (!aurEff) + continue; Aura* aura = aurEff->GetBase(); + if (!aura) + continue; AuraObjectType type = aura->GetType(); bool isPositive = aura->GetSpellInfo()->IsPositive(); if (type == DYNOBJ_AURA_TYPE && !isPositive)