diff options
author | Carbenium <carbenium@outlook.com> | 2015-04-19 23:37:29 +0200 |
---|---|---|
committer | Carbenium <carbenium@outlook.com> | 2015-04-21 00:52:21 +0200 |
commit | bba6eb8d3dfe73a02063a7cefe6f465dae69334b (patch) | |
tree | 16dbbcaab1bca43b281828fd20b12f2ce6441540 /src/server/game/Globals/ObjectMgr.cpp | |
parent | 4208c0d8396e10dc806939e1d17885d16ff7b84e (diff) |
Core/Player: Added character templates
* Characters with predefined levels can be created
* Avaiable factions and classes can be configured
* Valid values for `factionGroup` in table `character_template_class` are 3 (Alliance) or 5 (Horde)
* Added new permission RBAC_PERM_USE_CHARACTER_TEMPLATES - has to be set, to allow the usage of the templates
Closes #13952
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(); |