aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals/ObjectMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 57a773eab2b..c3d0cb0996f 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -49,6 +49,7 @@
#include "SpellAuras.h"
#include "SpellMgr.h"
#include "SpellScript.h"
+#include "StringConvert.h"
#include "TemporarySummon.h"
#include "UpdateMask.h"
#include "Util.h"
@@ -735,33 +736,35 @@ void ObjectMgr::LoadCreatureTemplateAddons()
creatureAddon.emote = fields[5].GetUInt32();
creatureAddon.visibilityDistanceType = VisibilityDistanceType(fields[6].GetUInt8());
- Tokenizer tokens(fields[7].GetString(), ' ');
- creatureAddon.auras.reserve(tokens.size());
- for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
+ for (std::string_view aura : Trinity::Tokenize(fields[7].GetStringView(), ' ', false))
{
- SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(atoul(*itr));
- if (!AdditionalSpellInfo)
+
+ SpellInfo const* spellInfo = nullptr;
+ if (Optional<uint32> spellId = Trinity::StringTo<uint32>(aura))
+ spellInfo = sSpellMgr->GetSpellInfo(*spellId);
+
+ if (!spellInfo)
{
- TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has wrong spell %lu defined in `auras` field in `creature_template_addon`.", entry, atoul(*itr));
+ TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has wrong spell '%s' defined in `auras` field in `creature_template_addon`.", entry, std::string(aura).c_str());
continue;
}
- if (AdditionalSpellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE))
- TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has SPELL_AURA_CONTROL_VEHICLE aura %lu defined in `auras` field in `creature_template_addon`.", entry, atoul(*itr));
+ if (spellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE))
+ TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has SPELL_AURA_CONTROL_VEHICLE aura %u defined in `auras` field in `creature_template_addon`.", entry, spellInfo->Id);
- if (std::find(creatureAddon.auras.begin(), creatureAddon.auras.end(), atoul(*itr)) != creatureAddon.auras.end())
+ if (std::find(creatureAddon.auras.begin(), creatureAddon.auras.end(), spellInfo->Id) != creatureAddon.auras.end())
{
- TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has duplicate aura (spell %lu) in `auras` field in `creature_template_addon`.", entry, atoul(*itr));
+ TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has duplicate aura (spell %u) in `auras` field in `creature_template_addon`.", entry, spellInfo->Id);
continue;
}
- if (AdditionalSpellInfo->GetDuration() > 0)
+ if (spellInfo->GetDuration() > 0)
{
- TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has temporary aura (spell %lu) in `auras` field in `creature_template_addon`.", entry, atoul(*itr));
+ TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has temporary aura (spell %u) in `auras` field in `creature_template_addon`.", entry, spellInfo->Id);
continue;
}
- creatureAddon.auras.push_back(atoul(*itr));
+ creatureAddon.auras.push_back(spellInfo->Id);
}
if (creatureAddon.mount)
@@ -1270,33 +1273,34 @@ void ObjectMgr::LoadCreatureAddons()
creatureAddon.emote = fields[5].GetUInt32();
creatureAddon.visibilityDistanceType = VisibilityDistanceType(fields[6].GetUInt8());
- Tokenizer tokens(fields[7].GetString(), ' ');
- creatureAddon.auras.reserve(tokens.size());
- for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
+ for (std::string_view aura : Trinity::Tokenize(fields[7].GetStringView(), ' ', false))
{
- SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(atoul(*itr));
- if (!AdditionalSpellInfo)
+ SpellInfo const* spellInfo = nullptr;
+ if (Optional<uint32> spellId = Trinity::StringTo<uint32>(aura))
+ spellInfo = sSpellMgr->GetSpellInfo(*spellId);
+
+ if (!spellInfo)
{
- TC_LOG_ERROR("sql.sql", "Creature (GUID: %u) has wrong spell %lu defined in `auras` field in `creature_addon`.", guid, atoul(*itr));
+ TC_LOG_ERROR("sql.sql", "Creature (GUID: %u) has wrong spell '%s' defined in `auras` field in `creature_addon`.", guid, std::string(aura).c_str());
continue;
}
- if (AdditionalSpellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE))
- TC_LOG_ERROR("sql.sql", "Creature (GUID: %u) has SPELL_AURA_CONTROL_VEHICLE aura %lu defined in `auras` field in `creature_addon`.", guid, atoul(*itr));
+ if (spellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE))
+ TC_LOG_ERROR("sql.sql", "Creature (GUID: %u) has SPELL_AURA_CONTROL_VEHICLE aura %u defined in `auras` field in `creature_addon`.", guid, spellInfo->Id);
- if (std::find(creatureAddon.auras.begin(), creatureAddon.auras.end(), atoul(*itr)) != creatureAddon.auras.end())
+ if (std::find(creatureAddon.auras.begin(), creatureAddon.auras.end(), spellInfo->Id) != creatureAddon.auras.end())
{
- TC_LOG_ERROR("sql.sql", "Creature (GUID: %u) has duplicate aura (spell %lu) in `auras` field in `creature_addon`.", guid, atoul(*itr));
+ TC_LOG_ERROR("sql.sql", "Creature (GUID: %u) has duplicate aura (spell %u) in `auras` field in `creature_addon`.", guid, spellInfo->Id);
continue;
}
- if (AdditionalSpellInfo->GetDuration() > 0)
+ if (spellInfo->GetDuration() > 0)
{
- TC_LOG_ERROR("sql.sql", "Creature (GUID: %u) has temporary aura (spell %lu) in `auras` field in `creature_addon`.", guid, atoul(*itr));
+ TC_LOG_ERROR("sql.sql", "Creature (GUID: %u) has temporary aura (spell %u) in `auras` field in `creature_addon`.", guid, spellInfo->Id);
continue;
}
- creatureAddon.auras.push_back(atoul(*itr));
+ creatureAddon.auras.push_back(spellInfo->Id);
}
if (creatureAddon.mount)