diff options
| author | DoctorKraft <DoctorKraft@users.noreply.github.com> | 2018-04-23 23:44:59 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2018-04-24 00:44:59 +0300 |
| commit | 8ca6a20e7303e942adfb6d97b9aa94fab7c6b895 (patch) | |
| tree | 7a45e9c22521d4fff769d5f80b79d95877b527ad /src/server/game/Spells/SpellMgr.cpp | |
| parent | 6b9948857057cfe495807a61b6797c75d9fc7a6a (diff) | |
Core/Spells: Fix display for Shaman totems (#21848)
Diffstat (limited to 'src/server/game/Spells/SpellMgr.cpp')
| -rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 5f29ef5eafe..5d05a3cbf2d 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3495,3 +3495,64 @@ void SpellMgr::LoadPetFamilySpellsStore() } } } + +void SpellMgr::LoadSpellTotemModel() +{ + uint32 oldMSTime = getMSTime(); + + QueryResult result = WorldDatabase.Query("SELECT SpellID, RaceID, DisplayID from spell_totem_model"); + + if (!result) + { + TC_LOG_INFO("server.loading", ">> Loaded 0 spell totem model records. DB table `spell_totem_model` is empty."); + return; + } + + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + + uint32 spellId = fields[0].GetUInt32(); + uint8 race = fields[1].GetUInt8(); + uint32 displayId = fields[2].GetUInt32(); + + SpellInfo const* spellEntry = GetSpellInfo(spellId); + if (!spellEntry) + { + TC_LOG_ERROR("sql.sql", "SpellID: %u in `spell_totem_model` table could not be found in dbc, skipped.", spellId); + continue; + } + + ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race); + if (!raceEntry) + { + TC_LOG_ERROR("sql.sql", "Race %u defined in `spell_totem_model` does not exists, skipped.", uint32(race)); + continue; + } + + CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(displayId); + if (!displayEntry) + { + TC_LOG_ERROR("sql.sql", "SpellID: %u defined in `spell_totem_model` has non-existing model (%u).", spellId, displayId); + continue; + } + + mSpellTotemModel[std::make_pair(spellId, race)] = displayId; + ++count; + + } while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded %u spell totem model records in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); + +} + +uint32 SpellMgr::GetModelForTotem(uint32 spellId, uint8 race) const +{ + auto itr = mSpellTotemModel.find(std::make_pair(spellId, race)); + if (itr != mSpellTotemModel.end()) + return itr->second; + + TC_LOG_ERROR("spells", "Spell %u with RaceID (%u) have no totem model data defined, set to default model.", spellId, race); + return 0; +} |
