Core/Cleanup: move repeating code for locale strings retrieval into separate method. Related code cleanup.
--HG-- branch : trunk
This commit is contained in:
@@ -171,14 +171,11 @@ void PlayerMenu::SendGossipMenu(uint32 TitleTextId, uint64 objectGUID)
|
||||
data << uint8(0); // 3.3.3 changes icon: blue question or yellow exclamation
|
||||
std::string Title = pQuest->GetTitle();
|
||||
|
||||
int8 loc_idx = pSession->GetSessionDbLocaleIndex();
|
||||
int loc_idx = pSession->GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint8 uloc_idx = uint8(loc_idx);
|
||||
if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(questID))
|
||||
if (ql->Title.size() > uloc_idx && !ql->Title[uloc_idx].empty())
|
||||
Title = ql->Title[uloc_idx];
|
||||
}
|
||||
sObjectMgr.GetLocaleString(ql->Title, loc_idx, Title);
|
||||
|
||||
data << Title; // max 0x200
|
||||
}
|
||||
|
||||
@@ -217,17 +214,10 @@ void PlayerMenu::SendPointOfInterest(uint32 poi_id)
|
||||
|
||||
std::string icon_name = poi->icon_name;
|
||||
|
||||
int8 loc_idx = pSession->GetSessionDbLocaleIndex();
|
||||
int loc_idx = pSession->GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint8 uloc_idx = uint8(loc_idx);
|
||||
PointOfInterestLocale const *pl = sObjectMgr.GetPointOfInterestLocale(poi_id);
|
||||
if (pl)
|
||||
{
|
||||
if (pl->IconName.size() > uloc_idx && !pl->IconName[uloc_idx].empty())
|
||||
icon_name = pl->IconName[uloc_idx];
|
||||
}
|
||||
}
|
||||
if (PointOfInterestLocale const *pl = sObjectMgr.GetPointOfInterestLocale(poi_id))
|
||||
sObjectMgr.GetLocaleString(pl->IconName, loc_idx, icon_name);
|
||||
|
||||
WorldPacket data(SMSG_GOSSIP_POI, (4+4+4+4+4+10)); // guess size
|
||||
data << uint32(poi->flags);
|
||||
@@ -266,29 +256,25 @@ void PlayerMenu::SendTalking(uint32 textID)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string Text_0[8],Text_1[8];
|
||||
for (int i=0; i<8; ++i)
|
||||
std::string Text_0[8], Text_1[8];
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
Text_0[i]=pGossip->Options[i].Text_0;
|
||||
Text_1[i]=pGossip->Options[i].Text_1;
|
||||
Text_0[i] = pGossip->Options[i].Text_0;
|
||||
Text_1[i] = pGossip->Options[i].Text_1;
|
||||
}
|
||||
int8 loc_idx = pSession->GetSessionDbLocaleIndex();
|
||||
int loc_idx = pSession->GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint8 uloc_idx = uint8(loc_idx);
|
||||
NpcTextLocale const *nl = sObjectMgr.GetNpcTextLocale(textID);
|
||||
if (nl)
|
||||
if (NpcTextLocale const *nl = sObjectMgr.GetNpcTextLocale(textID))
|
||||
{
|
||||
for (int i=0; i<8; ++i)
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
if (nl->Text_0[i].size() > uloc_idx && !nl->Text_0[i][uloc_idx].empty())
|
||||
Text_0[i]=nl->Text_0[i][uloc_idx];
|
||||
if (nl->Text_1[i].size() > uloc_idx && !nl->Text_1[i][uloc_idx].empty())
|
||||
Text_1[i]=nl->Text_1[i][uloc_idx];
|
||||
sObjectMgr.GetLocaleString(nl->Text_0[i], loc_idx, Text_0[i]);
|
||||
sObjectMgr.GetLocaleString(nl->Text_1[i], loc_idx, Text_1[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i=0; i<8; ++i)
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
data << pGossip->Options[i].Probability;
|
||||
|
||||
@@ -406,16 +392,10 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote eEmote, const std::string& Title
|
||||
{
|
||||
std::string title = pQuest->GetTitle();
|
||||
|
||||
int8 loc_idx = pSession->GetSessionDbLocaleIndex();
|
||||
int loc_idx = pSession->GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint8 uloc_idx = uint8(loc_idx);
|
||||
if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(questID))
|
||||
{
|
||||
if (ql->Title.size() > uloc_idx && !ql->Title[uloc_idx].empty())
|
||||
title = ql->Title[uloc_idx];
|
||||
}
|
||||
}
|
||||
sObjectMgr.GetLocaleString(ql->Title, loc_idx, title);
|
||||
|
||||
data << uint32(questID);
|
||||
data << uint32(qmi.m_qIcon);
|
||||
@@ -448,21 +428,15 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const *pQuest, uint64 npcGUID,
|
||||
std::string Objectives = pQuest->GetObjectives();
|
||||
std::string EndText = pQuest->GetEndText();
|
||||
|
||||
int8 loc_idx = pSession->GetSessionDbLocaleIndex();
|
||||
int loc_idx = pSession->GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint8 uloc_idx = uint8(loc_idx);
|
||||
QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId());
|
||||
if (ql)
|
||||
if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId()))
|
||||
{
|
||||
if (ql->Title.size() > uloc_idx && !ql->Title[uloc_idx].empty())
|
||||
Title=ql->Title[uloc_idx];
|
||||
if (ql->Details.size() > uloc_idx && !ql->Details[uloc_idx].empty())
|
||||
Details=ql->Details[uloc_idx];
|
||||
if (ql->Objectives.size() > uloc_idx && !ql->Objectives[uloc_idx].empty())
|
||||
Objectives=ql->Objectives[uloc_idx];
|
||||
if (ql->EndText.size() > uloc_idx && !ql->EndText[uloc_idx].empty())
|
||||
EndText=ql->EndText[uloc_idx];
|
||||
sObjectMgr.GetLocaleString(ql->Title, loc_idx, Title);
|
||||
sObjectMgr.GetLocaleString(ql->Details, loc_idx, Details);
|
||||
sObjectMgr.GetLocaleString(ql->Objectives, loc_idx, Objectives);
|
||||
sObjectMgr.GetLocaleString(ql->EndText, loc_idx, EndText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,24 +547,16 @@ void PlayerMenu::SendQuestQueryResponse(Quest const *pQuest)
|
||||
int loc_idx = pSession->GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint8 uloc_idx = uint8(loc_idx);
|
||||
QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId());
|
||||
if (ql)
|
||||
if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId()))
|
||||
{
|
||||
if (ql->Title.size() > uloc_idx && !ql->Title[uloc_idx].empty())
|
||||
Title=ql->Title[uloc_idx];
|
||||
if (ql->Details.size() > uloc_idx && !ql->Details[uloc_idx].empty())
|
||||
Details=ql->Details[uloc_idx];
|
||||
if (ql->Objectives.size() > uloc_idx && !ql->Objectives[uloc_idx].empty())
|
||||
Objectives=ql->Objectives[uloc_idx];
|
||||
if (ql->EndText.size() > uloc_idx && !ql->EndText[uloc_idx].empty())
|
||||
EndText=ql->EndText[uloc_idx];
|
||||
if (ql->CompletedText.size() > uloc_idx && !ql->CompletedText[uloc_idx].empty())
|
||||
CompletedText=ql->CompletedText[uloc_idx];
|
||||
sObjectMgr.GetLocaleString(ql->Title, loc_idx, Title);
|
||||
sObjectMgr.GetLocaleString(ql->Details, loc_idx, Details);
|
||||
sObjectMgr.GetLocaleString(ql->Objectives, loc_idx, Objectives);
|
||||
sObjectMgr.GetLocaleString(ql->EndText, loc_idx, EndText);
|
||||
sObjectMgr.GetLocaleString(ql->CompletedText, loc_idx, CompletedText);
|
||||
|
||||
for (int i=0; i<QUEST_OBJECTIVES_COUNT; ++i)
|
||||
if (ql->ObjectiveText[i].size() > uloc_idx && !ql->ObjectiveText[i][uloc_idx].empty())
|
||||
ObjectiveText[i]=ql->ObjectiveText[i][uloc_idx];
|
||||
for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
|
||||
sObjectMgr.GetLocaleString(ql->ObjectiveText[i], loc_idx, ObjectiveText[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -714,14 +680,10 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, uint64 npcGUID,
|
||||
int loc_idx = pSession->GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint8 uloc_idx = uint8(loc_idx);
|
||||
QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId());
|
||||
if (ql)
|
||||
if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId()))
|
||||
{
|
||||
if (ql->Title.size() > uloc_idx && !ql->Title[uloc_idx].empty())
|
||||
Title=ql->Title[uloc_idx];
|
||||
if (ql->OfferRewardText.size() > uloc_idx && !ql->OfferRewardText[uloc_idx].empty())
|
||||
OfferRewardText=ql->OfferRewardText[uloc_idx];
|
||||
sObjectMgr.GetLocaleString(ql->Title, loc_idx, Title);
|
||||
sObjectMgr.GetLocaleString(ql->OfferRewardText, loc_idx, OfferRewardText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,14 +780,10 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const *pQuest, uint64 npcGUID,
|
||||
int loc_idx = pSession->GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint8 uloc_idx = uint8(loc_idx);
|
||||
QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId());
|
||||
if (ql)
|
||||
if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId()))
|
||||
{
|
||||
if (ql->Title.size() > uloc_idx && !ql->Title[uloc_idx].empty())
|
||||
Title=ql->Title[uloc_idx];
|
||||
if (ql->RequestItemsText.size() > uloc_idx && !ql->RequestItemsText[uloc_idx].empty())
|
||||
RequestItemsText=ql->RequestItemsText[uloc_idx];
|
||||
sObjectMgr.GetLocaleString(ql->Title, loc_idx, Title);
|
||||
sObjectMgr.GetLocaleString(ql->RequestItemsText, loc_idx, RequestItemsText);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1716,7 +1716,7 @@ void WorldObject::MonsterWhisper(int32 textId, uint64 receiver, bool IsBossWhisp
|
||||
return;
|
||||
|
||||
uint32 loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
|
||||
char const* text = sObjectMgr.GetTrinityString(textId,loc_idx);
|
||||
char const* text = sObjectMgr.GetTrinityString(textId, loc_idx);
|
||||
|
||||
WorldPacket data(SMSG_MESSAGECHAT, 200);
|
||||
BuildMonsterChat(&data,IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER,text,LANG_UNIVERSAL,GetNameForLocaleIdx(loc_idx),receiver);
|
||||
|
||||
@@ -13543,18 +13543,13 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId, bool showQue
|
||||
std::string strBoxText = itr->second.box_text;
|
||||
|
||||
int loc_idx = GetSession()->GetSessionDbLocaleIndex();
|
||||
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint32 idxEntry = MAKE_PAIR32(menuId, itr->second.id);
|
||||
|
||||
if (GossipMenuItemsLocale const *no = sObjectMgr.GetGossipMenuItemsLocale(idxEntry))
|
||||
{
|
||||
if (no->OptionText.size() > (size_t)loc_idx && !no->OptionText[loc_idx].empty())
|
||||
strOptionText = no->OptionText[loc_idx];
|
||||
|
||||
if (no->BoxText.size() > (size_t)loc_idx && !no->BoxText[loc_idx].empty())
|
||||
strBoxText = no->BoxText[loc_idx];
|
||||
sObjectMgr.GetLocaleString(no->OptionText, loc_idx, strOptionText);
|
||||
sObjectMgr.GetLocaleString(no->BoxText, loc_idx, strBoxText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13921,15 +13916,8 @@ void Player::SendPreparedQuest(uint64 guid)
|
||||
|
||||
int loc_idx = GetSession()->GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint8 uloc_idx = uint8(loc_idx);
|
||||
NpcTextLocale const *nl = sObjectMgr.GetNpcTextLocale(textid);
|
||||
if (nl)
|
||||
{
|
||||
if (nl->Text_0[0].size() > uloc_idx && !nl->Text_0[0][uloc_idx].empty())
|
||||
title = nl->Text_0[0][uloc_idx];
|
||||
}
|
||||
}
|
||||
if (NpcTextLocale const *nl = sObjectMgr.GetNpcTextLocale(textid))
|
||||
sObjectMgr.GetLocaleString(nl->Text_0[0], loc_idx, title);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -13937,15 +13925,8 @@ void Player::SendPreparedQuest(uint64 guid)
|
||||
|
||||
int loc_idx = GetSession()->GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint8 uloc_idx = uint8(loc_idx);
|
||||
NpcTextLocale const *nl = sObjectMgr.GetNpcTextLocale(textid);
|
||||
if (nl)
|
||||
{
|
||||
if (nl->Text_1[0].size() > uloc_idx && !nl->Text_1[0][uloc_idx].empty())
|
||||
title = nl->Text_1[0][uloc_idx];
|
||||
}
|
||||
}
|
||||
if (NpcTextLocale const *nl = sObjectMgr.GetNpcTextLocale(textid))
|
||||
sObjectMgr.GetLocaleString(nl->Text_1[0], loc_idx, title);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15612,11 +15593,9 @@ void Player::SendQuestConfirmAccept(const Quest* pQuest, Player* pReceiver)
|
||||
std::string strTitle = pQuest->GetTitle();
|
||||
|
||||
int loc_idx = pReceiver->GetSession()->GetSessionDbLocaleIndex();
|
||||
|
||||
if (loc_idx >= 0)
|
||||
if (const QuestLocale* pLocale = sObjectMgr.GetQuestLocale(pQuest->GetQuestId()))
|
||||
if (int(pLocale->Title.size()) > loc_idx && !pLocale->Title[loc_idx].empty())
|
||||
strTitle = pLocale->Title[loc_idx];
|
||||
sObjectMgr.GetLocaleString(pLocale->Title, loc_idx, strTitle);
|
||||
|
||||
WorldPacket data(SMSG_QUEST_CONFIRM_ACCEPT, (4 + strTitle.size() + 8));
|
||||
data << uint32(pQuest->GetQuestId());
|
||||
|
||||
Reference in New Issue
Block a user