Skip to content

Commit

Permalink
-Bg crash fix: Fixes crash when bots join a bg from another bg.
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlikely4r committed Oct 2, 2024
1 parent 48c538e commit 09b5a9f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions playerbot/strategy/actions/BattleGroundJoinAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,18 @@ bool BGStatusAction::Execute(Event& event)
packet << type << unk2 << (uint32)_bgTypeId << unk << action;
#endif

if (bot->InBattleGround() && bot->GetBattleGroundTypeId() != _bgTypeId)
{
//We are already in a BG. Joining a new one directly causes a crash when SetBattleGroundId is reset during leave right before teleporting in the new one.
//Here we leave the current BG proper so we can join the next fresh.
WorldPacket leave(CMSG_LEAVE_BATTLEFIELD);
leave << uint8(0) << uint8(0) << uint32(0) << uint16(0);
bot->GetSession()->HandleLeaveBattlefieldOpcode(leave);
//Queue the event again to try to join next tick.
ai->HandleBotOutgoingPacket(event.getPacket());
return true;
}

bot->GetSession()->HandleBattlefieldPortOpcode(packet);

ai->ResetStrategies(false);
Expand Down

0 comments on commit 09b5a9f

Please sign in to comment.