Add /evidence_swap

This commit is contained in:
Salanto 2021-03-16 23:14:11 +01:00
parent d9b4936861
commit ba56eaa66d
2 changed files with 32 additions and 0 deletions

View File

@ -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}}
};
/**

View File

@ -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;