mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 17:27:36 +01:00
Core/Packets: converted SMSG_PLAY_MUSIC to packet class and corrected packet structure
This commit is contained in:
@@ -2626,14 +2626,12 @@ void WorldObject::PlayDirectSound(uint32 sound_id, Player* target /*= nullptr*/)
|
||||
SendMessageToSet(packet.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, GetGUID()).Write());
|
||||
else
|
||||
SendMessageToSet(&data, true);
|
||||
SendMessageToSet(WorldPackets::Misc::PlayMusic(musicId, GetGUID()).Write(), true);
|
||||
}
|
||||
|
||||
void WorldObject::DestroyForNearbyPlayers()
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "MapInstanced.h"
|
||||
#include "MapManager.h"
|
||||
#include "MMapFactory.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "MotionMaster.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectGridLoader.h"
|
||||
@@ -4674,12 +4675,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);
|
||||
data << uint64(player->GetGUID());
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
player->SendDirectMessage(WorldPackets::Misc::PlayMusic(music, player->GetGUID()).Write());
|
||||
|
||||
SendZoneWeather(itr->second, player);
|
||||
|
||||
@@ -4733,12 +4729,7 @@ void Map::SetZoneMusic(uint32 zoneId, uint32 musicId)
|
||||
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
|
||||
if (Player* player = itr->GetSource())
|
||||
if (player->GetZoneId() == zoneId && !player->HasAuraType(SPELL_AURA_FORCE_WEATHER))
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_MUSIC, 4);
|
||||
data << uint32(musicId);
|
||||
data << uint64(player->GetGUID());
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
player->SendDirectMessage(WorldPackets::Misc::PlayMusic(musicId, player->GetGUID()).Write);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -154,3 +154,11 @@ WorldPacket const* WorldPackets::Misc::PlayObjectSound::Write()
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Misc::PlayMusic::Write()
|
||||
{
|
||||
_worldPacket << uint32(SoundKitID);
|
||||
_worldPacket << SourceObjectGUID;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
@@ -177,6 +177,18 @@ namespace WorldPackets
|
||||
ObjectGuid TargetObjectGUID;
|
||||
uint32 SoundKitID = 0;
|
||||
};
|
||||
|
||||
class PlayMusic final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
PlayMusic() : ServerPacket(SMSG_PLAY_MUSIC, 4 + 8) { }
|
||||
PlayMusic(uint32 soundKitID, ObjectGuid sourceObjectGuid) : ServerPacket(SMSG_PLAY_MUSIC, 4), SoundKitID(soundKitID), SourceObjectGUID(sourceObjectGuid) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
uint32 SoundKitID = 0;
|
||||
ObjectGuid SourceObjectGUID;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "Language.h"
|
||||
#include "Log.h"
|
||||
#include "LootMgr.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "MotionMaster.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
@@ -5405,18 +5406,15 @@ void Spell::EffectPlayMusic(SpellEffIndex effIndex)
|
||||
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
uint32 soundid = m_spellInfo->Effects[effIndex].MiscValue;
|
||||
uint32 soundId = m_spellInfo->Effects[effIndex].MiscValue;
|
||||
|
||||
if (!sSoundEntriesStore.LookupEntry(soundid))
|
||||
if (!sSoundEntriesStore.LookupEntry(soundId))
|
||||
{
|
||||
TC_LOG_ERROR("spells", "EffectPlayMusic: Sound (Id: %u) does not exist in spell %u.", soundid, m_spellInfo->Id);
|
||||
TC_LOG_ERROR("spells", "EffectPlayMusic: Sound (Id: %u) does not exist in spell %u.", soundId, m_spellInfo->Id);
|
||||
return;
|
||||
}
|
||||
|
||||
WorldPacket data(SMSG_PLAY_MUSIC, 4);
|
||||
data << uint32(soundid);
|
||||
data << uint64(unitTarget->GetGUID());
|
||||
unitTarget->ToPlayer()->SendDirectMessage(&data);
|
||||
unitTarget->ToPlayer()->SendDirectMessage(WorldPackets::Misc::PlayMusic(soundId, unitTarget->GetGUID()).Write());
|
||||
}
|
||||
|
||||
void Spell::EffectSpecCount(SpellEffIndex /*effIndex*/)
|
||||
|
||||
Reference in New Issue
Block a user