From 56ef0d5958f4a1f45211e25413f0f80825c889f3 Mon Sep 17 00:00:00 2001 From: Salanto Date: Fri, 12 Mar 2021 18:41:21 +0100 Subject: [PATCH 1/5] Add /gm command --- include/aoclient.h | 3 +++ src/commands.cpp | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/aoclient.h b/include/aoclient.h index 1869bc6..75eaa39 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -79,6 +79,7 @@ class AOClient : public QObject { {"MOTD", 1ULL << 7}, {"ANNOUNCE", 1ULL << 8}, {"MODCHAT", 1ULL << 9}, + {"GM", 1ULL << 10}, {"SUPER", ~0ULL} }; @@ -220,6 +221,7 @@ class AOClient : public QObject { void cmdKick(int argc, QStringList argv); void cmdAnnounce(int argc, QStringList argv); void cmdM(int argc, QStringList argv); + void cmdGM(int argc, QStringList argv); // Casing/RP void cmdPlay(int argc, QStringList argv); void cmdNeed(int argc, QStringList argv); @@ -308,6 +310,7 @@ class AOClient : public QObject { {"motd", {ACLFlags.value("NONE"), 0, &AOClient::cmdMOTD}}, {"announce", {ACLFlags.value("ANNOUNCE"), 1, &AOClient::cmdAnnounce}}, {"m", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdM}}, + {"gm", {ACLFlags.value("GM"), 1, &AOClient::cmdGM}} }; QString partial_packet; diff --git a/src/commands.cpp b/src/commands.cpp index 8b87a42..71e7557 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -890,6 +890,22 @@ void AOClient::cmdM(int argc, QStringList argv) return; } +void AOClient::cmdGM(int argc, QStringList argv) +{ + if (checkAuth(ACLFlags.value("MOTD"))) { + QString sender_name = ooc_name; + QString sender_area = server->area_names.value(current_area); + QString sender_message = argv.join(" "); + for (AOClient* client : server->clients) { + if (client->global_enabled) + client->sendPacket("CT", {"[G][" + sender_area + "]" + "["+sender_name+"][M]", sender_message}); + } + } + else { + sendServerMessage("You do not have permission to use Global Mod Message."); + } +} + QStringList AOClient::buildAreaList(int area_idx) { QStringList entries; From 69911835eee7a1271edfaa34ca2c8702499fdbea Mon Sep 17 00:00:00 2001 From: Salanto Date: Fri, 12 Mar 2021 18:44:35 +0100 Subject: [PATCH 2/5] Wrong permission --- src/commands.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands.cpp b/src/commands.cpp index 71e7557..8f7ad14 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -892,7 +892,7 @@ void AOClient::cmdM(int argc, QStringList argv) void AOClient::cmdGM(int argc, QStringList argv) { - if (checkAuth(ACLFlags.value("MOTD"))) { + if (checkAuth(ACLFlags.value("GM"))) { QString sender_name = ooc_name; QString sender_area = server->area_names.value(current_area); QString sender_message = argv.join(" "); From 79d64e6153b4f8b26c32f81e6970021cac214f03 Mon Sep 17 00:00:00 2001 From: Salanto Date: Fri, 12 Mar 2021 22:12:33 +0100 Subject: [PATCH 3/5] Send music update to area instead of a single client --- src/commands.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commands.cpp b/src/commands.cpp index 8b87a42..45301a0 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -727,7 +727,8 @@ void AOClient::cmdPlay(int argc, QStringList argv) QString song = argv.join(" "); area->current_music = song; area->music_played_by = showname; - sendPacket("MC", {song, QString::number(server->getCharID(current_char)), showname, "1", "0"}); + AOPacket music_change("MC", {song, QString::number(server->getCharID(current_char)), showname, "1", "0"}); + server->broadcast(music_change, current_area); } void AOClient::cmdAreaKick(int argc, QStringList argv) From ed03666a2c5f1b3d142d4fa60d5e42a05a04b5d3 Mon Sep 17 00:00:00 2001 From: Salanto Date: Fri, 12 Mar 2021 22:14:45 +0100 Subject: [PATCH 4/5] Change permission, remove unused permission --- include/aoclient.h | 1 - src/commands.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/aoclient.h b/include/aoclient.h index 75eaa39..6fbb981 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -79,7 +79,6 @@ class AOClient : public QObject { {"MOTD", 1ULL << 7}, {"ANNOUNCE", 1ULL << 8}, {"MODCHAT", 1ULL << 9}, - {"GM", 1ULL << 10}, {"SUPER", ~0ULL} }; diff --git a/src/commands.cpp b/src/commands.cpp index 8f7ad14..2cd968f 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -892,7 +892,7 @@ void AOClient::cmdM(int argc, QStringList argv) void AOClient::cmdGM(int argc, QStringList argv) { - if (checkAuth(ACLFlags.value("GM"))) { + if (checkAuth(ACLFlags.value("MODCHAT"))) { QString sender_name = ooc_name; QString sender_area = server->area_names.value(current_area); QString sender_message = argv.join(" "); From 834f908d841fe4271c13b06160563d2b353a675a Mon Sep 17 00:00:00 2001 From: Salanto Date: Fri, 12 Mar 2021 22:17:19 +0100 Subject: [PATCH 5/5] For real this time --- include/aoclient.h | 2 +- src/commands.cpp | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/include/aoclient.h b/include/aoclient.h index 6fbb981..4ff94c7 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -309,7 +309,7 @@ class AOClient : public QObject { {"motd", {ACLFlags.value("NONE"), 0, &AOClient::cmdMOTD}}, {"announce", {ACLFlags.value("ANNOUNCE"), 1, &AOClient::cmdAnnounce}}, {"m", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdM}}, - {"gm", {ACLFlags.value("GM"), 1, &AOClient::cmdGM}} + {"gm", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdGM}} }; QString partial_packet; diff --git a/src/commands.cpp b/src/commands.cpp index 2cd968f..9d98004 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -892,18 +892,14 @@ void AOClient::cmdM(int argc, QStringList argv) void AOClient::cmdGM(int argc, QStringList argv) { - if (checkAuth(ACLFlags.value("MODCHAT"))) { - QString sender_name = ooc_name; - QString sender_area = server->area_names.value(current_area); - QString sender_message = argv.join(" "); - for (AOClient* client : server->clients) { - if (client->global_enabled) - client->sendPacket("CT", {"[G][" + sender_area + "]" + "["+sender_name+"][M]", sender_message}); + QString sender_name = ooc_name; + QString sender_area = server->area_names.value(current_area); + QString sender_message = argv.join(" "); + for (AOClient* client : server->clients) { + if (client->global_enabled) { + client->sendPacket("CT", {"[G][" + sender_area + "]" + "["+sender_name+"][M]", sender_message}); } } - else { - sendServerMessage("You do not have permission to use Global Mod Message."); - } } QStringList AOClient::buildAreaList(int area_idx)