diff --git a/include/aoclient.h b/include/aoclient.h index f65b737..6c87fff 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -219,6 +219,7 @@ class AOClient : public QObject { void cmdRandomChar(int argc, QStringList argv); void cmdG(int argc, QStringList argv); void cmdToggleGlobal(int argc, QStringList argv); + void cmdPM(int argc, QStringList argv); // Command helper functions QString getAreaTimer(int area_idx, QTimer* timer); @@ -284,6 +285,7 @@ class AOClient : public QObject { {"status", {ACLFlags.value("NONE"), 1, &AOClient::cmdStatus}}, {"forcepos", {ACLFlags.value("CM"), 2, &AOClient::cmdForcePos}}, {"currentmusic", {ACLFlags.value("NONE"), 0, &AOClient::cmdCurrentMusic}}, + {"pm", {ACLFlags.value("NONE"), 2, &AOClient::cmdPM}}, }; QString partial_packet; diff --git a/src/aoclient.cpp b/src/aoclient.cpp index c993443..49553b9 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -193,6 +193,13 @@ void AOClient::changeCharacter(int char_id) } } +void AOClient::changePosition(QString new_pos) +{ + pos = new_pos; + sendServerMessage("Position changed to " + pos + "."); + sendPacket("SP", {pos}); +} + void AOClient::handleCommand(QString command, int argc, QStringList argv) { CommandInfo info = commands.value(command, {false, -1, &AOClient::cmdDefault}); diff --git a/src/commands.cpp b/src/commands.cpp index 1f1151a..d568471 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -364,8 +364,7 @@ void AOClient::cmdLogout(int argc, QStringList argv) void AOClient::cmdPos(int argc, QStringList argv) { - pos = argv[0]; - sendServerMessage("Position changed to " + pos + "."); + changePosition(argv[0]); } void AOClient::cmdForcePos(int argc, QStringList argv) @@ -396,8 +395,8 @@ void AOClient::cmdForcePos(int argc, QStringList argv) } } for (AOClient* target : targets) { - target->pos = argv[0]; - target->sendServerMessage("Position forced to " + target->pos + " by CM."); + target->sendServerMessage("Position forcibly changed by CM."); + target->changePosition(argv[0]); forced_clients++; } sendServerMessage("Forced " + QString::number(forced_clients) + " into pos " + argv[0] + "."); @@ -813,6 +812,23 @@ void AOClient::cmdCurrentMusic(int argc, QStringList argv) sendServerMessage("There is no music playing."); } +void AOClient::cmdPM(int arc, QStringList argv) +{ + bool ok; + int target_id = argv.takeFirst().toInt(&ok); // using takeFirst removes the ID from our list of arguments... + if (!ok) { + sendServerMessage("That does not look like a valid ID."); + return; + } + AOClient* target_client = server->getClientByID(target_id); + if (target_client == nullptr) { + sendServerMessage("No client with that ID found."); + return; + } + QString message = argv.join(" "); //...which means it will not end up as part of the message + target_client->sendServerMessage("Message from " + ooc_name + " (" + QString::number(id) + "): " + message); +} + QStringList AOClient::buildAreaList(int area_idx) { QStringList entries;