Core/Common: Tokenizer -> Trinity::Tokenize
This commit is contained in:
1 parent
95329dc15c
commit
f95a8bfdca
32 files changed
+414
-354
No files matched your search
@@ -55,6 +55,7 @@
|
||||
#include "SpellAuras.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "SpellScript.h"
|
||||
#include "StringConvert.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "TerrainMgr.h"
|
||||
#include "ThreadPool.h"
|
||||
@@ -640,28 +641,36 @@ void ObjectMgr::LoadCreatureTemplateAddons()
|
||||
creatureAddon.meleeAnimKit = fields[12].GetUInt16();
|
||||
creatureAddon.visibilityDistanceType = VisibilityDistanceType(fields[13].GetUInt8());
|
||||
|
||||
Tokenizer tokens(fields[14].GetString(), ' ');
|
||||
uint8 i = 0;
|
||||
creatureAddon.auras.resize(tokens.size());
|
||||
for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
|
||||
for (std::string_view aura : Trinity::Tokenize(fields[14].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;
|
||||
}
|
||||
|
||||
creatureAddon.auras[i++] = atoul(*itr);
|
||||
/*
|
||||
if (spellInfo->GetDuration() > 0)
|
||||
{
|
||||
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(spellInfo->Id);
|
||||
}
|
||||
|
||||
if (creatureAddon.mount)
|
||||
@@ -1198,28 +1207,36 @@ void ObjectMgr::LoadCreatureAddons()
|
||||
creatureAddon.meleeAnimKit = fields[12].GetUInt16();
|
||||
creatureAddon.visibilityDistanceType = VisibilityDistanceType(fields[13].GetUInt8());
|
||||
|
||||
Tokenizer tokens(fields[14].GetString(), ' ');
|
||||
uint8 i = 0;
|
||||
creatureAddon.auras.resize(tokens.size());
|
||||
for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
|
||||
for (std::string_view aura : Trinity::Tokenize(fields[14].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;
|
||||
}
|
||||
|
||||
creatureAddon.auras[i++] = atoul(*itr);
|
||||
/*
|
||||
if (spellInfo->GetDuration() > 0)
|
||||
{
|
||||
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(spellInfo->Id);
|
||||
}
|
||||
|
||||
if (creatureAddon.mount)
|
||||
|
||||
Reference in new issue
Block a user