Core/PacketIO: updated SMSG_PLAY_SOUND, SMSG_PLAY_MUSIC and SMSG_PLAY_OBJECT_SOUND (#23636)

* Core/PacketIO: SMSG_PLAY_SOUND

(cherry picked from commit 82a33c7fa8)

# Conflicts:
#	src/server/game/Battlefield/Battlefield.cpp
#	src/server/game/Battlegrounds/Battleground.cpp
#	src/server/game/Battlegrounds/BattlegroundMgr.cpp
#	src/server/game/Battlegrounds/BattlegroundMgr.h
#	src/server/game/Entities/Object/Object.cpp
#	src/server/game/Server/Packets/MiscPackets.cpp
#	src/server/game/Server/Protocol/Opcodes.cpp
#	src/server/game/Texts/CreatureTextMgr.cpp
#	src/server/game/Texts/CreatureTextMgr.h
#	src/server/scripts/Commands/cs_misc.cpp

* Update for 3.3.5

* Core/PacketIO: updated and enabled SMSG_PLAY_MUSIC

(cherry picked from commit c6718dc120)

# Conflicts:
#	src/server/game/Maps/Map.cpp
#	src/server/game/Server/Packets/MiscPackets.cpp
#	src/server/game/Server/Protocol/Opcodes.cpp
#	src/server/game/Server/Protocol/Opcodes.h
#	src/server/game/Spells/SpellEffects.cpp

* Core/Packets: added SMSG_PLAY_OBJECT_SOUND packet class

(cherry picked from commit 1272e9eea6)

# Conflicts:
#	src/server/game/Server/Packets/MiscPackets.cpp
#	src/server/game/Server/Packets/MiscPackets.h
#	src/server/game/Server/Protocol/Opcodes.cpp

* fic build

* change variable names

* fix build error field will be initialized after
This commit is contained in:
ForesterDev
2019-08-23 21:28:21 +04:00
committed by Giacomo Pozzoni
parent 448facc5e7
commit 07e2264964
15 changed files with 107 additions and 73 deletions

View File

@@ -29,6 +29,7 @@
#include "Log.h"
#include "Map.h"
#include "MapManager.h"
#include "MiscPackets.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "WorldPacket.h"
@@ -350,13 +351,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);
data << uint32(SoundID);
BroadcastPacketToWar(data);
BroadcastPacketToWar(WorldPackets::Misc::PlaySound(soundID).Write());
}
bool Battlefield::HasPlayer(Player* player) const
@@ -423,28 +420,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 < PVP_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 < PVP_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 < PVP_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*/)

View File

@@ -347,7 +347,7 @@ class TC_GAME_API Battlefield : public ZoneScript
uint32 GetTimer() const { return m_Timer; }
void SetTimer(uint32 timer) { m_Timer = timer; }
void DoPlaySoundToAll(uint32 SoundID);
void DoPlaySoundToAll(uint32 soundID);
void InvitePlayerToQueue(Player* player);
void InvitePlayerToWar(Player* player);
@@ -407,9 +407,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; }

View File

@@ -28,6 +28,7 @@
#include "GameTime.h"
#include "GridNotifiersImpl.h"
#include "Group.h"
#include "MiscPackets.h"
#include "Object.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
@@ -604,20 +605,16 @@ 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(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(soundID).Write());
}
}
void Battleground::CastSpellOnTeam(uint32 SpellID, uint32 TeamID)

View File

@@ -380,8 +380,8 @@ class TC_GAME_API Battleground
template<class Do>
void BroadcastWorker(Do& _do);
void PlaySoundToTeam(uint32 SoundID, uint32 TeamID);
void PlaySoundToAll(uint32 SoundID);
void PlaySoundToTeam(uint32 soundID, uint32 teamID);
void PlaySoundToAll(uint32 soundID);
void CastSpellOnTeam(uint32 SpellID, uint32 TeamID);
void RemoveAuraOnTeam(uint32 SpellID, uint32 TeamID);
void RewardHonorToTeam(uint32 Honor, uint32 TeamID);

View File

