[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
This commit is contained in:
megamage
2009-03-09 17:06:13 -06:00
parent c9796bab32
commit 01b67a1f6a
12 changed files with 83 additions and 36 deletions
+50 -1
View File
@@ -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
+5 -6
View File
@@ -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; }
+19 -26
View File
@@ -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);
}
+1 -1
View File
@@ -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
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -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"
+1 -1
View File
@@ -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;
+1
View File
@@ -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"
+1
View File
@@ -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"