From 8ca6a20e7303e942adfb6d97b9aa94fab7c6b895 Mon Sep 17 00:00:00 2001 From: DoctorKraft Date: Mon, 23 Apr 2018 23:44:59 +0200 Subject: Core/Spells: Fix display for Shaman totems (#21848) --- src/server/game/Spells/SpellMgr.cpp | 61 +++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'src/server/game/Spells/SpellMgr.cpp') 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; +} -- cgit v1.2.3