@@ -40,6 +40,7 @@
#include "Language.h"
#include "Map.h"
#include "MapManager.h"
#include "MiscPackets.h"
#include "SharedDefines.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
@@ -244,12 +245,6 @@ void BattlegroundMgr::BuildGroupJoinedBattlegroundPacket(WorldPacket* data, Grou
*data << uint64(0); // player guid
}
void BattlegroundMgr::BuildPlaySoundPacket(WorldPacket* data, uint32 soundid)
{
data->Initialize(SMSG_PLAY_SOUND, 4);
*data << uint32(soundid);
}
void BattlegroundMgr::BuildPlayerLeftBattlegroundPacket(WorldPacket* data, ObjectGuid guid)
{
data->Initialize(SMSG_BATTLEGROUND_PLAYER_LEFT, 8);

View File

@@ -79,7 +79,6 @@ class TC_GAME_API BattlegroundMgr
void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
void BuildGroupJoinedBattlegroundPacket(WorldPacket* data, GroupJoinBattlegroundResult result);
void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, uint32 arenaFaction);
void BuildPlaySoundPacket(WorldPacket* data, uint32 soundId);
void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, ObjectGuid guid);
/* Battlegrounds */

View File

@@ -28,6 +28,7 @@
#include "Item.h"
#include "Log.h"
#include "Map.h"
#include "MiscPackets.h"
#include "MovementInfo.h"
#include "MovementPacketBuilder.h"
#include "ObjectAccessor.h"
@@ -3330,35 +3331,28 @@ void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
UpdateObjectVisibility();
}
void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= nullptr*/)
void WorldObject::PlayDistanceSound(uint32 soundId, Player* target /*= nullptr*/)
{
WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4+8);
data << uint32(sound_id);
data << uint64(GetGUID());
if (target)
target->SendDirectMessage(&data);
target->SendDirectMessage(WorldPackets::Misc::PlayObjectSound(GetGUID(), soundId).Write());
else
SendMessageToSet(&data, true);
SendMessageToSet(WorldPackets::Misc::PlayObjectSound(GetGUID(), soundId).Write(), true);
}
void WorldObject::PlayDirectSound(uint32 sound_id, Player* target /*= nullptr*/)
void WorldObject::PlayDirectSound(uint32 soundId, Player* target /*= nullptr*/)
{
WorldPacket data(SMSG_PLAY_SOUND, 4);
data << uint32(sound_id);
if (target)
target->SendDirectMessage(&data);
target->SendDirectMessage(WorldPackets::Misc::PlaySound(soundId).Write());
else
SendMessageToSet(&data, true);
SendMessageToSet(WorldPackets::Misc::PlaySound(soundId).Write(), true);
}
void WorldObject::PlayDirectMusic(uint32 music_id, Player* target /*= nullptr*/)
void WorldObject::PlayDirectMusic(uint32 musicId, Player* target /*= nullptr*/)
{
WorldPacket data(SMSG_PLAY_MUSIC, 4);
data << uint32(music_id);
if (target)
target->SendDirectMessage(&data);
target->SendDirectMessage(WorldPackets::Misc::PlayMusic(musicId).Write());
else
SendMessageToSet(&data, true);
SendMessageToSet(WorldPackets::Misc::PlayMusic(musicId).Write(), true);
}
void WorldObject::DestroyForNearbyPlayers()

View File

@@ -364,9 +364,9 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
virtual uint8 GetLevelForTarget(WorldObject const* /*target*/) const { return 1; }
void PlayDistanceSound(uint32 sound_id, Player* target = nullptr);
void PlayDirectSound(uint32 sound_id, Player* target = nullptr);
void PlayDirectMusic(uint32 music_id, Player* target = nullptr);
void PlayDistanceSound(uint32 soundId, Player* target = nullptr);
void PlayDirectSound(uint32 soundId, Player* target = nullptr);
void PlayDirectMusic(uint32 musicId, Player* target = nullptr);
void SendObjectDeSpawnAnim(ObjectGuid guid);

View File

@@ -4529,11 +4529,7 @@ void Map::SendZoneDynamicInfo(uint32 zoneId, Player* player) const
return;
if (uint32 music = itr->second.MusicId)
{
WorldPacket data(SMSG_PLAY_MUSIC, 4);
data << uint32(music);
player->SendDirectMessage(&data);
}
player->SendDirectMessage(WorldPackets::Misc::PlayMusic(music).Write());
SendZoneWeather(itr->second, player);
@@ -4578,13 +4574,13 @@ void Map::SetZoneMusic(uint32 zoneId, uint32 musicId)
Map::PlayerList const& players = GetPlayers();
if (!players.isEmpty())
{
WorldPacket data(SMSG_PLAY_MUSIC, 4);
data << uint32(musicId);
WorldPackets::Misc::PlayMusic playMusic(musicId);
playMusic.Write();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
if (Player* player = itr->GetSource())
if (player->GetZoneId() == zoneId)
player->SendDirectMessage(&data);
player->SendDirectMessage(playMusic.GetRawPacket());
}
}

