mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
Allow reply to whispers if you are under CONFIG_CHAT_WHISPER_LEVEL_REQ, and implement feature for GMs to remove single players from their WhisperWhiteList.
This commit is contained in:
2
sql/updates/world/2013_03_11_01_world_trinty_strings.sql
Normal file
2
sql/updates/world/2013_03_11_01_world_trinty_strings.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
DELETE FROM `trinity_string` where `entry` = 363;
|
||||
INSERT INTO `trinity_string` (`entry`, `content_default`) VALUES ('363', 'Player %s cannot whisper you any longer.');
|
||||
@@ -2272,6 +2272,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void ClearWhisperWhiteList() { WhisperList.clear(); }
|
||||
void AddWhisperWhiteList(uint64 guid) { WhisperList.push_back(guid); }
|
||||
bool IsInWhisperWhiteList(uint64 guid);
|
||||
void RemoveFromWhisperWhiteList(uint64 guid) { WhisperList.remove(guid); }
|
||||
|
||||
/*! These methods send different packets to the client in apply and unapply case.
|
||||
These methods are only sent to the current unit.
|
||||
|
||||
@@ -257,12 +257,6 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
|
||||
} break;
|
||||
case CHAT_MSG_WHISPER:
|
||||
{
|
||||
if (sender->getLevel() < sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ))
|
||||
{
|
||||
SendNotification(GetTrinityString(LANG_WHISPER_REQ), sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!normalizePlayerName(to))
|
||||
{
|
||||
SendPlayerNotFoundNotice(to);
|
||||
@@ -270,16 +264,18 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
Player* receiver = sObjectAccessor->FindPlayerByName(to);
|
||||
if (!receiver || (!HasPermission(RBAC_PERM_CAN_FILTER_WHISPERS) &&
|
||||
!receiver->isAcceptWhispers() && !receiver->IsInWhisperWhiteList(sender->GetGUID())))
|
||||
if (!receiver)
|
||||
{
|
||||
SendPlayerNotFoundNotice(to);
|
||||
return;
|
||||
}
|
||||
if (!sender->isGameMaster() && sender->getLevel() < sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ) && !receiver->IsInWhisperWhiteList(sender->GetGUID()))
|
||||
{
|
||||
SendNotification(GetTrinityString(LANG_WHISPER_REQ), sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ));
|
||||
return;
|
||||
}
|
||||
|
||||
// @todo: check only sender permission and add receiver to whiteList if receiver does not have the permission
|
||||
if (GetPlayer()->GetTeam() != receiver->GetTeam() && !HasPermission(RBAC_PERM_TWO_SIDE_INTERACTION_CHAT) &&
|
||||
!receiver->GetSession()->HasPermission(RBAC_PERM_TWO_SIDE_INTERACTION_CHAT))
|
||||
if (GetPlayer()->GetTeam() != receiver->GetTeam() && !HasPermission(RBAC_PERM_TWO_SIDE_INTERACTION_CHAT) && !receiver->IsInWhisperWhiteList(sender->GetGUID()))
|
||||
{
|
||||
SendWrongFactionNotice();
|
||||
return;
|
||||
@@ -292,7 +288,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
// If player is a Gamemaster and doesn't accept whisper, we auto-whitelist every player that the Gamemaster is talking to
|
||||
if (HasPermission(RBAC_PERM_CAN_FILTER_WHISPERS) && !sender->isAcceptWhispers() && !sender->IsInWhisperWhiteList(receiver->GetGUID()))
|
||||
// We also do that if a player is under the required level for whispers.
|
||||
if (receiver->getLevel() < sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ) ||
|
||||
(HasPermission(RBAC_PERM_CAN_FILTER_WHISPERS) && !sender->isAcceptWhispers() && !sender->IsInWhisperWhiteList(receiver->GetGUID())))
|
||||
sender->AddWhisperWhiteList(receiver->GetGUID());
|
||||
|
||||
GetPlayer()->Whisper(msg, lang, receiver->GetGUID());
|
||||
|
||||
@@ -376,7 +376,8 @@ enum TrinityStrings
|
||||
LANG_COMMAND_CHEAT_CD = 360,
|
||||
LANG_COMMAND_CHEAT_POWER = 361,
|
||||
LANG_COMMAND_CHEAT_WW = 362,
|
||||
// Room for more level 2 363-399 not used
|
||||
LANG_COMMAND_WHISPEROFFPLAYER = 363,
|
||||
// Room for more level 2 364-399 not used
|
||||
|
||||
// level 3 chat
|
||||
LANG_SCRIPTS_RELOADED = 400,
|
||||
|
||||
@@ -477,6 +477,9 @@ void WorldSession::LogoutPlayer(bool save)
|
||||
///- Remove pet
|
||||
_player->RemovePet(NULL, PET_SAVE_AS_CURRENT, true);
|
||||
|
||||
///- Clear whisper whitelist
|
||||
_player->ClearWhisperWhiteList();
|
||||
|
||||
///- empty buyback items and save the player in the database
|
||||
// some save parts only correctly work in case player present in map/player_lists (pets, etc)
|
||||
if (save)
|
||||
|
||||
@@ -186,7 +186,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string argStr = (char*)args;
|
||||
std::string argStr = strtok((char*)args, " ");
|
||||
// whisper on
|
||||
if (argStr == "on")
|
||||
{
|
||||
@@ -205,6 +205,23 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
if (argStr == "remove")
|
||||
{
|
||||
std::string name = strtok(NULL, " ");
|
||||
if (normalizePlayerName(name))
|
||||
if (Player* player = sObjectAccessor->FindPlayerByName(name))
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->RemoveFromWhisperWhiteList(player->GetGUID());
|
||||
handler->PSendSysMessage(LANG_COMMAND_WHISPEROFFPLAYER, name);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage(LANG_PLAYER_NOT_FOUND, name);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
handler->SendSysMessage(LANG_USE_BOL);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user