mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 17:27:36 +01:00
Core/Packets: converted SMSG_PLAY_SOUND and SMSG_PLAY_OBJECT_SOUND to packet class and corrected packet structure of
SMSG_PLAY_OBJECT_SOUND
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "Log.h"
|
||||
#include "Map.h"
|
||||
#include "MapManager.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Transport.h"
|
||||
@@ -354,12 +355,7 @@ void Battlefield::EndBattle(bool endByTimer)
|
||||
|
||||
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
|
||||
@@ -426,28 +422,28 @@ void Battlefield::TeamCastSpell(TeamId team, int32 spellId)
|
||||
}
|
||||
}
|
||||
|
||||
void Battlefield::BroadcastPacketToZone(WorldPacket& data) const
|
||||
void Battlefield::BroadcastPacketToZone(WorldPacket const* data) const
|
||||
{
|
||||
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
|
||||
for (auto itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
player->SendDirectMessage(&data);
|
||||
player->SendDirectMessage(data);
|
||||
}
|
||||
|
||||
void Battlefield::BroadcastPacketToQueue(WorldPacket& data) const
|
||||
void Battlefield::BroadcastPacketToQueue(WorldPacket const* data) const
|
||||
{
|
||||
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
|
||||
for (auto itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr)
|
||||
if (Player* player = ObjectAccessor::FindConnectedPlayer(*itr))
|
||||
player->SendDirectMessage(&data);
|
||||
player->SendDirectMessage(data);
|
||||
}
|
||||
|
||||
void Battlefield::BroadcastPacketToWar(WorldPacket& data) const
|
||||
void Battlefield::BroadcastPacketToWar(WorldPacket const* data) const
|
||||
{
|
||||
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
|
||||
for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
player->SendDirectMessage(&data);
|
||||
player->SendDirectMessage(data);
|
||||
}
|
||||
|
||||
void Battlefield::SendWarning(uint8 id, WorldObject const* target /*= nullptr*/)
|
||||
|
||||
@@ -412,9 +412,9 @@ class TC_GAME_API Battlefield : public ZoneScript
|
||||
virtual void SendRemoveWorldStates(Player* /*player*/) { }
|
||||
|
||||
// use for send a packet for all player list
|
||||
void BroadcastPacketToZone(WorldPacket& data) const;
|
||||
void BroadcastPacketToQueue(WorldPacket& data) const;
|
||||
void BroadcastPacketToWar(WorldPacket& data) const;
|
||||
void BroadcastPacketToZone(WorldPacket const* data) const;
|
||||
void BroadcastPacketToQueue(WorldPacket const* data) const;
|
||||
void BroadcastPacketToWar(WorldPacket const* data) const;
|
||||
|
||||
// CapturePoint system
|
||||
void AddCapturePoint(BfCapturePoint* cp) { m_capturePoints[cp->GetCapturePointEntry()] = cp; }
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "Group.h"
|
||||
#include "Guild.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "Object.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
@@ -648,7 +649,7 @@ Position const* Battleground::GetTeamStartPosition(TeamId teamId) const
|
||||
return &StartPosition[teamId];
|
||||
}
|
||||
|
||||
void Battleground::SendPacketToAll(WorldPacket* packet)
|
||||
void Battleground::SendPacketToAll(WorldPacket const* packet)
|
||||
{
|
||||
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
||||
if (Player* player = _GetPlayer(itr, "SendPacketToAll"))
|
||||
@@ -687,9 +688,7 @@ void Battleground::SendBroadcastText(uint32 id, ChatMsg msgType, WorldObject con
|
||||
|
||||
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)
|
||||
@@ -697,10 +696,7 @@ 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);
|
||||
}
|
||||
player->SendDirectMessage(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, SoundID).Write());
|
||||
}
|
||||
|
||||
void Battleground::CastSpellOnTeam(uint32 SpellID, uint32 TeamID)
|
||||
|
||||
@@ -368,7 +368,7 @@ class TC_GAME_API Battleground
|
||||
// method that should fill worldpacket with actual world states (not yet implemented for all battlegrounds!)
|
||||
virtual void FillInitialWorldStates(WorldPacket& /*data*/) { }
|
||||
void SendPacketToTeam(uint32 TeamID, WorldPacket* packet, Player* sender = nullptr, bool self = true);
|
||||
void SendPacketToAll(WorldPacket* packet);
|
||||
void SendPacketToAll(WorldPacket const* packet);
|
||||
|
||||
void SendChatMessage(Creature* source, uint8 textId, WorldObject* target = nullptr);
|
||||
void SendBroadcastText(uint32 id, ChatMsg msgType, WorldObject const* target = nullptr);
|
||||
|
||||
@@ -443,13 +443,6 @@ void BattlegroundMgr::BuildUpdateWorldStatePacket(WorldPacket* data, uint32 fiel
|
||||
*data << uint32(value);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -72,7 +72,6 @@ class TC_GAME_API BattlegroundMgr
|
||||
void BuildStatusFailedPacket(WorldPacket* data, Battleground* bg, Player* pPlayer, uint8 QueueSlot, GroupJoinBattlegroundResult result);
|
||||
void BuildUpdateWorldStatePacket(WorldPacket* data, uint32 field, uint32 value);
|
||||
void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, Player* player, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType);
|
||||
void BuildPlaySoundPacket(WorldPacket* data, uint32 soundId);
|
||||
void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, ObjectGuid guid);
|
||||
|
||||
/* Battlegrounds */
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "Item.h"
|
||||
#include "Log.h"
|
||||
#include "MapManager.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "MovementPacketBuilder.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
@@ -2602,24 +2603,26 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
|
||||
|
||||
void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= nullptr*/)
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4 + 8);
|
||||
data << uint32(sound_id);
|
||||
data << uint64(GetGUID());
|
||||
WorldPackets::Misc::PlayObjectSound packet;
|
||||
packet.SoundKitID = sound_id;
|
||||
packet.SourceObjectGUID = GetGUID();
|
||||
packet.TargetObjectGUID = target ? target->GetGUID() : GetGUID();
|
||||
|
||||
if (target)
|
||||
target->SendDirectMessage(&data);
|
||||
target->SendDirectMessage(packet.Write());
|
||||
else
|
||||
SendMessageToSet(&data, true);
|
||||
SendMessageToSet(packet.Write(), true);
|
||||
}
|
||||
|
||||
void WorldObject::PlayDirectSound(uint32 sound_id, Player* target /*= nullptr*/)
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_SOUND, 4 + 8);
|
||||
data << uint32(sound_id);
|
||||
data << uint64(GetGUID());
|
||||
WorldPackets::Misc::PlaySound packet;
|
||||
packet.SourceObjectGUID = GetGUID();
|
||||
packet.SoundKitID = sound_id;
|
||||
if (target)
|
||||
target->SendDirectMessage(&data);
|
||||
target->SendDirectMessage(packet.Write());
|
||||
else
|
||||
SendMessageToSet(&data, true);
|
||||
SendMessageToSet(packet.Write(), true);
|
||||
}
|
||||
|
||||
void WorldObject::PlayDirectMusic(uint32 music_id, Player* target /*= nullptr*/)
|
||||
|
||||
@@ -137,3 +137,20 @@ WorldPacket const* WorldPackets::Misc::UITime::Write()
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Misc::PlaySound::Write()
|
||||
{
|
||||
_worldPacket << uint32(SoundKitID);
|
||||
_worldPacket << SourceObjectGUID;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Misc::PlayObjectSound::Write()
|
||||
{
|
||||
_worldPacket << uint32(SoundKitID);
|
||||
_worldPacket << SourceObjectGUID;
|
||||
_worldPacket << TargetObjectGUID;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
@@ -153,6 +153,30 @@ namespace WorldPackets
|
||||
|
||||
uint32 Time = 0;
|
||||
};
|
||||
|
||||
class TC_GAME_API PlaySound final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
PlaySound() : ServerPacket(SMSG_PLAY_SOUND, 4 + 4) { }
|
||||
PlaySound(ObjectGuid sourceObjectGuid, uint32 soundKitID) : ServerPacket(SMSG_PLAY_SOUND, 4 + 4), SourceObjectGUID(sourceObjectGuid), SoundKitID(soundKitID) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
ObjectGuid SourceObjectGUID;
|
||||
uint32 SoundKitID;
|
||||
};
|
||||
|
||||
class PlayObjectSound final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
PlayObjectSound() : ServerPacket(SMSG_PLAY_OBJECT_SOUND, 8 + 8 + 4) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
ObjectGuid SourceObjectGUID;
|
||||
ObjectGuid TargetObjectGUID;
|
||||
uint32 SoundKitID = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "DBCStores.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Log.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "World.h"
|
||||
|
||||
@@ -305,13 +306,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 << uint64(source->GetGUID()); Todo: find out why some maps prevent the sound from appearing
|
||||
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) const
|
||||
void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket const* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly) const
|
||||
{
|
||||
switch (msgType)
|
||||
{
|
||||
|
||||
@@ -105,7 +105,7 @@ class TC_GAME_API CreatureTextMgr
|
||||
void SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, WorldObject const* whisperTarget = nullptr, CreatureTextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false) const;
|
||||
|
||||
private:
|
||||
void SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly) const;
|
||||
void SendNonChatPacket(WorldObject* source, WorldPacket const* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly) const;
|
||||
float GetRangeForChatType(ChatMsg msgType) const;
|
||||
|
||||
CreatureTextMap mTextMap;
|
||||
|
||||
Reference in New Issue
Block a user