From ed9e86e18302716e586c73aa39bdd11eb1b174b9 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 3 Jan 2021 18:19:48 -0600 Subject: [PATCH] add /pos --- include/aoclient.h | 5 ++++- src/commands.cpp | 11 ++++++++++- src/packets.cpp | 5 +++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/aoclient.h b/include/aoclient.h index f693943..20baef2 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -122,6 +122,7 @@ class AOClient : public QObject { QString emote = ""; QString offset = ""; QString flipping = ""; + QString pos = ""; struct PacketInfo { unsigned long long acl_mask; @@ -169,6 +170,7 @@ class AOClient : public QObject { void cmdRemovePerms(int argc, QStringList argv); void cmdListUsers(int argc, QStringList argv); void cmdLogout(int argc, QStringList argv); + void cmdPos(int argc, QStringList argv); // Command helper functions QStringList buildAreaList(int area_idx); @@ -199,7 +201,8 @@ class AOClient : public QObject { {"addperm", {ACLFlags.value("MODIFY_USERS"), 2, &AOClient::cmdAddPerms}}, {"removeperm", {ACLFlags.value("MODIFY_USERS"), 2, &AOClient::cmdRemovePerms}}, {"listusers", {ACLFlags.value("MODIFY_USERS"), 0, &AOClient::cmdListUsers}}, - {"logout", {ACLFlags.value("NONE"), 0, &AOClient::cmdLogout}} + {"logout", {ACLFlags.value("NONE"), 0, &AOClient::cmdLogout}}, + {"pos", {ACLFlags.value("NONE"), 1, &AOClient::cmdPos}} }; QString partial_packet; diff --git a/src/commands.cpp b/src/commands.cpp index ed631eb..4a66c4e 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -359,7 +359,16 @@ void AOClient::cmdLogout(int argc, QStringList argv) authenticated = false; moderator_name = ""; sendServerMessage("You have been logged out."); - return; +} + +void AOClient::cmdPos(int argc, QStringList argv) +{ + if (argv[0] != "def" && argv[0] != "hld" && argv[0] != "pro" && argv[0] != "hlp" && argv[0] != "wit" && argv[0] != "jud" && argv[0] != "jur" && argv[0] != "sea") { + sendServerMessage("Invalid position!"); + return; + } + pos = argv[0]; + sendServerMessage("Position changed to " + pos + "."); } QStringList AOClient::buildAreaList(int area_idx) diff --git a/src/packets.cpp b/src/packets.cpp index 75a0ae6..901952c 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -138,6 +138,8 @@ void AOClient::pktSelectChar(AreaData* area, int argc, QStringList argv, AOPacke current_char = ""; } + pos = ""; + server->updateCharsTaken(area); sendPacket("PV", {"271828", "CID", argv[1]}); } @@ -148,6 +150,9 @@ void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket pa if (validated_packet.header == "INVALID") return; + if (pos != "") + validated_packet.contents[5] = pos; + area->logger->logIC(this, &validated_packet); server->broadcast(validated_packet, current_area); }