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 0f1f7ef401 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

View File

@@ -27,6 +27,7 @@
#include "GroupMgr.h"
#include "Map.h"
#include "MapMgr.h"
#include "MiscPackets.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Transport.h"
@@ -374,14 +375,7 @@ void Battlefield::EndBattle(bool endByTimer)
void Battlefield::DoPlaySoundToAll(uint32 SoundID)
{
WorldPacket data;
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);
BroadcastPacketToWar(WorldPackets::Misc::Playsound(SoundID).Write());
}
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 (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++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 (GuidUnorderedSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++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 (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++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))
sCreatureTextMgr->SendChat(stalker, (uint8)entry, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE);
}
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);
sCreatureTextMgr->SendChat(stalker, id, target);
}
void Battlefield::SendUpdateWorldState(uint32 field, uint32 value)

View File

@@ -323,8 +323,7 @@ public:
/// Called when a player enter in battlefield zone
virtual void OnPlayerEnterZone(Player* /*player*/) {};
void SendWarningToAllInZone(uint32 entry);
void SendWarningToPlayer(Player* player, uint32 entry);
void SendWarning(uint8 id, WorldObject const* target = nullptr);
void PlayerAcceptInviteToQueue(Player* player);
void PlayerAcceptInviteToWar(Player* player);
@@ -414,9 +413,9 @@ protected:
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.push_back(cp); }

View File

@@ -278,7 +278,7 @@ void BattlefieldWG::OnBattleStart()
// Initialize vehicle counter
UpdateCounterVehicle(true);
// Send start warning to all players
SendWarningToAllInZone(BATTLEFIELD_WG_TEXT_START);
SendWarning(BATTLEFIELD_WG_TEXT_START);
// Xinef: reset tenacity counter
m_tenacityStack = 0;
@@ -476,9 +476,9 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer)
m_PlayersInWar[TEAM_HORDE].clear();
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
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()
{
if (!IsWarTime())
SendWarningToAllInZone(BATTLEFIELD_WG_TEXT_WILL_START);
SendWarning(BATTLEFIELD_WG_TEXT_WILL_START);
}
uint8 BattlefieldWG::GetSpiritGraveyardId(uint32 areaId) const
@@ -757,7 +757,7 @@ void BattlefieldWG::PromotePlayer(Player* killer)
{
killer->RemoveAura(SPELL_RECRUIT);
killer->CastSpell(killer, SPELL_CORPORAL, true);
SendWarningToPlayer(killer, BATTLEFIELD_WG_TEXT_FIRSTRANK);
SendWarning(BATTLEFIELD_WG_TEXT_FIRSTRANK, killer);
}
else
{
@@ -770,7 +770,7 @@ void BattlefieldWG::PromotePlayer(Player* killer)
{
killer->RemoveAura(SPELL_CORPORAL);
killer->CastSpell(killer, SPELL_LIEUTENANT, true);
SendWarningToPlayer(killer, BATTLEFIELD_WG_TEXT_SECONDRANK);
SendWarning(BATTLEFIELD_WG_TEXT_SECONDRANK, killer);
}
else
{

View File

@@ -1170,7 +1170,7 @@ struct BfWGGameObjectBuilding
// Send warning message
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)
if (Creature* creature = m_WG->GetCreature(*itr))
@@ -1193,7 +1193,7 @@ struct BfWGGameObjectBuilding
// Warn players
if (m_destroyedText)
m_WG->SendWarningToAllInZone(m_destroyedText);
m_WG->SendWarning(m_destroyedText);
switch (m_Type)
{
@@ -1467,7 +1467,7 @@ struct WGWorkshop
{
// Send warning message to all player to inform a faction attack to 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;
}
case TEAM_ALLIANCE:
@@ -1479,7 +1479,7 @@ struct WGWorkshop
// Warning message
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
if (workshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)