mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[7407] Implement per-client localization support for battleground broadcast messages.
This commit is contained in:
parent
27a2d88796
commit
28a8e0c9cf
3 changed files with 68 additions and 17 deletions
|
|
@ -31,6 +31,52 @@
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#include "GridNotifiersImpl.h"
|
||||||
|
|
||||||
|
namespace MaNGOS
|
||||||
|
{
|
||||||
|
class BattleGroundChatBuilder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BattleGroundChatBuilder(ChatMsg msgtype, int32 textId, va_list* args = NULL)
|
||||||
|
: i_msgtype(msgtype), i_textId(textId), i_args(args) {}
|
||||||
|
void operator()(WorldPacket& data, int32 loc_idx)
|
||||||
|
{
|
||||||
|
char const* text = objmgr.GetMangosString(i_textId,loc_idx);
|
||||||
|
|
||||||
|
if(i_args)
|
||||||
|
{
|
||||||
|
// we need copy va_list before use or original va_list will corrupted
|
||||||
|
va_list ap;
|
||||||
|
va_copy(ap,*i_args);
|
||||||
|
|
||||||
|
char str [2048];
|
||||||
|
vsnprintf(str,2048,text, ap );
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
do_helper(data,&str[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
do_helper(data,text);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
void do_helper(WorldPacket& data, char const* text)
|
||||||
|
{
|
||||||
|
data << uint8(i_msgtype);
|
||||||
|
data << uint32(LANG_UNIVERSAL);
|
||||||
|
data << uint64(0); // there 0 for BG messages
|
||||||
|
data << uint32(0); // can be chat msg group or something
|
||||||
|
data << uint64(0);
|
||||||
|
data << uint32(strlen(text)+1);
|
||||||
|
data << text;
|
||||||
|
data << uint8(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatMsg i_msgtype;
|
||||||
|
int32 i_textId;
|
||||||
|
va_list* i_args;
|
||||||
|
};
|
||||||
|
} // namespace MaNGOS
|
||||||
|
|
||||||
BattleGround::BattleGround()
|
BattleGround::BattleGround()
|
||||||
{
|
{
|
||||||
|
|
@ -1474,27 +1520,23 @@ bool BattleGround::AddSpiritGuide(uint32 type, float x, float y, float z, float
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleGround::SendMessageToAll(int32 entry, uint8 type)
|
void BattleGround::SendMessageToAll(int32 entry, ChatMsg type)
|
||||||
{
|
{
|
||||||
char const* text = GetMangosString(entry);
|
MaNGOS::BattleGroundChatBuilder bg_builder(type, entry);
|
||||||
WorldPacket data;
|
MaNGOS::LocalizedPacketDo<MaNGOS::BattleGroundChatBuilder> bg_do(bg_builder);
|
||||||
ChatHandler::FillMessageData(&data, NULL, type, LANG_UNIVERSAL, NULL, 0, text, NULL);
|
BroadcastWorker(bg_do);
|
||||||
SendPacketToAll(&data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//copied from void ChatHandler::PSendSysMessage(int32 entry, ...)
|
void BattleGround::PSendMessageToAll(int32 entry, ChatMsg type, ...)
|
||||||
void BattleGround::PSendMessageToAll(int32 entry, uint8 type, ...)
|
|
||||||
{
|
{
|
||||||
const char *format = GetMangosString(entry);
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char str [2048];
|
|
||||||
va_start(ap, type);
|
va_start(ap, type);
|
||||||
vsnprintf(str,2048,format, ap );
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
WorldPacket data;
|
MaNGOS::BattleGroundChatBuilder bg_builder(type, entry, &ap);
|
||||||
ChatHandler::FillMessageData(&data, NULL, type, LANG_UNIVERSAL, NULL, 0, str, NULL);
|
MaNGOS::LocalizedPacketDo<MaNGOS::BattleGroundChatBuilder> bg_do(bg_builder);
|
||||||
SendPacketToAll(&data);
|
BroadcastWorker(bg_do);
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleGround::EndNow()
|
void BattleGround::EndNow()
|
||||||
|
|
|
||||||
|
|
@ -399,6 +399,15 @@ class BattleGround
|
||||||
virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
|
virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
|
||||||
void SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *sender = NULL, bool self = true);
|
void SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *sender = NULL, bool self = true);
|
||||||
void SendPacketToAll(WorldPacket *packet);
|
void SendPacketToAll(WorldPacket *packet);
|
||||||
|
|
||||||
|
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 PlaySoundToTeam(uint32 SoundID, uint32 TeamID);
|
void PlaySoundToTeam(uint32 SoundID, uint32 TeamID);
|
||||||
void PlaySoundToAll(uint32 SoundID);
|
void PlaySoundToAll(uint32 SoundID);
|
||||||
void CastSpellOnTeam(uint32 SpellID, uint32 TeamID);
|
void CastSpellOnTeam(uint32 SpellID, uint32 TeamID);
|
||||||
|
|
@ -412,8 +421,8 @@ class BattleGround
|
||||||
void EndBattleGround(uint32 winner);
|
void EndBattleGround(uint32 winner);
|
||||||
void BlockMovement(Player *plr);
|
void BlockMovement(Player *plr);
|
||||||
|
|
||||||
void SendMessageToAll(int32 entry, uint8 type);
|
void SendMessageToAll(int32 entry, ChatMsg type);
|
||||||
void PSendMessageToAll(int32 entry, uint8 type, ... );
|
void PSendMessageToAll(int32 entry, ChatMsg type, ... );
|
||||||
|
|
||||||
/* Raid Group */
|
/* Raid Group */
|
||||||
Group *GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; }
|
Group *GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; }
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7406"
|
#define REVISION_NR "7407"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue