diff --git a/include/aoclient.h b/include/aoclient.h index 9da4658..332e043 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -219,7 +219,8 @@ class AOClient : public QObject { {"ANNOUNCE", 1ULL << 8 }, {"MODCHAT", 1ULL << 9 }, {"MUTE", 1ULL << 10}, - {"SAVETEST", 1ULL << 11}, + {"UNCM", 1ULL << 11}, + {"SAVETEST", 1ULL << 12}, {"SUPER", ~0ULL }, }; @@ -1453,6 +1454,15 @@ class AOClient : public QObject { */ void cmdUnShake(int argc, QStringList argv); + /** + * @brief Toggles whether this client is considered AFK. + * + * @details No arguments. + * + * @iscommand + */ + void cmdAfk(int argc, QStringList argv); + ///@} /** @@ -1620,16 +1630,6 @@ class AOClient : public QObject { */ void cmdCurrentMusic(int argc, QStringList argv); - - /** - * @brief Toggles whether this client is considered AFK. - * - * @details No arguments. - * - * @iscommand - */ - void cmdAfk(int argc, QStringList argv); - ///@} /** @@ -1886,6 +1886,18 @@ class AOClient : public QObject { {"savetestimony", {ACLFlags.value("NONE"), 1, &AOClient::cmdSaveTestimony}}, {"loadtestimony", {ACLFlags.value("CM"), 1, &AOClient::cmdLoadTestimony}}, {"permitsaving", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdPermitSaving}}, + {"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}}, + {"blockwtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockWtce}}, + {"block_wtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockWtce}}, + {"unblockwtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockWtce}}, + {"unblock_wtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockWtce}}, + {"blockdj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockDj}}, + {"block_dj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockDj}}, + {"unblockdj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockDj}}, + {"unblock_dj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockDj}}, }; /** @@ -1944,6 +1956,13 @@ class AOClient : public QObject { * @param action String containing the info that is being recorded. */ void updateJudgeLog(AreaData* area, AOClient* client, QString action); + + /** + * @brief A helper function for decoding AO encoding from a QString. + * + * @param incoming_message QString to be decoded. + */ + QString decodeMessage(QString incoming_message); }; #endif // AOCLIENT_H diff --git a/src/commands/area.cpp b/src/commands/area.cpp index f81c618..efa55f1 100644 --- a/src/commands/area.cpp +++ b/src/commands/area.cpp @@ -61,9 +61,36 @@ void AOClient::cmdCM(int argc, QStringList argv) void AOClient::cmdUnCM(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - int removed = area->owners.removeAll(id); - area->invited.removeAll(id); - sendServerMessage("You are no longer CM in this area."); + int uid; + + if (area->owners.isEmpty()) { + sendServerMessage("There are no CMs in this area."); + return; + } + else if (argc == 0) { + uid = id; + sendServerMessage("You are no longer CM in this area."); + } + else if (checkAuth(ACLFlags.value("UNCM")) && argc == 1) { + bool conv_ok = false; + uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + if (!area->owners.contains(uid)) { + sendServerMessage("That user is not CMed."); + return; + } + AOClient* target = server->getClientByID(uid); + target->sendServerMessage("You have been unCMed by a moderator."); + } + else { + sendServerMessage("Invalid command."); + return; + } + area->owners.removeAll(uid); + area->invited.removeAll(uid); arup(ARUPType::CM, true); if (area->owners.isEmpty()) { area->invited.clear(); @@ -283,9 +310,3 @@ void AOClient::cmdJudgeLog(int argc, QStringList argv) sendServerMessage(filteredmessage); } } - -void AOClient::cmdAfk(int argc, QStringList argv) -{ - is_afk = true; - sendServerMessage("You are now AFK."); -} diff --git a/src/commands/messaging.cpp b/src/commands/messaging.cpp index 9a852a6..e8517c2 100644 --- a/src/commands/messaging.cpp +++ b/src/commands/messaging.cpp @@ -274,3 +274,9 @@ void AOClient::cmdUnShake(int argc, QStringList argv) } target->is_shaken = false; } + +void AOClient::cmdAfk(int argc, QStringList argv) +{ + is_afk = true; + sendServerMessage("You are now AFK."); +} diff --git a/src/commands/music.cpp b/src/commands/music.cpp index 4bde396..2ae0f71 100644 --- a/src/commands/music.cpp +++ b/src/commands/music.cpp @@ -22,6 +22,10 @@ void AOClient::cmdPlay(int argc, QStringList argv) { + if (is_dj_blocked) { + sendServerMessage("You are blocked from changing the music."); + return; + } AreaData* area = server->areas[current_area]; QString song = argv.join(" "); area->current_music = song; diff --git a/src/main.cpp b/src/main.cpp index 8579592..e8b63e0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -62,7 +62,10 @@ int main(int argc, char* argv[]) } server = new Server(settings.port, settings.ws_port); - QObject::connect(server, &Server::reloadRequest, advertiser, &Advertiser::reloadRequested); + + if (advertiser != nullptr) { + QObject::connect(server, &Server::reloadRequest, advertiser, &Advertiser::reloadRequested); + } server->start(); } } else { diff --git a/src/packets.cpp b/src/packets.cpp index 6ddce8a..5ffede7 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -210,10 +210,6 @@ 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. @@ -225,6 +221,10 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack for (QString song : server->music_list) { if (song == argument || song == "~stop.mp3") { // ~stop.mp3 is a dummy track used by 2.9+ // We have a song here + if (is_dj_blocked) { + sendServerMessage("You are blocked from changing the music."); + return; + } QString effects; if (argc >= 4) effects = argv[3]; @@ -724,8 +724,9 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) area->statement = area->statement - 1; args = playTestimony(); } + QString decoded_message = decodeMessage(args[4]); //Get rid of that pesky encoding first. QRegularExpression jump("(?>)(?[0,1,2,3,4,5,6,7,8,9]+)"); - QRegularExpressionMatch match = jump.match(args[4]); + QRegularExpressionMatch match = jump.match(decoded_message); if (match.hasMatch()) { pos = "wit"; area->statement = match.captured("int").toInt(); @@ -773,3 +774,12 @@ void AOClient::updateJudgeLog(AreaData* area, AOClient* client, QString action) } else area->judgelog.append(logmessage); } + +QString AOClient::decodeMessage(QString incoming_message) +{ + QString decoded_message = incoming_message.replace("", "#") + .replace("", "%") + .replace("", "$") + .replace("", "&"); + return decoded_message; +}