From ba56eaa66dd7d83feab95fff66cbbc17155b8d67 Mon Sep 17 00:00:00 2001 From: Salanto Date: Tue, 16 Mar 2021 23:14:11 +0100 Subject: [PATCH] Add /evidence_swap --- include/aoclient.h | 14 ++++++++++++++ src/commands.cpp | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/aoclient.h b/include/aoclient.h index effbfcf..0652801 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -1146,6 +1146,18 @@ class AOClient : public QObject { */ void cmdEvidenceMod(int argc, QStringList argv); + /** + * @brief Changes position of two pieces of evidence in the area. + * + * @details The two arguments are the indices of the evidence items you want to swap the position of. + * + * @iscommand + * + * @see Area::Evidence_Swap + * + */ + void cmdEvidence_Swap(int argc, QStringList argv); + /** * @brief Changes the subtheme of the clients in the current area. * @@ -1153,6 +1165,7 @@ class AOClient : public QObject { * * @iscommand */ + void cmdSubTheme(int argc, QStringList argv); ///@} @@ -1423,6 +1436,7 @@ class AOClient : public QObject { {"removeuser", {ACLFlags.value("MODIFY_USERS"), 1, &AOClient::cmdRemoveUser}}, {"subtheme", {ACLFlags.value("CM"), 1, &AOClient::cmdSubTheme}}, {"about", {ACLFlags.value("NONE"), 0, &AOClient::cmdAbout}}, + {"evidence_swap", {ACLFlags.value("CM"), 2, &AOClient::cmdEvidence_Swap}} }; /** diff --git a/src/commands.cpp b/src/commands.cpp index 2455016..9519169 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1035,6 +1035,24 @@ void AOClient::cmdAbout(int argc, QStringList argv) sendPacket("CT", {"The akashi dev team", "Thank you for using akashi! Made with love by scatterflower, with help from in1tiate and Salanto. akashi " + QCoreApplication::applicationVersion()}); } +void AOClient::cmdEvidence_Swap(int argc, QStringList argv) +{ + AreaData* area = server->areas[current_area]; + bool ok, ok2; // This is btw a perfectly valid way to declare. + int EvID1 = argv[0].toInt(&ok), EvID2 = argv[1].toInt(&ok2); + int EvSize = area->evidence.size()-1; + if ((ok && ok2) && (EvID2 <= EvSize) && (EvID1 <= EvSize)) { + AreaData::Evidence EvData = area->evidence[EvID1]; + area->evidence[EvID1] = area->evidence[EvID2]; + area->evidence[EvID2] = EvData; + sendEvidenceList(area); + sendServerMessage("The evidence has been swapped."); + } + else { + sendServerMessage("Invalid evidence ID."); + } +} + QStringList AOClient::buildAreaList(int area_idx) { QStringList entries;