mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-21 20:56:23 +00:00
Core/Text: Implemented BroadcastText. (#227)
This commit is contained in:
73066
data/sql/updates/pending_db_world/rev_1478377821535626700.sql
Normal file
73066
data/sql/updates/pending_db_world/rev_1478377821535626700.sql
Normal file
File diff suppressed because it is too large
Load Diff
73070
data/sql/updates/pending_db_world/rev_1478377844582051200.sql
Normal file
73070
data/sql/updates/pending_db_world/rev_1478377844582051200.sql
Normal file
File diff suppressed because one or more lines are too long
@@ -8681,6 +8681,136 @@ uint32 ObjectMgr::GetScriptId(const char *name)
|
||||
return uint32(itr - _scriptNamesStore.begin());
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadBroadcastTexts()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
_broadcastTextStore.clear(); // for reload case
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12
|
||||
QueryResult result = WorldDatabase.Query("SELECT ID, Language, MaleText, FemaleText, EmoteID0, EmoteID1, EmoteID2, EmoteDelay0, EmoteDelay1, EmoteDelay2, SoundId, Unk1, Unk2 FROM broadcast_text");
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 broadcast texts. DB table `broadcast_text` is empty.");
|
||||
sLog->outString();
|
||||
return;
|
||||
}
|
||||
|
||||
_broadcastTextStore.rehash(result->GetRowCount());
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
BroadcastText bct;
|
||||
|
||||
bct.Id = fields[0].GetUInt32();
|
||||
bct.Language = fields[1].GetUInt32();
|
||||
bct.MaleText[DEFAULT_LOCALE] = fields[2].GetString();
|
||||
bct.FemaleText[DEFAULT_LOCALE] = fields[3].GetString();
|
||||
bct.EmoteId0 = fields[4].GetUInt32();
|
||||
bct.EmoteId1 = fields[5].GetUInt32();
|
||||
bct.EmoteId2 = fields[6].GetUInt32();
|
||||
bct.EmoteDelay0 = fields[7].GetUInt32();
|
||||
bct.EmoteDelay1 = fields[8].GetUInt32();
|
||||
bct.EmoteDelay2 = fields[9].GetUInt32();
|
||||
bct.SoundId = fields[10].GetUInt32();
|
||||
bct.Unk1 = fields[11].GetUInt32();
|
||||
bct.Unk2 = fields[12].GetUInt32();
|
||||
|
||||
if (bct.SoundId)
|
||||
{
|
||||
if (!sSoundEntriesStore.LookupEntry(bct.SoundId))
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NONE, "BroadcastText (Id: %u) in table `broadcast_text` has SoundId %u but sound does not exist.", bct.Id, bct.SoundId);
|
||||
bct.SoundId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!GetLanguageDescByID(bct.Language))
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NONE, "BroadcastText (Id: %u) in table `broadcast_text` using Language %u but Language does not exist.", bct.Id, bct.Language);
|
||||
bct.Language = LANG_UNIVERSAL;
|
||||
}
|
||||
|
||||
if (bct.EmoteId0)
|
||||
{
|
||||
if (!sEmotesStore.LookupEntry(bct.EmoteId0))
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NONE, "BroadcastText (Id: %u) in table `broadcast_text` has EmoteId0 %u but emote does not exist.", bct.Id, bct.EmoteId0);
|
||||
bct.EmoteId0 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (bct.EmoteId1)
|
||||
{
|
||||
if (!sEmotesStore.LookupEntry(bct.EmoteId1))
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NONE, "BroadcastText (Id: %u) in table `broadcast_text` has EmoteId1 %u but emote does not exist.", bct.Id, bct.EmoteId1);
|
||||
bct.EmoteId1 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (bct.EmoteId2)
|
||||
{
|
||||
if (!sEmotesStore.LookupEntry(bct.EmoteId2))
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NONE, "BroadcastText (Id: %u) in table `broadcast_text` has EmoteId2 %u but emote does not exist.", bct.Id, bct.EmoteId2);
|
||||
bct.EmoteId2 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
_broadcastTextStore[bct.Id] = bct;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded " SIZEFMTD " broadcast texts in %u ms", _broadcastTextStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadBroadcastTextLocales()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
||||
QueryResult result = WorldDatabase.Query("SELECT Id, MaleText_loc1, MaleText_loc2, MaleText_loc3, MaleText_loc4, MaleText_loc5, MaleText_loc6, MaleText_loc7, MaleText_loc8, FemaleText_loc1, FemaleText_loc2, FemaleText_loc3, FemaleText_loc4, FemaleText_loc5, FemaleText_loc6, FemaleText_loc7, FemaleText_loc8 FROM locales_broadcast_text");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 broadcast text locales. DB table `locales_broadcast_text` is empty.");
|
||||
sLog->outString();
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id);
|
||||
if (bct == _broadcastTextStore.end())
|
||||
{
|
||||
sLog->outErrorDb("BroadcastText (Id: %u) in table `locales_broadcast_text` does not exist. Skipped!", id);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i)
|
||||
{
|
||||
LocaleConstant locale = LocaleConstant(i);
|
||||
AddLocaleString(fields[1 + (i - 1)].GetString(), locale, bct->second.MaleText);
|
||||
AddLocaleString(fields[9 + (i - 1)].GetString(), locale, bct->second.FemaleText);
|
||||
}
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u broadcast text locales in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
|
||||
void ObjectMgr::CheckScripts(ScriptsType type, std::set<int32>& ids)
|
||||
{
|
||||
ScriptMapMap* scripts = GetScriptsMapByType(type);
|
||||
|
||||
@@ -398,6 +398,49 @@ struct AreaTrigger
|
||||
float target_Orientation;
|
||||
};
|
||||
|
||||
struct BroadcastText
|
||||
{
|
||||
BroadcastText() : Id(0), Language(0), EmoteId0(0), EmoteId1(0), EmoteId2(0),
|
||||
EmoteDelay0(0), EmoteDelay1(0), EmoteDelay2(0), SoundId(0), Unk1(0), Unk2(0)
|
||||
{
|
||||
MaleText.resize(DEFAULT_LOCALE + 1);
|
||||
FemaleText.resize(DEFAULT_LOCALE + 1);
|
||||
}
|
||||
|
||||
uint32 Id;
|
||||
uint32 Language;
|
||||
StringVector MaleText;
|
||||
StringVector FemaleText;
|
||||
uint32 EmoteId0;
|
||||
uint32 EmoteId1;
|
||||
uint32 EmoteId2;
|
||||
uint32 EmoteDelay0;
|
||||
uint32 EmoteDelay1;
|
||||
uint32 EmoteDelay2;
|
||||
uint32 SoundId;
|
||||
uint32 Unk1;
|
||||
uint32 Unk2;
|
||||
// uint32 VerifiedBuild;
|
||||
|
||||
std::string const& GetText(LocaleConstant locale = DEFAULT_LOCALE, uint8 gender = GENDER_MALE, bool forceGender = false) const
|
||||
{
|
||||
if (gender == GENDER_FEMALE && (forceGender || !FemaleText[DEFAULT_LOCALE].empty()))
|
||||
{
|
||||
if (FemaleText.size() > size_t(locale) && !FemaleText[locale].empty())
|
||||
return FemaleText[locale];
|
||||
return FemaleText[DEFAULT_LOCALE];
|
||||
}
|
||||
// else if (gender == GENDER_MALE)
|
||||
{
|
||||
if (MaleText.size() > size_t(locale) && !MaleText[locale].empty())
|
||||
return MaleText[locale];
|
||||
return MaleText[DEFAULT_LOCALE];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::unordered_map<uint32, BroadcastText> BroadcastTextContainer;
|
||||
|
||||
typedef std::set<uint32> CellGuidSet;
|
||||
typedef UNORDERED_MAP<uint32/*player guid*/, uint32/*instance*/> CellCorpseSet;
|
||||
struct CellObjectGuids
|
||||
@@ -884,6 +927,8 @@ class ObjectMgr
|
||||
bool LoadTrinityStrings(char const* table, int32 min_value, int32 max_value);
|
||||
bool LoadTrinityStrings() { return LoadTrinityStrings("trinity_string", MIN_TRINITY_STRING_ID, MAX_TRINITY_STRING_ID); }
|
||||
void LoadDbScriptStrings();
|
||||
void LoadBroadcastTexts();
|
||||
void LoadBroadcastTextLocales();
|
||||
void LoadCreatureClassLevelStats();
|
||||
void LoadCreatureLocales();
|
||||
void LoadCreatureTemplates();
|
||||
@@ -1029,6 +1074,13 @@ class ObjectMgr
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BroadcastText const* GetBroadcastText(uint32 id) const
|
||||
{
|
||||
BroadcastTextContainer::const_iterator itr = _broadcastTextStore.find(id);
|
||||
if (itr != _broadcastTextStore.end())
|
||||
return &itr->second;
|
||||
return nullptr;
|
||||
}
|
||||
CreatureData const* GetCreatureData(uint32 guid) const
|
||||
{
|
||||
CreatureDataContainer::const_iterator itr = _creatureDataStore.find(guid);
|
||||
@@ -1334,6 +1386,7 @@ class ObjectMgr
|
||||
/// Stores temp summon data grouped by summoner's entry, summoner's type and group id
|
||||
TempSummonDataContainer _tempSummonDataStore;
|
||||
|
||||
BroadcastTextContainer _broadcastTextStore;
|
||||
ItemTemplateContainer _itemTemplateStore;
|
||||
std::vector<ItemTemplate*> _itemTemplateStoreFast; // pussywizard
|
||||
ItemLocaleContainer _itemLocaleStore;
|
||||
|
||||
@@ -1366,6 +1366,10 @@ void World::SetInitialWorldSettings()
|
||||
sLog->outString("Loading instances...");
|
||||
sInstanceSaveMgr->LoadInstances();
|
||||
|
||||
sLog->outString("Loading Broadcast texts...");
|
||||
sObjectMgr->LoadBroadcastTexts();
|
||||
sObjectMgr->LoadBroadcastTextLocales();
|
||||
|
||||
sLog->outString("Loading Localization strings...");
|
||||
uint32 oldMSTime = getMSTime();
|
||||
sObjectMgr->LoadCreatureLocales();
|
||||
|
||||
Reference in New Issue
Block a user