From 23d50b9216cb267f52158febb24f3442047e4ec9 Mon Sep 17 00:00:00 2001 From: MangosArentLiterature <58055358+MangosArentLiterature@users.noreply.github.com> Date: Fri, 9 Apr 2021 03:18:10 -0500 Subject: [PATCH 1/5] Add /gimp - Also adds some documentation of other joke mod commands to aoclient.h. --- include/aoclient.h | 57 +++++++++++++++++++++++++++++++++++++++++- include/server.h | 5 ++++ src/commands.cpp | 20 +++++++++++++++ src/config_manager.cpp | 2 +- src/packets.cpp | 5 ++++ src/server.cpp | 1 + 6 files changed, 88 insertions(+), 2 deletions(-) diff --git a/include/aoclient.h b/include/aoclient.h index e99d417..3c2c5c1 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -231,7 +231,7 @@ class AOClient : public QObject { /** * @brief If true, the client's in-character messages will be overwritten by a randomly picked predetermined message. */ - bool is_gimped; + bool is_gimped = false; public slots: /** @@ -1399,6 +1399,60 @@ class AOClient : public QObject { */ void cmd8Ball(int argc, QStringList argv); + /** + * @brief Replaces a target client's in-character messages with strings randomly selected from gimp.txt. + * + * @details The only argument is the **the target's ID** whom the client wants to gimp. + * + * @iscommand + */ + void cmdGimp(int argc, QStringList argv); + + /** + * @brief Allows a gimped client to speak normally. + * + * @details The only argument is **the target's ID** whom the client wants to ungimp. + * + * @iscommand + */ + void cmdUnGimp(int argc, QStringList argv); + + /** + * @brief Removes all vowels from a target client's in-character messages. + * + * @details The only argument is **the target's ID** whom the client wants to disemvowel. + * + * @iscommand + */ + void cmdDisemvowel(int argc, QStringList argv); + + /** + * @brief Allows a disemvoweled client to speak normally. + * + * @details The only argument is **the target's ID** whom the client wants to undisemvowel. + * + * @iscommand + */ + void cmdUnDisemvowel(int argc, QStringList argv); + + /** + * @brief Scrambles the words of a target client's in-character messages. + * + * @details The only argument is **the target's ID** whom the client wants to shake. + * + * @iscommand + */ + void cmdShake(int argc, QStringList argv); + + /** + * @brief Allows a shaken client to speak normally. + * + * @details The only argument is **the target's ID** whom the client wants to unshake. + * + * @iscommand + */ + void cmdUnShake(int argc, QStringList argv); + ///@} /** @@ -1593,6 +1647,7 @@ class AOClient : public QObject { {"8ball", {ACLFlags.value("NONE"), 1, &AOClient::cmd8Ball}}, {"lm", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdLM}}, {"allow_blankposting", {ACLFlags.value("MODCHAT"), 0, &AOClient::cmdAllow_Blankposting}}, + {"gimp", {ACLFlags.value("MUTE"), 1, &AOClient::cmdGimp}}, }; /** diff --git a/include/server.h b/include/server.h index 6ac60ad..31e0aa9 100644 --- a/include/server.h +++ b/include/server.h @@ -243,6 +243,11 @@ class Server : public QObject { */ QStringList reprimands_list; + /** + * @brief List holding the contents of gimp.txt, used by AOClient::cmdGimp. + */ + QStringList gimp_list; + public slots: /** * @brief Handles a new connection. diff --git a/src/commands.cpp b/src/commands.cpp index b642cba..14707f3 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1276,6 +1276,26 @@ void AOClient::cmdAllow_Blankposting(int argc, QStringList argv) } } +void AOClient::cmdGimp(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_gimped) + sendServerMessage("That player is already gimped!"); + else { + sendServerMessage("Gimped player."); + target->sendServerMessage("You have been gimped! " + getReprimand()); + } + target->is_gimped = true; +} + QStringList AOClient::buildAreaList(int area_idx) { QStringList entries; diff --git a/src/config_manager.cpp b/src/config_manager.cpp index 016991e..048bd4d 100644 --- a/src/config_manager.cpp +++ b/src/config_manager.cpp @@ -182,7 +182,7 @@ bool ConfigManager::fileExists(QFileInfo* file) bool ConfigManager::verifyCommandConfig() { - QStringList filelist = {"8ball", "praise", "reprimands"}; + QStringList filelist = {"8ball", "praise", "reprimands", "gimp"}; foreach (QString filename, filelist) { QFileInfo file("config/text/" + filename + ".txt"); if (!(fileExists(&file))) { diff --git a/src/packets.cpp b/src/packets.cpp index dd4d225..99fcf70 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -441,6 +441,11 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) return invalid; } + if (is_gimped) { + QString gimp_message = server->gimp_list[(genRand(1, server->gimp_list.size() - 1))]; + incoming_msg = gimp_message; + } + last_message = incoming_msg; args.append(incoming_msg); diff --git a/src/server.cpp b/src/server.cpp index 99562c2..a8aa299 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -221,6 +221,7 @@ void Server::loadCommandConfig() magic_8ball_answers.append(loadConfigFile("8ball")); praise_list.append(loadConfigFile("praise")); reprimands_list.append(loadConfigFile("reprimands")); + gimp_list.append(loadConfigFile("gimp")); } QStringList Server::loadConfigFile(QString filename) From 43ce86ff126c447287a7cd04f371938df570247b Mon Sep 17 00:00:00 2001 From: MangosArentLiterature <58055358+MangosArentLiterature@users.noreply.github.com> Date: Fri, 9 Apr 2021 15:07:09 -0500 Subject: [PATCH 2/5] Add /ungimp --- include/aoclient.h | 1 + src/commands.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/aoclient.h b/include/aoclient.h index 3c2c5c1..d06c073 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -1648,6 +1648,7 @@ class AOClient : public QObject { {"lm", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdLM}}, {"allow_blankposting", {ACLFlags.value("MODCHAT"), 0, &AOClient::cmdAllow_Blankposting}}, {"gimp", {ACLFlags.value("MUTE"), 1, &AOClient::cmdGimp}}, + {"ungimp", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnGimp}}, }; /** diff --git a/src/commands.cpp b/src/commands.cpp index 14707f3..2b2ba26 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1296,6 +1296,26 @@ void AOClient::cmdGimp(int argc, QStringList argv) target->is_gimped = true; } +void AOClient::cmdUnGimp(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_gimped)) + sendServerMessage("That player is not gimped!"); + else { + sendServerMessage("Ungimped player."); + target->sendServerMessage("A moderator has ungimped you! " + getReprimand(true)); + } + target->is_gimped = false; +} + QStringList AOClient::buildAreaList(int area_idx) { QStringList entries; From 9b54a44a529c2fbcb227e497950cad3e7c91a2d5 Mon Sep 17 00:00:00 2001 From: MangosArentLiterature <58055358+MangosArentLiterature@users.noreply.github.com> Date: Wed, 14 Apr 2021 01:45:26 -0500 Subject: [PATCH 3/5] Add /disemvowel --- include/aoclient.h | 6 ++++-- src/commands.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ src/packets.cpp | 5 +++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/include/aoclient.h b/include/aoclient.h index 52cb9cc..d8f8f31 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -221,12 +221,12 @@ class AOClient : public QObject { /** * @brief If true, the client's in-character messages will have their word order randomised. */ - bool is_shaken; + bool is_shaken = false; /** * @brief If true, the client's in-character messages will have their vowels (English alphabet only) removed. */ - bool is_disemvoweled; + bool is_disemvoweled = false; /** * @brief If true, the client's in-character messages will be overwritten by a randomly picked predetermined message. @@ -1682,6 +1682,8 @@ class AOClient : public QObject { {"ungimp", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnGimp}}, {"baninfo", {ACLFlags.value("BAN"), 1, &AOClient::cmdBanInfo}}, {"reload", {ACLFlags.value("SUPER"), 0, &AOClient::cmdReload}}, + {"disemvowel", {ACLFlags.value("MUTE"), 1, &AOClient::cmdDisemvowel}}, + {"undisemvowel", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnDisemvowel}}, }; /** diff --git a/src/commands.cpp b/src/commands.cpp index f9c8b22..2e7ef18 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1374,6 +1374,46 @@ void AOClient::cmdReload(int argc, QStringList argv) sendServerMessage("Reloaded configurations"); } +void AOClient::cmdDisemvowel(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_disemvoweled) + sendServerMessage("That player is already disemvoweled!"); + else { + sendServerMessage("Disemvoweled player."); + target->sendServerMessage("You have been disemvoweled! " + getReprimand()); + } + target->is_disemvoweled = true; +} + +void AOClient::cmdUnDisemvowel(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_disemvoweled)) + sendServerMessage("That player is not disemvoweled!"); + else { + sendServerMessage("Undisemvoweled player."); + target->sendServerMessage("A moderator has undisemvoweled you! " + getReprimand(true)); + } + target->is_disemvoweled = false; +} + QStringList AOClient::buildAreaList(int area_idx) { QStringList entries; diff --git a/src/packets.cpp b/src/packets.cpp index cfa12ee..c211455 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -449,6 +449,11 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) incoming_msg = gimp_message; } + if (is_disemvoweled) { + QString disemvoweled_message = incoming_msg.remove(QRegExp("[AEIOUaeiou]")); + incoming_msg = disemvoweled_message; + } + last_message = incoming_msg; args.append(incoming_msg); From 8e4f8c31c74b9402808986351d3586785e89a7e4 Mon Sep 17 00:00:00 2001 From: MangosArentLiterature <58055358+MangosArentLiterature@users.noreply.github.com> Date: Wed, 14 Apr 2021 02:09:58 -0500 Subject: [PATCH 4/5] Add /shake - also adds /unshake --- include/aoclient.h | 2 ++ src/commands.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ src/packets.cpp | 6 ++++++ 3 files changed, 48 insertions(+) diff --git a/include/aoclient.h b/include/aoclient.h index d8f8f31..fa755a6 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -1684,6 +1684,8 @@ class AOClient : public QObject { {"reload", {ACLFlags.value("SUPER"), 0, &AOClient::cmdReload}}, {"disemvowel", {ACLFlags.value("MUTE"), 1, &AOClient::cmdDisemvowel}}, {"undisemvowel", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnDisemvowel}}, + {"shake", {ACLFlags.value("MUTE"), 1, &AOClient::cmdShake}}, + {"unshake", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnShake}}, }; /** diff --git a/src/commands.cpp b/src/commands.cpp index 2e7ef18..b5a47d6 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1414,6 +1414,46 @@ void AOClient::cmdUnDisemvowel(int argc, QStringList argv) target->is_disemvoweled = false; } +void AOClient::cmdShake(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_shaken) + sendServerMessage("That player is already shaken!"); + else { + sendServerMessage("Shook player."); + target->sendServerMessage("A moderator has shaken your words! " + getReprimand()); + } + target->is_shaken = true; +} + +void AOClient::cmdUnShake(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_shaken)) + sendServerMessage("That player is not shaken!"); + else { + sendServerMessage("Unshook player."); + target->sendServerMessage("A moderator has unshook you! " + getReprimand(true)); + } + target->is_shaken = false; +} + QStringList AOClient::buildAreaList(int area_idx) { QStringList entries; diff --git a/src/packets.cpp b/src/packets.cpp index c211455..a922595 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -449,6 +449,12 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) incoming_msg = gimp_message; } + if (is_shaken) { + QStringList parts = incoming_msg.split(" "); + std::random_shuffle(parts.begin(), parts.end()); + incoming_msg = parts.join(" "); + } + if (is_disemvoweled) { QString disemvoweled_message = incoming_msg.remove(QRegExp("[AEIOUaeiou]")); incoming_msg = disemvoweled_message; From a6d602e32e5fb6a6b5cf087a20eb5b798e28c21d Mon Sep 17 00:00:00 2001 From: MangosArentLiterature <58055358+MangosArentLiterature@users.noreply.github.com> Date: Wed, 14 Apr 2021 02:17:47 -0500 Subject: [PATCH 5/5] Add config/text/gimp.txt --- bin/config_sample/text/gimp.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 bin/config_sample/text/gimp.txt diff --git a/bin/config_sample/text/gimp.txt b/bin/config_sample/text/gimp.txt new file mode 100644 index 0000000..db1e8ea --- /dev/null +++ b/bin/config_sample/text/gimp.txt @@ -0,0 +1,11 @@ +I love the mods on this server! +At 3:03 PM maya went into my house and ate my corn bread +Enlargement +Do you think I am imcompetent? +WE CAN'T TRUST ANY OF THE WITNESSES THROW THEM ALL OUT +I'm not a clown, I'm the entire circus. +What if the murder, it was not a murder? +omti +<3 +what's an akashi +*punches bailiff*