fix(Core): check spell info and prevent crash (#6454)
This commit is contained in:
@@ -4417,7 +4417,11 @@ void Player::RemoveArenaSpellCooldowns(bool removeActivePetCooldowns)
|
|||||||
{
|
{
|
||||||
next = itr;
|
next = itr;
|
||||||
++next;
|
++next;
|
||||||
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first);
|
SpellInfo const* spellInfo = sSpellMgr->CheckSpellInfo(itr->first);
|
||||||
|
if (!spellInfo)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (spellInfo->HasAttribute(SPELL_ATTR4_IGNORE_DEFAULT_ARENA_RESTRICTIONS))
|
if (spellInfo->HasAttribute(SPELL_ATTR4_IGNORE_DEFAULT_ARENA_RESTRICTIONS))
|
||||||
RemoveSpellCooldown(itr->first, true);
|
RemoveSpellCooldown(itr->first, true);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
// For static or at-server-startup loaded spell data
|
// For static or at-server-startup loaded spell data
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
#include "Log.h"
|
||||||
#include "SharedDefines.h"
|
#include "SharedDefines.h"
|
||||||
#include "Unit.h"
|
#include "Unit.h"
|
||||||
|
|
||||||
@@ -692,6 +693,22 @@ public:
|
|||||||
ASSERT(spellInfo);
|
ASSERT(spellInfo);
|
||||||
return spellInfo;
|
return spellInfo;
|
||||||
}
|
}
|
||||||
|
// use this instead of AssertSpellInfo to have the problem logged instead of crashing the server
|
||||||
|
SpellInfo const* CheckSpellInfo(uint32 spellId) const
|
||||||
|
{
|
||||||
|
if (spellId >= GetSpellInfoStoreSize())
|
||||||
|
{
|
||||||
|
LOG_ERROR("server", "spellId %u is not lower than GetSpellInfoStoreSize() (%u)", spellId, GetSpellInfoStoreSize());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
SpellInfo const* spellInfo = mSpellInfoMap[spellId];
|
||||||
|
if (!spellInfo)
|
||||||
|
{
|
||||||
|
LOG_ERROR("server", "spellId %u has invalid spellInfo", spellId);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return spellInfo;
|
||||||
|
}
|
||||||
[[nodiscard]] uint32 GetSpellInfoStoreSize() const { return mSpellInfoMap.size(); }
|
[[nodiscard]] uint32 GetSpellInfoStoreSize() const { return mSpellInfoMap.size(); }
|
||||||
|
|
||||||
// Talent Additional Set
|
// Talent Additional Set
|
||||||
|
|||||||
Reference in New Issue
Block a user