mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Chat: Send broadcast text id in sound packets to allow playing encrypted sound files
This commit is contained in:
@@ -297,7 +297,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
if (IsUnit(target))
|
||||
{
|
||||
target->PlayDirectSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr);
|
||||
target->PlayDirectSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr, e.action.sound.keyBroadcastTextId);
|
||||
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: %s (%s), sound: %u, onlyself: %u",
|
||||
target->GetName().c_str(), target->GetGUID().ToString().c_str(), e.action.sound.sound, e.action.sound.onlySelf);
|
||||
}
|
||||
|
||||
@@ -625,6 +625,8 @@ struct SmartAction
|
||||
{
|
||||
uint32 sound;
|
||||
uint32 onlySelf;
|
||||
uint32 distance; // NYI: awaiting cherry-pick
|
||||
uint32 keyBroadcastTextId;
|
||||
} sound;
|
||||
|
||||
struct
|
||||
|
||||
@@ -359,7 +359,7 @@ void Battlefield::EndBattle(bool endByTimer)
|
||||
|
||||
void Battlefield::DoPlaySoundToAll(uint32 soundID)
|
||||
{
|
||||
BroadcastPacketToWar(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID).Write());
|
||||
BroadcastPacketToWar(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID, 0).Write());
|
||||
}
|
||||
|
||||
bool Battlefield::HasPlayer(Player* player) const
|
||||
|
||||
@@ -619,12 +619,12 @@ void Battleground::SendBroadcastText(uint32 id, ChatMsg msgType, WorldObject con
|
||||
|
||||
void Battleground::PlaySoundToAll(uint32 soundID)
|
||||
{
|
||||
SendPacketToAll(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID).Write());
|
||||
SendPacketToAll(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID, 0).Write());
|
||||
}
|
||||
|
||||
void Battleground::PlaySoundToTeam(uint32 soundID, uint32 teamID)
|
||||
{
|
||||
SendPacketToTeam(teamID, WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID).Write());
|
||||
SendPacketToTeam(teamID, WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID, 0).Write());
|
||||
}
|
||||
|
||||
void Battleground::CastSpellOnTeam(uint32 SpellID, uint32 TeamID)
|
||||
|
||||
@@ -2212,12 +2212,12 @@ void WorldObject::PlayDistanceSound(uint32 soundId, Player* target /*= nullptr*/
|
||||
SendMessageToSet(WorldPackets::Misc::PlaySpeakerbotSound(GetGUID(), soundId).Write(), true);
|
||||
}
|
||||
|
||||
void WorldObject::PlayDirectSound(uint32 soundId, Player* target /*= nullptr*/)
|
||||
void WorldObject::PlayDirectSound(uint32 soundId, Player* target /*= nullptr*/, uint32 broadcastTextId /*= 0*/)
|
||||
{
|
||||
if (target)
|
||||
target->SendDirectMessage(WorldPackets::Misc::PlaySound(GetGUID(), soundId).Write());
|
||||
target->SendDirectMessage(WorldPackets::Misc::PlaySound(GetGUID(), soundId, broadcastTextId).Write());
|
||||
else
|
||||
SendMessageToSet(WorldPackets::Misc::PlaySound(GetGUID(), soundId).Write(), true);
|
||||
SendMessageToSet(WorldPackets::Misc::PlaySound(GetGUID(), soundId, broadcastTextId).Write(), true);
|
||||
}
|
||||
|
||||
void WorldObject::PlayDirectMusic(uint32 musicId, Player* target /*= nullptr*/)
|
||||
|
||||
@@ -472,7 +472,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
virtual uint8 GetLevelForTarget(WorldObject const* /*target*/) const { return 1; }
|
||||
|
||||
void PlayDistanceSound(uint32 soundId, Player* target = nullptr);
|
||||
void PlayDirectSound(uint32 soundId, Player* target = nullptr);
|
||||
void PlayDirectSound(uint32 soundId, Player* target = nullptr, uint32 broadcastTextId = 0);
|
||||
void PlayDirectMusic(uint32 musicId, Player* target = nullptr);
|
||||
|
||||
virtual void SaveRespawnTime(uint32 /*forceDelay*/ = 0, bool /*saveToDB*/ = true) { }
|
||||
|
||||
@@ -640,7 +640,8 @@ namespace WorldPackets
|
||||
{
|
||||
public:
|
||||
PlaySound() : ServerPacket(SMSG_PLAY_SOUND, 20) { }
|
||||
PlaySound(ObjectGuid sourceObjectGuid, int32 soundKitID) : ServerPacket(SMSG_PLAY_SOUND, 20), SourceObjectGuid(sourceObjectGuid), SoundKitID(soundKitID) { }
|
||||
PlaySound(ObjectGuid sourceObjectGuid, int32 soundKitID, int32 broadcastTextId) : ServerPacket(SMSG_PLAY_SOUND, 20),
|
||||
SourceObjectGuid(sourceObjectGuid), SoundKitID(soundKitID), BroadcastTextID(broadcastTextId) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject
|
||||
range = iter->TextRange;
|
||||
|
||||
if (finalSound)
|
||||
SendSound(source, finalSound, finalType, whisperTarget, range, team, gmOnly);
|
||||
SendSound(source, finalSound, finalType, whisperTarget, range, team, gmOnly, iter->BroadcastTextId);
|
||||
|
||||
Unit* finalSource = source;
|
||||
if (srcPlr)
|
||||
@@ -302,12 +302,13 @@ float CreatureTextMgr::GetRangeForChatType(ChatMsg msgType)
|
||||
return dist;
|
||||
}
|
||||
|
||||
void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget /*= nullptr*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/)
|
||||
void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget /*= nullptr*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/,
|
||||
Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/, uint32 keyBroadcastTextId /*= 0*/)
|
||||
{
|
||||
if (!sound || !source)
|
||||
return;
|
||||
|
||||
SendNonChatPacket(source, WorldPackets::Misc::PlaySound(source->GetGUID(), sound).Write(), msgType, whisperTarget, range, team, gmOnly);
|
||||
SendNonChatPacket(source, WorldPackets::Misc::PlaySound(source->GetGUID(), sound, keyBroadcastTextId).Write(), msgType, whisperTarget, range, team, gmOnly);
|
||||
}
|
||||
|
||||
void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket const* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly)
|
||||
|
||||
@@ -93,7 +93,7 @@ class TC_GAME_API CreatureTextMgr
|
||||
void LoadCreatureTextLocales();
|
||||
CreatureTextMap const& GetTextMap() const { return mTextMap; }
|
||||
|
||||
static void SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget = nullptr, CreatureTextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false);
|
||||
static void SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget = nullptr, CreatureTextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false, uint32 keyBroadcastTextId = 0);
|
||||
static void SendEmote(Unit* source, uint32 emote);
|
||||
|
||||
//if sent, returns the 'duration' of the text else 0 if error
|
||||
|
||||
@@ -2686,7 +2686,9 @@ public:
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
uint32 soundId = atoul(args);
|
||||
char const* soundIdToken = strtok((char*)args, " ");
|
||||
|
||||
uint32 soundId = atoul(soundIdToken);
|
||||
|
||||
if (!sSoundKitStore.LookupEntry(soundId))
|
||||
{
|
||||
@@ -2695,7 +2697,12 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
sWorld->SendGlobalMessage(WorldPackets::Misc::PlaySound(handler->GetSession()->GetPlayer()->GetGUID(), soundId).Write());
|
||||
uint32 broadcastTextId = 0;
|
||||
char const* broadcastTextIdToken = strtok(nullptr, " ");
|
||||
if (broadcastTextIdToken)
|
||||
broadcastTextId = atoul(broadcastTextIdToken);
|
||||
|
||||
sWorld->SendGlobalMessage(WorldPackets::Misc::PlaySound(handler->GetSession()->GetPlayer()->GetGUID(), soundId, broadcastTextId).Write());
|
||||
|
||||
handler->PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user