From 0b024abe5c9d1624458e6d40b1fee0984b83e01c Mon Sep 17 00:00:00 2001 From: in1tiate Date: Tue, 2 Mar 2021 20:45:01 -0600 Subject: [PATCH] hook into ACL system for CM shenanigans --- include/aoclient.h | 13 +++++++------ src/aoclient.cpp | 8 +++++++- src/commands.cpp | 38 +++++++------------------------------- 3 files changed, 21 insertions(+), 38 deletions(-) diff --git a/include/aoclient.h b/include/aoclient.h index a72f483..ec1fbc4 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -63,6 +63,7 @@ class AOClient : public QObject { {"BAN", 1ULL << 1}, {"BGLOCK", 1ULL << 2}, {"MODIFY_USERS", 1ULL << 3}, + {"CM", 1ULL << 4}, {"SUPER", ~0ULL} }; @@ -231,12 +232,12 @@ class AOClient : public QObject { {"doc", {ACLFlags.value("NONE"), 0, &AOClient::cmdDoc}}, {"cleardoc", {ACLFlags.value("NONE"), 0, &AOClient::cmdClearDoc}}, {"cm", {ACLFlags.value("NONE"), 0, &AOClient::cmdCM}}, - {"uncm", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnCM}}, - {"invite", {ACLFlags.value("NONE"), 1, &AOClient::cmdInvite}}, - {"uninvite", {ACLFlags.value("NONE"), 1, &AOClient::cmdUnInvite}}, - {"lock", {ACLFlags.value("NONE"), 0, &AOClient::cmdLock}}, - {"spectatable", {ACLFlags.value("NONE"), 0, &AOClient::cmdSpectatable}}, - {"unlock", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnLock}}, + {"uncm", {ACLFlags.value("CM"), 0, &AOClient::cmdUnCM}}, + {"invite", {ACLFlags.value("CM"), 1, &AOClient::cmdInvite}}, + {"uninvite", {ACLFlags.value("CM"), 1, &AOClient::cmdUnInvite}}, + {"lock", {ACLFlags.value("CM"), 0, &AOClient::cmdLock}}, + {"spectatable", {ACLFlags.value("CM"), 0, &AOClient::cmdSpectatable}}, + {"unlock", {ACLFlags.value("CM"), 0, &AOClient::cmdUnLock}}, }; diff --git a/src/aoclient.cpp b/src/aoclient.cpp index 075caaa..710247c 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -264,10 +264,16 @@ void AOClient::sendServerBroadcast(QString message) bool AOClient::checkAuth(unsigned long long acl_mask) { if (acl_mask != ACLFlags.value("NONE")) { - if (!authenticated) { + if (!authenticated && acl_mask != ACLFlags.value("CM")) { return false; } + if (acl_mask == ACLFlags.value("CM")) { + AreaData* area = server->areas[current_area]; + if (area->owners.contains(id)) + return true; + } + QSettings settings("config/config.ini", QSettings::IniFormat); settings.beginGroup("Options"); QString auth_type = settings.value("auth", "simple").toString(); diff --git a/src/commands.cpp b/src/commands.cpp index 46d19c0..facfb13 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -448,12 +448,8 @@ void AOClient::cmdUnCM(int argc, QStringList argv) AreaData* area = server->areas[current_area]; int removed = area->owners.removeAll(id); area->invited.removeAll(id); - if (removed == 0) - sendServerMessage("You are not a CM in this area."); - else { - sendServerMessage("You are no longer CM in this area."); - arup(ARUPType::CM, true); - } + sendServerMessage("You are no longer CM in this area."); + arup(ARUPType::CM, true); if (area->owners.isEmpty()) area->invited.clear(); } @@ -462,11 +458,7 @@ void AOClient::cmdInvite(int argc, QStringList argv) AreaData* area = server->areas[current_area]; bool ok; int invited_id = argv[0].toInt(&ok); - if (!area->owners.contains(id)) { - sendServerMessage("You are not a CM in this area."); - return; - } - else if (!ok) { + if (!ok) { sendServerMessage("That does not look like a valid ID."); return; } @@ -482,11 +474,7 @@ void AOClient::cmdUnInvite(int argc, QStringList argv) AreaData* area = server->areas[current_area]; bool ok; int uninvited_id = argv[0].toInt(&ok); - if (!area->owners.contains(id)) { - sendServerMessage("You are not a CM in this area."); - return; - } - else if (!ok) { + if (!ok) { sendServerMessage("That does not look like a valid ID."); return; } @@ -504,11 +492,7 @@ void AOClient::cmdUnInvite(int argc, QStringList argv) void AOClient::cmdLock(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (!area->owners.contains(id)) { - sendServerMessage("You are not a CM in this area."); - return; - } - else if (area->locked == AreaData::LockStatus::LOCKED) { + if (area->locked == AreaData::LockStatus::LOCKED) { sendServerMessage("This area is already locked."); return; } @@ -524,11 +508,7 @@ void AOClient::cmdLock(int argc, QStringList argv) void AOClient::cmdSpectatable(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (!area->owners.contains(id)) { - sendServerMessage("You are not a CM in this area."); - return; - } - else if (area->locked == AreaData::LockStatus::SPECTATABLE) { + if (area->locked == AreaData::LockStatus::SPECTATABLE) { sendServerMessage("This area is already in spectate mode."); return; } @@ -544,11 +524,7 @@ void AOClient::cmdSpectatable(int argc, QStringList argv) void AOClient::cmdUnLock(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (!area->owners.contains(id)) { - sendServerMessage("You are not a CM in this area."); - return; - } - else if (area->locked == AreaData::LockStatus::FREE) { + if (area->locked == AreaData::LockStatus::FREE) { sendServerMessage("This area is not locked."); return; }