Core/Commands: Allow muting offline players - the mute will become effective on next player login.

This commit is contained in:
Machiavelli
2011-07-27 17:51:57 +02:00
parent 2eb69330b4
commit 0dcc229071
7 changed files with 25 additions and 10 deletions

View File

@@ -61,7 +61,7 @@ CREATE TABLE `account` (
`last_login` timestamp NOT NULL default '0000-00-00 00:00:00',
`online` tinyint(4) NOT NULL default '0',
`expansion` tinyint(3) unsigned NOT NULL default '2',
`mutetime` bigint(40) unsigned NOT NULL default '0',
`mutetime` bigint(40) NOT NULL default '0',
`locale` tinyint(3) unsigned NOT NULL default '0',
`recruiter` int(11) NOT NULL default '0',
PRIMARY KEY (`id`),

View File

@@ -27147,6 +27147,7 @@ INSERT INTO `trinity_string` (`entry`,`content_default`,`content_loc1`,`content_
(280, 'Vendor has too many items (max 128)', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(281, 'You can''t kick self, logout instead', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(282, 'Player %s kicked.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(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),
(284, 'Accepting Whisper: %s', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(285, 'Accepting Whisper: ON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(286, 'Accepting Whisper: OFF', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),

View File

@@ -0,0 +1 @@
ALTER TABLE `account` CHANGE `mutetime` `mutetime` bigint(40) NOT NULL DEFAULT 0;

View File

@@ -0,0 +1,2 @@
INSERT INTO `trinity_string` (`entry`,`content_default`) VALUES
(283,'You have disabled %s\'s chat for %u minutes, effective at the player\'s next login. Reason: %s.');

View File

@@ -76,19 +76,24 @@ bool ChatHandler::HandleMuteCommand(const char* args)
if (HasLowerSecurity (target, target_guid, true))
return false;
time_t mutetime = time(NULL) + notspeaktime*60;
if (target)
{
//! Target is online, mute will be in effect right away.
int64 mutetime = time(NULL) + notspeaktime * MINUTE;
target->GetSession()->m_muteTime = mutetime;
LoginDatabase.PExecute("UPDATE account SET mutetime = " UI64FMTD " WHERE id = '%u'", uint64(mutetime), account_id);
if (target)
LoginDatabase.PExecute("UPDATE account SET mutetime = " SI64FMTD " WHERE id = '%u'", mutetime, account_id);
ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime, mutereasonstr.c_str());
}
else
{
//! Target is offline, mute will be in effect starting from the next login.
int32 muteTime = -(notspeaktime * MINUTE);
LoginDatabase.PExecute("UPDATE account SET mutetime = %d WHERE id = %u", muteTime, account_id);
}
std::string nameLink = playerLink(target_name);
PSendSysMessage(LANG_YOU_DISABLE_CHAT, nameLink.c_str(), notspeaktime, mutereasonstr.c_str());
PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notspeaktime, mutereasonstr.c_str());
return true;
}

View File

@@ -267,7 +267,7 @@ enum TrinityStrings
LANG_COMMAND_ADDVENDORITEMITEMS = 280,
LANG_COMMAND_KICKSELF = 281,
LANG_COMMAND_KICKMESSAGE = 282,
// 283, not used
LANG_COMMAND_DISABLE_CHAT_DELAYED = 283,
LANG_COMMAND_WHISPERACCEPTING = 284,
LANG_COMMAND_WHISPERON = 285,
LANG_COMMAND_WHISPEROFF = 286,

View File

@@ -889,7 +889,13 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
K.SetHexStr (fields[1].GetCString());
time_t mutetime = time_t (fields[7].GetUInt64());
int64 mutetime = fields[7].GetInt64();
//! Negative mutetime indicates amount of seconds to be muted effective on next login - which is now.
if (mutetime < 0)
{
mutetime = time(NULL) + abs(mutetime);
LoginDatabase.PExecute("UPDATE account SET mutetime = " SI64FMTD " WHERE id = '%u'", mutetime, id);
}
locale = LocaleConstant (fields[8].GetUInt8());
if (locale >= TOTAL_LOCALES)