From 388ad345a51b78a91ab9f4e04936dd89605d8ae9 Mon Sep 17 00:00:00 2001 From: MangosArentLiterature <58055358+MangosArentLiterature@users.noreply.github.com> Date: Sat, 17 Apr 2021 14:15:04 -0500 Subject: [PATCH 1/2] Add /mutepm --- include/aoclient.h | 13 +++++++++++++ src/commands/messaging.cpp | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/aoclient.h b/include/aoclient.h index 3ab8429..5bb48d9 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -249,6 +249,11 @@ class AOClient : public QObject { */ bool is_afk = false; + /** + * @brief If true, the client will not recieve PM messages. + */ + bool pm_mute = false; + /** * @brief Timer for tracking user interaction. Automatically restarted whenever a user interacts (i.e. sends any packet besides CH) */ @@ -1438,6 +1443,13 @@ class AOClient : public QObject { */ void cmdUnShake(int argc, QStringList argv); + /** + * @brief Toggles whether a client will recieve @ref cmdPM private messages or not. + * + * @details No arguments. + */ + void cmdMutePM(int argc, QStringList argv); + ///@} /** @@ -1850,6 +1862,7 @@ class AOClient : public QObject { {"allowiniswap", {ACLFlags.value("CM"), 0, &AOClient::cmdAllowIniswap}}, {"allow_iniswap", {ACLFlags.value("CM"), 0, &AOClient::cmdAllowIniswap}}, {"afk", {ACLFlags.value("NONE"), 0, &AOClient::cmdAfk}}, + {"mutepm", {ACLFlags.value("NONE"), 0, &AOClient::cmdMutePM}}, }; /** diff --git a/src/commands/messaging.cpp b/src/commands/messaging.cpp index 9a852a6..0273d70 100644 --- a/src/commands/messaging.cpp +++ b/src/commands/messaging.cpp @@ -116,6 +116,10 @@ void AOClient::cmdPM(int arc, QStringList argv) sendServerMessage("No client with that ID found."); return; } + if (target_client->pm_mute) { + sendServerMessage("That user is not recieving PMs."); + return; + } QString message = argv.join(" "); //...which means it will not end up as part of the message target_client->sendServerMessage("Message from " + ooc_name + " (" + QString::number(id) + "): " + message); } @@ -274,3 +278,10 @@ void AOClient::cmdUnShake(int argc, QStringList argv) } target->is_shaken = false; } + +void AOClient::cmdMutePM(int argc, QStringList argv) +{ + pm_mute = !pm_mute; + QString str_en = pm_mute ? "muted" : "unmuted"; + sendServerMessage("PM's are now " + str_en); +} From e52d85c01a6bc6af77eed613b650fab004561dfb Mon Sep 17 00:00:00 2001 From: MangosArentLiterature <58055358+MangosArentLiterature@users.noreply.github.com> Date: Sat, 17 Apr 2021 15:20:28 -0500 Subject: [PATCH 2/2] Add /toggleadverts --- include/aoclient.h | 13 +++++++++++++ src/commands/messaging.cpp | 13 ++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/aoclient.h b/include/aoclient.h index 5bb48d9..381e34b 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -254,6 +254,11 @@ class AOClient : public QObject { */ bool pm_mute = false; + /** + * @brief If true, the client will recieve advertisements. + */ + bool advert_enabled = true; + /** * @brief Timer for tracking user interaction. Automatically restarted whenever a user interacts (i.e. sends any packet besides CH) */ @@ -1450,6 +1455,13 @@ class AOClient : public QObject { */ void cmdMutePM(int argc, QStringList argv); + /** + * @brief Toggles whether a client will recieve @ref cmdNeed "advertisement" messages. + * + * @details No arguments. + */ + void cmdToggleAdverts(int argc, QStringList argv); + ///@} /** @@ -1863,6 +1875,7 @@ class AOClient : public QObject { {"allow_iniswap", {ACLFlags.value("CM"), 0, &AOClient::cmdAllowIniswap}}, {"afk", {ACLFlags.value("NONE"), 0, &AOClient::cmdAfk}}, {"mutepm", {ACLFlags.value("NONE"), 0, &AOClient::cmdMutePM}}, + {"toggleadverts", {ACLFlags.value("NONE"), 0, &AOClient::cmdToggleAdverts}}, }; /** diff --git a/src/commands/messaging.cpp b/src/commands/messaging.cpp index 0273d70..a086e8d 100644 --- a/src/commands/messaging.cpp +++ b/src/commands/messaging.cpp @@ -77,7 +77,11 @@ void AOClient::cmdNeed(int argc, QStringList argv) { QString sender_area = server->area_names.value(current_area); QString sender_message = argv.join(" "); - sendServerBroadcast({"=== Advert ===\n[" + sender_area + "] needs " + sender_message+ "."}); + for (AOClient* client : server->clients) { + if (client->advert_enabled) { + client->sendServerMessage({"=== Advert ===\n[" + sender_area + "] needs " + sender_message+ "."}); + } + } } void AOClient::cmdSwitch(int argc, QStringList argv) @@ -285,3 +289,10 @@ void AOClient::cmdMutePM(int argc, QStringList argv) QString str_en = pm_mute ? "muted" : "unmuted"; sendServerMessage("PM's are now " + str_en); } + +void AOClient::cmdToggleAdverts(int argc, QStringList argv) +{ + advert_enabled = !advert_enabled; + QString str_en = advert_enabled ? "on" : "off"; + sendServerMessage("Advertisements turned " + str_en); +}