aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/QueryHandler.cpp
diff options
context:
space:
mode:
authorVincent-Michael <Vincent_Michael@gmx.de>2014-04-25 23:42:40 +0200
committerVincent-Michael <Vincent_Michael@gmx.de>2014-04-25 23:42:40 +0200
commit1390621f4da88d6749e42bea0a131fae74742fa4 (patch)
tree5c6b3c03866feb85ade9f5f95b5cb7cbd5617f61 /src/server/game/Handlers/QueryHandler.cpp
parent7edfbaeb6ee667584b14fc3f59189aa762ae38c5 (diff)
parentc81d6e9b4bec14a46fd4eb01ce51d874a12bf5f7 (diff)
Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4
Conflicts: src/server/game/Handlers/MiscHandler.cpp src/server/scripts/Commands/cs_reload.cpp
Diffstat (limited to 'src/server/game/Handlers/QueryHandler.cpp')
-rw-r--r--src/server/game/Handlers/QueryHandler.cpp64
1 files changed, 34 insertions, 30 deletions
diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp
index c3ac98aa76a..0288e3c86cd 100644
--- a/src/server/game/Handlers/QueryHandler.cpp
+++ b/src/server/game/Handlers/QueryHandler.cpp
@@ -270,18 +270,18 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket& recvData)
uint64 guid;
recvData >> textID;
- TC_LOG_DEBUG("network", "WORLD: CMSG_NPC_TEXT_QUERY ID '%u'", textID);
+ TC_LOG_DEBUG("network", "WORLD: CMSG_NPC_TEXT_QUERY TextId: %u", textID);
recvData >> guid;
- GossipText const* pGossip = sObjectMgr->GetGossipText(textID);
+ GossipText const* gossip = sObjectMgr->GetGossipText(textID);
WorldPacket data(SMSG_NPC_TEXT_UPDATE, 100); // guess size
data << textID;
- if (!pGossip)
+ if (!gossip)
{
- for (uint32 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
+ for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
{
data << float(0);
data << "Greetings $N";
@@ -297,46 +297,50 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket& recvData)
}
else
{
- std::string Text_0[MAX_LOCALES], Text_1[MAX_LOCALES];
- for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
- {
- Text_0[i]=pGossip->Options[i].Text_0;
- Text_1[i]=pGossip->Options[i].Text_1;
- }
+ std::string text0[MAX_GOSSIP_TEXT_OPTIONS], text1[MAX_GOSSIP_TEXT_OPTIONS];
+ LocaleConstant locale = GetSessionDbLocaleIndex();
- int loc_idx = GetSessionDbLocaleIndex();
- if (loc_idx >= 0)
+ for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
{
- if (NpcTextLocale const* nl = sObjectMgr->GetNpcTextLocale(textID))
+ BroadcastText const* bct = sObjectMgr->GetBroadcastText(gossip->Options[i].BroadcastTextID);
+ if (bct)
+ {
+ ObjectMgr::GetLocaleString(bct->MaleText, locale, text0[i]);
+ ObjectMgr::GetLocaleString(bct->FemaleText, locale, text1[i]);
+ }
+ else
+ {
+ text0[i] = gossip->Options[i].Text_0;
+ text1[i] = gossip->Options[i].Text_1;
+ }
+
+ if (locale != DEFAULT_LOCALE && !bct)
{
- for (int i = 0; i < MAX_LOCALES; ++i)
+ if (NpcTextLocale const* npcTextLocale = sObjectMgr->GetNpcTextLocale(textID))
{
- ObjectMgr::GetLocaleString(nl->Text_0[i], loc_idx, Text_0[i]);
- ObjectMgr::GetLocaleString(nl->Text_1[i], loc_idx, Text_1[i]);
+ ObjectMgr::GetLocaleString(npcTextLocale->Text_0[i], locale, text0[i]);
+ ObjectMgr::GetLocaleString(npcTextLocale->Text_1[i], locale, text1[i]);
}
}
- }
- for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
- {
- data << pGossip->Options[i].Probability;
+ data << gossip->Options[i].Probability;
- if (Text_0[i].empty())
- data << Text_1[i];
+ if (text0[i].empty())
+ data << text1[i];
else
- data << Text_0[i];
+ data << text0[i];
- if (Text_1[i].empty())
- data << Text_0[i];
+ if (text1[i].empty())
+ data << text0[i];
else
- data << Text_1[i];
+ data << text1[i];
- data << pGossip->Options[i].Language;
+ data << gossip->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]._Emote;
+ data << gossip->Options[i].Emotes[j]._Delay;
+ data << gossip->Options[i].Emotes[j]._Emote;
}
}
}