From ccc6cda1a9e9afafdaddef6ae92193383e78ad1a Mon Sep 17 00:00:00 2001 From: gromchek Date: Wed, 27 Dec 2023 11:06:00 +0300 Subject: [PATCH] Null pointers check --- src/game/AI/ScriptDevAI/scripts/kalimdor/desolace.cpp | 10 ++++------ src/game/PlayerBot/Base/PlayerbotAI.cpp | 6 +++--- src/game/PlayerBot/Base/PlayerbotMgr.cpp | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/game/AI/ScriptDevAI/scripts/kalimdor/desolace.cpp b/src/game/AI/ScriptDevAI/scripts/kalimdor/desolace.cpp index 72a7ba2c33..7378599e75 100644 --- a/src/game/AI/ScriptDevAI/scripts/kalimdor/desolace.cpp +++ b/src/game/AI/ScriptDevAI/scripts/kalimdor/desolace.cpp @@ -508,11 +508,10 @@ struct npc_cork_gizeltonAI : public npc_escortAI case 19: if (!SouthQuest) { - if (player->GetQuestStatus(QUEST_BODYGUARD_TO_HIRE) == QUEST_STATUS_INCOMPLETE) + if (player && player->GetQuestStatus(QUEST_BODYGUARD_TO_HIRE) == QUEST_STATUS_INCOMPLETE) { // Award quest credit - if (player) - player->RewardPlayerAndGroupAtEventExplored(QUEST_BODYGUARD_TO_HIRE, m_creature); + player->RewardPlayerAndGroupAtEventExplored(QUEST_BODYGUARD_TO_HIRE, m_creature); } m_creature->GetMotionMaster()->Clear(false, true); m_creature->GetMotionMaster()->MoveWaypoint(WAYPOINT_PATH_ID, PATH_FROM_WAYPOINT_PATH); @@ -526,11 +525,10 @@ struct npc_cork_gizeltonAI : public npc_escortAI case 21: if (SouthQuest) { - if (player->GetQuestStatus(QUEST_GIZELTON_CARAVAN) == QUEST_STATUS_INCOMPLETE) + if (player && player->GetQuestStatus(QUEST_GIZELTON_CARAVAN) == QUEST_STATUS_INCOMPLETE) { // Award quest credit - if (player) - player->RewardPlayerAndGroupAtEventExplored(QUEST_GIZELTON_CARAVAN, m_creature); + player->RewardPlayerAndGroupAtEventExplored(QUEST_GIZELTON_CARAVAN, m_creature); } m_creature->GetMotionMaster()->Clear(false, true); m_creature->GetMotionMaster()->MoveWaypoint(WAYPOINT_PATH_ID, PATH_FROM_WAYPOINT_PATH); diff --git a/src/game/PlayerBot/Base/PlayerbotAI.cpp b/src/game/PlayerBot/Base/PlayerbotAI.cpp index eb9133cc8c..e9ce7f856b 100644 --- a/src/game/PlayerBot/Base/PlayerbotAI.cpp +++ b/src/game/PlayerBot/Base/PlayerbotAI.cpp @@ -4412,6 +4412,9 @@ SpellCastResult PlayerbotAI::Buff(uint32 spellId, Unit* target, void (*beforeCas if (spellId == 0) return SPELL_FAILED_NOT_KNOWN; + if (!target) + return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + // Target already has aura from spellId, skip for speed. May need to add exceptions if (target->HasAura(spellId)) return SPELL_FAILED_AURA_BOUNCED; @@ -4421,9 +4424,6 @@ SpellCastResult PlayerbotAI::Buff(uint32 spellId, Unit* target, void (*beforeCas if (!spellProto) return SPELL_NOT_FOUND; - if (!target) - return SPELL_FAILED_BAD_IMPLICIT_TARGETS; - // Select appropriate spell rank for target's level spellProto = sSpellMgr.SelectAuraRankForLevel(spellProto, target->GetLevel()); if (!spellProto) diff --git a/src/game/PlayerBot/Base/PlayerbotMgr.cpp b/src/game/PlayerBot/Base/PlayerbotMgr.cpp index 99576238da..9dbe7cb7a5 100644 --- a/src/game/PlayerBot/Base/PlayerbotMgr.cpp +++ b/src/game/PlayerBot/Base/PlayerbotMgr.cpp @@ -1047,7 +1047,7 @@ uint32 Player::GetSpec() bool ChatHandler::HandlePlayerbotCommand(char* args) { - if (!(m_session->GetSecurity() > SEC_PLAYER)) + if (m_session && !(m_session->GetSecurity() > SEC_PLAYER)) { if (botConfig.GetBoolDefault("PlayerbotAI.DisableBots", false)) {