Core/Chat: Send broadcast text id in sound packets to allow playing encrypted sound files

This commit is contained in:
Shauren
2020-12-27 22:43:36 +01:00
parent 88301ec3be
commit 2e4609f6e1
10 changed files with 26 additions and 15 deletions

View File

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

View File

@@ -625,6 +625,8 @@ struct SmartAction
{
uint32 sound;
uint32 onlySelf;
uint32 distance; // NYI: awaiting cherry-pick
uint32 keyBroadcastTextId;
} sound;
struct

View File

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

View File

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

View File

@@ -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*/)

View File

@@ -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) { }

View File

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

View File

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

View File

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

View File

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