Merge branch 'master' into Playerbot
This commit is contained in:
@@ -6213,7 +6213,7 @@ void ObjectMgr::LoadQuestAreaTriggers()
|
||||
|
||||
QuestGreeting const* ObjectMgr::GetQuestGreeting(TypeID type, uint32 id) const
|
||||
{
|
||||
uint32 typeIndex;
|
||||
uint8 typeIndex;
|
||||
if (type == TYPEID_UNIT)
|
||||
typeIndex = 0;
|
||||
else if (type == TYPEID_GAMEOBJECT)
|
||||
@@ -6221,15 +6221,19 @@ QuestGreeting const* ObjectMgr::GetQuestGreeting(TypeID type, uint32 id) const
|
||||
else
|
||||
return nullptr;
|
||||
|
||||
return Acore::Containers::MapGetValuePtr(_questGreetingStore[typeIndex], id);
|
||||
std::pair<uint32, uint8> pairKey = std::make_pair(id, typeIndex);
|
||||
QuestGreetingContainer::const_iterator itr = _questGreetingStore.find(pairKey);
|
||||
if (itr == _questGreetingStore.end())
|
||||
return nullptr;
|
||||
|
||||
return &itr->second;
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadQuestGreetings()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
for (std::size_t i = 0; i < _questGreetingStore.size(); ++i)
|
||||
_questGreetingStore[i].clear();
|
||||
_questGreetingStore.clear(); // For reload case
|
||||
|
||||
// 0 1 2 3 4
|
||||
QueryResult result = WorldDatabase.Query("SELECT ID, Type, GreetEmoteType, GreetEmoteDelay, Greeting FROM quest_greeting");
|
||||
@@ -6239,8 +6243,6 @@ void ObjectMgr::LoadQuestGreetings()
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
@@ -6249,35 +6251,35 @@ void ObjectMgr::LoadQuestGreetings()
|
||||
uint8 type = fields[1].Get<uint8>();
|
||||
switch (type)
|
||||
{
|
||||
case 0: // Creature
|
||||
if (!sObjectMgr->GetCreatureTemplate(id))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `quest_greeting`: creature template entry {} does not exist.", id);
|
||||
case 0: // Creature
|
||||
if (!sObjectMgr->GetCreatureTemplate(id))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `quest_greeting`: creature template entry {} does not exist.", id);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 1: // GameObject
|
||||
if (!sObjectMgr->GetGameObjectTemplate(id))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `quest_greeting`: gameobject template entry {} does not exist.", id);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("sql.sql", "Table `quest_greeting` has unknown type {} for id {}, skipped.", type, id);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 1: // GameObject
|
||||
if (!sObjectMgr->GetGameObjectTemplate(id))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `quest_greeting`: gameobject template entry {} does not exist.", id);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
uint16 greetEmoteType = fields[2].Get<uint16>();
|
||||
uint32 greetEmoteDelay = fields[3].Get<uint32>();
|
||||
std::string greeting = fields[4].Get<std::string>();
|
||||
std::pair<uint32, uint8> pairKey = std::make_pair(id, type);
|
||||
QuestGreeting& data = _questGreetingStore[pairKey];
|
||||
|
||||
_questGreetingStore[type].emplace(std::piecewise_construct, std::forward_as_tuple(id), std::forward_as_tuple(greetEmoteType, greetEmoteDelay, std::move(greeting)));
|
||||
|
||||
++count;
|
||||
data.EmoteType = fields[2].Get<uint16>();
|
||||
data.EmoteDelay = fields[3].Get<uint32>();
|
||||
AddLocaleString(fields[4].Get<std::string>(), LOCALE_enUS, data.Greeting);
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
LOG_INFO("server.loading", ">> Loaded {} quest_greeting in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", ">> Loaded {} quest_greeting in {} ms", _questGreetingStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", " ");
|
||||
}
|
||||
|
||||
@@ -6285,8 +6287,6 @@ void ObjectMgr::LoadQuestGreetingsLocales()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
_questGreetingLocaleStore.clear();
|
||||
|
||||
// 0 1 2 3
|
||||
QueryResult result = WorldDatabase.Query("SELECT ID, Type, Locale, Greeting FROM quest_greeting_locale");
|
||||
if (!result)
|
||||
@@ -6295,6 +6295,7 @@ void ObjectMgr::LoadQuestGreetingsLocales()
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 localeCount = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
@@ -6321,17 +6322,25 @@ void ObjectMgr::LoadQuestGreetingsLocales()
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string localeName = fields[2].Get<std::string>();
|
||||
std::pair<uint32, uint8> pairKey = std::make_pair(id, type);
|
||||
QuestGreeting& data = _questGreetingStore[pairKey];
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
QuestGreetingContainer::iterator qgc = _questGreetingStore.find(pairKey);
|
||||
if (qgc == _questGreetingStore.end())
|
||||
{
|
||||
LOG_ERROR("sql.sql", "QuestGreeting (Id: {} Type: {}) found in table `quest_greeting_locale` but does not exist in `quest_greeting`. Skipped!", id, type);
|
||||
continue;
|
||||
}
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
QuestGreetingLocale& data = _questGreetingLocaleStore[MAKE_PAIR32(type, id)];
|
||||
AddLocaleString(fields[3].Get<std::string>(), locale, data.Greeting);
|
||||
localeCount++;
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server.loading", ">> Loaded {} quest greeting Locale Strings in {} ms", (uint32)_questGreetingLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", ">> Loaded {} quest greeting Locale Strings in {} ms", localeCount, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", " ");
|
||||
}
|
||||
|
||||
@@ -8544,6 +8553,98 @@ void ObjectMgr::LoadGameObjectForQuests()
|
||||
LOG_INFO("server.loading", " ");
|
||||
}
|
||||
|
||||
bool ObjectMgr::LoadModuleStrings()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
_moduleStringStore.clear(); // for reload case
|
||||
QueryResult result = WorldDatabase.Query("SELECT module, id, string FROM module_string");
|
||||
if (!result)
|
||||
{
|
||||
LOG_WARN("server.loading", ">> Loaded 0 module strings. DB table `module_string` is empty.");
|
||||
LOG_INFO("server.loading", " ");
|
||||
return false;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
std::string module = fields[0].Get<std::string>();
|
||||
uint32 id = fields[1].Get<uint32>();
|
||||
|
||||
std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
|
||||
ModuleString& data = _moduleStringStore[pairKey];
|
||||
|
||||
AddLocaleString(fields[2].Get<std::string>(), LOCALE_enUS, data.Content);
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server.loading", ">> Loaded {} Module Strings in {} ms", _moduleStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", " ");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectMgr::LoadModuleStringsLocale()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
QueryResult result = WorldDatabase.Query("SELECT module, id, locale, string FROM module_string_locale");
|
||||
if (!result)
|
||||
{
|
||||
LOG_WARN("server.loading", ">> Loaded 0 module strings locale. DB table `module_string_locale` is empty.");
|
||||
LOG_INFO("server.loading", " ");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 localeCount = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
std::string module = fields[0].Get<std::string>();
|
||||
uint32 id = fields[1].Get<uint32>();
|
||||
|
||||
std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
|
||||
ModuleString& data = _moduleStringStore[pairKey];
|
||||
|
||||
ModuleStringContainer::iterator ms = _moduleStringStore.find(pairKey);
|
||||
if (ms == _moduleStringStore.end())
|
||||
{
|
||||
LOG_ERROR("sql.sql", "ModuleString (Module: {} Id: {}) found in table `module_string_locale` but does not exist in `module_string`. Skipped!", module, id);
|
||||
continue;
|
||||
}
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
AddLocaleString(fields[3].Get<std::string>(), locale, data.Content);
|
||||
localeCount++;
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server.loading", ">> Loaded {} Module Strings Locales in {} ms", localeCount, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", " ");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string const* ObjectMgr::GetModuleString(std::string module, uint32 id, LocaleConstant locale) const
|
||||
{
|
||||
ModuleString const* ms = GetModuleString(module, id);
|
||||
if (ms->Content.size())
|
||||
{
|
||||
if (ms->Content.size() > size_t(locale) && !ms->Content[locale].empty())
|
||||
return &ms->Content[locale];
|
||||
|
||||
return &ms->Content[DEFAULT_LOCALE];
|
||||
}
|
||||
|
||||
LOG_ERROR("sql.sql", "Module string module {} id {} not found in DB.", module, id);
|
||||
|
||||
return (std::string*)"error";
|
||||
}
|
||||
|
||||
bool ObjectMgr::LoadAcoreStrings()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
@@ -493,6 +493,11 @@ typedef std::unordered_map<uint32/*(mapid, spawnMode) pair*/, CellObjectGuidsMap
|
||||
// Acore Trainer Reference start range
|
||||
#define ACORE_TRAINER_START_REF 200000
|
||||
|
||||
struct ModuleString
|
||||
{
|
||||
std::vector<std::string> Content;
|
||||
};
|
||||
|
||||
struct AcoreString
|
||||
{
|
||||
std::vector<std::string> Content;
|
||||
@@ -511,6 +516,7 @@ typedef std::unordered_map<uint32, QuestOfferRewardLocale> QuestOfferRewardLocal
|
||||
typedef std::unordered_map<uint32, QuestRequestItemsLocale> QuestRequestItemsLocaleContainer;
|
||||
typedef std::unordered_map<uint32, NpcTextLocale> NpcTextLocaleContainer;
|
||||
typedef std::unordered_map<uint32, PageTextLocale> PageTextLocaleContainer;
|
||||
typedef std::map<std::pair<std::string, uint32>, ModuleString> ModuleStringContainer;
|
||||
typedef std::unordered_map<int32, AcoreString> AcoreStringContainer;
|
||||
typedef std::unordered_map<uint32, GossipMenuItemsLocale> GossipMenuItemsLocaleContainer;
|
||||
typedef std::unordered_map<uint32, PointOfInterestLocale> PointOfInterestLocaleContainer;
|
||||
@@ -593,20 +599,9 @@ struct QuestGreeting
|
||||
{
|
||||
uint16 EmoteType;
|
||||
uint32 EmoteDelay;
|
||||
std::string Text;
|
||||
|
||||
QuestGreeting() : EmoteType(0), EmoteDelay(0) { }
|
||||
QuestGreeting(uint16 emoteType, uint32 emoteDelay, std::string text)
|
||||
: EmoteType(emoteType), EmoteDelay(emoteDelay), Text(std::move(text)) { }
|
||||
};
|
||||
|
||||
struct QuestGreetingLocale
|
||||
{
|
||||
std::vector<std::string> Greeting;
|
||||
};
|
||||
|
||||
typedef std::unordered_map<uint32, QuestGreetingLocale> QuestGreetingLocaleContainer;
|
||||
|
||||
struct GossipMenuItems
|
||||
{
|
||||
uint32 MenuID;
|
||||
@@ -666,7 +661,7 @@ struct QuestPOI
|
||||
typedef std::vector<QuestPOI> QuestPOIVector;
|
||||
typedef std::unordered_map<uint32, QuestPOIVector> QuestPOIContainer;
|
||||
|
||||
typedef std::array<std::unordered_map<uint32, QuestGreeting>, 2> QuestGreetingContainer;
|
||||
typedef std::map<std::pair<uint32, uint8>, QuestGreeting> QuestGreetingContainer;
|
||||
|
||||
typedef std::unordered_map<uint32, VendorItemData> CacheVendorItemContainer;
|
||||
typedef std::unordered_map<uint32, TrainerSpellData> CacheTrainerSpellContainer;
|
||||
@@ -1013,6 +1008,8 @@ public:
|
||||
void ValidateSpellScripts();
|
||||
void InitializeSpellInfoPrecomputedData();
|
||||
|
||||
bool LoadModuleStrings();
|
||||
bool LoadModuleStringsLocale();
|
||||
bool LoadAcoreStrings();
|
||||
void LoadBroadcastTexts();
|
||||
void LoadBroadcastTextLocales();
|
||||
@@ -1268,26 +1265,6 @@ public:
|
||||
if (itr == _pointOfInterestLocaleStore.end()) return nullptr;
|
||||
return &itr->second;
|
||||
}
|
||||
[[nodiscard]] QuestGreetingLocale const* GetQuestGreetingLocale(TypeID type, uint32 id) const
|
||||
{
|
||||
uint32 typeIndex;
|
||||
if (type == TYPEID_UNIT)
|
||||
{
|
||||
typeIndex = 0;
|
||||
}
|
||||
else if (type == TYPEID_GAMEOBJECT)
|
||||
{
|
||||
typeIndex = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QuestGreetingLocaleContainer::const_iterator itr = _questGreetingLocaleStore.find(MAKE_PAIR32(typeIndex, id));
|
||||
if (itr == _questGreetingLocaleStore.end()) return nullptr;
|
||||
return &itr->second;
|
||||
}
|
||||
[[nodiscard]] QuestOfferRewardLocale const* GetQuestOfferRewardLocale(uint32 entry) const
|
||||
{
|
||||
auto itr = _questOfferRewardLocaleStore.find(entry);
|
||||
@@ -1306,11 +1283,22 @@ public:
|
||||
if (itr == _npcTextLocaleStore.end()) return nullptr;
|
||||
return &itr->second;
|
||||
}
|
||||
QuestGreeting const* GetQuestGreeting(TypeID type, uint32 id) const;
|
||||
[[nodiscard]] QuestGreeting const* GetQuestGreeting(TypeID type, uint32 id) const;
|
||||
|
||||
GameObjectData& NewGOData(ObjectGuid::LowType guid) { return _gameObjectDataStore[guid]; }
|
||||
void DeleteGOData(ObjectGuid::LowType guid);
|
||||
|
||||
[[nodiscard]] ModuleString const* GetModuleString(std::string module, uint32 id) const
|
||||
{
|
||||
std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
|
||||
ModuleStringContainer::const_iterator itr = _moduleStringStore.find(pairKey);
|
||||
if (itr == _moduleStringStore.end())
|
||||
return nullptr;
|
||||
|
||||
return &itr->second;
|
||||
}
|
||||
[[nodiscard]] std::string const* GetModuleString(std::string module, uint32 id, LocaleConstant locale) const;
|
||||
|
||||
[[nodiscard]] AcoreString const* GetAcoreString(uint32 entry) const
|
||||
{
|
||||
AcoreStringContainer::const_iterator itr = _acoreStringStore.find(entry);
|
||||
@@ -1599,10 +1587,10 @@ private:
|
||||
QuestRequestItemsLocaleContainer _questRequestItemsLocaleStore;
|
||||
NpcTextLocaleContainer _npcTextLocaleStore;
|
||||
PageTextLocaleContainer _pageTextLocaleStore;
|
||||
ModuleStringContainer _moduleStringStore;
|
||||
AcoreStringContainer _acoreStringStore;
|
||||
GossipMenuItemsLocaleContainer _gossipMenuItemsLocaleStore;
|
||||
PointOfInterestLocaleContainer _pointOfInterestLocaleStore;
|
||||
QuestGreetingLocaleContainer _questGreetingLocaleStore;
|
||||
|
||||
CacheVendorItemContainer _cacheVendorItemStore;
|
||||
CacheTrainerSpellContainer _cacheTrainerSpellStore;
|
||||
|
||||
Reference in New Issue
Block a user