fix/feat: (Core/PacketIO): updated sound and creature addon (#10813)

* fix\feat: (Core/PacketIO): updated sound and creature addon

updated SMSG_PLAY_SOUND, SMSG_PLAY_MUSIC and SMSG_PLAY_OBJECT_SOUND via tc cherry pick
https://github.com/TrinityCore/TrinityCore/pull/2363 and https://github.com/TrinityCore/TrinityCore/commit/0f1f7ef4017ac32df669ceee120489321da680aa by @joschiwald  and @ForesterDev
This so far a attempt to align atleast with sound with tc, and correct a potentional issue of hearing creature sounds that is not in visible range. I notice PlaySound was being defined in some weird dependency as it isnt with tc so I renamed it to Playsound. Notice a isLarge still being used in the creature addon when it was depreciated, so i removed that a that seem to of interfered with visibilitydistanceType.

Co-Authored-By: joschiwald <736792+joschiwald@users.noreply.github.com>
Co-Authored-By: ForesterDev <11771800+ForesterDev@users.noreply.github.com>
This commit is contained in:
acidmanifesto
2022-02-26 10:05:58 -05:00
committed by GitHub
parent ea497f2b6e
commit 69e2f2e3aa
20 changed files with 120 additions and 104 deletions
+10 -24
View File
@@ -27,6 +27,7 @@
#include "GroupMgr.h" #include "GroupMgr.h"
#include "Map.h" #include "Map.h"
#include "MapMgr.h" #include "MapMgr.h"
#include "MiscPackets.h"
#include "ObjectAccessor.h" #include "ObjectAccessor.h"
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "Transport.h" #include "Transport.h"
@@ -374,14 +375,7 @@ void Battlefield::EndBattle(bool endByTimer)
void Battlefield::DoPlaySoundToAll(uint32 SoundID) void Battlefield::DoPlaySoundToAll(uint32 SoundID)
{ {
WorldPacket data; BroadcastPacketToWar(WorldPackets::Misc::Playsound(SoundID).Write());
data.Initialize(SMSG_PLAY_SOUND, 4);
data << uint32(SoundID);
for (int team = 0; team < PVP_TEAMS_COUNT; team++)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->GetSession()->SendPacket(&data);
} }
bool Battlefield::HasPlayer(Player* player) const bool Battlefield::HasPlayer(Player* player) const
@@ -447,42 +441,34 @@ 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 (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr)) if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->GetSession()->SendPacket(&data); player->GetSession()->SendPacket(data);
} }
void Battlefield::BroadcastPacketToQueue(WorldPacket& data) const void Battlefield::BroadcastPacketToQueue(WorldPacket const* data) const
{ {
for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team) for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr) for (GuidUnorderedSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr)) if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->GetSession()->SendPacket(&data); player->GetSession()->SendPacket(data);
} }
void Battlefield::BroadcastPacketToWar(WorldPacket& data) const void Battlefield::BroadcastPacketToWar(WorldPacket const* data) const
{ {
for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team) for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr)) if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->GetSession()->SendPacket(&data); player->GetSession()->SendPacket(data);
} }
void Battlefield::SendWarningToAllInZone(uint32 entry) void Battlefield::SendWarning(uint8 id, WorldObject const* target /*= nullptr*/)
{ {
if (Creature* stalker = GetCreature(StalkerGuid)) if (Creature* stalker = GetCreature(StalkerGuid))
sCreatureTextMgr->SendChat(stalker, (uint8)entry, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE); sCreatureTextMgr->SendChat(stalker, id, target);
}
void Battlefield::SendWarningToPlayer(Player* player, uint32 entry)
{
if (player)
if (Unit* unit = ObjectAccessor::GetCreature(*player, StalkerGuid))
if (Creature* stalker = unit->ToCreature())
sCreatureTextMgr->SendChat(stalker, (uint8)entry, player);
} }
void Battlefield::SendUpdateWorldState(uint32 field, uint32 value) void Battlefield::SendUpdateWorldState(uint32 field, uint32 value)
+4 -5
View File
@@ -323,8 +323,7 @@ public:
/// Called when a player enter in battlefield zone /// Called when a player enter in battlefield zone
virtual void OnPlayerEnterZone(Player* /*player*/) {}; virtual void OnPlayerEnterZone(Player* /*player*/) {};
void SendWarningToAllInZone(uint32 entry); void SendWarning(uint8 id, WorldObject const* target = nullptr);
void SendWarningToPlayer(Player* player, uint32 entry);
void PlayerAcceptInviteToQueue(Player* player); void PlayerAcceptInviteToQueue(Player* player);
void PlayerAcceptInviteToWar(Player* player); void PlayerAcceptInviteToWar(Player* player);
@@ -414,9 +413,9 @@ protected:
virtual void SendRemoveWorldStates(Player* /*player*/) {} virtual void SendRemoveWorldStates(Player* /*player*/) {}
// use for send a packet for all player list // use for send a packet for all player list
void BroadcastPacketToZone(WorldPacket& data) const; void BroadcastPacketToZone(WorldPacket const* data) const;
void BroadcastPacketToQueue(WorldPacket& data) const; void BroadcastPacketToQueue(WorldPacket const* data) const;
void BroadcastPacketToWar(WorldPacket& data) const; void BroadcastPacketToWar(WorldPacket const* data) const;
// CapturePoint system // CapturePoint system
void AddCapturePoint(BfCapturePoint* cp) { m_capturePoints.push_back(cp); } void AddCapturePoint(BfCapturePoint* cp) { m_capturePoints.push_back(cp); }
@@ -278,7 +278,7 @@ void BattlefieldWG::OnBattleStart()
// Initialize vehicle counter // Initialize vehicle counter
UpdateCounterVehicle(true); UpdateCounterVehicle(true);
// Send start warning to all players // Send start warning to all players
SendWarningToAllInZone(BATTLEFIELD_WG_TEXT_START); SendWarning(BATTLEFIELD_WG_TEXT_START);
// Xinef: reset tenacity counter // Xinef: reset tenacity counter
m_tenacityStack = 0; m_tenacityStack = 0;
@@ -476,9 +476,9 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer)
m_PlayersInWar[TEAM_HORDE].clear(); m_PlayersInWar[TEAM_HORDE].clear();
if (!endByTimer) // win alli/horde if (!endByTimer) // win alli/horde
SendWarningToAllInZone((GetDefenderTeam() == TEAM_ALLIANCE) ? BATTLEFIELD_WG_TEXT_WIN_KEEP : (BATTLEFIELD_WG_TEXT_WIN_KEEP + 2)); SendWarning((GetDefenderTeam() == TEAM_ALLIANCE) ? BATTLEFIELD_WG_TEXT_WIN_KEEP : (BATTLEFIELD_WG_TEXT_WIN_KEEP + 2));
else // defend alli/horde else // defend alli/horde
SendWarningToAllInZone((GetDefenderTeam() == TEAM_ALLIANCE) ? BATTLEFIELD_WG_TEXT_DEFEND_KEEP : (BATTLEFIELD_WG_TEXT_DEFEND_KEEP + 2)); SendWarning((GetDefenderTeam() == TEAM_ALLIANCE) ? BATTLEFIELD_WG_TEXT_DEFEND_KEEP : (BATTLEFIELD_WG_TEXT_DEFEND_KEEP + 2));
} }
// ******************************************************* // *******************************************************
@@ -488,7 +488,7 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer)
void BattlefieldWG::OnStartGrouping() void BattlefieldWG::OnStartGrouping()
{ {
if (!IsWarTime()) if (!IsWarTime())
SendWarningToAllInZone(BATTLEFIELD_WG_TEXT_WILL_START); SendWarning(BATTLEFIELD_WG_TEXT_WILL_START);
} }
uint8 BattlefieldWG::GetSpiritGraveyardId(uint32 areaId) const uint8 BattlefieldWG::GetSpiritGraveyardId(uint32 areaId) const
@@ -757,7 +757,7 @@ void BattlefieldWG::PromotePlayer(Player* killer)
{ {
killer->RemoveAura(SPELL_RECRUIT); killer->RemoveAura(SPELL_RECRUIT);
killer->CastSpell(killer, SPELL_CORPORAL, true); killer->CastSpell(killer, SPELL_CORPORAL, true);
SendWarningToPlayer(killer, BATTLEFIELD_WG_TEXT_FIRSTRANK); SendWarning(BATTLEFIELD_WG_TEXT_FIRSTRANK, killer);
} }
else else
{ {
@@ -770,7 +770,7 @@ void BattlefieldWG::PromotePlayer(Player* killer)
{ {
killer->RemoveAura(SPELL_CORPORAL); killer->RemoveAura(SPELL_CORPORAL);
killer->CastSpell(killer, SPELL_LIEUTENANT, true); killer->CastSpell(killer, SPELL_LIEUTENANT, true);
SendWarningToPlayer(killer, BATTLEFIELD_WG_TEXT_SECONDRANK); SendWarning(BATTLEFIELD_WG_TEXT_SECONDRANK, killer);
} }
else else
{ {
@@ -1170,7 +1170,7 @@ struct BfWGGameObjectBuilding
// Send warning message // Send warning message
if (m_damagedText) // tower damage + name if (m_damagedText) // tower damage + name
m_WG->SendWarningToAllInZone(m_damagedText); m_WG->SendWarning(m_damagedText);
for (GuidUnorderedSet::const_iterator itr = m_CreatureTopList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureTopList[m_WG->GetAttackerTeam()].end(); ++itr) for (GuidUnorderedSet::const_iterator itr = m_CreatureTopList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureTopList[m_WG->GetAttackerTeam()].end(); ++itr)
if (Creature* creature = m_WG->GetCreature(*itr)) if (Creature* creature = m_WG->GetCreature(*itr))
@@ -1193,7 +1193,7 @@ struct BfWGGameObjectBuilding
// Warn players // Warn players
if (m_destroyedText) if (m_destroyedText)
m_WG->SendWarningToAllInZone(m_destroyedText); m_WG->SendWarning(m_destroyedText);
switch (m_Type) switch (m_Type)
{ {
@@ -1467,7 +1467,7 @@ struct WGWorkshop
{ {
// Send warning message to all player to inform a faction attack to a workshop // Send warning message to all player to inform a faction attack to a workshop
// alliance / horde attacking a workshop // alliance / horde attacking a workshop
bf->SendWarningToAllInZone(teamControl ? WorkshopsData[workshopId].attackText : (WorkshopsData[workshopId].attackText + 2)); bf->SendWarning(teamControl ? WorkshopsData[workshopId].attackText : (WorkshopsData[workshopId].attackText + 2));
break; break;
} }
case TEAM_ALLIANCE: case TEAM_ALLIANCE:
@@ -1479,7 +1479,7 @@ struct WGWorkshop
// Warning message // Warning message
if (!init) // workshop taken - alliance if (!init) // workshop taken - alliance
bf->SendWarningToAllInZone(team == TEAM_ALLIANCE ? WorkshopsData[workshopId].takenText : (WorkshopsData[workshopId].takenText + 2)); bf->SendWarning(team == TEAM_ALLIANCE ? WorkshopsData[workshopId].takenText : (WorkshopsData[workshopId].takenText + 2));
// Found associate graveyard and update it // Found associate graveyard and update it
if (workshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST) if (workshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
@@ -34,6 +34,7 @@
#include "GridNotifiersImpl.h" #include "GridNotifiersImpl.h"
#include "Group.h" #include "Group.h"
#include "MapMgr.h" #include "MapMgr.h"
#include "MiscPackets.h"
#include "Object.h" #include "Object.h"
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "Pet.h" #include "Pet.h"
@@ -673,9 +674,7 @@ void Battleground::SendBroadcastText(uint32 id, ChatMsg msgType, WorldObject con
void Battleground::PlaySoundToAll(uint32 soundID) void Battleground::PlaySoundToAll(uint32 soundID)
{ {
WorldPacket data; SendPacketToAll(WorldPackets::Misc::Playsound(soundID).Write());
sBattlegroundMgr->BuildPlaySoundPacket(&data, soundID);
SendPacketToAll(&data);
} }
void Battleground::CastSpellOnTeam(uint32 spellId, TeamId teamId) void Battleground::CastSpellOnTeam(uint32 spellId, TeamId teamId)
@@ -39,6 +39,7 @@
#include "GameTime.h" #include "GameTime.h"
#include "Map.h" #include "Map.h"
#include "MapMgr.h" #include "MapMgr.h"
#include "MiscPackets.h"
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "Opcodes.h" #include "Opcodes.h"
#include "Player.h" #include "Player.h"
@@ -212,12 +213,6 @@ void BattlegroundMgr::BuildGroupJoinedBattlegroundPacket(WorldPacket* data, Grou
*data << uint64(0); // player guid *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) void BattlegroundMgr::BuildPlayerLeftBattlegroundPacket(WorldPacket* data, ObjectGuid guid)
{ {
data->Initialize(SMSG_BATTLEGROUND_PLAYER_LEFT, 8); data->Initialize(SMSG_BATTLEGROUND_PLAYER_LEFT, 8);
@@ -68,7 +68,6 @@ public:
void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere); void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
void BuildGroupJoinedBattlegroundPacket(WorldPacket* data, GroupJoinBattlegroundResult result); void BuildGroupJoinedBattlegroundPacket(WorldPacket* data, GroupJoinBattlegroundResult result);
void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, TeamId teamId, bool isRated = false, BattlegroundTypeId forceBgTypeId = BATTLEGROUND_TYPE_NONE); void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, TeamId teamId, bool isRated = false, BattlegroundTypeId forceBgTypeId = BATTLEGROUND_TYPE_NONE);
void BuildPlaySoundPacket(WorldPacket* data, uint32 soundid);
void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, ObjectGuid guid); void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, ObjectGuid guid);
/* Battlegrounds */ /* Battlegrounds */
@@ -2563,12 +2563,6 @@ bool Creature::LoadCreaturesAddon(bool reload)
SetByteValue(UNIT_FIELD_BYTES_2, 3, 0); SetByteValue(UNIT_FIELD_BYTES_2, 3, 0);
} }
// Check if Creature is Large
if (cainfo->isLarge)
{
SetVisibilityDistanceOverride(cainfo->visibilityDistanceType);
}
SetUInt32Value(UNIT_NPC_EMOTESTATE, cainfo->emote); SetUInt32Value(UNIT_NPC_EMOTESTATE, cainfo->emote);
// Check if visibility distance different // Check if visibility distance different
@@ -433,7 +433,6 @@ struct CreatureAddon
uint32 bytes1; uint32 bytes1;
uint32 bytes2; uint32 bytes2;
uint32 emote; uint32 emote;
bool isLarge;
std::vector<uint32> auras; std::vector<uint32> auras;
VisibilityDistanceType visibilityDistanceType; VisibilityDistanceType visibilityDistanceType;
}; };
+7 -13
View File
@@ -27,6 +27,7 @@
#include "GridNotifiers.h" #include "GridNotifiers.h"
#include "Log.h" #include "Log.h"
#include "MapMgr.h" #include "MapMgr.h"
#include "MiscPackets.h"
#include "MovementPacketBuilder.h" #include "MovementPacketBuilder.h"
#include "ObjectAccessor.h" #include "ObjectAccessor.h"
#include "ObjectMgr.h" #include "ObjectMgr.h"
@@ -2809,36 +2810,29 @@ void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= nullptr*/) void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= nullptr*/)
{ {
WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4 + 8);
data << uint32(sound_id);
data << GetGUID();
if (target) if (target)
target->SendDirectMessage(&data); target->SendDirectMessage(WorldPackets::Misc::PlayObjectSound(GetGUID(), sound_id).Write());
else else
SendMessageToSet(&data, true); SendMessageToSet(WorldPackets::Misc::PlayObjectSound(GetGUID(), sound_id).Write(), true);
} }
void WorldObject::PlayDirectSound(uint32 sound_id, Player* target /*= nullptr*/) void WorldObject::PlayDirectSound(uint32 sound_id, Player* target /*= nullptr*/)
{ {
WorldPacket data(SMSG_PLAY_SOUND, 4);
data << uint32(sound_id);
if (target) if (target)
target->SendDirectMessage(&data); target->SendDirectMessage(WorldPackets::Misc::Playsound(sound_id).Write());
else else
SendMessageToSet(&data, true); SendMessageToSet(WorldPackets::Misc::Playsound(sound_id).Write(), true);
} }
void WorldObject::PlayDirectMusic(uint32 music_id, Player* target /*= nullptr*/) void WorldObject::PlayDirectMusic(uint32 music_id, Player* target /*= nullptr*/)
{ {
WorldPacket data(SMSG_PLAY_MUSIC, 4);
data << uint32(music_id);
if (target) if (target)
{ {
target->SendDirectMessage(&data); target->SendDirectMessage(WorldPackets::Misc::PlayMusic(music_id).Write());
} }
else else
{ {
SendMessageToSet(&data, true); SendMessageToSet(WorldPackets::Misc::PlayMusic(music_id).Write(), true);
} }
} }
+2 -2
View File
@@ -179,7 +179,7 @@ enum eScriptFlags
SF_CASTSPELL_SEARCH_CREATURE = 4, SF_CASTSPELL_SEARCH_CREATURE = 4,
SF_CASTSPELL_TRIGGERED = 0x1, SF_CASTSPELL_TRIGGERED = 0x1,
// PlaySound flags // Playsound flags
SF_PLAYSOUND_TARGET_PLAYER = 0x1, SF_PLAYSOUND_TARGET_PLAYER = 0x1,
SF_PLAYSOUND_DISTANCE_SOUND = 0x2, SF_PLAYSOUND_DISTANCE_SOUND = 0x2,
@@ -309,7 +309,7 @@ struct ScriptInfo
{ {
uint32 SoundID; // datalong uint32 SoundID; // datalong
uint32 Flags; // datalong2 uint32 Flags; // datalong2
} PlaySound; } Playsound;
struct // SCRIPT_COMMAND_CREATE_ITEM (17) struct // SCRIPT_COMMAND_CREATE_ITEM (17)
{ {
+4 -8
View File
@@ -3655,11 +3655,7 @@ void Map::SendZoneDynamicInfo(Player* player)
return; return;
if (uint32 music = itr->second.MusicId) if (uint32 music = itr->second.MusicId)
{ player->SendDirectMessage(WorldPackets::Misc::PlayMusic(music).Write());
WorldPacket data(SMSG_PLAY_MUSIC, 4);
data << uint32(music);
player->SendDirectMessage(&data);
}
if (WeatherState weatherId = itr->second.WeatherId) if (WeatherState weatherId = itr->second.WeatherId)
{ {
@@ -3702,13 +3698,13 @@ void Map::SetZoneMusic(uint32 zoneId, uint32 musicId)
Map::PlayerList const& players = GetPlayers(); Map::PlayerList const& players = GetPlayers();
if (!players.IsEmpty()) if (!players.IsEmpty())
{ {
WorldPacket data(SMSG_PLAY_MUSIC, 4); WorldPackets::Misc::PlayMusic playMusic(musicId);
data << uint32(musicId); playMusic.Write();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
if (Player* player = itr->GetSource()) if (Player* player = itr->GetSource())
if (player->GetZoneId() == zoneId) if (player->GetZoneId() == zoneId)
player->SendDirectMessage(&data); player->SendDirectMessage(playMusic.GetRawPacket());
} }
} }
+6 -6
View File
@@ -721,9 +721,9 @@ void Map::ScriptsProcess()
// Source must be WorldObject. // Source must be WorldObject.
if (WorldObject* object = _GetScriptWorldObject(source, true, step.script)) if (WorldObject* object = _GetScriptWorldObject(source, true, step.script))
{ {
// PlaySound.Flags bitmask: 0/1=anyone/target // Playsound.Flags bitmask: 0/1=anyone/target
Player* player = nullptr; Player* player = nullptr;
if (step.script->PlaySound.Flags & SF_PLAYSOUND_TARGET_PLAYER) if (step.script->Playsound.Flags & SF_PLAYSOUND_TARGET_PLAYER)
{ {
// Target must be Player. // Target must be Player.
player = _GetScriptPlayer(target, false, step.script); player = _GetScriptPlayer(target, false, step.script);
@@ -731,11 +731,11 @@ void Map::ScriptsProcess()
break; break;
} }
// PlaySound.Flags bitmask: 0/2=without/with distance dependent // Playsound.Flags bitmask: 0/2=without/with distance dependent
if (step.script->PlaySound.Flags & SF_PLAYSOUND_DISTANCE_SOUND) if (step.script->Playsound.Flags & SF_PLAYSOUND_DISTANCE_SOUND)
object->PlayDistanceSound(step.script->PlaySound.SoundID, player); object->PlayDistanceSound(step.script->Playsound.SoundID, player);
else else
object->PlayDirectSound(step.script->PlaySound.SoundID, player); object->PlayDirectSound(step.script->Playsound.SoundID, player);
} }
break; break;
@@ -31,6 +31,28 @@ WorldPacket const* WorldPackets::Misc::Weather::Write()
return &_worldPacket; 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;
}
void WorldPackets::Misc::RandomRollClient::Read() void WorldPackets::Misc::RandomRollClient::Read()
{ {
_worldPacket >> Min; _worldPacket >> Min;
@@ -41,6 +41,42 @@ namespace WorldPackets
WeatherState WeatherID = WeatherState(0); WeatherState WeatherID = WeatherState(0);
}; };
class AC_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 AC_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 AC_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 RandomRollClient final : public ClientPacket class RandomRollClient final : public ClientPacket
{ {
public: public:
+2 -3
View File
@@ -36,6 +36,7 @@
#include "Language.h" #include "Language.h"
#include "Log.h" #include "Log.h"
#include "MapMgr.h" #include "MapMgr.h"
#include "MiscPackets.h"
#include "ObjectAccessor.h" #include "ObjectAccessor.h"
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "Opcodes.h" #include "Opcodes.h"
@@ -6265,9 +6266,7 @@ void Spell::EffectPlayMusic(SpellEffIndex effIndex)
return; return;
} }
WorldPacket data(SMSG_PLAY_MUSIC, 4); unitTarget->ToPlayer()->SendDirectMessage(WorldPackets::Misc::PlayMusic(soundid).Write());
data << uint32(soundid);
player->GetSession()->SendPacket(&data);
} }
void Spell::EffectSpecCount(SpellEffIndex /*effIndex*/) void Spell::EffectSpecCount(SpellEffIndex /*effIndex*/)
+3 -4
View File
@@ -23,6 +23,7 @@
#include "DatabaseEnv.h" #include "DatabaseEnv.h"
#include "GridNotifiers.h" #include "GridNotifiers.h"
#include "GridNotifiersImpl.h" #include "GridNotifiersImpl.h"
#include "MiscPackets.h"
#include "ObjectMgr.h" #include "ObjectMgr.h"
class CreatureTextBuilder class CreatureTextBuilder
@@ -331,12 +332,10 @@ void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType,
if (!sound || !source) if (!sound || !source)
return; return;
WorldPacket data(SMSG_PLAY_SOUND, 4); SendNonChatPacket(source, WorldPackets::Misc::Playsound(sound).Write(), msgType, target, range, teamId, gmOnly);
data << uint32(sound);
SendNonChatPacket(source, &data, msgType, target, range, teamId, gmOnly);
} }
void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* target, CreatureTextRange range, TeamId teamId, bool gmOnly) const void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket const* data, ChatMsg msgType, WorldObject const* target, CreatureTextRange range, TeamId teamId, bool gmOnly) const
{ {
float dist = GetRangeForChatType(msgType); float dist = GetRangeForChatType(msgType);
+1 -1
View File
@@ -108,7 +108,7 @@ private:
CreatureTextRepeatIds GetRepeatGroup(Creature* source, uint8 textGroup); CreatureTextRepeatIds GetRepeatGroup(Creature* source, uint8 textGroup);
void SetRepeatId(Creature* source, uint8 textGroup, uint8 id); void SetRepeatId(Creature* source, uint8 textGroup, uint8 id);
void SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* target, CreatureTextRange range, TeamId teamId, bool gmOnly) const; void SendNonChatPacket(WorldObject* source, WorldPacket const* data, ChatMsg msgType, WorldObject const* target, CreatureTextRange range, TeamId teamId, bool gmOnly) const;
float GetRangeForChatType(ChatMsg msgType) const; float GetRangeForChatType(ChatMsg msgType) const;
CreatureTextMap mTextMap; CreatureTextMap mTextMap;
+2 -3
View File
@@ -31,6 +31,7 @@
#include "LFG.h" #include "LFG.h"
#include "Language.h" #include "Language.h"
#include "MapMgr.h" #include "MapMgr.h"
#include "MiscPackets.h"
#include "MovementGenerator.h" #include "MovementGenerator.h"
#include "ObjectAccessor.h" #include "ObjectAccessor.h"
#include "Opcodes.h" #include "Opcodes.h"
@@ -2891,9 +2892,7 @@ public:
return false; return false;
} }
WorldPacket data(SMSG_PLAY_SOUND, 4); sWorld->SendGlobalMessage(WorldPackets::Misc::Playsound(soundId).Write());
data << uint32(soundId);
sWorld->SendGlobalMessage(&data);
handler->PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId); handler->PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId);
return true; return true;
@@ -1932,10 +1932,10 @@ public:
else else
return; return;
PlaySound(soundId); Playsound(soundId);
} }
void PlaySound(uint32 soundId) void Playsound(uint32 soundId)
{ {
WorldPacket data(SMSG_PLAY_SOUND, 4); WorldPacket data(SMSG_PLAY_SOUND, 4);
data << uint32(soundId); data << uint32(soundId);
@@ -2046,10 +2046,10 @@ public:
else else
return; return;
PlaySound(soundId); Playsound(soundId);
} }
void PlaySound(uint32 soundId) void Playsound(uint32 soundId)
{ {
WorldPacket data(SMSG_PLAY_SOUND, 4); WorldPacket data(SMSG_PLAY_SOUND, 4);
data << uint32(soundId); data << uint32(soundId);
@@ -2080,7 +2080,7 @@ public:
NextStep(2000); NextStep(2000);
break; break;
case 2: case 2:
PlaySound(GAR_2); Playsound(GAR_2);
NextStep(6500); NextStep(6500);
break; break;
case 3: case 3:
@@ -2092,7 +2092,7 @@ public:
NextStep(2500); NextStep(2500);
break; break;
case 5: case 5:
PlaySound(YS_V1_2); Playsound(YS_V1_2);
NextStep(2500); NextStep(2500);
break; break;
case 6: case 6:
@@ -2166,10 +2166,10 @@ public:
else else
return; return;
PlaySound(soundId); Playsound(soundId);
} }
void PlaySound(uint32 soundId) void Playsound(uint32 soundId)
{ {
WorldPacket data(SMSG_PLAY_SOUND, 4); WorldPacket data(SMSG_PLAY_SOUND, 4);
data << uint32(soundId); data << uint32(soundId);