From 0dde51f518aea5652400521c34fcf02f4e08ecdb Mon Sep 17 00:00:00 2001 From: nytmyr <53322305+nytmyr@users.noreply.github.com> Date: Thu, 6 Feb 2025 03:14:25 -0600 Subject: [PATCH] [Bots] Fix crash related to GetTempSpellType() (#4649) _tempSpellType was not getting defined during bot spawn process which could lead to a potential crash in RaidGroupSay. Auto archery toggle was what triggered the crash as it announces their status on spawn. Also moved this toggle for Rangers further down the proccess line. --- zone/bot.cpp | 10 ++++++---- zone/bot.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index c1835b64d..c5f03850f 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -106,6 +106,7 @@ Bot::Bot(NPCType *npcTypeData, Client* botOwner) : NPC(npcTypeData, nullptr, glm LoadDefaultBotSettings(); SetCastedSpellType(UINT16_MAX); + SetTempSpellType(UINT16_MAX); SetCommandedSpell(false); SetPullingSpell(false); @@ -189,6 +190,7 @@ Bot::Bot( SetSpawnStatus(false); SetBotCharmer(false); SetCastedSpellType(UINT16_MAX); + SetTempSpellType(UINT16_MAX); SetCommandedSpell(false); SetPullingSpell(false); @@ -3669,10 +3671,6 @@ bool Bot::Spawn(Client* botCharacterOwner) { } } - if (IsBotRanged()) { - ChangeBotRangedWeapons(true); - } - if (auto raid = entity_list.GetRaidByBotName(GetName())) { // Safety Check to confirm we have a valid raid auto owner = GetBotOwner(); @@ -3706,6 +3704,10 @@ bool Bot::Spawn(Client* botCharacterOwner) { CheckBotSpells(); //This runs through a serious of checks and outputs any spells that are set to the wrong spell type in the database } + if (IsBotRanged()) { + ChangeBotRangedWeapons(true); + } + return true; } diff --git a/zone/bot.h b/zone/bot.h index f5da08b23..d709220c4 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -1218,7 +1218,7 @@ private: std::vector _group_spell_target_list; Raid* _storedRaid; bool _verifiedRaid; - uint16 _tempSpellType; + uint16 _tempSpellType; // this is used to check the spell type being cast against ^spellannouncecasts status // Private "base stats" Members int32 _baseMR;