mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/PacketIO: SMSG_PLAY_SOUND
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "MiscPackets.h"
|
||||
|
||||
Battlefield::Battlefield()
|
||||
{
|
||||
@@ -344,14 +345,9 @@ void Battlefield::EndBattle(bool endByTimer)
|
||||
SendInitWorldStatesToAll();
|
||||
}
|
||||
|
||||
void Battlefield::DoPlaySoundToAll(uint32 SoundID)
|
||||
void Battlefield::DoPlaySoundToAll(uint32 soundID)
|
||||
{
|
||||
WorldPacket data;
|
||||
data.Initialize(SMSG_PLAY_SOUND, 4 + 8);
|
||||
data << uint32(SoundID);
|
||||
data << uint64(0);
|
||||
|
||||
BroadcastPacketToWar(&data);
|
||||
BroadcastPacketToWar(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID).Write());
|
||||
}
|
||||
|
||||
bool Battlefield::HasPlayer(Player* player) const
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "WorldPacket.h"
|
||||
#include "Transport.h"
|
||||
#include "BattlegroundPackets.h"
|
||||
#include "MiscPackets.h"
|
||||
|
||||
namespace Trinity
|
||||
{
|
||||
@@ -667,22 +668,18 @@ void Battleground::SendChatMessage(Creature* source, uint8 textId, WorldObject*
|
||||
sCreatureTextMgr->SendChat(source, textId, target);
|
||||
}
|
||||
|
||||
void Battleground::PlaySoundToAll(uint32 SoundID)
|
||||
void Battleground::PlaySoundToAll(uint32 soundID)
|
||||
{
|
||||
WorldPacket data;
|
||||
sBattlegroundMgr->BuildPlaySoundPacket(&data, SoundID);
|
||||
SendPacketToAll(&data);
|
||||
SendPacketToAll(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID).Write());
|
||||
}
|
||||
|
||||
void Battleground::PlaySoundToTeam(uint32 SoundID, uint32 TeamID)
|
||||
void Battleground::PlaySoundToTeam(uint32 soundID, uint32 teamID)
|
||||
{
|
||||
WorldPacket data;
|
||||
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
||||
if (Player* player = _GetPlayerForTeam(TeamID, itr, "PlaySoundToTeam"))
|
||||
{
|
||||
sBattlegroundMgr->BuildPlaySoundPacket(&data, SoundID);
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
{
|
||||
if (Player* player = _GetPlayerForTeam(teamID, itr, "PlaySoundToTeam"))
|
||||
player->SendDirectMessage(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID).Write());
|
||||
}
|
||||
}
|
||||
|
||||
void Battleground::CastSpellOnTeam(uint32 SpellID, uint32 TeamID)
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "Formulas.h"
|
||||
#include "DisableMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "MiscPackets.h"
|
||||
|
||||
/*********************************************************/
|
||||
/*** BATTLEGROUND MANAGER ***/
|
||||
@@ -212,13 +213,6 @@ void BattlegroundMgr::BuildBattlegroundStatusFailed(WorldPackets::Battleground::
|
||||
battlefieldStatus->ClientID = *errorGuid;
|
||||
}
|
||||
|
||||
void BattlegroundMgr::BuildPlaySoundPacket(WorldPacket* data, uint32 soundid)
|
||||
{
|
||||
data->Initialize(SMSG_PLAY_SOUND, 4 + 8);
|
||||
*data << uint32(soundid);
|
||||
*data << uint64(0);
|
||||
}
|
||||
|
||||
void BattlegroundMgr::BuildPlayerLeftBattlegroundPacket(WorldPacket* data, ObjectGuid guid)
|
||||
{
|
||||
data->Initialize(SMSG_BATTLEGROUND_PLAYER_LEFT, 8);
|
||||
|
||||
@@ -92,7 +92,6 @@ class BattlegroundMgr
|
||||
void BuildBattlegroundStatusActive(WorldPackets::Battleground::BattlefieldStatusActive* battlefieldStatus, Battleground* bg, Player* player, uint32 ticketId, uint32 joinTime, uint32 arenaType);
|
||||
void BuildBattlegroundStatusQueued(WorldPackets::Battleground::BattlefieldStatusQueued* battlefieldStatus, Battleground* bg, Player* player, uint32 ticketId, uint32 joinTime, uint32 avgWaitTime, uint32 arenaType, bool asGroup);
|
||||
void BuildBattlegroundStatusFailed(WorldPackets::Battleground::BattlefieldStatusFailed* battlefieldStatus, Battleground* bg, Player* pPlayer, uint32 ticketId, uint32 arenaType, GroupJoinBattlegroundResult result, ObjectGuid const* errorGuid = nullptr);
|
||||
void BuildPlaySoundPacket(WorldPacket* data, uint32 soundId);
|
||||
void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, ObjectGuid guid);
|
||||
|
||||
/* Battlegrounds */
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include "Battleground.h"
|
||||
#include "Chat.h"
|
||||
#include "GameObjectPackets.h"
|
||||
#include "MiscPackets.h"
|
||||
|
||||
Object::Object()
|
||||
{
|
||||
@@ -3167,13 +3168,10 @@ void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= NULL*/)
|
||||
|
||||
void WorldObject::PlayDirectSound(uint32 sound_id, Player* target /*= NULL*/)
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_SOUND, 4 + 8);
|
||||
data << uint32(sound_id);
|
||||
data << GetGUID();
|
||||
if (target)
|
||||
target->SendDirectMessage(&data);
|
||||
target->SendDirectMessage(WorldPackets::Misc::PlaySound(GetGUID(), sound_id).Write());
|
||||
else
|
||||
SendMessageToSet(&data, true);
|
||||
SendMessageToSet(WorldPackets::Misc::PlaySound(GetGUID(), sound_id).Write(), true);
|
||||
}
|
||||
|
||||
void WorldObject::DestroyForNearbyPlayers()
|
||||
|
||||
@@ -431,3 +431,11 @@ void WorldPackets::Misc::ObjectUpdateRescued::Read()
|
||||
{
|
||||
_worldPacket >> ObjectGUID;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Misc::PlaySound::Write()
|
||||
{
|
||||
_worldPacket << int32(SoundKitID);
|
||||
_worldPacket << SourceObjectGuid;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
@@ -594,6 +594,18 @@ namespace WorldPackets
|
||||
|
||||
ObjectGuid ObjectGUID;
|
||||
};
|
||||
|
||||
class PlaySound final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
PlaySound() : ServerPacket(SMSG_PLAY_SOUND, 20) { }
|
||||
PlaySound(ObjectGuid sourceObjectGuid, int32 soundKitID) : ServerPacket(SMSG_PLAY_SOUND, 20), SourceObjectGuid(sourceObjectGuid), SoundKitID(soundKitID) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
ObjectGuid SourceObjectGuid;
|
||||
int32 SoundKitID = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1484,7 +1484,7 @@ void OpcodeTable::Initialize()
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PLAY_ONE_SHOT_ANIM_KIT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PLAY_ORPHAN_SPELL_VISUAL, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PLAY_SCENE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PLAY_SOUND, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PLAY_SOUND, STATUS_NEVER, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PLAY_SPEAKERBOT_SOUND, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PLAY_SPELL_VISUAL, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PLAY_SPELL_VISUAL_KIT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "CreatureTextMgr.h"
|
||||
#include "ChatPackets.h"
|
||||
#include "MiscPackets.h"
|
||||
|
||||
class CreatureTextBuilder
|
||||
{
|
||||
@@ -334,13 +335,10 @@ void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType,
|
||||
if (!sound || !source)
|
||||
return;
|
||||
|
||||
WorldPacket data(SMSG_PLAY_SOUND, 4 + 8);
|
||||
data << uint32(sound);
|
||||
data << source->GetGUID();
|
||||
SendNonChatPacket(source, &data, msgType, whisperTarget, range, team, gmOnly);
|
||||
SendNonChatPacket(source, WorldPackets::Misc::PlaySound(source->GetGUID(), sound).Write(), msgType, whisperTarget, range, team, gmOnly);
|
||||
}
|
||||
|
||||
void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly)
|
||||
void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket const* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly)
|
||||
{
|
||||
switch (msgType)
|
||||
{
|
||||
|
||||
@@ -112,7 +112,7 @@ class CreatureTextMgr
|
||||
CreatureTextRepeatIds GetRepeatGroup(Creature* source, uint8 textGroup) const;
|
||||
void SetRepeatId(Creature* source, uint8 textGroup, uint8 id);
|
||||
|
||||
static void SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly);
|
||||
static void SendNonChatPacket(WorldObject* source, WorldPacket const* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly);
|
||||
static float GetRangeForChatType(ChatMsg msgType);
|
||||
|
||||
CreatureTextMap mTextMap;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "MMapFactory.h"
|
||||
#include "DisableMgr.h"
|
||||
#include "SpellHistory.h"
|
||||
#include "MiscPackets.h"
|
||||
|
||||
class misc_commandscript : public CommandScript
|
||||
{
|
||||
@@ -2567,10 +2568,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
WorldPacket data(SMSG_PLAY_SOUND, 4 + 8);
|
||||
data << uint32(soundId);
|
||||
data << handler->GetSession()->GetPlayer()->GetGUID();
|
||||
sWorld->SendGlobalMessage(&data);
|
||||
sWorld->SendGlobalMessage(WorldPackets::Misc::PlaySound(handler->GetSession()->GetPlayer()->GetGUID(), soundId).Write());
|
||||
|
||||
handler->PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user