Core/Misc: Update page text locale to simple system
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
DROP TABLE IF EXISTS `locales_page_text`;
|
||||
|
||||
DROP TABLE IF EXISTS `page_text_locale`;
|
||||
CREATE TABLE IF NOT EXISTS `page_text_locale` (
|
||||
`ID` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`locale` VARCHAR(4) NOT NULL,
|
||||
`Text` TEXT,
|
||||
`VerifiedBuild` SMALLINT(5) DEFAULT '0'
|
||||
) ENGINE=MYISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
ALTER TABLE `page_text_locale`
|
||||
ADD PRIMARY KEY (`ID`,`locale`);
|
||||
@@ -1750,13 +1750,13 @@ void AchievementMgr<Player>::CompletedAchievement(AchievementEntry const* achiev
|
||||
std::string subject = reward->subject;
|
||||
std::string text = reward->text;
|
||||
|
||||
int locIdx = GetOwner()->GetSession()->GetSessionDbLocaleIndex();
|
||||
if (locIdx >= 0)
|
||||
LocaleConstant localeConstant = GetOwner()->GetSession()->GetSessionDbLocaleIndex();
|
||||
if (localeConstant >= LOCALE_enUS)
|
||||
{
|
||||
if (AchievementRewardLocale const* loc = sAchievementMgr->GetAchievementRewardLocale(achievement))
|
||||
{
|
||||
ObjectMgr::GetLocaleString(loc->subject, locIdx, subject);
|
||||
ObjectMgr::GetLocaleString(loc->text, locIdx, text);
|
||||
ObjectMgr::GetLocaleString(loc->subject, localeConstant, subject);
|
||||
ObjectMgr::GetLocaleString(loc->text, localeConstant, text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -235,10 +235,10 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID)
|
||||
text.Repeatable = quest->IsRepeatable();
|
||||
|
||||
std::string title = quest->GetLogTitle();
|
||||
int32 locale = _session->GetSessionDbLocaleIndex();
|
||||
if (locale >= 0)
|
||||
LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex();
|
||||
if (localeConstant >= LOCALE_enUS)
|
||||
if (QuestTemplateLocale const* localeData = sObjectMgr->GetQuestLocale(questID))
|
||||
ObjectMgr::GetLocaleString(localeData->LogTitle, locale, title);
|
||||
ObjectMgr::GetLocaleString(localeData->LogTitle, localeConstant, title);
|
||||
|
||||
if (questLevelInTitle)
|
||||
AddQuestLevelToTitle(title, quest->GetQuestLevel());
|
||||
@@ -272,10 +272,10 @@ void PlayerMenu::SendPointOfInterest(uint32 poiId) const
|
||||
}
|
||||
|
||||
std::string iconText = poi->Name;
|
||||
int32 locale = _session->GetSessionDbLocaleIndex();
|
||||
if (locale >= 0)
|
||||
LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex();
|
||||
if (localeConstant >= LOCALE_enUS)
|
||||
if (PointOfInterestLocale const* localeData = sObjectMgr->GetPointOfInterestLocale(poiId))
|
||||
ObjectMgr::GetLocaleString(localeData->IconName, locale, iconText);
|
||||
ObjectMgr::GetLocaleString(localeData->IconName, localeConstant, iconText);
|
||||
|
||||
WorldPacket data(SMSG_GOSSIP_POI, 4 + 4 + 4 + 4 + 4 + 10); // guess size
|
||||
data << uint32(poi->Flags);
|
||||
@@ -358,10 +358,10 @@ void PlayerMenu::SendQuestGiverQuestList(ObjectGuid guid)
|
||||
{
|
||||
std::string title = quest->GetLogTitle();
|
||||
|
||||
LocaleConstant locale = _session->GetSessionDbLocaleIndex();
|
||||
if (locale >= LOCALE_enUS)
|
||||
if (QuestTemplateLocale const* questTemplateLocaleData = sObjectMgr->GetQuestLocale(questID))
|
||||
ObjectMgr::GetLocaleString(questTemplateLocaleData->LogTitle, locale, title);
|
||||
LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex();
|
||||
if (localeConstant >= LOCALE_enUS)
|
||||
if (QuestTemplateLocale const* questTemplateLocale = sObjectMgr->GetQuestLocale(questID))
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->LogTitle, localeConstant, title);
|
||||
|
||||
if (questLevelInTitle)
|
||||
AddQuestLevelToTitle(title, quest->GetQuestLevel());
|
||||
@@ -391,23 +391,23 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGU
|
||||
std::string questLogTitle = quest->GetLogTitle();
|
||||
std::string questLogDescription = quest->GetLogDescription();
|
||||
std::string questDescription = quest->GetQuestDescription();
|
||||
std::string portraitGiverText = quest->GetPortraitGiverText();
|
||||
std::string portraitGiverName = quest->GetPortraitGiverName();
|
||||
std::string portraitTurnInText = quest->GetPortraitTurnInText();
|
||||
std::string portraitTurnInName = quest->GetPortraitTurnInName();
|
||||
std::string portraitGiverText = quest->GetPortraitGiverText();
|
||||
std::string portraitGiverName = quest->GetPortraitGiverName();
|
||||
std::string portraitTurnInText = quest->GetPortraitTurnInText();
|
||||
std::string portraitTurnInName = quest->GetPortraitTurnInName();
|
||||
|
||||
int32 locale = _session->GetSessionDbLocaleIndex();
|
||||
if (locale >= 0)
|
||||
LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex();
|
||||
if (localeConstant >= LOCALE_enUS)
|
||||
{
|
||||
if (QuestTemplateLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
|
||||
if (QuestTemplateLocale const* questTemplateLocale = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
|
||||
{
|
||||
ObjectMgr::GetLocaleString(localeData->LogTitle, locale, questLogTitle);
|
||||
ObjectMgr::GetLocaleString(localeData->LogDescription, locale, questLogDescription);
|
||||
ObjectMgr::GetLocaleString(localeData->QuestDescription, locale, questDescription);
|
||||
ObjectMgr::GetLocaleString(localeData->PortraitGiverText, locale, portraitGiverText);
|
||||
ObjectMgr::GetLocaleString(localeData->PortraitGiverName, locale, portraitGiverName);
|
||||
ObjectMgr::GetLocaleString(localeData->PortraitTurnInText, locale, portraitTurnInText);
|
||||
ObjectMgr::GetLocaleString(localeData->PortraitTurnInName, locale, portraitTurnInName);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->LogTitle, localeConstant, questLogTitle);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->LogDescription, localeConstant, questLogDescription);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->QuestDescription, localeConstant, questDescription);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->PortraitGiverText, localeConstant, portraitGiverText);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->PortraitGiverName, localeConstant, portraitGiverName);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->PortraitTurnInText, localeConstant, portraitTurnInText);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->PortraitTurnInName, localeConstant, portraitTurnInName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGU
|
||||
|
||||
void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
|
||||
{
|
||||
LocaleConstant locale = _session->GetSessionDbLocaleIndex();
|
||||
LocaleConstant LocaleConstant = _session->GetSessionDbLocaleIndex();
|
||||
|
||||
std::string questLogTitle = quest->GetLogTitle();
|
||||
std::string questLogDescription = quest->GetLogDescription();
|
||||
@@ -473,19 +473,19 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
|
||||
std::string portraitTurnInText = quest->GetPortraitTurnInText();
|
||||
std::string portraitTurnInName = quest->GetPortraitTurnInName();
|
||||
|
||||
if (locale >= LOCALE_enUS)
|
||||
if (LocaleConstant >= LOCALE_enUS)
|
||||
{
|
||||
if (QuestTemplateLocale const* questTemplateLocale = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
|
||||
{
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->LogTitle, locale, questLogTitle);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->LogDescription, locale, questLogDescription);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->QuestDescription, locale, questDescription);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->AreaDescription, locale, areaDescription);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->QuestCompletionLog, locale, questCompletionLog);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->PortraitGiverText, locale, portraitGiverText);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->PortraitGiverName, locale, portraitGiverName);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->PortraitTurnInText, locale, portraitTurnInText);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->PortraitTurnInName, locale, portraitTurnInName);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->LogTitle, LocaleConstant, questLogTitle);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->LogDescription, LocaleConstant, questLogDescription);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->QuestDescription, LocaleConstant, questDescription);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->AreaDescription, LocaleConstant, areaDescription);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->QuestCompletionLog, LocaleConstant, questCompletionLog);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->PortraitGiverText, LocaleConstant, portraitGiverText);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->PortraitGiverName, LocaleConstant, portraitGiverName);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->PortraitTurnInText, LocaleConstant, portraitTurnInText);
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->PortraitTurnInName, LocaleConstant, portraitTurnInName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,10 +576,10 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
|
||||
{
|
||||
packet.Info.Objectives.push_back(questObjective);
|
||||
|
||||
if (locale >= LOCALE_enUS)
|
||||
if (LocaleConstant >= LOCALE_enUS)
|
||||
{
|
||||
if (QuestObjectivesLocale const* questObjectivesLocaleData = sObjectMgr->GetQuestObjectivesLocale(questObjective.ID))
|
||||
ObjectMgr::GetLocaleString(questObjectivesLocaleData->Description, locale, packet.Info.Objectives.back().Description);
|
||||
if (QuestObjectivesLocale const* questObjectivesLocale = sObjectMgr->GetQuestObjectivesLocale(questObjective.ID))
|
||||
ObjectMgr::GetLocaleString(questObjectivesLocale->Description, LocaleConstant, packet.Info.Objectives.back().Description);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16263,10 +16263,10 @@ void Player::SendQuestConfirmAccept(const Quest* quest, Player* pReceiver)
|
||||
{
|
||||
std::string strTitle = quest->GetLogTitle();
|
||||
|
||||
int loc_idx = pReceiver->GetSession()->GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
if (const QuestTemplateLocale* pLocale = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
|
||||
ObjectMgr::GetLocaleString(pLocale->LogTitle, loc_idx, strTitle);
|
||||
LocaleConstant localeConstant = pReceiver->GetSession()->GetSessionDbLocaleIndex();
|
||||
if (localeConstant >= 0)
|
||||
if (QuestTemplateLocale const* questTemplateLocale = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
|
||||
ObjectMgr::GetLocaleString(questTemplateLocale->LogTitle, localeConstant, strTitle);
|
||||
|
||||
WorldPacket data(SMSG_QUEST_CONFIRM_ACCEPT, (4 + strTitle.size() + 8));
|
||||
data << uint32(quest->GetQuestId());
|
||||
|
||||
@@ -302,14 +302,14 @@ ObjectMgr::~ObjectMgr()
|
||||
delete itr->second;
|
||||
}
|
||||
|
||||
void ObjectMgr::AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data)
|
||||
void ObjectMgr::AddLocaleString(std::string const& value, LocaleConstant localeConstant, StringVector& data)
|
||||
{
|
||||
if (!s.empty())
|
||||
if (!value.empty())
|
||||
{
|
||||
if (data.size() <= size_t(locale))
|
||||
data.resize(locale + 1);
|
||||
if (data.size() <= size_t(localeConstant))
|
||||
data.resize(localeConstant + 1);
|
||||
|
||||
data[locale] = s;
|
||||
data[localeConstant] = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4839,7 +4839,6 @@ void ObjectMgr::LoadPageTexts()
|
||||
|
||||
// 0 1 2
|
||||
QueryResult result = WorldDatabase.Query("SELECT ID, Text, NextPageID FROM page_text");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
TC_LOG_INFO("server.loading", ">> Loaded 0 page texts. DB table `page_text` is empty!");
|
||||
@@ -4851,8 +4850,9 @@ void ObjectMgr::LoadPageTexts()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
PageText& pageText = _pageTextStore[fields[0].GetUInt32()];
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
|
||||
PageText& pageText = _pageTextStore[id];
|
||||
pageText.Text = fields[1].GetString();
|
||||
pageText.NextPageID = fields[2].GetUInt32();
|
||||
|
||||
@@ -4889,8 +4889,8 @@ void ObjectMgr::LoadPageTextLocales()
|
||||
|
||||
_pageTextLocaleStore.clear(); // needed for reload case
|
||||
|
||||
QueryResult result = WorldDatabase.Query("SELECT ID, Text_loc1, Text_loc2, Text_loc3, Text_loc4, Text_loc5, Text_loc6, Text_loc7, Text_loc8 FROM locales_page_text");
|
||||
|
||||
// 0 1 2
|
||||
QueryResult result = WorldDatabase.Query("SELECT ID, locale, Text FROM page_text_locale");
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
@@ -4898,12 +4898,14 @@ void ObjectMgr::LoadPageTextLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string localeName = fields[1].GetString();
|
||||
std::string text = fields[2].GetString();
|
||||
|
||||
PageTextLocale& data = _pageTextLocaleStore[entry];
|
||||
PageTextLocale& data = _pageTextLocaleStore[id];
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
|
||||
for (uint8 i = OLD_TOTAL_LOCALES - 1; i > 0; --i)
|
||||
AddLocaleString(fields[i].GetString(), LocaleConstant(i), data.Text);
|
||||
AddLocaleString(text, locale, data.Text);
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u PageText locale strings in %u ms", uint32(_pageTextLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
|
||||
|
||||
@@ -1274,11 +1274,11 @@ class ObjectMgr
|
||||
// for wintergrasp only
|
||||
GraveYardContainer GraveYardStore;
|
||||
|
||||
static void AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data);
|
||||
static inline void GetLocaleString(const StringVector& data, int loc_idx, std::string& value)
|
||||
static void AddLocaleString(std::string const& value, LocaleConstant localeConstant, StringVector& data);
|
||||
static inline void GetLocaleString(StringVector const& data, LocaleConstant localeConstant, std::string& value)
|
||||
{
|
||||
if (data.size() > size_t(loc_idx) && !data[loc_idx].empty())
|
||||
value = data[loc_idx];
|
||||
if (data.size() > size_t(localeConstant) && !data[localeConstant].empty())
|
||||
value = data[localeConstant];
|
||||
}
|
||||
|
||||
CharacterConversionMap FactionChangeAchievements;
|
||||
|
||||
@@ -228,9 +228,9 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPackets::Query::QueryNPCText& p
|
||||
}
|
||||
|
||||
/// Only _static_ data is sent in this packet !!!
|
||||
void WorldSession::HandlePageTextQueryOpcode(WorldPackets::Query::QueryPageText& packet)
|
||||
void WorldSession::HandleQueryPageText(WorldPackets::Query::QueryPageText& packet)
|
||||
{
|
||||
TC_LOG_DEBUG("network", "WORLD: Received CMSG_PAGE_TEXT_QUERY");
|
||||
TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUERY_PAGE_TEXT");
|
||||
|
||||
uint32 pageID = packet.PageTextID;
|
||||
|
||||
@@ -251,10 +251,10 @@ void WorldSession::HandlePageTextQueryOpcode(WorldPackets::Query::QueryPageText&
|
||||
response.Allow = true;
|
||||
response.Info.ID = pageID;
|
||||
|
||||
int loc_idx = GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
if (PageTextLocale const* player = sObjectMgr->GetPageTextLocale(pageID))
|
||||
ObjectMgr::GetLocaleString(player->Text, loc_idx, response.Info.Text);
|
||||
LocaleConstant localeConstant = GetSessionDbLocaleIndex();
|
||||
if (localeConstant >= LOCALE_enUS)
|
||||
if (PageTextLocale const* pageTextLocale = sObjectMgr->GetPageTextLocale(pageID))
|
||||
ObjectMgr::GetLocaleString(pageTextLocale->Text, localeConstant, response.Info.Text);
|
||||
|
||||
response.Info.NextPageID = pageText->NextPageID;
|
||||
pageID = pageText->NextPageID;
|
||||
@@ -262,7 +262,7 @@ void WorldSession::HandlePageTextQueryOpcode(WorldPackets::Query::QueryPageText&
|
||||
|
||||
SendPacket(response.Write());
|
||||
|
||||
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_PAGE_TEXT_QUERY_RESPONSE");
|
||||
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUERY_PAGE_TEXT_RESPONSE");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -628,7 +628,7 @@ void OpcodeTable::Initialize()
|
||||
DEFINE_HANDLER(CMSG_QUERY_INSPECT_ACHIEVEMENTS, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, WorldPackets::Inspect::QueryInspectAchievements, &WorldSession::HandleQueryInspectAchievements);
|
||||
DEFINE_HANDLER(CMSG_QUERY_NEXT_MAIL_TIME, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Mail::MailQueryNextMailTime, &WorldSession::HandleQueryNextMailTime);
|
||||
DEFINE_HANDLER(CMSG_QUERY_NPC_TEXT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Query::QueryNPCText, &WorldSession::HandleNpcTextQueryOpcode);
|
||||
DEFINE_HANDLER(CMSG_QUERY_PAGE_TEXT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Query::QueryPageText, &WorldSession::HandlePageTextQueryOpcode);
|
||||
DEFINE_HANDLER(CMSG_QUERY_PAGE_TEXT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Query::QueryPageText, &WorldSession::HandleQueryPageText);
|
||||
DEFINE_HANDLER(CMSG_QUERY_PETITION, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, WorldPackets::Petition::QueryPetition, &WorldSession::HandleQueryPetition);
|
||||
DEFINE_OPCODE_HANDLER_OLD(CMSG_QUERY_PET_NAME, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandlePetNameQuery );
|
||||
DEFINE_HANDLER(CMSG_QUERY_PLAYER_NAME, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Query::QueryPlayerName, &WorldSession::HandleNameQueryOpcode);
|
||||
|
||||
@@ -1240,7 +1240,7 @@ class WorldSession
|
||||
void HandleCompleteCinematic(WorldPacket& recvPacket);
|
||||
void HandleNextCinematicCamera(WorldPacket& recvPacket);
|
||||
|
||||
void HandlePageTextQueryOpcode(WorldPackets::Query::QueryPageText& packet);
|
||||
void HandleQueryPageText(WorldPackets::Query::QueryPageText& packet);
|
||||
|
||||
void HandleTutorialFlag(WorldPackets::Misc::TutorialSetFlag& packet);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user