Skip to content

Commit 0dcc229

Browse files
committed
Core/Commands: Allow muting offline players - the mute will become effective on next player login.
1 parent 2eb6933 commit 0dcc229

File tree

7 files changed

+25
-10
lines changed

7 files changed

+25
-10
lines changed

sql/base/auth_database.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ CREATE TABLE `account` (
6161
`last_login` timestamp NOT NULL default '0000-00-00 00:00:00',
6262
`online` tinyint(4) NOT NULL default '0',
6363
`expansion` tinyint(3) unsigned NOT NULL default '2',
64-
`mutetime` bigint(40) unsigned NOT NULL default '0',
64+
`mutetime` bigint(40) NOT NULL default '0',
6565
`locale` tinyint(3) unsigned NOT NULL default '0',
6666
`recruiter` int(11) NOT NULL default '0',
6767
PRIMARY KEY (`id`),

sql/base/world_database.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27147,6 +27147,7 @@ INSERT INTO `trinity_string` (`entry`,`content_default`,`content_loc1`,`content_
2714727147
(280, 'Vendor has too many items (max 128)', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
2714827148
(281, 'You can''t kick self, logout instead', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
2714927149
(282, 'Player %s kicked.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
27150+
(283, 'You have disabled %s\'s chat for %u minutes, effective at the player\'s next login. Reason: %s.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
2715027151
(284, 'Accepting Whisper: %s', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
2715127152
(285, 'Accepting Whisper: ON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
2715227153
(286, 'Accepting Whisper: OFF', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE `account` CHANGE `mutetime` `mutetime` bigint(40) NOT NULL DEFAULT 0;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
INSERT INTO `trinity_string` (`entry`,`content_default`) VALUES
2+
(283,'You have disabled %s\'s chat for %u minutes, effective at the player\'s next login. Reason: %s.');

src/server/game/Chat/Commands/Level2.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,24 @@ bool ChatHandler::HandleMuteCommand(const char* args)
7676
if (HasLowerSecurity (target, target_guid, true))
7777
return false;
7878

79-
time_t mutetime = time(NULL) + notspeaktime*60;
80-
8179
if (target)
80+
{
81+
//! Target is online, mute will be in effect right away.
82+
int64 mutetime = time(NULL) + notspeaktime * MINUTE;
8283
target->GetSession()->m_muteTime = mutetime;
83-
84-
LoginDatabase.PExecute("UPDATE account SET mutetime = " UI64FMTD " WHERE id = '%u'", uint64(mutetime), account_id);
85-
86-
if (target)
84+
LoginDatabase.PExecute("UPDATE account SET mutetime = " SI64FMTD " WHERE id = '%u'", mutetime, account_id);
8785
ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime, mutereasonstr.c_str());
86+
}
87+
else
88+
{
89+
//! Target is offline, mute will be in effect starting from the next login.
90+
int32 muteTime = -(notspeaktime * MINUTE);
91+
LoginDatabase.PExecute("UPDATE account SET mutetime = %d WHERE id = %u", muteTime, account_id);
92+
}
8893

8994
std::string nameLink = playerLink(target_name);
9095

91-
PSendSysMessage(LANG_YOU_DISABLE_CHAT, nameLink.c_str(), notspeaktime, mutereasonstr.c_str());
96+
PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notspeaktime, mutereasonstr.c_str());
9297

9398
return true;
9499
}

src/server/game/Miscellaneous/Language.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ enum TrinityStrings
267267
LANG_COMMAND_ADDVENDORITEMITEMS = 280,
268268
LANG_COMMAND_KICKSELF = 281,
269269
LANG_COMMAND_KICKMESSAGE = 282,
270-
// 283, not used
270+
LANG_COMMAND_DISABLE_CHAT_DELAYED = 283,
271271
LANG_COMMAND_WHISPERACCEPTING = 284,
272272
LANG_COMMAND_WHISPERON = 285,
273273
LANG_COMMAND_WHISPEROFF = 286,

src/server/game/Server/WorldSocket.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,13 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
889889

890890
K.SetHexStr (fields[1].GetCString());
891891

892-
time_t mutetime = time_t (fields[7].GetUInt64());
892+
int64 mutetime = fields[7].GetInt64();
893+
//! Negative mutetime indicates amount of seconds to be muted effective on next login - which is now.
894+
if (mutetime < 0)
895+
{
896+
mutetime = time(NULL) + abs(mutetime);
897+
LoginDatabase.PExecute("UPDATE account SET mutetime = " SI64FMTD " WHERE id = '%u'", mutetime, id);
898+
}
893899

894900
locale = LocaleConstant (fields[8].GetUInt8());
895901
if (locale >= TOTAL_LOCALES)

0 commit comments

Comments
 (0)