From a792c063ee4ab942b892241ee115974a685484ee Mon Sep 17 00:00:00 2001 From: in1tiate Date: Wed, 10 Mar 2021 18:47:22 -0600 Subject: [PATCH] add help command --- include/aoclient.h | 2 ++ src/commands.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/aoclient.h b/include/aoclient.h index 7918072..530efd5 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -171,6 +171,7 @@ class AOClient : public QObject { //// Commands void cmdDefault(int argc, QStringList argv); + void cmdHelp(int argc, QStringList argv); // Authentication void cmdLogin(int argc, QStringList argv); void cmdChangeAuth(int argc, QStringList argv); @@ -276,6 +277,7 @@ class AOClient : public QObject { {"switch", {ACLFlags.value("NONE"), 1, &AOClient::cmdSwitch}}, {"toggleglobal", {ACLFlags.value("NONE"), 0, &AOClient::cmdToggleGlobal}}, {"mods", {ACLFlags.value("NONE"), 0, &AOClient::cmdMods}}, + {"help", {ACLFlags.value("NONE"), 0, &AOClient::cmdHelp}}, }; QString partial_packet; diff --git a/src/commands.cpp b/src/commands.cpp index 5396260..68ca736 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -716,6 +716,20 @@ void AOClient::cmdMods(int argc, QStringList argv) sendServerMessage(entries.join("\n")); } +void AOClient::cmdHelp(int argc, QStringList argv) +{ + QStringList entries; + entries << "Allowed commands:"; + QMap::const_iterator i; + for (i = commands.constBegin(); i!= commands.constEnd(); ++i) { + CommandInfo info = i.value(); + if (checkAuth(info.acl_mask)) { + entries << "/" + i.key(); + } + } + sendServerMessage(entries.join("\n")); +} + QStringList AOClient::buildAreaList(int area_idx) { QStringList entries;