Core/Text: Locales for npc_text.
Closes https://github.com/azerothcore/azerothcore-wotlk/issues/452#issuecomment-291891686
This commit is contained in:
@@ -1170,6 +1170,12 @@ class ObjectMgr
|
|||||||
if (itr == _pointOfInterestLocaleStore.end()) return NULL;
|
if (itr == _pointOfInterestLocaleStore.end()) return NULL;
|
||||||
return &itr->second;
|
return &itr->second;
|
||||||
}
|
}
|
||||||
|
NpcTextLocale const* GetNpcTextLocale(uint32 entry) const
|
||||||
|
{
|
||||||
|
NpcTextLocaleContainer::const_iterator itr = _npcTextLocaleStore.find(entry);
|
||||||
|
if (itr == _npcTextLocaleStore.end()) return NULL;
|
||||||
|
return &itr->second;
|
||||||
|
}
|
||||||
GameObjectData& NewGOData(uint32 guid) { return _gameObjectDataStore[guid]; }
|
GameObjectData& NewGOData(uint32 guid) { return _gameObjectDataStore[guid]; }
|
||||||
void DeleteGOData(uint32 guid);
|
void DeleteGOData(uint32 guid);
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ struct GossipTextOption
|
|||||||
{
|
{
|
||||||
std::string Text_0;
|
std::string Text_0;
|
||||||
std::string Text_1;
|
std::string Text_1;
|
||||||
|
uint32 BroadcastTextID;
|
||||||
uint32 Language;
|
uint32 Language;
|
||||||
float Probability;
|
float Probability;
|
||||||
QEmote Emotes[MAX_GOSSIP_TEXT_EMOTES];
|
QEmote Emotes[MAX_GOSSIP_TEXT_EMOTES];
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket & recvData)
|
|||||||
|
|
||||||
if (!pGossip)
|
if (!pGossip)
|
||||||
{
|
{
|
||||||
for (uint32 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
|
for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
|
||||||
{
|
{
|
||||||
data << float(0);
|
data << float(0);
|
||||||
data << "Greetings $N";
|
data << "Greetings $N";
|
||||||
@@ -290,23 +290,47 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket & recvData)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
|
std::string text0[MAX_GOSSIP_TEXT_OPTIONS], text1[MAX_GOSSIP_TEXT_OPTIONS];
|
||||||
|
LocaleConstant locale = GetSessionDbLocaleIndex();
|
||||||
|
|
||||||
|
for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
|
||||||
{
|
{
|
||||||
|
BroadcastText const* bct = sObjectMgr->GetBroadcastText(pGossip->Options[i].BroadcastTextID);
|
||||||
|
if (bct)
|
||||||
|
{
|
||||||
|
text0[i] = bct->GetText(locale, GENDER_MALE, true);
|
||||||
|
text1[i] = bct->GetText(locale, GENDER_FEMALE, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text0[i] = pGossip->Options[i].Text_0;
|
||||||
|
text1[i] = pGossip->Options[i].Text_1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (locale != DEFAULT_LOCALE && !bct)
|
||||||
|
{
|
||||||
|
if (NpcTextLocale const* npcTextLocale = sObjectMgr->GetNpcTextLocale(textID))
|
||||||
|
{
|
||||||
|
ObjectMgr::GetLocaleString(npcTextLocale->Text_0[i], locale, text0[i]);
|
||||||
|
ObjectMgr::GetLocaleString(npcTextLocale->Text_1[i], locale, text1[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data << pGossip->Options[i].Probability;
|
data << pGossip->Options[i].Probability;
|
||||||
|
|
||||||
if (pGossip->Options[i].Text_0.empty())
|
if (text0[i].empty())
|
||||||
data << pGossip->Options[i].Text_1;
|
data << text1[i];
|
||||||
else
|
else
|
||||||
data << pGossip->Options[i].Text_0;
|
data << text0[i];
|
||||||
|
|
||||||
if (pGossip->Options[i].Text_1.empty())
|
if (text1[i].empty())
|
||||||
data << pGossip->Options[i].Text_0;
|
data << text0[i];
|
||||||
else
|
else
|
||||||
data << pGossip->Options[i].Text_1;
|
data << text1[i];
|
||||||
|
|
||||||
data << pGossip->Options[i].Language;
|
data << pGossip->Options[i].Language;
|
||||||
|
|
||||||
for (int j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j)
|
for (uint8 j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j)
|
||||||
{
|
{
|
||||||
data << pGossip->Options[i].Emotes[j]._Delay;
|
data << pGossip->Options[i].Emotes[j]._Delay;
|
||||||
data << pGossip->Options[i].Emotes[j]._Emote;
|
data << pGossip->Options[i].Emotes[j]._Emote;
|
||||||
|
|||||||
Reference in New Issue
Block a user