From 8156ae651515f0ca84fca47f7bb84fd4be751133 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 18 Apr 2021 16:04:20 -0500 Subject: [PATCH] add /charselect --- include/aoclient.h | 6 +++++- src/aoclient.cpp | 8 ++++---- src/commands/messaging.cpp | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/include/aoclient.h b/include/aoclient.h index ef72d08..14c6f84 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -221,7 +221,8 @@ class AOClient : public QObject { {"MUTE", 1ULL << 10}, {"UNCM", 1ULL << 11}, {"SAVETEST", 1ULL << 12}, - {"SUPER", ~0ULL }, + {"FORCE_CHARSELECT",1ULL << 13}, + {"SUPER", ~0ULL } }; @@ -1485,6 +1486,8 @@ class AOClient : public QObject { */ void cmdAfk(int argc, QStringList argv); + void cmdCharSelect(int argc, QStringList argv); + ///@} /** @@ -1933,6 +1936,7 @@ class AOClient : public QObject { {"block_dj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockDj}}, {"unblockdj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockDj}}, {"unblock_dj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockDj}}, + {"charselect", {ACLFlags.value("NONE"), 0, &AOClient::cmdCharSelect}} }; /** diff --git a/src/aoclient.cpp b/src/aoclient.cpp index 6e8dfbd..c4332ea 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -148,16 +148,16 @@ bool AOClient::changeCharacter(int char_id) if(char_id >= server->characters.length()) return false; + if (current_char != "") { + area->characters_taken.removeAll(server->getCharID(current_char)); + } + if (char_id >= 0) { QString char_selected = server->characters[char_id]; bool taken = area->characters_taken.contains(char_id); if (taken || char_selected == "") return false; - if (current_char != "") { - area->characters_taken.removeAll(server->getCharID(current_char)); - } - area->characters_taken.append(char_id); current_char = char_selected; } diff --git a/src/commands/messaging.cpp b/src/commands/messaging.cpp index 24e8db5..bfc4d81 100644 --- a/src/commands/messaging.cpp +++ b/src/commands/messaging.cpp @@ -317,3 +317,26 @@ void AOClient::cmdAfk(int argc, QStringList argv) is_afk = true; sendServerMessage("You are now AFK."); } + +void AOClient::cmdCharSelect(int argc, QStringList argv) +{ + if (argc == 0) { + changeCharacter(-1); + sendPacket("DONE"); + } + else { + if (!checkAuth(ACLFlags.value("FORCE_CHARSELECT"))) { + sendServerMessage("You do not have permission to force another player to character select!"); + return; + } + + bool ok = false; + int target_id = argv[0].toInt(&ok); + if (!ok) + return; + + AOClient* target = server->getClientByID(target_id); + target->changeCharacter(-1); + target->sendPacket("DONE"); + } +}