BG Crash fixes

This commit is contained in:
郑佩茹
2022-09-26 10:56:43 -06:00
parent f88f49471a
commit 0a62ee0041
4 changed files with 9 additions and 4 deletions

View File

@@ -431,7 +431,7 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa
}
// Battleground switch
if (player->InBattleground())
if (player->InBattleground() && player->GetBattleground())
{
BattlegroundTypeId bgType = player->GetBattlegroundTypeId();
if (bgType == BATTLEGROUND_RB)
@@ -632,7 +632,7 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const
}
// Battleground switch
if (player->InBattleground())
if (player->InBattleground() && player->GetBattleground())
{
nonCombatEngine->addStrategies("nc", "chat", "default", "buff", "food", "mount", "pvp", "collision", "dps assist", "attack tagged", "emote", nullptr);
nonCombatEngine->removeStrategy("custom::say");

View File

@@ -897,7 +897,7 @@ void PlayerbotAI::DoNextAction(bool min)
}
// same BG
if (bot->InBattleground() && bot->GetBattleground()->GetBgTypeID() == BATTLEGROUND_AV && !GET_PLAYERBOT_AI(member) && member->InBattleground() && bot->GetMapId() == member->GetMapId())
if (bot->InBattleground() && bot->GetBattleground() && bot->GetBattleground()->GetBgTypeID() == BATTLEGROUND_AV && !GET_PLAYERBOT_AI(member) && member->InBattleground() && bot->GetMapId() == member->GetMapId())
{
// TODO disable move to objective if have master in bg
continue;

View File

@@ -539,7 +539,7 @@ void RandomPlayerbotMgr::CheckBgQueue()
else
BgPlayers[queueTypeId][bracketId][teamId]++;
if (!player->IsInvitedForBattlegroundInstance() && (!player->InBattleground() || player->GetBattleground()->GetBgTypeID() != BattlegroundMgr::BGTemplateId(queueTypeId)))
if (!player->IsInvitedForBattlegroundInstance() && (!player->InBattleground() || (player->GetBattleground() && player->GetBattleground()->GetBgTypeID() != BattlegroundMgr::BGTemplateId(queueTypeId))))
{
if (BattlegroundMgr::BGArenaType(queueTypeId))
{

View File

@@ -4880,6 +4880,11 @@ bool ArenaTactics::Execute(Event event)
bool ArenaTactics::moveToCenter(Battleground* bg)
{
// Sanity check
if (!bg)
{
return true;
}
uint32 Preference = context->GetValue<uint32>("bg role")->Get();
switch (bg->GetBgTypeID())
{