diff options
author | megamage <none@none> | 2009-03-09 17:06:13 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-03-09 17:06:13 -0600 |
commit | 01b67a1f6a08b22dcdea6e7f5647bb37dc2465d9 (patch) | |
tree | 9f49d0c2250b2a795a0017a124e8b487b0dee10e /src/game/BattleGround.cpp | |
parent | c9796bab32f3c0ba2859d33e1a56f6d734164b0c (diff) |
[7413] Fixed finally problems with node names localization in BattleGroundAB messages. Author: VladimirMangos
Also fix build at some platforms.
Note: GetTrinityString should be removed in the future when AV is updated.
--HG--
branch : trunk
Diffstat (limited to 'src/game/BattleGround.cpp')
-rw-r--r-- | src/game/BattleGround.cpp | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index cf887ffd2ee..f420eb38f40 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -80,8 +80,50 @@ namespace MaNGOS Player const* i_source; va_list* i_args; }; + + class BattleGround2ChatBuilder + { + public: + BattleGround2ChatBuilder(ChatMsg msgtype, int32 textId, Player const* source, int32 arg1, int32 arg2) + : i_msgtype(msgtype), i_textId(textId), i_source(source), i_arg1(arg1), i_arg2(arg2) {} + void operator()(WorldPacket& data, int32 loc_idx) + { + char const* text = objmgr.GetMangosString(i_textId,loc_idx); + char const* arg1str = i_arg1 ? objmgr.GetMangosString(i_arg1,loc_idx) : ""; + char const* arg2str = i_arg2 ? objmgr.GetMangosString(i_arg2,loc_idx) : ""; + + char str [2048]; + snprintf(str,2048,text, arg1str, arg2str ); + + uint64 target_guid = i_source ? i_source ->GetGUID() : 0; + + data << uint8(i_msgtype); + data << uint32(LANG_UNIVERSAL); + data << uint64(target_guid); // there 0 for BG messages + data << uint32(0); // can be chat msg group or something + data << uint64(target_guid); + data << uint32(strlen(str)+1); + data << str; + data << uint8(i_source ? i_source->chatTag() : uint8(0)); + } + private: + + ChatMsg i_msgtype; + int32 i_textId; + Player const* i_source; + int32 i_arg1; + int32 i_arg2; + }; } // namespace MaNGOS +template<class Do> +void BattleGround::BroadcastWorker(Do& _do) +{ + for(std::map<uint64, BattleGroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + if(Player *plr = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER))) + _do(plr); +} + BattleGround::BattleGround() { m_TypeID = BattleGroundTypeId(0); @@ -1558,6 +1600,13 @@ void BattleGround::PSendMessageToAll(int32 entry, ChatMsg type, Player const* so va_end(ap); } +void BattleGround::SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 arg1, int32 arg2) +{ + MaNGOS::BattleGround2ChatBuilder bg_builder(type, entry, source, arg1, arg2); + MaNGOS::LocalizedPacketDo<MaNGOS::BattleGround2ChatBuilder> bg_do(bg_builder); + BroadcastWorker(bg_do); +} + void BattleGround::EndNow() { RemoveFromBGFreeSlotQueue(); @@ -1567,7 +1616,7 @@ void BattleGround::EndNow() sBattleGroundMgr.m_BattleGroundQueues[BattleGroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType())].BGEndedRemoveInvites(this); } -// Battleground messages are localized using the dbc lang, they are not client language dependent +//to be removed const char *BattleGround::GetTrinityString(int32 entry) { // FIXME: now we have different DBC locales and need localized message for each target client |