mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 05:06:24 +00:00
feat(Core/Pet): DK Petname generation locale (#14059)
This commit is contained in:
@@ -8827,7 +8827,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
|
||||
// Generate a new name for the newly summoned ghoul
|
||||
if (pet->IsPetGhoul())
|
||||
{
|
||||
std::string new_name = sObjectMgr->GeneratePetName(entry);
|
||||
std::string new_name = sObjectMgr->GeneratePetNameLocale(entry, GetSession()->GetSessionDbLocaleIndex());
|
||||
if (!new_name.empty())
|
||||
pet->SetName(new_name);
|
||||
}
|
||||
|
||||
@@ -448,6 +448,42 @@ void ObjectMgr::LoadGossipMenuItemsLocales()
|
||||
LOG_INFO("server.loading", ">> Loaded {} Gossip Menu Option Locale Strings in {} ms", (uint32)_gossipMenuItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadPetNamesLocales()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// 0 1 2 3
|
||||
QueryResult result = WorldDatabase.Query("SELECT locale, word, entry, half FROM pet_name_generation_locale");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
LOG_WARN("server.loading", ">> Loaded 0 pet name locales parts. DB table `pet_name_generation_locale` is empty!");
|
||||
LOG_INFO("server.loading", " ");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
LocaleConstant locale = GetLocaleByName(fields[0].Get<std::string>());
|
||||
std::string word = fields[1].Get<std::string>();
|
||||
|
||||
uint32 entry = fields[2].Get<uint32>();
|
||||
bool half = fields[3].Get<bool>();
|
||||
std::pair<uint32, LocaleConstant> pairkey = std::make_pair(entry, locale);
|
||||
if (half)
|
||||
_petHalfLocaleName1[pairkey].push_back(word);
|
||||
else
|
||||
_petHalfLocaleName0[pairkey].push_back(word);
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server.loading", ">> Loaded {} Pet Name Locales Parts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", " ");
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadPointOfInterestLocales()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
@@ -7402,6 +7438,19 @@ void ObjectMgr::LoadPetNumber()
|
||||
LOG_INFO("server.loading", " ");
|
||||
}
|
||||
|
||||
std::string ObjectMgr::GeneratePetNameLocale(uint32 entry, LocaleConstant locale)
|
||||
{
|
||||
std::vector<std::string>& list0 = _petHalfLocaleName0[std::make_pair(entry, locale)];
|
||||
std::vector<std::string>& list1 = _petHalfLocaleName1[std::make_pair(entry, locale)];
|
||||
|
||||
if (list0.empty() || list1.empty())
|
||||
{
|
||||
return GeneratePetName(entry);
|
||||
}
|
||||
|
||||
return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
|
||||
}
|
||||
|
||||
std::string ObjectMgr::GeneratePetName(uint32 entry)
|
||||
{
|
||||
std::vector<std::string>& list0 = _petHalfName0[entry];
|
||||
|
||||
@@ -1075,6 +1075,7 @@ public:
|
||||
void LoadPetLevelInfo();
|
||||
void LoadExplorationBaseXP();
|
||||
void LoadPetNames();
|
||||
void LoadPetNamesLocales();
|
||||
void LoadPetNumber();
|
||||
void LoadFishingBaseSkillLevel();
|
||||
void ChangeFishingBaseSkillLevel(uint32 entry, int32 skill);
|
||||
@@ -1098,6 +1099,7 @@ public:
|
||||
void AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost, uint32 reqSkill, uint32 reqSkillValue, uint32 reqLevel, uint32 reqSpell);
|
||||
|
||||
std::string GeneratePetName(uint32 entry);
|
||||
std::string GeneratePetNameLocale(uint32 entry, LocaleConstant locale);
|
||||
uint32 GetBaseXP(uint8 level);
|
||||
[[nodiscard]] uint32 GetXPForLevel(uint8 level) const;
|
||||
|
||||
@@ -1549,6 +1551,9 @@ private:
|
||||
typedef std::map<uint32, std::vector<std::string>> HalfNameContainer;
|
||||
HalfNameContainer _petHalfName0;
|
||||
HalfNameContainer _petHalfName1;
|
||||
typedef std::map<std::pair<uint32, LocaleConstant>, std::vector<std::string>> HalfNameContainerLocale;
|
||||
HalfNameContainerLocale _petHalfLocaleName0;
|
||||
HalfNameContainerLocale _petHalfLocaleName1;
|
||||
|
||||
typedef std::unordered_map<uint32, ItemSetNameEntry> ItemSetNameContainer;
|
||||
ItemSetNameContainer _itemSetNameStore;
|
||||
|
||||
@@ -1634,6 +1634,7 @@ void World::SetInitialWorldSettings()
|
||||
sObjectMgr->LoadPageTextLocales();
|
||||
sObjectMgr->LoadGossipMenuItemsLocales();
|
||||
sObjectMgr->LoadPointOfInterestLocales();
|
||||
sObjectMgr->LoadPetNamesLocales();
|
||||
|
||||
sObjectMgr->SetDBCLocaleIndex(GetDefaultDbcLocale()); // Get once for all the locale index of DBC language (console/broadcasts)
|
||||
LOG_INFO("server.loading", ">> Localization Strings loaded in {} ms", GetMSTimeDiffToNow(oldMSTime));
|
||||
|
||||
Reference in New Issue
Block a user