Skip to content

Commit

Permalink
Null pointers check
Browse files Browse the repository at this point in the history
  • Loading branch information
gromchek authored and killerwife committed Jan 8, 2024
1 parent 1162116 commit ccc6cda
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
10 changes: 4 additions & 6 deletions src/game/AI/ScriptDevAI/scripts/kalimdor/desolace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/game/PlayerBot/Base/PlayerbotAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/game/PlayerBot/Base/PlayerbotMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down

0 comments on commit ccc6cda

Please sign in to comment.