View File

@@ -31,6 +31,28 @@ WorldPacket const* WorldPackets::Misc::Weather::Write()
return &_worldPacket;
}
WorldPacket const* WorldPackets::Misc::PlayMusic::Write()
{
_worldPacket << SoundKitID;
return &_worldPacket;
}
WorldPacket const* WorldPackets::Misc::PlayObjectSound::Write()
{
_worldPacket << SoundKitID;
_worldPacket << SourceObjectGUID;
return &_worldPacket;
}
WorldPacket const* WorldPackets::Misc::PlaySound::Write()
{
_worldPacket << SoundKitID;
return &_worldPacket;
}
WorldPacket const* WorldPackets::Misc::OverrideLight::Write()
{
_worldPacket << int32(AreaLightID);

View File

@@ -19,6 +19,7 @@
#define MiscPackets_h__
#include "Packet.h"
#include "ObjectGuid.h"
#include "Weather.h"
enum WeatherState : uint32;
@@ -40,6 +41,42 @@ namespace WorldPackets
WeatherState WeatherID = WeatherState(0);
};
class TC_GAME_API PlayMusic final : public ServerPacket
{
public:
PlayMusic() : ServerPacket(SMSG_PLAY_MUSIC, 4) { }
PlayMusic(uint32 soundKitID) : ServerPacket(SMSG_PLAY_MUSIC, 4), SoundKitID(soundKitID) { }
WorldPacket const* Write() override;
uint32 SoundKitID = 0;
};
class TC_GAME_API PlayObjectSound final : public ServerPacket
{
public:
PlayObjectSound() : ServerPacket(SMSG_PLAY_OBJECT_SOUND, 4 + 8) { }
PlayObjectSound(ObjectGuid const& sourceObjectGUID, uint32 soundKitID)
: ServerPacket(SMSG_PLAY_OBJECT_SOUND, 4 + 8), SourceObjectGUID(sourceObjectGUID), SoundKitID(soundKitID) { }
WorldPacket const* Write() override;
ObjectGuid SourceObjectGUID;
uint32 SoundKitID = 0;
};
class TC_GAME_API PlaySound final : public ServerPacket
{
public:
PlaySound() : ServerPacket(SMSG_PLAY_SOUND, 4) { }
PlaySound(uint32 soundKitID) : ServerPacket(SMSG_PLAY_SOUND, 4), SoundKitID(soundKitID) { }
WorldPacket const* Write() override;
uint32 SoundKitID = 0;
};
class OverrideLight final : public ServerPacket
{
public:

View File

@@ -35,6 +35,7 @@
#include "Language.h"
#include "Log.h"
#include "LootMgr.h"
#include "MiscPackets.h"
#include "MotionMaster.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
@@ -5243,9 +5244,7 @@ void Spell::EffectPlayMusic(SpellEffIndex effIndex)
return;
}
WorldPacket data(SMSG_PLAY_MUSIC, 4);
data << uint32(soundid);
unitTarget->ToPlayer()->SendDirectMessage(&data);
unitTarget->ToPlayer()->SendDirectMessage(WorldPackets::Misc::PlayMusic(soundid).Write());
}
void Spell::EffectSpecCount(SpellEffIndex /*effIndex*/)

View File

@@ -24,6 +24,7 @@
#include "DBCStores.h"
#include "GridNotifiersImpl.h"
#include "Log.h"
#include "MiscPackets.h"
#include "ObjectMgr.h"
#include "World.h"
@@ -300,12 +301,10 @@ void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType,
if (!sound || !source)
return;
WorldPacket data(SMSG_PLAY_SOUND, 4);
data << uint32(sound);
SendNonChatPacket(source, &data, msgType, whisperTarget, range, team, gmOnly);
SendNonChatPacket(source, WorldPackets::Misc::PlaySound(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)
{

View File

@@ -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;

View File

@@ -33,6 +33,7 @@
#include "Language.h"
#include "LFG.h"
#include "Log.h"
#include "MiscPackets.h"
#include "MMapFactory.h"
#include "MotionMaster.h"
#include "MovementDefines.h"
@@ -2611,9 +2612,7 @@ public:
return false;
}
WorldPacket data(SMSG_PLAY_SOUND, 4);
data << uint32(soundId);
sWorld->SendGlobalMessage(&data);
sWorld->SendGlobalMessage(WorldPackets::Misc::PlaySound(soundId).Write());
handler->PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId);
return true;