aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorVincent-Michael <Vincent_Michael@gmx.de>2014-04-25 23:24:29 +0200
committerVincent-Michael <Vincent_Michael@gmx.de>2014-04-25 23:25:59 +0200
commitc81d6e9b4bec14a46fd4eb01ce51d874a12bf5f7 (patch)
treeb59e12749120651458fe9d80e477bfd6d78a35ce /src/server/game
parentf27057bf2406797f12b995f1fb40d6750c83af87 (diff)
Core/Texts:
* Enable some BroadcastTexts stuff (is not finish) * Added reload command for broadcast_text table ToDo: - Enable: Sound/Emote stuff, etc. - Auth base need refresh
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/Accounts/RBAC.h2
-rw-r--r--src/server/game/Entities/Creature/GossipDef.cpp37
-rw-r--r--src/server/game/Entities/Player/Player.cpp34
-rw-r--r--src/server/game/Handlers/QueryHandler.cpp64
-rw-r--r--src/server/game/Texts/CreatureTextMgr.cpp16
5 files changed, 101 insertions, 52 deletions
diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h
index 9b84d7ddb7d..9ce1f9bb67a 100644
--- a/src/server/game/Accounts/RBAC.h
+++ b/src/server/game/Accounts/RBAC.h
@@ -517,7 +517,7 @@ enum RBACPermissions
RBAC_PERM_COMMAND_RELOAD_ALL = 611,
RBAC_PERM_COMMAND_RELOAD_ALL_ACHIEVEMENT = 612,
RBAC_PERM_COMMAND_RELOAD_ALL_AREA = 613,
- RBAC_PERM_UNUSED_614 = 614, // unused
+ RBAC_PERM_COMMAND_RELOAD_BROADCAST_TEXT = 614,
RBAC_PERM_COMMAND_RELOAD_ALL_GOSSIP = 615,
RBAC_PERM_COMMAND_RELOAD_ALL_ITEM = 616,
RBAC_PERM_COMMAND_RELOAD_ALL_LOCALES = 617,
diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp
index 8671caf864d..078b6758860 100644
--- a/src/server/game/Entities/Creature/GossipDef.cpp
+++ b/src/server/game/Entities/Creature/GossipDef.cpp
@@ -91,19 +91,40 @@ void GossipMenu::AddMenuItem(uint32 menuId, uint32 menuItemId, uint32 sender, ui
continue;
/// Store texts for localization.
- std::string strOptionText = itr->second.OptionText;
- std::string strBoxText = itr->second.BoxText;
+ std::string strOptionText, strBoxText;
+ BroadcastText const* optionBroadcastText = sObjectMgr->GetBroadcastText(itr->second.OptionBroadcastTextId);
+ BroadcastText const* boxBroadcastText = sObjectMgr->GetBroadcastText(itr->second.BoxBroadcastTextId);
+
+ /// OptionText
+ if (optionBroadcastText)
+ ObjectMgr::GetLocaleString(optionBroadcastText->MaleText, GetLocale(), strOptionText);
+ else
+ strOptionText = itr->second.OptionText;
+
+ /// BoxText
+ if (boxBroadcastText)
+ ObjectMgr::GetLocaleString(boxBroadcastText->MaleText, GetLocale(), strBoxText);
+ else
+ strBoxText = itr->second.BoxText;
/// Check need of localization.
- if (GetLocale() > LOCALE_enUS)
- /// Find localizations from database.
- if (GossipMenuItemsLocale const* no = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, menuItemId)))
+ if (GetLocale() != DEFAULT_LOCALE)
+ {
+ if (!optionBroadcastText)
{
- /// Translate texts if there are any.
- ObjectMgr::GetLocaleString(no->OptionText, GetLocale(), strOptionText);
- ObjectMgr::GetLocaleString(no->BoxText, GetLocale(), strBoxText);
+ /// Find localizations from database.
+ if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, menuItemId)))
+ ObjectMgr::GetLocaleString(gossipMenuLocale->OptionText, GetLocale(), strOptionText);
}
+ if (!boxBroadcastText)
+ {
+ /// Find localizations from database.
+ if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, menuItemId)))
+ ObjectMgr::GetLocaleString(gossipMenuLocale->BoxText, GetLocale(), strBoxText);
+ }
+ }
+
/// Add menu item with existing method. Menu item id -1 is also used in ADD_GOSSIP_ITEM macro.
AddMenuItem(-1, itr->second.OptionIcon, strOptionText, sender, action, strBoxText, itr->second.BoxMoney, itr->second.BoxCoded);
}
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 2c5bf220896..11f1050684b 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -14441,17 +14441,35 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
if (canTalk)
{
- std::string strOptionText = itr->second.OptionText;
- std::string strBoxText = itr->second.BoxText;
+ std::string strOptionText, strBoxText;
+ BroadcastText const* optionBroadcastText = sObjectMgr->GetBroadcastText(itr->second.OptionBroadcastTextId);
+ BroadcastText const* boxBroadcastText = sObjectMgr->GetBroadcastText(itr->second.BoxBroadcastTextId);
+ LocaleConstant locale = GetSession()->GetSessionDbLocaleIndex();
- int32 locale = GetSession()->GetSessionDbLocaleIndex();
- if (locale >= 0)
+ if (optionBroadcastText)
+ ObjectMgr::GetLocaleString(getGender() == GENDER_MALE ? optionBroadcastText->MaleText : optionBroadcastText->FemaleText, locale, strOptionText);
+ else
+ strOptionText = itr->second.OptionText;
+
+ if (boxBroadcastText)
+ ObjectMgr::GetLocaleString(getGender() == GENDER_MALE ? boxBroadcastText->MaleText : boxBroadcastText->FemaleText, locale, strBoxText);
+ else
+ strBoxText = itr->second.BoxText;
+
+ if (locale != DEFAULT_LOCALE)
{
- uint32 idxEntry = MAKE_PAIR32(menuId, itr->second.OptionIndex);
- if (GossipMenuItemsLocale const* no = sObjectMgr->GetGossipMenuItemsLocale(idxEntry))
+ if (!optionBroadcastText)
+ {
+ /// Find localizations from database.
+ if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, menuId)))
+ ObjectMgr::GetLocaleString(gossipMenuLocale->OptionText, locale, strOptionText);
+ }
+
+ if (!boxBroadcastText)
{
- ObjectMgr::GetLocaleString(no->OptionText, locale, strOptionText);
- ObjectMgr::GetLocaleString(no->BoxText, locale, strBoxText);
+ /// Find localizations from database.
+ if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, menuId)))
+ ObjectMgr::GetLocaleString(gossipMenuLocale->BoxText, locale, strBoxText);
}
}
diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp
index e30260d34e2..3d083b3aa05 100644
--- a/src/server/game/Handlers/QueryHandler.cpp
+++ b/src/server/game/Handlers/QueryHandler.cpp
@@ -264,18 +264,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";
@@ -291,46 +291,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;
}
}
}
diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp
index dd790cf9072..77592ab4a8e 100644
--- a/src/server/game/Texts/CreatureTextMgr.cpp
+++ b/src/server/game/Texts/CreatureTextMgr.cpp
@@ -472,13 +472,19 @@ std::string CreatureTextMgr::GetLocalizedChatString(uint32 entry, uint8 textGrou
if (locale > MAX_LOCALES)
locale = DEFAULT_LOCALE;
- std::string baseText = groupItr->text;
+ std::string baseText = "";
+ BroadcastText const* bct = sObjectMgr->GetBroadcastText(groupItr->BroadcastTextId);
- if (locale != DEFAULT_LOCALE)
+ if (bct)
+ ObjectMgr::GetLocaleString(bct->MaleText, locale, baseText);
+ else
+ baseText = groupItr->text;
+
+ if (locale != DEFAULT_LOCALE && !bct)
{
- LocaleCreatureTextMap::const_iterator locItr = mLocaleTextMap.find(CreatureTextId(entry, uint32(textGroup), id));
- if (locItr != mLocaleTextMap.end())
- ObjectMgr::GetLocaleString(locItr->second.Text, locale, baseText);
+ LocaleCreatureTextMap::const_iterator locItr = mLocaleTextMap.find(CreatureTextId(entry, uint32(textGroup), id));
+ if (locItr != mLocaleTextMap.end())
+ ObjectMgr::GetLocaleString(locItr->second.Text, locale, baseText);
}
return baseText;