mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
[Fix issue #1528] Close small window where the “in a BG/arena” state can change between the check (InBattleground() / InArena()) and grabbing the pointer (GetBattleground()), which leads to a null dereference. (#1530)
* Harden playerbot logout & packet dispatch; add null-safety in chat hooks and RPG checks * Fix Issue 1528
This commit is contained in:
@@ -994,9 +994,18 @@ void RandomPlayerbotMgr::CheckBgQueue()
|
||||
isRated = ginfo.IsRated;
|
||||
}
|
||||
|
||||
if (bgQueue.IsPlayerInvitedToRatedArena(player->GetGUID()) ||
|
||||
/*if (bgQueue.IsPlayerInvitedToRatedArena(player->GetGUID()) ||
|
||||
(player->InArena() && player->GetBattleground()->isRated()))
|
||||
isRated = true;*/
|
||||
if (bgQueue.IsPlayerInvitedToRatedArena(player->GetGUID())) // [Crash Fix] Issue Crash in RandomPlayerbotMgr:1018 #1528
|
||||
{
|
||||
isRated = true;
|
||||
}
|
||||
else if (Battleground const* bg = player->GetBattleground())
|
||||
{
|
||||
if (player->InArena() && bg->isRated())
|
||||
isRated = true;
|
||||
}
|
||||
|
||||
if (isRated)
|
||||
BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount++;
|
||||
@@ -1011,15 +1020,24 @@ void RandomPlayerbotMgr::CheckBgQueue()
|
||||
else
|
||||
BattlegroundData[queueTypeId][bracketId].bgHordePlayerCount++;
|
||||
|
||||
// If a player has joined the BG, update the instance count in BattlegroundData (for consistency)
|
||||
/*// If a player has joined the BG, update the instance count in BattlegroundData (for consistency)
|
||||
if (player->InBattleground())
|
||||
{
|
||||
std::vector<uint32>* instanceIds = nullptr;
|
||||
uint32 instanceId = player->GetBattleground()->GetInstanceID();
|
||||
|
||||
instanceIds = &BattlegroundData[queueTypeId][bracketId].bgInstances;*/
|
||||
// If a player has joined the BG, update the instance count in BattlegroundData (for consistency)
|
||||
if (Battleground const* bg = player->GetBattleground()) // [Crash Fix] Issue Crash in RandomPlayerbotMgr:1018 #1528
|
||||
{
|
||||
std::vector<uint32>* instanceIds = nullptr;
|
||||
uint32 instanceId = bg->GetInstanceID();
|
||||
|
||||
instanceIds = &BattlegroundData[queueTypeId][bracketId].bgInstances;
|
||||
if (instanceIds &&
|
||||
|
||||
if (instanceIds &&
|
||||
std::find(instanceIds->begin(), instanceIds->end(), instanceId) == instanceIds->end())
|
||||
|
||||
instanceIds->push_back(instanceId);
|
||||
|
||||
BattlegroundData[queueTypeId][bracketId].bgInstanceCount = instanceIds->size();
|
||||
@@ -1082,10 +1100,20 @@ void RandomPlayerbotMgr::CheckBgQueue()
|
||||
isRated = ginfo.IsRated;
|
||||
}
|
||||
|
||||
if (bgQueue.IsPlayerInvitedToRatedArena(guid) || (bot->InArena() && bot->GetBattleground()->isRated()))
|
||||
/*if (bgQueue.IsPlayerInvitedToRatedArena(guid) || (bot->InArena() && bot->GetBattleground()->isRated()))
|
||||
isRated = true;*/
|
||||
if (bgQueue.IsPlayerInvitedToRatedArena(guid)) // [Crash Fix] Issue Crash in RandomPlayerbotMgr:1018 #1528
|
||||
{
|
||||
isRated = true;
|
||||
}
|
||||
else if (Battleground const* bg = bot->GetBattleground())
|
||||
{
|
||||
if (bot->InArena() && bg->isRated())
|
||||
isRated = true;
|
||||
}
|
||||
// END [Crash Fix] Issue Crash in RandomPlayerbotMgr:1018 #1528
|
||||
|
||||
if (isRated)
|
||||
if (isRated)
|
||||
BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount++;
|
||||
else
|
||||
BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount++;
|
||||
@@ -1098,10 +1126,15 @@ void RandomPlayerbotMgr::CheckBgQueue()
|
||||
BattlegroundData[queueTypeId][bracketId].bgHordeBotCount++;
|
||||
}
|
||||
|
||||
if (bot->InBattleground())
|
||||
/*if (bot->InBattleground())
|
||||
{
|
||||
std::vector<uint32>* instanceIds = nullptr;
|
||||
uint32 instanceId = bot->GetBattleground()->GetInstanceID();
|
||||
uint32 instanceId = bot->GetBattleground()->GetInstanceID();*/
|
||||
if (Battleground const* bg = bot->GetBattleground()) // [Crash Fix] Issue Crash in RandomPlayerbotMgr:1018 #1528
|
||||
{
|
||||
std::vector<uint32>* instanceIds = nullptr;
|
||||
uint32 instanceId = bg->GetInstanceID();
|
||||
//END [Crash Fix] Issue Crash in RandomPlayerbotMgr:1018 #1528
|
||||
bool isArena = false;
|
||||
bool isRated = false;
|
||||
|
||||
@@ -1109,7 +1142,8 @@ void RandomPlayerbotMgr::CheckBgQueue()
|
||||
if (bot->InArena())
|
||||
{
|
||||
isArena = true;
|
||||
if (bot->GetBattleground()->isRated())
|
||||
// if (bot->GetBattleground()->isRated())
|
||||
if (bg->isRated()) // [Crash Fix] Issue Crash in RandomPlayerbotMgr:1018 #1528
|
||||
{
|
||||
isRated = true;
|
||||
instanceIds = &BattlegroundData[queueTypeId][bracketId].ratedArenaInstances;
|
||||
|
||||
Reference in New Issue
Block a user