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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user