Core/DataStores: Moved broadcast_text handling to DB2Storage

This commit is contained in:
Shauren
2014-12-25 22:20:16 +01:00
parent 4e8217754e
commit 9eb70940bd
21 changed files with 116 additions and 237 deletions
File diff suppressed because one or more lines are too long
+2
View File
@@ -0,0 +1,2 @@
DELETE FROM `rbac_permissions` WHERE `id`=614;
DELETE FROM `rbac_linked_permissions` WHERE `linkedId`=614;
@@ -0,0 +1,34 @@
SET @world_db_name := 'world_db_name_goes_here_or_error_in_yo_face'; -- fill in your world database name
DROP TABLE IF EXISTS `locales_broadcast_text`;
CREATE TABLE `locales_broadcast_text` (
`ID` mediumint(8) UNSIGNED NOT NULL DEFAULT 0 ,
`MaleText_loc1` longtext,
`MaleText_loc2` longtext,
`MaleText_loc3` longtext,
`MaleText_loc4` longtext,
`MaleText_loc5` longtext,
`MaleText_loc6` longtext,
`MaleText_loc7` longtext,
`MaleText_loc8` longtext,
`FemaleText_loc1` longtext,
`FemaleText_loc2` longtext,
`FemaleText_loc3` longtext,
`FemaleText_loc4` longtext,
`FemaleText_loc5` longtext,
`FemaleText_loc6` longtext,
`FemaleText_loc7` longtext,
`FemaleText_loc8` longtext,
`VerifiedBuild` smallint(5) NULL DEFAULT 0,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET @query := CONCAT('INSERT INTO `locales_broadcast_text` SELECT * FROM `', @world_db_name, '`.`locales_broadcast_text`;');
PREPARE stmt FROM @query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @query := CONCAT('DROP TABLE IF EXISTS `', @world_db_name, '`.`locales_broadcast_text`;');
PREPARE stmt2 FROM @query;
EXECUTE stmt2;
DEALLOCATE PREPARE stmt2;
@@ -0,0 +1 @@
DELETE FROM `command` WHERE `name`='reload broadcast_text';
+18
View File
@@ -23,6 +23,7 @@
#include "World.h"
#include <functional>
DB2Storage<BroadcastTextEntry> sBroadcastTextStore(BroadcastTextEntryfmt, HOTFIX_SEL_BROADCAST_TEXT);
std::map<uint32 /*curveID*/, std::map<uint32/*index*/, CurvePointEntry const*, std::greater<uint32>>> HeirloomCurvePoints;
DB2Storage<CurvePointEntry> sCurvePointStore(CurvePointEntryfmt);
DB2Storage<HolidaysEntry> sHolidaysStore(HolidaysEntryfmt);
@@ -130,6 +131,7 @@ void LoadDB2Stores(std::string const& dataPath)
DB2StoreProblemList bad_db2_files;
uint32 availableDb2Locales = 0xFF;
LoadDB2(availableDb2Locales, bad_db2_files, sBroadcastTextStore, db2Path, "BroadcastText.db2");
LoadDB2(availableDb2Locales, bad_db2_files, sCurvePointStore, db2Path, "CurvePoint.db2");
LoadDB2(availableDb2Locales, bad_db2_files, sHolidaysStore, db2Path, "Holidays.db2");
LoadDB2(availableDb2Locales, bad_db2_files, sItemStore, db2Path, "Item.db2");
@@ -308,6 +310,22 @@ DB2StorageBase const* GetDB2Storage(uint32 type)
return NULL;
}
char const* GetBroadcastTextValue(BroadcastTextEntry const* broadcastText, LocaleConstant locale /*= DEFAULT_LOCALE*/, uint8 gender /*= GENDER_MALE*/, bool forceGender /*= false*/)
{
if (gender == GENDER_FEMALE && (forceGender || broadcastText->FemaleText->Str[DEFAULT_LOCALE][0] != '\0'))
{
if (broadcastText->FemaleText->Str[locale][0] != '\0')
return broadcastText->FemaleText->Str[locale];
return broadcastText->FemaleText->Str[DEFAULT_LOCALE];
}
if (broadcastText->MaleText->Str[locale][0] != '\0')
return broadcastText->MaleText->Str[locale];
return broadcastText->MaleText->Str[DEFAULT_LOCALE];
}
uint32 GetHeirloomItemLevel(uint32 curveId, uint32 level)
{
// Assuming linear item level scaling for heirlooms
+2
View File
@@ -23,6 +23,7 @@
#include <string>
#include <map>
extern DB2Storage<BroadcastTextEntry> sBroadcastTextStore;
extern DB2Storage<HolidaysEntry> sHolidaysStore;
extern DB2Storage<ItemEntry> sItemStore;
extern DB2Storage<ItemCurrencyCostEntry> sItemCurrencyCostStore;
@@ -56,6 +57,7 @@ void LoadDB2Stores(std::string const& dataPath);
DB2StorageBase const* GetDB2Storage(uint32 type);
char const* GetBroadcastTextValue(BroadcastTextEntry const* broadcastText, LocaleConstant locale = DEFAULT_LOCALE, uint8 gender = GENDER_MALE, bool forceGender = false);
uint32 GetHeirloomItemLevel(uint32 curveId, uint32 level);
uint32 GetItemDisplayId(uint32 itemId, uint32 appearanceModId);
std::vector<ItemBonusEntry const*> GetItemBonuses(uint32 bonusListId);
+14
View File
@@ -24,6 +24,7 @@
#pragma pack(push, 1)
#define MAX_BROADCAST_TEXT_EMOTES 3
#define MAX_HOLIDAY_DURATIONS 10
#define MAX_HOLIDAY_DATES 16
#define MAX_HOLIDAY_FLAGS 10
@@ -31,6 +32,19 @@
#define MAX_ITEM_PROTO_SOCKETS 3
#define MAX_ITEM_PROTO_STATS 10
struct BroadcastTextEntry
{
uint32 ID;
int32 Language;
LocalizedString* MaleText;
LocalizedString* FemaleText;
uint32 EmoteID[MAX_BROADCAST_TEXT_EMOTES];
uint32 EmoteDelay[MAX_BROADCAST_TEXT_EMOTES];
uint32 SoundID;
uint32 UnkEmoteID;
uint32 Type;
};
struct CurvePointEntry
{
uint32 ID; // 0
+1
View File
@@ -18,6 +18,7 @@
#ifndef TRINITY_DB2SFRM_H
#define TRINITY_DB2SFRM_H
char const BroadcastTextEntryfmt[] = "nissiiiiiiiii";
char const CurvePointEntryfmt[] = "niiff";
char const HolidaysEntryfmt[] = "niiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiixxsiix";
char const Itemfmt[] = "niiiiiiii";
@@ -94,18 +94,18 @@ void GossipMenu::AddMenuItem(uint32 menuId, uint32 menuItemId, uint32 sender, ui
/// Store texts for localization.
std::string strOptionText, strBoxText;
BroadcastText const* optionBroadcastText = sObjectMgr->GetBroadcastText(itr->second.OptionBroadcastTextId);
BroadcastText const* boxBroadcastText = sObjectMgr->GetBroadcastText(itr->second.BoxBroadcastTextId);
BroadcastTextEntry const* optionBroadcastText = sBroadcastTextStore.LookupEntry(itr->second.OptionBroadcastTextId);
BroadcastTextEntry const* boxBroadcastText = sBroadcastTextStore.LookupEntry(itr->second.BoxBroadcastTextId);
/// OptionText
if (optionBroadcastText)
strOptionText = optionBroadcastText->GetText(GetLocale());
strOptionText = GetBroadcastTextValue(optionBroadcastText, GetLocale());
else
strOptionText = itr->second.OptionText;
/// BoxText
if (boxBroadcastText)
strBoxText = boxBroadcastText->GetText(GetLocale());
strBoxText = GetBroadcastTextValue(boxBroadcastText, GetLocale());
else
strBoxText = itr->second.BoxText;
+4 -4
View File
@@ -13852,17 +13852,17 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
if (canTalk)
{
std::string strOptionText, strBoxText;
BroadcastText const* optionBroadcastText = sObjectMgr->GetBroadcastText(itr->second.OptionBroadcastTextId);
BroadcastText const* boxBroadcastText = sObjectMgr->GetBroadcastText(itr->second.BoxBroadcastTextId);
BroadcastTextEntry const* optionBroadcastText = sBroadcastTextStore.LookupEntry(itr->second.OptionBroadcastTextId);
BroadcastTextEntry const* boxBroadcastText = sBroadcastTextStore.LookupEntry(itr->second.BoxBroadcastTextId);
LocaleConstant locale = GetSession()->GetSessionDbLocaleIndex();
if (optionBroadcastText)
strOptionText = optionBroadcastText->GetText(locale, getGender());
strOptionText = GetBroadcastTextValue(optionBroadcastText, locale, getGender());
else
strOptionText = itr->second.OptionText;
if (boxBroadcastText)
strBoxText = boxBroadcastText->GetText(locale, getGender());
strBoxText = GetBroadcastTextValue(boxBroadcastText, locale, getGender());
else
strBoxText = itr->second.BoxText;
+3 -3
View File
@@ -16462,7 +16462,7 @@ void Unit::Whisper(std::string const& text, Language language, Player* target, b
void Unit::Talk(uint32 textId, ChatMsg msgType, float textRange, WorldObject const* target)
{
if (!sObjectMgr->GetBroadcastText(textId))
if (!sBroadcastTextStore.LookupEntry(textId))
{
TC_LOG_ERROR("entities.unit", "WorldObject::MonsterText: `broadcast_text` was not %u found", textId);
return;
@@ -16494,7 +16494,7 @@ void Unit::Whisper(uint32 textId, Player* target, bool isBossWhisper /*= false*/
if (!target)
return;
BroadcastText const* bct = sObjectMgr->GetBroadcastText(textId);
BroadcastTextEntry const* bct = sBroadcastTextStore.LookupEntry(textId);
if (!bct)
{
TC_LOG_ERROR("entities.unit", "WorldObject::MonsterWhisper: `broadcast_text` was not %u found", textId);
@@ -16503,6 +16503,6 @@ void Unit::Whisper(uint32 textId, Player* target, bool isBossWhisper /*= false*/
LocaleConstant locale = target->GetSession()->GetSessionDbLocaleIndex();
WorldPackets::Chat::Chat packet;
packet.Initalize(isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, bct->GetText(locale, getGender()), 0, "", locale);
packet.Initalize(isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, GetBroadcastTextValue(bct, locale, getGender()), 0, "", locale);
target->SendDirectMessage(packet.Write());
}
+4 -139
View File
@@ -4323,7 +4323,7 @@ void ObjectMgr::LoadScripts(ScriptsType type)
tableName.c_str(), tmp.Talk.ChatType, tmp.id);
continue;
}
if (!sObjectMgr->GetBroadcastText(uint32(tmp.Talk.TextID)))
if (!sBroadcastTextStore.LookupEntry(uint32(tmp.Talk.TextID)))
{
TC_LOG_ERROR("sql.sql", "Table `%s` has invalid talk text id (dataint = %i) in SCRIPT_COMMAND_TALK for script id %u",
tableName.c_str(), tmp.Talk.TextID, tmp.id);
@@ -5087,7 +5087,7 @@ void ObjectMgr::LoadGossipText()
{
if (gText.Options[i].BroadcastTextID)
{
if (!sObjectMgr->GetBroadcastText(gText.Options[i].BroadcastTextID))
if (!sBroadcastTextStore.LookupEntry(gText.Options[i].BroadcastTextID))
{
TC_LOG_ERROR("sql.sql", "GossipText (Id: %u) in table `npc_text` has non-existing or incompatible BroadcastTextID%u %u.", id, i, gText.Options[i].BroadcastTextID);
gText.Options[i].BroadcastTextID = 0;
@@ -8042,7 +8042,7 @@ void ObjectMgr::LoadGossipMenuItems()
if (gMenuItem.OptionBroadcastTextId)
{
if (!GetBroadcastText(gMenuItem.OptionBroadcastTextId))
if (!sBroadcastTextStore.LookupEntry(gMenuItem.OptionBroadcastTextId))
{
TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu %u, id %u has non-existing or incompatible OptionBroadcastTextId %u, ignoring.", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.OptionBroadcastTextId);
gMenuItem.OptionBroadcastTextId = 0;
@@ -8060,7 +8060,7 @@ void ObjectMgr::LoadGossipMenuItems()
if (gMenuItem.BoxBroadcastTextId)
{
if (!GetBroadcastText(gMenuItem.BoxBroadcastTextId))
if (!sBroadcastTextStore.LookupEntry(gMenuItem.BoxBroadcastTextId))
{
TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu %u, id %u has non-existing or incompatible BoxBroadcastTextId %u, ignoring.", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.BoxBroadcastTextId);
gMenuItem.BoxBroadcastTextId = 0;
@@ -8273,141 +8273,6 @@ uint32 ObjectMgr::GetScriptId(char const* 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)
{
TC_LOG_INFO("server.loading", ">> Loaded 0 broadcast texts. DB table `broadcast_text` is empty.");
return;
}
_broadcastTextStore.rehash(result->GetRowCount());
uint32 count = 0;
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))
{
TC_LOG_INFO("sql.sql", "BroadcastText (Id: %u) in table `broadcast_text` has SoundId %u but sound does not exist. Skipped.", bct.Id, bct.SoundId);
// don't load bct of higher expansions
continue;
}
}
if (!GetLanguageDescByID(bct.Language))
{
TC_LOG_INFO("sql.sql", "BroadcastText (Id: %u) in table `broadcast_text` using Language %u but Language does not exist. Skipped.", bct.Id, bct.Language);
// don't load bct of higher expansions
continue;
}
if (bct.EmoteId0)
{
if (!sEmotesStore.LookupEntry(bct.EmoteId0))
{
TC_LOG_INFO("sql.sql", "BroadcastText (Id: %u) in table `broadcast_text` has EmoteId0 %u but emote does not exist. Skipped.", bct.Id, bct.EmoteId0);
// don't load bct of higher expansions
continue;
}
}
if (bct.EmoteId1)
{
if (!sEmotesStore.LookupEntry(bct.EmoteId1))
{
TC_LOG_INFO("sql.sql", "BroadcastText (Id: %u) in table `broadcast_text` has EmoteId1 %u but emote does not exist. Skipped.", bct.Id, bct.EmoteId1);
// don't load bct of higher expansions
continue;
}
}
if (bct.EmoteId2)
{
if (!sEmotesStore.LookupEntry(bct.EmoteId2))
{
TC_LOG_INFO("sql.sql", "BroadcastText (Id: %u) in table `broadcast_text` has EmoteId2 %u but emote does not exist. Skipped.", bct.Id, bct.EmoteId2);
// don't load bct of higher expansions
continue;
}
}
_broadcastTextStore[bct.Id] = bct;
++count;
}
while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u broadcast texts in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
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)
{
TC_LOG_INFO("server.loading", ">> Loaded 0 broadcast text locales. DB table `locales_broadcast_text` is empty.");
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id);
if (bct == _broadcastTextStore.end())
{
TC_LOG_INFO("sql.sql", "BroadcastText (Id: %u) in table `locales_broadcast_text` does not exist or is incompatible. Skipped!", id);
// don't load bct of higher expansions
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());
TC_LOG_INFO("server.loading", ">> Loaded %u broadcast text locales in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
CreatureBaseStats const* ObjectMgr::GetCreatureBaseStats(uint8 level, uint8 unitClass)
{
CreatureBaseStatsContainer::const_iterator it = _creatureBaseStatsStore.find(MAKE_PAIR16(level, unitClass));
-54
View File
@@ -436,49 +436,6 @@ struct AreaTriggerStruct
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<ObjectGuid::LowType> CellGuidSet;
typedef std::map<ObjectGuid/*player guid*/, uint32/*instance*/> CellCorpseSet;
struct CellObjectGuids
@@ -994,8 +951,6 @@ class ObjectMgr
void LoadSpellScriptNames();
void ValidateSpellScripts();
void LoadBroadcastTexts();
void LoadBroadcastTextLocales();
void LoadCreatureClassLevelStats();
void LoadCreatureLocales();
void LoadCreatureTemplates();
@@ -1136,14 +1091,6 @@ 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 NULL;
}
CreatureData const* GetCreatureData(ObjectGuid::LowType guid) const
{
CreatureDataContainer::const_iterator itr = _creatureDataStore.find(guid);
@@ -1499,7 +1446,6 @@ class ObjectMgr
/// Stores temp summon data grouped by summoner's entry, summoner's type and group id
TempSummonDataContainer _tempSummonDataStore;
BroadcastTextContainer _broadcastTextStore;
ItemTemplateContainer _itemTemplateStore;
ItemLocaleContainer _itemLocaleStore;
QuestLocaleContainer _questLocaleStore;
+2 -2
View File
@@ -231,8 +231,8 @@ void OutdoorPvPMgr::HandlePlayerResurrects(Player* player, uint32 zoneid)
std::string OutdoorPvPMgr::GetDefenseMessage(uint32 zoneId, uint32 id, LocaleConstant locale) const
{
if (BroadcastText const* bct = sObjectMgr->GetBroadcastText(id))
return bct->GetText(locale);
if (BroadcastTextEntry const* bct = sBroadcastTextStore.LookupEntry(id))
return GetBroadcastTextValue(bct, locale);
TC_LOG_ERROR("outdoorpvp", "Can not find DefenseMessage (Zone: %u, Id: %u). BroadcastText (Id: %u) does not exist.", zoneId, id, id);
return "";
+2 -2
View File
@@ -32,9 +32,9 @@ namespace Trinity
void operator()(WorldPacket& data, LocaleConstant locale)
{
BroadcastText const* bct = sObjectMgr->GetBroadcastText(_textId);
BroadcastTextEntry const* bct = sBroadcastTextStore.LookupEntry(_textId);
WorldPackets::Chat::Chat packet;
packet.Initalize(_msgType, bct ? Language(bct->Language) : LANG_UNIVERSAL, _source, _target, bct ? bct->GetText(locale, _source->getGender()) : "", _achievementId, "", locale);
packet.Initalize(_msgType, bct ? Language(bct->Language) : LANG_UNIVERSAL, _source, _target, bct ? GetBroadcastTextValue(bct, locale, _source->getGender()) : "", _achievementId, "", locale);
packet.Write();
data = packet.Move();
}
+3 -3
View File
@@ -146,7 +146,7 @@ void CreatureTextMgr::LoadCreatureTexts()
if (temp.BroadcastTextId)
{
if (!sObjectMgr->GetBroadcastText(temp.BroadcastTextId))
if (!sBroadcastTextStore.LookupEntry(temp.BroadcastTextId))
{
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u, Id %u in table `creature_text` has non-existing or incompatible BroadcastTextId %u.", temp.entry, temp.group, temp.id, temp.BroadcastTextId);
temp.BroadcastTextId = 0;
@@ -499,10 +499,10 @@ std::string CreatureTextMgr::GetLocalizedChatString(uint32 entry, uint8 gender,
locale = DEFAULT_LOCALE;
std::string baseText = "";
BroadcastText const* bct = sObjectMgr->GetBroadcastText(groupItr->BroadcastTextId);
BroadcastTextEntry const* bct = sBroadcastTextStore.LookupEntry(groupItr->BroadcastTextId);
if (bct)
baseText = bct->GetText(locale, gender);
baseText = GetBroadcastTextValue(bct, locale, gender);
else
baseText = groupItr->text;
-4
View File
@@ -1445,10 +1445,6 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.loading", "Loading instances...");
sInstanceSaveMgr->LoadInstances();
TC_LOG_INFO("server.loading", "Loading Broadcast texts...");
sObjectMgr->LoadBroadcastTexts();
sObjectMgr->LoadBroadcastTextLocales();
TC_LOG_INFO("server.loading", "Loading Localization strings...");
uint32 oldMSTime = getMSTime();
sObjectMgr->LoadCreatureLocales();
-10
View File
@@ -76,7 +76,6 @@ public:
{ "areatrigger_teleport", rbac::RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_TELEPORT, true, &HandleReloadAreaTriggerTeleportCommand, "", NULL },
{ "autobroadcast", rbac::RBAC_PERM_COMMAND_RELOAD_AUTOBROADCAST, true, &HandleReloadAutobroadcastCommand, "", NULL },
{ "battleground_template", rbac::RBAC_PERM_COMMAND_RELOAD_BATTLEGROUND_TEMPLATE, true, &HandleReloadBattlegroundTemplate, "", NULL },
{ "broadcast_text", rbac::RBAC_PERM_COMMAND_RELOAD_BROADCAST_TEXT, true, &HandleReloadBroadcastTextCommand, "", NULL },
{ "command", rbac::RBAC_PERM_COMMAND_RELOAD_COMMAND, true, &HandleReloadCommandCommand, "", NULL },
{ "conditions", rbac::RBAC_PERM_COMMAND_RELOAD_CONDITIONS, true, &HandleReloadConditions, "", NULL },
{ "config", rbac::RBAC_PERM_COMMAND_RELOAD_CONFIG, true, &HandleReloadConfigCommand, "", NULL },
@@ -381,15 +380,6 @@ public:
return true;
}
static bool HandleReloadBroadcastTextCommand(ChatHandler* handler, const char* /*args*/)
{
TC_LOG_INFO("misc", "Re-Loading Broadcast texts...");
sObjectMgr->LoadBroadcastTexts();
sObjectMgr->LoadBroadcastTextLocales();
handler->SendGlobalGMSysMessage("DB table `broadcast_text` reloaded.");
return true;
}
static bool HandleReloadCommandCommand(ChatHandler* handler, const char* /*args*/)
{
handler->SetLoadCommandTable(true);
@@ -436,10 +436,17 @@ char* DB2DatabaseLoader::Load(const char* format, int32 preparedStatement, uint3
// each string field at load have array of string for each locale
size_t stringHolderSize = sizeof(char*) * TOTAL_LOCALES;
size_t stringHoldersRecordPoolSize = stringFields * stringHolderSize;
size_t stringHoldersPoolSize = stringHoldersRecordPoolSize * result->GetRowCount();
if (stringFields)
{
size_t stringHoldersPoolSize = stringHoldersRecordPoolSize * result->GetRowCount();
stringHolders = new char[stringHoldersPoolSize];
// DB2 strings expected to have at least empty string
for (size_t i = 0; i < stringHoldersPoolSize / sizeof(char*); ++i)
((char const**)stringHolders)[i] = nullStr;
}
else
stringHolders = nullptr;
@@ -467,21 +474,21 @@ char* DB2DatabaseLoader::Load(const char* format, int32 preparedStatement, uint3
else
tempIndexTable[records++] = &dataTable[offset];
for (uint32 x = 0; x < fieldCount; x++)
for (uint32 f = 0; f < fieldCount; f++)
{
switch (format[x])
switch (format[f])
{
case FT_FLOAT:
*((float*)(&dataTable[offset])) = fields[x].GetFloat();
*((float*)(&dataTable[offset])) = fields[f].GetFloat();
offset += 4;
break;
case FT_IND:
case FT_INT:
*((int32*)(&dataTable[offset])) = fields[x].GetInt32();
*((int32*)(&dataTable[offset])) = fields[f].GetInt32();
offset += 4;
break;
case FT_BYTE:
*((int8*)(&dataTable[offset])) = fields[x].GetInt8();
*((int8*)(&dataTable[offset])) = fields[f].GetInt8();
offset += 1;
break;
case FT_STRING:
@@ -490,11 +497,11 @@ char* DB2DatabaseLoader::Load(const char* format, int32 preparedStatement, uint3
*slot = (LocalizedString*)(&stringHolders[stringHoldersRecordPoolSize * rec++ + stringHolderSize * stringFieldNumInRecord]);
// Value in database in main table field must be for enUS locale
if (char* str = AddLocaleString(*slot, LOCALE_enUS, fields[x].GetString()))
if (char* str = AddLocaleString(*slot, LOCALE_enUS, fields[f].GetString()))
stringPool.push_back(str);
for (uint32 i = LOCALE_koKR; i < TOTAL_LOCALES; ++i)
if (char* str = AddLocaleString(*slot, i, fields[localeFieldsOffset + (i - 1) * stringFieldNumInRecord].GetString()))
for (uint32 locale = LOCALE_koKR; locale < TOTAL_LOCALES; ++locale)
if (char* str = AddLocaleString(*slot, locale, fields[localeFieldsOffset + (locale - 1) + stringFields * stringFieldNumInRecord].GetString()))
stringPool.push_back(str);
++stringFieldNumInRecord;
@@ -527,7 +534,8 @@ char* DB2DatabaseLoader::AddLocaleString(LocalizedString* holder, uint32 locale,
if (!value.empty())
{
char* str = new char[value.length() + 1];
strcpy(str, value.c_str());
memcpy(str, value.c_str(), value.length());
str[value.length()] = '\0';
holder->Str[locale] = str;
return str;
}
@@ -22,5 +22,6 @@ void HotfixDatabaseConnection::DoPrepareStatements()
if (!m_reconnecting)
m_stmts.resize(MAX_HOTFIXDATABASE_STATEMENTS);
PrepareStatement(HOTFIX_SEL_BROADCAST_TEXT, "SELECT * FROM broadcast_text b LEFT JOIN locales_broadcast_text lb ON b.ID = lb.ID", CONNECTION_SYNCH);
PrepareStatement(HOTFIX_SEL_TAXI_PATH_NODE, "SELECT * FROM taxi_path_node", CONNECTION_SYNCH);
}
@@ -42,6 +42,7 @@ enum HotfixDatabaseStatements
name for a suiting suffix.
*/
HOTFIX_SEL_BROADCAST_TEXT,
HOTFIX_SEL_TAXI_PATH_NODE,
MAX_HOTFIXDATABASE_STATEMENTS
};