diff options
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index fda6779c30f..eafcf16383c 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -9133,6 +9133,81 @@ void ObjectMgr::LoadRaceAndClassExpansionRequirements() TC_LOG_INFO("server.loading", ">> Loaded 0 class expansion requirements. DB table `class_expansion_requirement` is empty."); } +void ObjectMgr::LoadCharacterTemplates() +{ + uint32 oldMSTime = getMSTime(); + _characterTemplateStore.clear(); + + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_TEMPLATES); + PreparedQueryResult templates = CharacterDatabase.Query(stmt); + + if (!templates) + { + TC_LOG_INFO("server.loading", ">> Loaded 0 character templates. DB table `character_template` is empty."); + return; + } + + PreparedQueryResult classes; + uint32 count = 0; + + do + { + Field* fields = templates->Fetch(); + + uint32 templateSetId = fields[0].GetUInt32(); + + stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_TEMPLATE_CLASSES); + stmt->setUInt32(0, templateSetId); + classes = CharacterDatabase.Query(stmt); + + if (classes) + { + CharacterTemplate templ; + templ.TemplateSetId = templateSetId; + templ.Name = fields[1].GetString(); + templ.Description = fields[2].GetString(); + templ.Level = fields[3].GetUInt8(); + + do + { + fields = classes->Fetch(); + + uint8 factionGroup = fields[0].GetUInt8(); + uint8 classID = fields[1].GetUInt8(); + + if (!((factionGroup & (FACTION_MASK_PLAYER | FACTION_MASK_ALLIANCE)) == (FACTION_MASK_PLAYER | FACTION_MASK_ALLIANCE)) && + !((factionGroup & (FACTION_MASK_PLAYER | FACTION_MASK_HORDE)) == (FACTION_MASK_PLAYER | FACTION_MASK_HORDE))) + { + TC_LOG_ERROR("sql.sql", "Faction group %u defined for character template %u in `character_template_class` is invalid. Skipped.", factionGroup, templateSetId); + continue; + } + + ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(classID); + if (!classEntry) + { + TC_LOG_ERROR("sql.sql", "Class %u defined for character template %u in `character_template_class` does not exists, skipped.", classID, templateSetId); + continue; + } + + templ.Classes.emplace_back(factionGroup, classID); + + } while (classes->NextRow()); + + if (!templ.Classes.empty()) + { + _characterTemplateStore[templateSetId] = templ; + ++count; + } + } + else + { + TC_LOG_ERROR("sql.sql", "Character template %u does not have any classes defined in `character_template_class`. Skipped.", templateSetId); + continue; + } + } while (templates->NextRow()); + TC_LOG_INFO("server.loading", ">> Loaded %u character templates in %u ms.", count, GetMSTimeDiffToNow(oldMSTime)); +} + void ObjectMgr::LoadRealmNames() { uint32 oldMSTime = getMSTime(); |