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)