Scripts/Commands: Fix crash caused by .set npc model (#22877)

* Scripts/Commands: Fix crash caused by .set npc model

Fix crash caused by .set npc model with invalid model id

(cherry picked from commit 20ea24bf5c)
This commit is contained in:
Giacomo Pozzoni
2019-01-01 15:00:27 +01:00
committed by Shauren
parent ce794f3978
commit ff2cd4a032
3 changed files with 9 additions and 2 deletions

View File

@@ -362,7 +362,7 @@ enum TrinityStrings
LANG_COMMAND_MODIFY_ARENA = 306,
LANG_COMMAND_FACTION_NOTFOUND = 307,
LANG_COMMAND_FACTION_UNKNOWN = 308,
LANG_COMMAND_FACTION_INVPARAM = 309,
LANG_COMMAND_INVALID_PARAM = 309,
LANG_COMMAND_FACTION_DELTA = 310,
LANG_FACTION_LIST = 311,
LANG_FACTION_VISIBLE = 312,

View File

@@ -734,7 +734,7 @@ public:
if (rankThresholdItr == end)
{
handler->PSendSysMessage(LANG_COMMAND_FACTION_INVPARAM, rankTxt);
handler->PSendSysMessage(LANG_COMMAND_INVALID_PARAM, rankTxt);
handler->SetSentErrorMessage(true);
return false;
}

View File

@@ -879,6 +879,13 @@ public:
return false;
}
if (!sCreatureDisplayInfoStore.LookupEntry(displayId))
{
handler->PSendSysMessage(LANG_COMMAND_INVALID_PARAM, args);
handler->SetSentErrorMessage(true);
return false;
}
creature->SetDisplayId(displayId);
creature->SetNativeDisplayId(displayId);