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 | |
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')
-rw-r--r-- | src/game/BattleGround.cpp | 51 | ||||
-rw-r--r-- | src/game/BattleGround.h | 11 | ||||
-rw-r--r-- | src/game/BattleGroundAB.cpp | 45 | ||||
-rw-r--r-- | src/game/BattleGroundAB.h | 2 | ||||
-rw-r--r-- | src/game/Debugcmds.cpp | 1 | ||||
-rw-r--r-- | src/game/MovementHandler.cpp | 1 | ||||
-rw-r--r-- | src/game/Object.cpp | 1 | ||||
-rw-r--r-- | src/game/ObjectAccessor.cpp | 1 | ||||
-rw-r--r-- | src/game/ObjectAccessor.h | 2 | ||||
-rw-r--r-- | src/game/Player.cpp | 1 | ||||
-rw-r--r-- | src/game/World.cpp | 1 | ||||
-rw-r--r-- | src/shared/revision_nr.h | 2 |
12 files changed, 83 insertions, 36 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 diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h index d77577449c9..9d060f9d2c6 100644 --- a/src/game/BattleGround.h +++ b/src/game/BattleGround.h @@ -411,12 +411,7 @@ class BattleGround void YellToAll(Creature* creature, const char* text, uint32 language); template<class Do> - void 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); - } + void BroadcastWorker(Do& _do); void PlaySoundToTeam(uint32 SoundID, uint32 TeamID); void PlaySoundToAll(uint32 SoundID); @@ -434,6 +429,9 @@ class BattleGround void SendMessageToAll(int32 entry, ChatMsg type, Player const* source = NULL); void PSendMessageToAll(int32 entry, ChatMsg type, Player const* source, ... ); + // specialized version with 2 string id args + void SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 strId1 = 0, int32 strId2 = 0); + /* Raid Group */ Group *GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; } void SetBgRaid(uint32 TeamID, Group *bg_raid); @@ -500,6 +498,7 @@ class BattleGround void DoorOpen(uint32 type); void DoorClose(uint32 type); + //to be removed const char *GetTrinityString(int32 entry); virtual bool HandlePlayerUnderMap(Player * /*plr*/) { return false; } diff --git a/src/game/BattleGroundAB.cpp b/src/game/BattleGroundAB.cpp index 78f77cd55cd..99ef5d550d2 100644 --- a/src/game/BattleGroundAB.cpp +++ b/src/game/BattleGroundAB.cpp @@ -101,15 +101,13 @@ void BattleGroundAB::Update(uint32 diff) if(teamIndex == 0) { // FIXME: team and node names not localized - PSendMessageToAll(LANG_BG_AB_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_ALLIANCE,NULL, - GetMangosString(LANG_BG_AB_ALLY), _GetNodeName(node)); + SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_ALLIANCE,NULL,LANG_BG_AB_ALLY,_GetNodeNameId(node)); PlaySoundToAll(SOUND_NODE_CAPTURED_ALLIANCE); } else { // FIXME: team and node names not localized - PSendMessageToAll(LANG_BG_AB_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_HORDE,NULL, - GetMangosString(LANG_BG_AB_HORDE),_GetNodeName(node)); + SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_HORDE,NULL,LANG_BG_AB_HORDE,_GetNodeNameId(node)); PlaySoundToAll(SOUND_NODE_CAPTURED_HORDE); } } @@ -288,24 +286,19 @@ void BattleGroundAB::_DelBanner(uint8 node, uint8 type, uint8 teamIndex) SpawnBGObject(obj, RESPAWN_ONE_DAY); } -const char* BattleGroundAB::_GetNodeName(uint8 node) +int32 BattleGroundAB::_GetNodeNameId(uint8 node) { switch (node) { - case BG_AB_NODE_STABLES: - return GetTrinityString(LANG_BG_AB_NODE_STABLES); - case BG_AB_NODE_BLACKSMITH: - return GetTrinityString(LANG_BG_AB_NODE_BLACKSMITH); - case BG_AB_NODE_FARM: - return GetTrinityString(LANG_BG_AB_NODE_FARM); - case BG_AB_NODE_LUMBER_MILL: - return GetTrinityString(LANG_BG_AB_NODE_LUMBER_MILL); - case BG_AB_NODE_GOLD_MINE: - return GetTrinityString(LANG_BG_AB_NODE_GOLD_MINE); + case BG_AB_NODE_STABLES: return LANG_BG_AB_NODE_STABLES; + case BG_AB_NODE_BLACKSMITH: return LANG_BG_AB_NODE_BLACKSMITH; + case BG_AB_NODE_FARM: return LANG_BG_AB_NODE_FARM; + case BG_AB_NODE_LUMBER_MILL:return LANG_BG_AB_NODE_LUMBER_MILL; + case BG_AB_NODE_GOLD_MINE: return LANG_BG_AB_NODE_GOLD_MINE; default: ASSERT(0); } - return ""; + return 0; } void BattleGroundAB::FillInitialWorldStates(WorldPacket& data) @@ -457,9 +450,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ // FIXME: team and node names not localized if(teamIndex == 0) - PSendMessageToAll(LANG_BG_AB_NODE_CLAIMED,CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeName(node), GetMangosString(LANG_BG_AB_ALLY)); + SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED,CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node), LANG_BG_AB_ALLY); else - PSendMessageToAll(LANG_BG_AB_NODE_CLAIMED,CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeName(node), GetMangosString(LANG_BG_AB_HORDE)); + SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED,CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node), LANG_BG_AB_HORDE); sound = SOUND_NODE_CLAIMED; } @@ -481,9 +474,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ // FIXME: node names not localized if(teamIndex == 0) - PSendMessageToAll(LANG_BG_AB_NODE_ASSAULTED,CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeName(node)); + SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED,CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); else - PSendMessageToAll(LANG_BG_AB_NODE_ASSAULTED,CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeName(node)); + SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED,CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); } // If contested, change back to occupied else @@ -501,9 +494,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ // FIXME: node names not localized if(teamIndex == 0) - PSendMessageToAll(LANG_BG_AB_NODE_DEFENDED,CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeName(node)); + SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED,CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); else - PSendMessageToAll(LANG_BG_AB_NODE_DEFENDED,CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeName(node)); + SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED,CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); } sound = (teamIndex == 0) ? SOUND_NODE_ASSAULTED_ALLIANCE : SOUND_NODE_ASSAULTED_HORDE; } @@ -523,9 +516,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ // FIXME: node names not localized if(teamIndex == 0) - PSendMessageToAll(LANG_BG_AB_NODE_ASSAULTED,CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeName(node)); + SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED,CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); else - PSendMessageToAll(LANG_BG_AB_NODE_ASSAULTED,CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeName(node)); + SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED,CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); sound = (teamIndex == 0) ? SOUND_NODE_ASSAULTED_ALLIANCE : SOUND_NODE_ASSAULTED_HORDE; } @@ -535,9 +528,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ { // FIXME: team and node names not localized if(teamIndex == 0) - PSendMessageToAll(LANG_BG_AB_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, GetMangosString(LANG_BG_AB_ALLY), _GetNodeName(node)); + SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, LANG_BG_AB_ALLY, _GetNodeNameId(node)); else - PSendMessageToAll(LANG_BG_AB_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_HORDE, NULL, GetMangosString(LANG_BG_AB_HORDE), _GetNodeName(node)); + SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_HORDE, NULL, LANG_BG_AB_HORDE, _GetNodeNameId(node)); } PlaySoundToAll(sound); } diff --git a/src/game/BattleGroundAB.h b/src/game/BattleGroundAB.h index 65ee073c9ae..64046c0d9ec 100644 --- a/src/game/BattleGroundAB.h +++ b/src/game/BattleGroundAB.h @@ -267,7 +267,7 @@ class BattleGroundAB : public BattleGround void _NodeOccupied(uint8 node,Team team); void _NodeDeOccupied(uint8 node); - const char* _GetNodeName(uint8 node); + int32 _GetNodeNameId(uint8 node); /* Nodes info: 0: neutral diff --git a/src/game/Debugcmds.cpp b/src/game/Debugcmds.cpp index 4323ef3897b..8a28ae72e00 100644 --- a/src/game/Debugcmds.cpp +++ b/src/game/Debugcmds.cpp @@ -21,6 +21,7 @@ #include "Common.h" #include "Database/DatabaseEnv.h" #include "WorldPacket.h" +#include "Vehicle.h" #include "Player.h" #include "Opcodes.h" #include "Chat.h" diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index d8ce6c0a46a..e2bbf8b956b 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -25,6 +25,7 @@ #include "Log.h" #include "Corpse.h" #include "Player.h" +#include "Vehicle.h" #include "MapManager.h" #include "Transports.h" #include "BattleGround.h" diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 3cb5d31b6cc..9fdca51777a 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -27,6 +27,7 @@ #include "Object.h" #include "Creature.h" #include "Player.h" +#include "Vehicle.h" #include "ObjectMgr.h" #include "UpdateData.h" #include "UpdateMask.h" diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index e89149a88ed..db9717759e7 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -25,6 +25,7 @@ #include "Creature.h" #include "GameObject.h" #include "DynamicObject.h" +#include "Vehicle.h" #include "WorldPacket.h" #include "Item.h" #include "Corpse.h" diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h index c6144ec4d5b..fea2331695c 100644 --- a/src/game/ObjectAccessor.h +++ b/src/game/ObjectAccessor.h @@ -33,7 +33,6 @@ #include "GridDefines.h" #include "Object.h" #include "Player.h" -#include "Vehicle.h" #include <set> @@ -42,6 +41,7 @@ class Corpse; class Unit; class GameObject; class DynamicObject; +class Vehicle; class WorldObject; class Map; diff --git a/src/game/Player.cpp b/src/game/Player.cpp index b73c548e56c..4707900f198 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -29,6 +29,7 @@ #include "WorldSession.h" #include "UpdateMask.h" #include "Player.h" +#include "Vehicle.h" #include "SkillDiscovery.h" #include "QuestDef.h" #include "GossipDef.h" diff --git a/src/game/World.cpp b/src/game/World.cpp index eaacbb18565..91662e53152 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -32,6 +32,7 @@ #include "WorldPacket.h" #include "Weather.h" #include "Player.h" +#include "Vehicle.h" #include "SkillExtraItems.h" #include "SkillDiscovery.h" #include "World.h" diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 157439bbbd1..0079ff50ae2 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7412" + #define REVISION_NR "7413" #endif // __REVISION_NR_H__ |