diff --git a/bin/config_sample/text/praise.txt b/bin/config_sample/text/praise.txt new file mode 100644 index 0000000..5cad5b1 --- /dev/null +++ b/bin/config_sample/text/praise.txt @@ -0,0 +1,10 @@ +:3 +\o/ +Be safe! +Have fun! +Be careful! +Have a nice day! +Be responsible! +Be good! +I believe in you! + diff --git a/bin/config_sample/text/reprimands.txt b/bin/config_sample/text/reprimands.txt new file mode 100644 index 0000000..9ed1548 --- /dev/null +++ b/bin/config_sample/text/reprimands.txt @@ -0,0 +1,11 @@ +>:( +;w; +I should have you held in contempt. +You should be ashamed of yourself. +Tsk, tsk. +What did you do this time? +You're better than this. +*sigh* +Didn't anyone ever teach you manners? +Really? +Shameful. \ No newline at end of file diff --git a/include/aoclient.h b/include/aoclient.h index 214189c..71d9d06 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -161,6 +161,21 @@ class AOClient : public QObject { * @brief If true, the client may not use in-character chat. */ bool is_muted = false; + + /** + * @brief If true, the client may not use out-of-character chat. + */ + bool is_ooc_muted = false; + + /** + * @brief If true, the client may not use the music list. + */ + bool is_dj_blocked = false; + + /** + * @brief If true, the client may not use the judge controls. + */ + bool is_wtce_blocked = false; /** * @brief Represents the client's client software, and its version. @@ -329,7 +344,6 @@ class AOClient : public QObject { * @brief Sends all four types of ARUP to the client. */ void fullArup(); - /** * @brief Sends an out-of-character message originating from the server to the client. * @@ -1009,6 +1023,8 @@ class AOClient : public QObject { * @see AOClient::cmdG() */ void cmdGM(int argc, QStringList argv); + + // Casing/RP /** * @brief Mutes a client. @@ -1022,7 +1038,7 @@ class AOClient : public QObject { void cmdMute(int argc, QStringList argv); /** - * @brief Removes the muted status a client. + * @brief Removes the muted status from a client. * * @details The only argument is the **target client's user ID**. * @@ -1030,8 +1046,74 @@ class AOClient : public QObject { * * @see #is_muted */ - void cmdUnmute(int argc, QStringList argv); + void cmdUnMute(int argc, QStringList argv); + /** + * @brief OOC-mutes a client. + * + * @details The only argument is the **target client's user ID**. + * + * @iscommand + * + * @see #is_ooc_muted + */ + void cmdOocMute(int argc, QStringList argv); + + /** + * @brief Removes the OOC-muted status from a client. + * + * @details The only argument is the **target client's user ID**. + * + * @iscommand + * + * @see #is_ooc_muted + */ + void cmdOocUnMute(int argc, QStringList argv); + + /** + * @brief DJ-blocks a client. + * + * @details The only argument is the **target client's user ID**. + * + * @iscommand + * + * @see #is_dj_blocked + */ + void cmdBlockDj(int argc, QStringList argv); + + /** + * @brief Removes the DJ-blocked status from a client. + * + * @details The only argument is the **target client's user ID**. + * + * @iscommand + * + * @see #is_dj_blocked + */ + void cmdUnBlockDj(int argc, QStringList argv); + + /** + * @brief WTCE-blocks a client. + * + * @details The only argument is the **target client's user ID**. + * + * @iscommand + * + * @see #is_wtce_blocked + */ + void cmdBlockWtce(int argc, QStringList argv); + + /** + * @brief Removes the WTCE-blocked status from a client. + * + * @details The only argument is the **target client's user ID**. + * + * @iscommand + * + * @see #is_wtce_blocked + */ + void cmdUnBlockWtce(int argc, QStringList argv); + /** * @brief Lists the last five bans made on the server. * @@ -1329,6 +1411,7 @@ class AOClient : public QObject { * @return The parsed text, converted into their respective durations, summed up, then converted into seconds. */ long long parseTime(QString input); + QString getReprimand(bool positive = false); ///@} @@ -1424,7 +1507,15 @@ class AOClient : public QObject { {"m", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdM}}, {"gm", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdGM}}, {"mute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdMute}}, - {"unmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnmute}}, + {"unmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnMute}}, + {"oocmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocMute}}, + {"ooc_mute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocMute}}, + {"oocunmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocUnMute}}, + {"ooc_unmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocUnMute}}, + {"blockdj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockDj}}, + {"unblockdj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockDj}}, + {"blockwtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockWtce}}, + {"unblockwtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockWtce}}, {"bans", {ACLFlags.value("BAN"), 0, &AOClient::cmdBans}}, {"unban", {ACLFlags.value("BAN"), 1, &AOClient::cmdUnBan}}, {"removeuser", {ACLFlags.value("MODIFY_USERS"), 1, &AOClient::cmdRemoveUser}}, diff --git a/src/commands.cpp b/src/commands.cpp index 2455016..3f3aa4e 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -953,38 +953,6 @@ void AOClient::cmdGM(int argc, QStringList argv) } } -void AOClient::cmdMute(int argc, QStringList argv) -{ - bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); - if (!conv_ok) { - sendServerMessage("Invalid user ID."); - return; - } - - if (server->getClientByID(uid)->is_muted) - sendServerMessage("That player is already muted!"); - else - sendServerMessage("Muted player."); - server->getClientByID(uid)->is_muted = true; -} - -void AOClient::cmdUnmute(int argc, QStringList argv) -{ - bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); - if (!conv_ok) { - sendServerMessage("Invalid user ID."); - return; - } - - if (!server->getClientByID(uid)->is_muted) - sendServerMessage("That player is already unmuted!"); - else - sendServerMessage("Unmuted player."); - server->getClientByID(uid)->is_muted = false; -} - void AOClient::cmdBans(int argc, QStringList argv) { QStringList recent_bans; @@ -1035,6 +1003,167 @@ void AOClient::cmdAbout(int argc, QStringList argv) sendPacket("CT", {"The akashi dev team", "Thank you for using akashi! Made with love by scatterflower, with help from in1tiate and Salanto. akashi " + QCoreApplication::applicationVersion()}); } + +void AOClient::cmdMute(int argc, QStringList argv) +{ + bool conv_ok = false; + int uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + + AOClient* target = server->getClientByID(uid); + + if (target->is_muted) + sendServerMessage("That player is already muted!"); + else { + sendServerMessage("Muted player."); + target->sendServerMessage("You were muted by a moderator. " + getReprimand()); + } + target->is_muted = true; +} + +void AOClient::cmdUnMute(int argc, QStringList argv) +{ + bool conv_ok = false; + int uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + + AOClient* target = server->getClientByID(uid); + + if (!target->is_muted) + sendServerMessage("That player is not muted!"); + else { + sendServerMessage("Unmuted player."); + target->sendServerMessage("You were unmuted by a moderator. " + getReprimand(true)); + } + target->is_muted = false; +} + +void AOClient::cmdOocMute(int argc, QStringList argv) +{ + bool conv_ok = false; + int uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + + AOClient* target = server->getClientByID(uid); + + if (target->is_ooc_muted) + sendServerMessage("That player is already OOC muted!"); + else { + sendServerMessage("OOC muted player."); + target->sendServerMessage("You were OOC muted by a moderator. " + getReprimand()); + } + target->is_ooc_muted = true; +} + +void AOClient::cmdOocUnMute(int argc, QStringList argv) +{ + bool conv_ok = false; + int uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + + AOClient* target = server->getClientByID(uid); + + if (!target->is_ooc_muted) + sendServerMessage("That player is not OOC muted!"); + else { + sendServerMessage("OOC unmuted player."); + target->sendServerMessage("You were OOC unmuted by a moderator. " + getReprimand(true)); + } + target->is_ooc_muted = false; +} + +void AOClient::cmdBlockDj(int argc, QStringList argv) +{ + bool conv_ok = false; + int uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + + AOClient* target = server->getClientByID(uid); + + if (target->is_dj_blocked) + sendServerMessage("That player is already DJ blocked!"); + else { + sendServerMessage("DJ blocked player."); + target->sendServerMessage("You were blocked from changing the music by a moderator. " + getReprimand()); + } + target->is_dj_blocked = true; +} + +void AOClient::cmdUnBlockDj(int argc, QStringList argv) +{ + bool conv_ok = false; + int uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + + AOClient* target = server->getClientByID(uid); + + if (!target->is_dj_blocked) + sendServerMessage("That player is not DJ blocked!"); + else { + sendServerMessage("DJ permissions restored to player."); + target->sendServerMessage("A moderator restored your music permissions. " + getReprimand(true)); + } + target->is_dj_blocked = false; +} + +void AOClient::cmdBlockWtce(int argc, QStringList argv) +{ + bool conv_ok = false; + int uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + + AOClient* target = server->getClientByID(uid); + + if (target->is_wtce_blocked) + sendServerMessage("That player is already judge blocked!"); + else { + sendServerMessage("Revoked player's access to judge controls."); + target->sendServerMessage("A moderator revoked your judge controls access. " + getReprimand()); + } + target->is_wtce_blocked = true; +} + +void AOClient::cmdUnBlockWtce(int argc, QStringList argv) +{ + bool conv_ok = false; + int uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + + AOClient* target = server->getClientByID(uid); + + if (!target->is_wtce_blocked) + sendServerMessage("That player is not judge blocked!"); + else { + sendServerMessage("Restored player's access to judge controls."); + target->sendServerMessage("A moderator restored your judge controls access. " + getReprimand(true)); + } + target->is_wtce_blocked = false; +} + QStringList AOClient::buildAreaList(int area_idx) { QStringList entries; @@ -1193,3 +1322,21 @@ long long AOClient::parseTime(QString input) return total; } + +QString AOClient::getReprimand(bool positive) +{ + QString filename = positive ? "praise" : "reprimands"; + QFileInfo reprimands_info("config/text/" + filename + ".txt"); + if (!(reprimands_info.exists() && reprimands_info.isFile())) { + qWarning() << filename + ".txt doesn't exist!"; + return ""; + } + QStringList reprimands; + QFile file("config/text/" + filename + ".txt"); + file.open(QIODevice::ReadOnly | QIODevice::Text); + while (!file.atEnd()) { + reprimands.append(file.readLine().trimmed()); + } + file.close(); + return reprimands[genRand(0, reprimands.size() - 1)]; +} diff --git a/src/packets.cpp b/src/packets.cpp index 1bd3f0d..7d24fe4 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -172,6 +172,11 @@ void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket pa void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket packet) { + if (is_ooc_muted) { + sendServerMessage("You are OOC muted, and cannot speak."); + return; + } + ooc_name = dezalgo(argv[0]).replace(QRegExp("\\[|\\]|\\{|\\}|\\#|\\$|\\%|\\&"), ""); // no fucky wucky shit here if (ooc_name.isEmpty() || ooc_name == server->getServerName()) // impersonation & empty name protection return; @@ -203,6 +208,10 @@ void AOClient::pktPing(AreaData* area, int argc, QStringList argv, AOPacket pack void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPacket packet) { + if (is_dj_blocked) { + sendServerMessage("You are blocked from changing the music."); + return; + } // Due to historical reasons, this // packet has two functions: // Change area, and set music. @@ -243,6 +252,10 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack void AOClient::pktWtCe(AreaData* area, int argc, QStringList argv, AOPacket packet) { + if (is_wtce_blocked) { + sendServerMessage("You are blocked from using the judge controls."); + return; + } if (QDateTime::currentDateTime().toSecsSinceEpoch() - last_wtce_time <= 5) return; last_wtce_time = QDateTime::currentDateTime().toSecsSinceEpoch(); @@ -251,6 +264,10 @@ void AOClient::pktWtCe(AreaData* area, int argc, QStringList argv, AOPacket pack void AOClient::pktHpBar(AreaData* area, int argc, QStringList argv, AOPacket packet) { + if (is_wtce_blocked) { + sendServerMessage("You are blocked from using the judge controls."); + return; + } if (argv[0] == "1") { area->def_hp = std::min(std::max(0, argv[1].toInt()), 10); }