Skip to content

Commit

Permalink
add nullptr safety around pet commands
Browse files Browse the repository at this point in the history
fix pet state command

close cmangos#492
  • Loading branch information
insunaa authored and cyberium committed Dec 29, 2021
1 parent f9b179b commit 8aa3936
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/game/PlayerBot/Base/PlayerbotAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7446,8 +7446,10 @@ void PlayerbotAI::_HandleCommandPet(std::string& text, Player& fromPlayer)
return;
}

std::string state;
switch (pet->GetCharmInfo()->GetAI()->GetReactState())
if(!pet || !pet->AI())
return;

switch (pet->AI()->GetReactState())
{
case REACT_AGGRESSIVE:
SendWhisper("My pet is aggressive.", fromPlayer);
Expand All @@ -7467,6 +7469,9 @@ void PlayerbotAI::_HandleCommandPet(std::string& text, Player& fromPlayer)
return;
}

if(!pet)
return;

uint32 spellId = (uint32) atol(text.c_str());

if (spellId == 0)
Expand Down Expand Up @@ -7497,6 +7502,9 @@ void PlayerbotAI::_HandleCommandPet(std::string& text, Player& fromPlayer)
return;
}

if(!pet)
return;

uint32 spellId = (uint32) atol(text.c_str());

if (spellId == 0)
Expand Down Expand Up @@ -7530,6 +7538,9 @@ void PlayerbotAI::_HandleCommandPet(std::string& text, Player& fromPlayer)
return;
}

if(!pet)
return;

int loc = GetMaster()->GetSession()->GetSessionDbcLocale();

std::ostringstream posOut;
Expand Down

0 comments on commit 8aa3936

Please sign in to comment.