mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-31 01:23:47 +00:00
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;
|
||||
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))
|
||||
RemoveSpellCooldown(itr->first, true);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// For static or at-server-startup loaded spell data
|
||||
|
||||
#include "Common.h"
|
||||
#include "Log.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "Unit.h"
|
||||
|
||||
@@ -692,6 +693,22 @@ public:
|
||||
ASSERT(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(); }
|
||||
|
||||
// Talent Additional Set
|
||||
|
||||
Reference in New Issue
Block a user