Created
January 27, 2019 11:10
-
-
Save Langerz82/0e8babb658709fc367548c653c368564 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/game/Object/Player.cpp b/src/game/Object/Player.cpp | |
index 7bc1c3b..3a69cdc 100644 | |
--- a/src/game/Object/Player.cpp | |
+++ b/src/game/Object/Player.cpp | |
@@ -5688,10 +5688,10 @@ void Player::SendMessageToSetInRange(WorldPacket* data, float dist, bool self) c | |
{ GetSession()->SendPacket(data); } | |
} | |
-void Player::SendMessageToSetInRange(WorldPacket* data, float dist, bool self, bool own_team_only) const | |
+void Player::SendMessageToSetInRange(WorldPacket* data, float dist, bool self, bool own_team_only, bool to_gm) const | |
{ | |
if (IsInWorld()) | |
- { GetMap()->MessageDistBroadcast(this, data, dist, false, own_team_only); } | |
+ { GetMap()->MessageDistBroadcast(this, data, dist, false, own_team_only, to_gm); } | |
if (self) | |
{ GetSession()->SendPacket(data); } | |
@@ -16456,16 +16456,31 @@ Pet* Player::GetMiniPet() const | |
void Player::Say(const std::string& text, const uint32 language) | |
{ | |
- WorldPacket data; | |
- ChatHandler::BuildChatPacket(data, CHAT_MSG_SAY, text.c_str(), Language(language), GetChatTag(), GetObjectGuid(), GetName()); | |
- SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY), true); | |
+ WorldPacket data; | |
+ ChatHandler::BuildChatPacket(data, CHAT_MSG_SAY, text.c_str(), Language(language), GetChatTag(), GetObjectGuid(), GetName()); | |
+ | |
+ if (GetSession()->m_mutePlayer) | |
+ { | |
+ SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY), true, false, true); | |
+ } | |
+ else | |
+ { | |
+ SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY), true); | |
+ } | |
} | |
void Player::Yell(const std::string& text, const uint32 language) | |
{ | |
WorldPacket data; | |
ChatHandler::BuildChatPacket(data, CHAT_MSG_YELL, text.c_str(), Language(language), GetChatTag(), GetObjectGuid(), GetName()); | |
- SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_YELL), true); | |
+ if (GetSession()->m_mutePlayer) | |
+ { | |
+ SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_YELL), true, false, true); | |
+ } | |
+ else | |
+ { | |
+ SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_YELL), true); | |
+ } | |
} | |
void Player::TextEmote(const std::string& text) | |
diff --git a/src/game/Object/Player.h b/src/game/Object/Player.h | |
index 8743e82..9d37da2 100644 | |
--- a/src/game/Object/Player.h | |
+++ b/src/game/Object/Player.h | |
@@ -1866,7 +1866,7 @@ class Player : public Unit | |
void SendMessageToSet(WorldPacket* data, bool self) const override;// overwrite Object::SendMessageToSet | |
void SendMessageToSetInRange(WorldPacket* data, float fist, bool self) const override; | |
// overwrite Object::SendMessageToSetInRange | |
- void SendMessageToSetInRange(WorldPacket* data, float dist, bool self, bool own_team_only) const; | |
+ void SendMessageToSetInRange(WorldPacket* data, float dist, bool self, bool own_team_only, bool to_gm = false) const; | |
Corpse* GetCorpse() const; | |
void SpawnCorpseBones(); | |
diff --git a/src/game/Server/WorldSession.cpp b/src/game/Server/WorldSession.cpp | |
index 0611c04..efea70d 100644 | |
--- a/src/game/Server/WorldSession.cpp | |
+++ b/src/game/Server/WorldSession.cpp | |
@@ -95,7 +95,7 @@ bool WorldSessionFilter::Process(WorldPacket* packet) | |
/// WorldSession constructor | |
WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, time_t mute_time, LocaleConstant locale) : | |
- m_muteTime(mute_time), | |
+ m_muteTime(mute_time), m_mutePlayer(false), | |
_player(NULL), m_Socket(sock), _security(sec), _accountId(id), _warden(NULL), _build(0), _logoutTime(0), | |
m_inQueue(false), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyLogout(false), m_playerSave(false), | |
m_sessionDbcLocale(sWorld.GetAvailableDbcLocale(locale)), m_sessionDbLocaleIndex(sObjectMgr.GetIndexForLocale(locale)), | |
diff --git a/src/game/Server/WorldSession.h b/src/game/Server/WorldSession.h | |
index 920096b..070d741 100644 | |
--- a/src/game/Server/WorldSession.h | |
+++ b/src/game/Server/WorldSession.h | |
@@ -316,6 +316,7 @@ class WorldSession | |
// Account mute time | |
time_t m_muteTime; | |
+ bool m_mutePlayer; | |
// Locales | |
LocaleConstant GetSessionDbcLocale() const | |
diff --git a/src/game/Tools/Language.h b/src/game/Tools/Language.h | |
index b5283aa..0ad758c 100644 | |
--- a/src/game/Tools/Language.h | |
+++ b/src/game/Tools/Language.h | |
@@ -1051,11 +1051,13 @@ enum MangosStrings | |
LANG_OPVP_SI_CAPTURE_H = 1635, | |
LANG_OPVP_SI_CAPTURE_A = 1636, | |
- LANG_AUTOBROADCAST = 1700 | |
+ LANG_AUTOBROADCAST = 1700, | |
// FREE IDS 1701-9999 | |
// Use for not-in-official-sources patches | |
// 10000-10999 | |
+ LANG_YOUR_CHAT_DISABLED_BY_GM = 1701, | |
+ LANG_YOUR_CHAT_ENABLED_BY_GM = 1702 | |
// Use for custom patches 11000-11999 | |
diff --git a/src/game/WorldHandlers/ChatHandler.cpp b/src/game/WorldHandlers/ChatHandler.cpp | |
index ea3bf0c..6a6371b 100644 | |
--- a/src/game/WorldHandlers/ChatHandler.cpp | |
+++ b/src/game/WorldHandlers/ChatHandler.cpp | |
@@ -166,6 +166,10 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) | |
} | |
} | |
+ // Muted Player can only say or yell. | |
+ if (_player->GetSession()->m_mutePlayer && !(type == CHAT_MSG_SAY || type == CHAT_MSG_YELL)) | |
+ return; | |
+ | |
switch (type) | |
{ | |
case CHAT_MSG_SAY: | |
@@ -193,7 +197,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) | |
if (!sEluna->OnChat(GetPlayer(), type, lang, msg)) | |
return; | |
#endif /* ENABLE_ELUNA */ | |
- GetPlayer()->Say(msg, lang); | |
+ GetPlayer()->Say(msg, lang); | |
} | |
else if (type == CHAT_MSG_EMOTE) | |
{ | |
diff --git a/src/game/WorldHandlers/GridNotifiers.cpp b/src/game/WorldHandlers/GridNotifiers.cpp | |
index 9fec6a5..e56bf62 100644 | |
--- a/src/game/WorldHandlers/GridNotifiers.cpp | |
+++ b/src/game/WorldHandlers/GridNotifiers.cpp | |
@@ -146,6 +146,7 @@ void MessageDistDeliverer::Visit(CameraMapType& m) | |
Player* owner = iter->getSource()->GetOwner(); | |
if ((i_toSelf || owner != &i_player) && | |
+ (!i_toGM || (owner->isGameMaster() || i_player.isGameMaster())) && | |
(!i_ownTeamOnly || owner->GetTeam() == i_player.GetTeam()) && | |
(!i_dist || iter->getSource()->GetBody()->IsWithinDist(&i_player, i_dist))) | |
{ | |
diff --git a/src/game/WorldHandlers/GridNotifiers.h b/src/game/WorldHandlers/GridNotifiers.h | |
index 4b1d740..ec882e2 100644 | |
--- a/src/game/WorldHandlers/GridNotifiers.h | |
+++ b/src/game/WorldHandlers/GridNotifiers.h | |
@@ -93,11 +93,12 @@ namespace MaNGOS | |
Player const& i_player; | |
WorldPacket* i_message; | |
bool i_toSelf; | |
+ bool i_toGM; | |
bool i_ownTeamOnly; | |
float i_dist; | |
- MessageDistDeliverer(Player const& pl, WorldPacket* msg, float dist, bool to_self, bool ownTeamOnly) | |
- : i_player(pl), i_message(msg), i_toSelf(to_self), i_ownTeamOnly(ownTeamOnly), i_dist(dist) {} | |
+ MessageDistDeliverer(Player const& pl, WorldPacket* msg, float dist, bool to_self, bool ownTeamOnly, bool to_gm) | |
+ : i_player(pl), i_message(msg), i_toSelf(to_self), i_ownTeamOnly(ownTeamOnly), i_toGM(to_gm), i_dist(dist) {} | |
void Visit(CameraMapType& m); | |
template<class SKIP> void Visit(GridRefManager<SKIP>&) {} | |
}; | |
diff --git a/src/game/WorldHandlers/Map.cpp b/src/game/WorldHandlers/Map.cpp | |
index 5d19412..741a5a9 100644 | |
--- a/src/game/WorldHandlers/Map.cpp | |
+++ b/src/game/WorldHandlers/Map.cpp | |
@@ -430,7 +430,7 @@ void Map::MessageBroadcast(WorldObject const* obj, WorldPacket* msg) | |
cell.Visit(p, message, *this, *obj, GetVisibilityDistance()); | |
} | |
-void Map::MessageDistBroadcast(Player const* player, WorldPacket* msg, float dist, bool to_self, bool own_team_only) | |
+void Map::MessageDistBroadcast(Player const* player, WorldPacket* msg, float dist, bool to_self, bool own_team_only, bool to_gm) | |
{ | |
CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); | |
@@ -446,7 +446,7 @@ void Map::MessageDistBroadcast(Player const* player, WorldPacket* msg, float dis | |
if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y))) | |
{ return; } | |
- MaNGOS::MessageDistDeliverer post_man(*player, msg, dist, to_self, own_team_only); | |
+ MaNGOS::MessageDistDeliverer post_man(*player, msg, dist, to_self, own_team_only, to_gm); | |
TypeContainerVisitor<MaNGOS::MessageDistDeliverer , WorldTypeMapContainer > message(post_man); | |
cell.Visit(p, message, *this, *player, dist); | |
} | |
diff --git a/src/game/WorldHandlers/Map.h b/src/game/WorldHandlers/Map.h | |
index 0870a9d..7710392 100644 | |
--- a/src/game/WorldHandlers/Map.h | |
+++ b/src/game/WorldHandlers/Map.h | |
@@ -126,7 +126,7 @@ class Map : public GridRefManager<NGridType> | |
void MessageBroadcast(Player const*, WorldPacket*, bool to_self); | |
void MessageBroadcast(WorldObject const*, WorldPacket*); | |
- void MessageDistBroadcast(Player const*, WorldPacket*, float dist, bool to_self, bool own_team_only = false); | |
+ void MessageDistBroadcast(Player const*, WorldPacket*, float dist, bool to_self, bool own_team_only = false, bool to_gm = false); | |
void MessageDistBroadcast(WorldObject const*, WorldPacket*, float dist); | |
float GetVisibilityDistance() const { return m_VisibleDistance; } | |
diff --git a/src/game/WorldHandlers/SpellAuras.cpp b/src/game/WorldHandlers/SpellAuras.cpp | |
index fb14a6f..7ef7401 100644 | |
--- a/src/game/WorldHandlers/SpellAuras.cpp | |
+++ b/src/game/WorldHandlers/SpellAuras.cpp | |
@@ -27,6 +27,7 @@ | |
#include "WorldPacket.h" | |
#include "WorldSession.h" | |
#include "Opcodes.h" | |
+#include "Language.h" | |
#include "Log.h" | |
#include "World.h" | |
#include "ObjectMgr.h" | |
@@ -3300,9 +3301,36 @@ void Aura::HandleAuraModBaseResistancePCT(bool apply, bool /*Real*/) | |
} | |
} | |
-void Aura::HandleAurasVisible(bool apply, bool /*Real*/) | |
-{ | |
- GetTarget()->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_AURAS_VISIBLE, apply); | |
+void Aura::HandleAurasVisible(bool apply, bool Real) | |
+{ | |
+ if (m_spellAuraHolder->GetSpellProto() && m_spellAuraHolder->GetSpellProto()->Id == 1852) | |
+ { | |
+ Player* player = GetTarget()->ToPlayer(); | |
+ if (!player) | |
+ return; | |
+ | |
+ if (apply) | |
+ { | |
+ m_spellAuraHolder->SetGameMasterAura(); | |
+ player->GetSession()->m_mutePlayer = true; | |
+ if (player->IsInWorld()) | |
+ ChatHandler(player).PSendSysMessage(LANG_YOUR_CHAT_DISABLED_BY_GM, player->GetName()); | |
+ GetTarget()->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_AURAS_VISIBLE, true); | |
+ } | |
+ else | |
+ { | |
+ if (!player->isGameMaster()) | |
+ return; | |
+ player->GetSession()->m_mutePlayer = false; | |
+ if (player->IsInWorld()) | |
+ ChatHandler(player).PSendSysMessage(LANG_YOUR_CHAT_ENABLED_BY_GM, player->GetName()); | |
+ GetTarget()->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_AURAS_VISIBLE, false); | |
+ } | |
+ } | |
+ else | |
+ { | |
+ GetTarget()->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_AURAS_VISIBLE, apply); | |
+ } | |
} | |
void Aura::HandleModResistancePercent(bool apply, bool /*Real*/) | |
@@ -4931,7 +4959,7 @@ SpellAuraHolder::SpellAuraHolder(SpellEntry const* spellproto, Unit* target, Wor | |
m_auraSlot(MAX_AURAS), m_auraLevel(1), | |
m_procCharges(0), m_stackAmount(1), | |
m_timeCla(1000), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE), | |
- m_permanent(false), m_isRemovedOnShapeLost(true), m_deleted(false), m_in_use(0) | |
+ m_permanent(false), m_isRemovedOnShapeLost(true), m_deleted(false), m_isGameMasterAura(false), m_in_use(0) | |
{ | |
MANGOS_ASSERT(target); | |
MANGOS_ASSERT(spellproto && spellproto == sSpellStore.LookupEntry(spellproto->Id)); // `info` must be pointer to sSpellStore element | |
diff --git a/src/game/WorldHandlers/SpellAuras.h b/src/game/WorldHandlers/SpellAuras.h | |
index 6e15f38..7108d70 100644 | |
--- a/src/game/WorldHandlers/SpellAuras.h | |
+++ b/src/game/WorldHandlers/SpellAuras.h | |
@@ -137,6 +137,9 @@ class SpellAuraHolder | |
bool IsDeleted() const { return m_deleted;} | |
bool IsEmptyHolder() const; | |
+ bool IsGameMasterAura() const { return m_isGameMasterAura; } | |
+ void SetGameMasterAura() { m_isGameMasterAura = true; } | |
+ | |
void SetDeleted() { m_deleted = true; } | |
void SetInUse(bool state) | |
@@ -239,6 +242,7 @@ class SpellAuraHolder | |
bool m_isRemovedOnShapeLost: 1; | |
bool m_isHeartbeatSubject: 1; | |
bool m_deleted: 1; | |
+ bool m_isGameMasterAura : 1; | |
uint32 m_in_use; // > 0 while in SpellAuraHolder::ApplyModifiers call/SpellAuraHolder::Update/etc | |
}; | |
diff --git a/src/game/WorldHandlers/SpellHandler.cpp b/src/game/WorldHandlers/SpellHandler.cpp | |
index 6483072..dc332c3 100644 | |
--- a/src/game/WorldHandlers/SpellHandler.cpp | |
+++ b/src/game/WorldHandlers/SpellHandler.cpp | |
@@ -421,6 +421,9 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket) | |
if (holder && holder->GetCasterGuid() != _player->GetObjectGuid() && HasAreaAuraEffect(holder->GetSpellProto())) | |
{ return; } | |
+ if (holder->IsGameMasterAura() && !_player->isGameMaster()) | |
+ return; | |
+ | |
// non channeled case | |
_player->RemoveAurasDueToSpellByCancel(spellId); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment