From 033d4f93e51580a3496910c7b5571d9a1b536765 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sat, 27 Feb 2021 17:36:21 -0600 Subject: [PATCH 01/17] add CMing and document commands --- include/aoclient.h | 39 +++++++++++++++++-------- include/area_data.h | 10 +++++-- include/server.h | 1 + src/aoclient.cpp | 16 ++++++++-- src/area_data.cpp | 4 +-- src/commands.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++-- src/packets.cpp | 1 + src/server.cpp | 22 +++++++++++++- 8 files changed, 141 insertions(+), 23 deletions(-) diff --git a/include/aoclient.h b/include/aoclient.h index bcd63f0..4a35313 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -38,7 +38,7 @@ class Server; class AOClient : public QObject { Q_OBJECT public: - AOClient(Server* p_server, QTcpSocket* p_socket, QObject* parent = nullptr); + AOClient(Server* p_server, QTcpSocket* p_socket, QObject* parent = nullptr, int user_id = 0); ~AOClient(); QString getHwid(); @@ -46,6 +46,8 @@ class AOClient : public QObject { Server* getServer(); void setHwid(QString p_hwid); + int id; + QHostAddress remote_ip; QString password; bool joined; @@ -152,28 +154,37 @@ class AOClient : public QObject { {"EE", {ACLFlags.value("NONE"), 4, &AOClient::pktEditEvidence}} }; - // Commands + //// Commands void cmdDefault(int argc, QStringList argv); + // Authentication void cmdLogin(int argc, QStringList argv); - void cmdGetAreas(int argc, QStringList argv); - void cmdGetArea(int argc, QStringList argv); - void cmdBan(int argc, QStringList argv); - void cmdKick(int argc, QStringList argv); void cmdChangeAuth(int argc, QStringList argv); void cmdSetRootPass(int argc, QStringList argv); - void cmdSetBackground(int argc, QStringList argv); - void cmdBgLock(int argc, QStringList argv); - void cmdBgUnlock(int argc, QStringList argv); void cmdAddUser(int argc, QStringList argv); void cmdListPerms(int argc, QStringList argv); void cmdAddPerms(int argc, QStringList argv); void cmdRemovePerms(int argc, QStringList argv); void cmdListUsers(int argc, QStringList argv); void cmdLogout(int argc, QStringList argv); - void cmdPos(int argc, QStringList argv); - void cmdG(int argc, QStringList argv); + // Areas + void cmdCM(int argc, QStringList argv); + void cmdUnCM(int argc, QStringList argv); + void cmdGetAreas(int argc, QStringList argv); + void cmdGetArea(int argc, QStringList argv); + void cmdSetBackground(int argc, QStringList argv); + void cmdBgLock(int argc, QStringList argv); + void cmdBgUnlock(int argc, QStringList argv); + // Moderation + void cmdBan(int argc, QStringList argv); + void cmdKick(int argc, QStringList argv); + // Casing/RP void cmdNeed(int argc, QStringList argv); void cmdFlip(int argc, QStringList argv); + void cmdDoc(int argc, QStringList argv); + void cmdClearDoc(int argc, QStringList argv); + // Messaging/Client + void cmdPos(int argc, QStringList argv); + void cmdG(int argc, QStringList argv); // Command helper functions QStringList buildAreaList(int area_idx); @@ -209,7 +220,11 @@ class AOClient : public QObject { {"pos", {ACLFlags.value("NONE"), 1, &AOClient::cmdPos}}, {"g", {ACLFlags.value("NONE"), 1, &AOClient::cmdG}}, {"need", {ACLFlags.value("NONE"), 1, &AOClient::cmdNeed}}, - {"flip", {ACLFlags.value("NONE"), 0, &AOClient::cmdFlip}} + {"flip", {ACLFlags.value("NONE"), 0, &AOClient::cmdFlip}}, + {"doc", {ACLFlags.value("NONE"), 0, &AOClient::cmdDoc}}, + {"cleardoc", {ACLFlags.value("NONE"), 0, &AOClient::cmdClearDoc}}, + {"cm", {ACLFlags.value("NONE"), 0, &AOClient::cmdCM}}, + {"uncm", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnCM}} }; QString partial_packet; diff --git a/include/area_data.h b/include/area_data.h index 175b595..cf0994f 100644 --- a/include/area_data.h +++ b/include/area_data.h @@ -42,13 +42,19 @@ class AreaData { QList evidence; int player_count; QString status; - QString current_cm; - bool locked; + QList owners; + enum LockStatus { + FREE, + LOCKED, + SPECTATABLE + }; + LockStatus locked; QString background; bool showname_allowed; bool locking_allowed; bool iniswap_allowed; bool bg_locked; + QString document; int def_hp; int pro_hp; Logger* logger; diff --git a/include/server.h b/include/server.h index 4e7d823..38a97e1 100644 --- a/include/server.h +++ b/include/server.h @@ -46,6 +46,7 @@ class Server : public QObject { void start(); AOClient* getClient(QString ipid); + AOClient* getClientByID(int id); void updateCharsTaken(AreaData* area); void broadcast(AOPacket packet, int area_index); void broadcast(AOPacket packet); diff --git a/src/aoclient.cpp b/src/aoclient.cpp index 1e10adc..7ce234d 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -17,11 +17,12 @@ ////////////////////////////////////////////////////////////////////////////////////// #include "include/aoclient.h" -AOClient::AOClient(Server* p_server, QTcpSocket* p_socket, QObject* parent) +AOClient::AOClient(Server* p_server, QTcpSocket* p_socket, QObject* parent, int user_id) : QObject(parent) { socket = p_socket; server = p_server; + id = user_id; joined = false; password = ""; current_area = 0; @@ -155,8 +156,17 @@ void AOClient::arup(ARUPType type, bool broadcast) arup_data.append(area->status); } else if (type == ARUPType::CM) { - arup_data.append(area->current_cm); - } + if (area->owners.isEmpty()) + arup_data.append("FREE"); + else { + QStringList area_owners; + for (int owner_id : area->owners) { + AOClient* owner = server->getClientByID(owner_id); + area_owners.append("[" + QString::number(owner->id) + "] " + owner->current_char); + } + arup_data.append(area_owners.join(", ")); + } + } else if (type == ARUPType::LOCKED) { arup_data.append(area->locked ? "LOCKED" : "FREE"); } diff --git a/src/area_data.cpp b/src/area_data.cpp index 63b57aa..b6916e9 100644 --- a/src/area_data.cpp +++ b/src/area_data.cpp @@ -29,12 +29,12 @@ AreaData::AreaData(QStringList characters, QString p_name, int p_index) background = areas_ini.value("background", "gs4").toString(); areas_ini.endGroup(); player_count = 0; - current_cm = "FREE"; - locked = false; + locked = FREE; status = "FREE"; def_hp = 10; pro_hp = 10; bg_locked = false; + document = "No document."; QSettings config_ini("config/config.ini", QSettings::IniFormat); config_ini.beginGroup("Options"); int log_size = config_ini.value("logbuffer", 50).toInt(); diff --git a/src/commands.cpp b/src/commands.cpp index aa84f9f..0232d13 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -394,6 +394,71 @@ void AOClient::cmdFlip(int argc, QStringList argv) sendServerMessage(sender_name + " flipped a coin and got " + face + "."); } +void AOClient::cmdDoc(int argc, QStringList argv) +{ + QString sender_name = ooc_name; + AreaData* area = server->areas[current_area]; + if (argc == 0) { + sendServerMessage("Document: " + area->document); + } + else { + area->document = argv.join(" "); + sendServerMessage(sender_name + " changed the document."); // broadcast this! + } +} + +void AOClient::cmdClearDoc(int argc, QStringList argv) +{ + QString sender_name = ooc_name; + AreaData* area = server->areas[current_area]; + area->document = "No document."; + sendServerMessage(sender_name + " cleared the document."); // broadcast this! +} + +void AOClient::cmdCM(int argc, QStringList argv) +{ + QString sender_name = ooc_name; + AreaData* area = server->areas[current_area]; + if (area->owners.isEmpty()) { + area->owners.append(id); + sendServerMessage(sender_name + " is now CM in this area."); // broadcast this! + arup(ARUPType::CM, true); + } + else if (!area->owners.contains(id)) { + sendServerMessage("You cannot become a CM in this area."); + } + else if (argc == 1) { + bool ok; + AOClient* owner_candidate = server->getClientByID(argv[0].toInt(&ok)); + if (!ok) { + sendServerMessage("That doesn't look like a valid ID."); + return; + } + if (owner_candidate == nullptr) { + sendServerMessage("Unable to find client with ID " + argv[0] + "."); + return; + } + area->owners.append(owner_candidate->id); + sendServerMessage(owner_candidate->ooc_name + " is now CM in this area."); // broadcast this! + arup(ARUPType::CM, true); + } + else { + sendServerMessage("You are already a CM in this area."); + } +} +void AOClient::cmdUnCM(int argc, QStringList argv) +{ + AreaData* area = server->areas[current_area]; + int removed = area->owners.removeAll(id); + if (removed == 0) + sendServerMessage("You are not a CM in this area."); + else { + sendServerMessage("You are no longer CM in this area."); + arup(ARUPType::CM, true); + } +} + + QStringList AOClient::buildAreaList(int area_idx) { QStringList entries; @@ -403,9 +468,9 @@ QStringList AOClient::buildAreaList(int area_idx) entries.append("[" + QString::number(area->player_count) + " users][" + area->status + "]"); for (AOClient* client : server->clients) { if (client->current_area == area_idx && client->joined) { - QString char_entry = client->current_char; - if (char_entry == "") - char_entry = "Spectator"; + QString char_entry = "[" + QString::number(client->id) + "] " + client->current_char; + if (client->current_char == "") + char_entry += "Spectator"; if (authenticated) char_entry += " (" + client->getIpid() + "): " + client->ooc_name; entries.append(char_entry); diff --git a/src/packets.cpp b/src/packets.cpp index 901952c..8036462 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -142,6 +142,7 @@ void AOClient::pktSelectChar(AreaData* area, int argc, QStringList argv, AOPacke server->updateCharsTaken(area); sendPacket("PV", {"271828", "CID", argv[1]}); + fullArup(); } void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket packet) diff --git a/src/server.cpp b/src/server.cpp index 690a4f2..e89e884 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -92,7 +92,18 @@ void Server::start() void Server::clientConnected() { QTcpSocket* socket = server->nextPendingConnection(); - AOClient* client = new AOClient(this, socket, this); + int user_id; + QList user_ids; + for (AOClient* client : clients) { + user_ids.append(client->id); + } + for (user_id = 0; user_id <= player_count; user_id++) { + if (user_ids.contains(user_id)) + continue; + else + break; + } + AOClient* client = new AOClient(this, socket, this, user_id); if (db_manager->isIPBanned(socket->peerAddress())) { AOPacket ban_reason("BD", {db_manager->getBanReason(socket->peerAddress())}); socket->write(ban_reason.toUtf8()); @@ -156,6 +167,15 @@ AOClient* Server::getClient(QString ipid) return nullptr; } +AOClient* Server::getClientByID(int id) +{ + for (AOClient* client : clients) { + if (client->id == id) + return client; + } + return nullptr; +} + Server::~Server() { for (AOClient* client : clients) { From 516610efebbd90c5a26c3c07fcebc6717e8897f3 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sat, 27 Feb 2021 17:43:20 -0600 Subject: [PATCH 02/17] Indicate CM status in getarea --- src/commands.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/commands.cpp b/src/commands.cpp index 0232d13..45eb066 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -471,6 +471,8 @@ QStringList AOClient::buildAreaList(int area_idx) QString char_entry = "[" + QString::number(client->id) + "] " + client->current_char; if (client->current_char == "") char_entry += "Spectator"; + if (area->owners.contains(client->id)) + char_entry.insert(0, "[CM] "); if (authenticated) char_entry += " (" + client->getIpid() + "): " + client->ooc_name; entries.append(char_entry); From 69da440e548765feff1f46e302a25666b0030e0f Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sat, 27 Feb 2021 18:00:00 -0600 Subject: [PATCH 03/17] add invite system --- include/area_data.h | 1 + src/aoclient.cpp | 5 +++++ src/commands.cpp | 50 +++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/include/area_data.h b/include/area_data.h index cf0994f..e284915 100644 --- a/include/area_data.h +++ b/include/area_data.h @@ -43,6 +43,7 @@ class AreaData { int player_count; QString status; QList owners; + QList invited; enum LockStatus { FREE, LOCKED, diff --git a/src/aoclient.cpp b/src/aoclient.cpp index 7ce234d..a4f4da9 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -68,6 +68,11 @@ void AOClient::clientDisconnected() false; server->updateCharsTaken(server->areas[current_area]); } + for (AreaData* area : server->areas) { + area->owners.removeAll(id); + area->invited.removeAll(id); + } + arup(ARUPType::CM, true); } void AOClient::handlePacket(AOPacket packet) diff --git a/src/commands.cpp b/src/commands.cpp index 45eb066..d4f7cd0 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -363,10 +363,6 @@ void AOClient::cmdLogout(int argc, QStringList argv) 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 + "."); } @@ -421,6 +417,7 @@ void AOClient::cmdCM(int argc, QStringList argv) AreaData* area = server->areas[current_area]; if (area->owners.isEmpty()) { area->owners.append(id); + area->invited.append(id); sendServerMessage(sender_name + " is now CM in this area."); // broadcast this! arup(ARUPType::CM, true); } @@ -450,6 +447,7 @@ void AOClient::cmdUnCM(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; int removed = area->owners.removeAll(id); + area->invited.removeAll(id); if (removed == 0) sendServerMessage("You are not a CM in this area."); else { @@ -457,6 +455,50 @@ void AOClient::cmdUnCM(int argc, QStringList argv) arup(ARUPType::CM, true); } } +void AOClient::cmdInvite(int argc, QStringList argv) +{ + AreaData* area = server->areas[current_area]; + bool ok; + int invited_id = argv[0].toInt(&ok); + if (!area->owners.contains(id)) { + sendServerMessage("You are not a CM in this area."); + return; + } + else if (!ok) { + sendServerMessage("That does not look like a valid ID."); + return; + } + else if (area->invited.contains(invited_id)) { + sendServerMessage("That ID is already on the invite list."); + return; + } + area->invited.append(invited_id); + sendServerMessage("You invited ID " + argv[0]); +} +void AOClient::cmdUnInvite(int argc, QStringList argv) +{ + AreaData* area = server->areas[current_area]; + bool ok; + int uninvited_id = argv[0].toInt(&ok); + if (!area->owners.contains(id)) { + sendServerMessage("You are not a CM in this area."); + return; + } + else if (!ok) { + sendServerMessage("That does not look like a valid ID."); + return; + } + else if (area->owners.contains(uninvited_id)) { + sendServerMessage("You cannot uninvite a CM!"); + return; + } + else if (!area->invited.contains(uninvited_id)) { + sendServerMessage("That ID is not on the invite list."); + return; + } + area->invited.removeAll(uninvited_id); + sendServerMessage("You uninvited ID " + argv[0]); +} QStringList AOClient::buildAreaList(int area_idx) From c1b697c9a4b578e80faf185fd7929f412c5c03e9 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sat, 27 Feb 2021 18:01:15 -0600 Subject: [PATCH 04/17] add new commands to aoclient header --- include/aoclient.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/aoclient.h b/include/aoclient.h index 4a35313..7225c99 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -169,6 +169,8 @@ class AOClient : public QObject { // Areas void cmdCM(int argc, QStringList argv); void cmdUnCM(int argc, QStringList argv); + void cmdInvite(int argc, QStringList argv); + void cmdUnInvite(int argc, QStringList argv); void cmdGetAreas(int argc, QStringList argv); void cmdGetArea(int argc, QStringList argv); void cmdSetBackground(int argc, QStringList argv); @@ -224,7 +226,9 @@ class AOClient : public QObject { {"doc", {ACLFlags.value("NONE"), 0, &AOClient::cmdDoc}}, {"cleardoc", {ACLFlags.value("NONE"), 0, &AOClient::cmdClearDoc}}, {"cm", {ACLFlags.value("NONE"), 0, &AOClient::cmdCM}}, - {"uncm", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnCM}} + {"uncm", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnCM}}, + {"invite", {ACLFlags.value("NONE"), 0, &AOClient::cmdInvite}}, + {"uninvite", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnInvite}} }; QString partial_packet; From fd8654de978bd48a95ebf78e0191721df6869660 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sun, 28 Feb 2021 09:59:37 -0600 Subject: [PATCH 05/17] add area locking --- include/aoclient.h | 11 +++++++-- src/aoclient.cpp | 16 ++++++++++++- src/commands.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++ src/packets.cpp | 4 ++++ 4 files changed, 85 insertions(+), 3 deletions(-) diff --git a/include/aoclient.h b/include/aoclient.h index 7225c99..55b331f 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -171,6 +171,9 @@ class AOClient : public QObject { void cmdUnCM(int argc, QStringList argv); void cmdInvite(int argc, QStringList argv); void cmdUnInvite(int argc, QStringList argv); + void cmdLock(int argc, QStringList argv); + void cmdSpectatable(int argc, QStringList argv); + void cmdUnLock(int argc, QStringList argv); void cmdGetAreas(int argc, QStringList argv); void cmdGetArea(int argc, QStringList argv); void cmdSetBackground(int argc, QStringList argv); @@ -227,8 +230,12 @@ class AOClient : public QObject { {"cleardoc", {ACLFlags.value("NONE"), 0, &AOClient::cmdClearDoc}}, {"cm", {ACLFlags.value("NONE"), 0, &AOClient::cmdCM}}, {"uncm", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnCM}}, - {"invite", {ACLFlags.value("NONE"), 0, &AOClient::cmdInvite}}, - {"uninvite", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnInvite}} + {"invite", {ACLFlags.value("NONE"), 1, &AOClient::cmdInvite}}, + {"uninvite", {ACLFlags.value("NONE"), 1, &AOClient::cmdUnInvite}}, + {"lock", {ACLFlags.value("NONE"), 0, &AOClient::cmdLock}}, + {"spectatable", {ACLFlags.value("NONE"), 0, &AOClient::cmdSpectatable}}, + {"unlock", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnLock}}, + }; QString partial_packet; diff --git a/src/aoclient.cpp b/src/aoclient.cpp index a4f4da9..c0d8e99 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -173,7 +173,21 @@ void AOClient::arup(ARUPType type, bool broadcast) } } else if (type == ARUPType::LOCKED) { - arup_data.append(area->locked ? "LOCKED" : "FREE"); + QString lock_status; + switch (area->locked) { + case FREE: + lock_status = "FREE"; + break; + case LOCKED: + lock_status = "LOCKED"; + break; + case SPECTATABLE: + lock_status = "SPECTATABLE"; + break; + default: + break; + } + arup_data.append(lock_status); } else return; } diff --git a/src/commands.cpp b/src/commands.cpp index d4f7cd0..43b3cda 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -454,6 +454,8 @@ void AOClient::cmdUnCM(int argc, QStringList argv) sendServerMessage("You are no longer CM in this area."); arup(ARUPType::CM, true); } + if (area->owners.isEmpty()) + area->invited.clear(); } void AOClient::cmdInvite(int argc, QStringList argv) { @@ -499,6 +501,61 @@ void AOClient::cmdUnInvite(int argc, QStringList argv) area->invited.removeAll(uninvited_id); sendServerMessage("You uninvited ID " + argv[0]); } +void AOClient::cmdLock(int argc, QStringList argv) +{ + AreaData* area = server->areas[current_area]; + if (!area->owners.contains(id)) { + sendServerMessage("You are not a CM in this area."); + return; + } + else if (area->locked == LOCKED) { + sendServerMessage("This area is already locked."); + return; + } + sendServerMessage("This area is now locked."); + area->locked = LOCKED; + for (AOClient* client : server->clients) { + if (client->current_area == current_area && client->joined) { + area->invited.append(client->id); + } + } + arup(ARUPType::LOCKED, true); +} +void AOClient::cmdSpectatable(int argc, QStringList argv) +{ + AreaData* area = server->areas[current_area]; + if (!area->owners.contains(id)) { + sendServerMessage("You are not a CM in this area."); + return; + } + else if (area->locked == SPECTATABLE) { + sendServerMessage("This area is already in spectate mode."); + return; + } + sendServerMessage("This area is now spectatable."); + area->locked = SPECTATABLE; + for (AOClient* client : server->clients) { + if (client->current_area == current_area && client->joined) { + area->invited.append(client->id); + } + } + arup(ARUPType::LOCKED, true); +} +void AOClient::cmdUnLock(int argc, QStringList argv) +{ + AreaData* area = server->areas[current_area]; + if (!area->owners.contains(id)) { + sendServerMessage("You are not a CM in this area."); + return; + } + else if (area->locked == FREE) { + sendServerMessage("This area is not locked."); + return; + } + sendServerMessage("This area is now unlocked."); + area->locked = FREE; + arup(ARUPType::LOCKED, true); +} QStringList AOClient::buildAreaList(int area_idx) diff --git a/src/packets.cpp b/src/packets.cpp index 8036462..464d9c4 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -319,6 +319,10 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) // Spectators cannot use IC return invalid; + if (current_area->locked == SPECTATABLE && !current_area->invited.contains(id)) + // Non-invited players cannot speak in spectatable areas + return invalid; + QList incoming_args; for (QString arg : packet.contents) { incoming_args.append(QVariant(arg)); From 30eb010bb6c28a6876a42a01c45020eb95872929 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sun, 28 Feb 2021 10:08:23 -0600 Subject: [PATCH 06/17] compiles again, convenience messages --- src/aoclient.cpp | 13 ++++++++----- src/commands.cpp | 12 ++++++------ src/packets.cpp | 5 ++--- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/aoclient.cpp b/src/aoclient.cpp index c0d8e99..af34da1 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -103,10 +103,11 @@ void AOClient::changeArea(int new_area) sendServerMessage("You are already in area " + server->area_names[current_area]); return; } - if (server->areas[new_area]->locked) { + if (server->areas[new_area]->locked == AreaData::LockStatus::LOCKED) { sendServerMessage("Area " + server->area_names[new_area] + " is locked."); return; } + if (current_char != "") { server->areas[current_area]->characters_taken[current_char] = false; @@ -129,7 +130,9 @@ void AOClient::changeArea(int new_area) server->areas[current_area]->characters_taken[current_char] = true; server->updateCharsTaken(server->areas[current_area]); } - sendServerMessage("You have been moved to area " + server->area_names[current_area]); + sendServerMessage("You moved to area " + server->area_names[current_area]); + if (server->areas[current_area]->locked == AreaData::LockStatus::SPECTATABLE) + sendServerMessage("Area " + server->area_names[current_area] + " is spectate-only; to chat IC you will need to be invited by the CM."); } void AOClient::handleCommand(QString command, int argc, QStringList argv) @@ -175,13 +178,13 @@ void AOClient::arup(ARUPType type, bool broadcast) else if (type == ARUPType::LOCKED) { QString lock_status; switch (area->locked) { - case FREE: + case AreaData::LockStatus::FREE: lock_status = "FREE"; break; - case LOCKED: + case AreaData::LockStatus::LOCKED: lock_status = "LOCKED"; break; - case SPECTATABLE: + case AreaData::LockStatus::SPECTATABLE: lock_status = "SPECTATABLE"; break; default: diff --git a/src/commands.cpp b/src/commands.cpp index 43b3cda..2d31aba 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -508,12 +508,12 @@ void AOClient::cmdLock(int argc, QStringList argv) sendServerMessage("You are not a CM in this area."); return; } - else if (area->locked == LOCKED) { + else if (area->locked == AreaData::LockStatus::LOCKED) { sendServerMessage("This area is already locked."); return; } sendServerMessage("This area is now locked."); - area->locked = LOCKED; + area->locked = AreaData::LockStatus::LOCKED; for (AOClient* client : server->clients) { if (client->current_area == current_area && client->joined) { area->invited.append(client->id); @@ -528,12 +528,12 @@ void AOClient::cmdSpectatable(int argc, QStringList argv) sendServerMessage("You are not a CM in this area."); return; } - else if (area->locked == SPECTATABLE) { + else if (area->locked == AreaData::LockStatus::SPECTATABLE) { sendServerMessage("This area is already in spectate mode."); return; } sendServerMessage("This area is now spectatable."); - area->locked = SPECTATABLE; + area->locked = AreaData::LockStatus::SPECTATABLE; for (AOClient* client : server->clients) { if (client->current_area == current_area && client->joined) { area->invited.append(client->id); @@ -548,12 +548,12 @@ void AOClient::cmdUnLock(int argc, QStringList argv) sendServerMessage("You are not a CM in this area."); return; } - else if (area->locked == FREE) { + else if (area->locked == AreaData::LockStatus::FREE) { sendServerMessage("This area is not locked."); return; } sendServerMessage("This area is now unlocked."); - area->locked = FREE; + area->locked = AreaData::LockStatus::FREE; arup(ARUPType::LOCKED, true); } diff --git a/src/packets.cpp b/src/packets.cpp index 464d9c4..33e9ca9 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -318,8 +318,8 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) if (current_char == "" || !joined) // Spectators cannot use IC return invalid; - - if (current_area->locked == SPECTATABLE && !current_area->invited.contains(id)) + AreaData* area = server->areas[current_area]; + if (area->locked == AreaData::LockStatus::SPECTATABLE && !area->invited.contains(id)) // Non-invited players cannot speak in spectatable areas return invalid; @@ -410,7 +410,6 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) // evidence int evi_idx = incoming_args[11].toInt(); - AreaData* area = server->areas[current_area]; if (evi_idx > area->evidence.length()) return invalid; args.append(QString::number(evi_idx)); From fcca15a78502525b101c5448e1b4f25d21c925ce Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sun, 28 Feb 2021 10:11:52 -0600 Subject: [PATCH 07/17] show lock status in getarea --- src/commands.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/commands.cpp b/src/commands.cpp index 2d31aba..6aca17d 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -564,6 +564,17 @@ QStringList AOClient::buildAreaList(int area_idx) QString area_name = server->area_names[area_idx]; AreaData* area = server->areas[area_idx]; entries.append("=== " + area_name + " ==="); + switch (area->locked) { + case AreaData::LockStatus::LOCKED: + entries.append("[LOCKED]"); + break; + case AreaData::LockStatus::SPECTATABLE: + entries.append("[SPECTATABLE]"); + break; + case AreaData::LockStatus::FREE: + default: + break; + } entries.append("[" + QString::number(area->player_count) + " users][" + area->status + "]"); for (AOClient* client : server->clients) { if (client->current_area == area_idx && client->joined) { From 7f615df8c50211e410107787fff24b6a88c35d9d Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sun, 28 Feb 2021 10:49:40 -0600 Subject: [PATCH 08/17] comments, allow invited users 2 enter locked areas --- src/aoclient.cpp | 2 +- src/commands.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/aoclient.cpp b/src/aoclient.cpp index af34da1..b238bc5 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -103,7 +103,7 @@ void AOClient::changeArea(int new_area) sendServerMessage("You are already in area " + server->area_names[current_area]); return; } - if (server->areas[new_area]->locked == AreaData::LockStatus::LOCKED) { + if (server->areas[new_area]->locked == AreaData::LockStatus::LOCKED && !server->areas[new_area]->invited.contains(id)) { sendServerMessage("Area " + server->area_names[new_area] + " is locked."); return; } diff --git a/src/commands.cpp b/src/commands.cpp index 6aca17d..c9fdf43 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -512,7 +512,7 @@ void AOClient::cmdLock(int argc, QStringList argv) sendServerMessage("This area is already locked."); return; } - sendServerMessage("This area is now locked."); + sendServerMessage("This area is now locked."); // broadcast me! area->locked = AreaData::LockStatus::LOCKED; for (AOClient* client : server->clients) { if (client->current_area == current_area && client->joined) { @@ -532,7 +532,7 @@ void AOClient::cmdSpectatable(int argc, QStringList argv) sendServerMessage("This area is already in spectate mode."); return; } - sendServerMessage("This area is now spectatable."); + sendServerMessage("This area is now spectatable."); // broadcast me! area->locked = AreaData::LockStatus::SPECTATABLE; for (AOClient* client : server->clients) { if (client->current_area == current_area && client->joined) { @@ -552,7 +552,7 @@ void AOClient::cmdUnLock(int argc, QStringList argv) sendServerMessage("This area is not locked."); return; } - sendServerMessage("This area is now unlocked."); + sendServerMessage("This area is now unlocked."); // broadcast me! area->locked = AreaData::LockStatus::FREE; arup(ARUPType::LOCKED, true); } From 080e215fb3ac13733887790f58f6b2d2ba930885 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sun, 28 Feb 2021 18:12:42 -0600 Subject: [PATCH 09/17] cherrypick additional functionality from Salanto:Rolling-Rocks --- include/aoclient.h | 2 ++ include/server.h | 2 ++ src/aoclient.cpp | 12 +++++++++++- src/commands.cpp | 14 +++++++------- src/server.cpp | 8 ++++++++ 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/include/aoclient.h b/include/aoclient.h index 55b331f..a72f483 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -90,6 +90,8 @@ class AOClient : public QObject { void arup(ARUPType type, bool broadcast); void fullArup(); void sendServerMessage(QString message); + void sendServerMessageArea(QString message); + void sendServerBroadcast(QString message); bool checkAuth(unsigned long long acl_mask); // Packet headers diff --git a/include/server.h b/include/server.h index 38a97e1..2865c63 100644 --- a/include/server.h +++ b/include/server.h @@ -50,6 +50,7 @@ class Server : public QObject { void updateCharsTaken(AreaData* area); void broadcast(AOPacket packet, int area_index); void broadcast(AOPacket packet); + QString getServerName(); QVector clients; @@ -60,6 +61,7 @@ class Server : public QObject { QStringList music_list; QStringList backgrounds; DBManager* db_manager; + QString server_name; signals: diff --git a/src/aoclient.cpp b/src/aoclient.cpp index b238bc5..075caaa 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -248,7 +248,17 @@ void AOClient::setHwid(QString p_hwid) void AOClient::sendServerMessage(QString message) { - sendPacket("CT", {"Server", message, "1"}); + sendPacket("CT", {server->getServerName(), message, "1"}); +} + +void AOClient::sendServerMessageArea(QString message) +{ + server->broadcast(AOPacket("CT", {server->getServerName(), message, "1"}), current_area); +} + +void AOClient::sendServerBroadcast(QString message) +{ + server->broadcast(AOPacket("CT", {server->getServerName(), message, "1"})); } bool AOClient::checkAuth(unsigned long long acl_mask) diff --git a/src/commands.cpp b/src/commands.cpp index c9fdf43..46d19c0 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -399,7 +399,7 @@ void AOClient::cmdDoc(int argc, QStringList argv) } else { area->document = argv.join(" "); - sendServerMessage(sender_name + " changed the document."); // broadcast this! + sendServerMessageArea(sender_name + " changed the document."); } } @@ -408,7 +408,7 @@ void AOClient::cmdClearDoc(int argc, QStringList argv) QString sender_name = ooc_name; AreaData* area = server->areas[current_area]; area->document = "No document."; - sendServerMessage(sender_name + " cleared the document."); // broadcast this! + sendServerMessageArea(sender_name + " cleared the document."); } void AOClient::cmdCM(int argc, QStringList argv) @@ -418,7 +418,7 @@ void AOClient::cmdCM(int argc, QStringList argv) if (area->owners.isEmpty()) { area->owners.append(id); area->invited.append(id); - sendServerMessage(sender_name + " is now CM in this area."); // broadcast this! + sendServerMessageArea(sender_name + " is now CM in this area."); arup(ARUPType::CM, true); } else if (!area->owners.contains(id)) { @@ -436,7 +436,7 @@ void AOClient::cmdCM(int argc, QStringList argv) return; } area->owners.append(owner_candidate->id); - sendServerMessage(owner_candidate->ooc_name + " is now CM in this area."); // broadcast this! + sendServerMessageArea(owner_candidate->ooc_name + " is now CM in this area."); arup(ARUPType::CM, true); } else { @@ -512,7 +512,7 @@ void AOClient::cmdLock(int argc, QStringList argv) sendServerMessage("This area is already locked."); return; } - sendServerMessage("This area is now locked."); // broadcast me! + sendServerMessageArea("This area is now locked."); area->locked = AreaData::LockStatus::LOCKED; for (AOClient* client : server->clients) { if (client->current_area == current_area && client->joined) { @@ -532,7 +532,7 @@ void AOClient::cmdSpectatable(int argc, QStringList argv) sendServerMessage("This area is already in spectate mode."); return; } - sendServerMessage("This area is now spectatable."); // broadcast me! + sendServerMessageArea("This area is now spectatable."); area->locked = AreaData::LockStatus::SPECTATABLE; for (AOClient* client : server->clients) { if (client->current_area == current_area && client->joined) { @@ -552,7 +552,7 @@ void AOClient::cmdUnLock(int argc, QStringList argv) sendServerMessage("This area is not locked."); return; } - sendServerMessage("This area is now unlocked."); // broadcast me! + sendServerMessageArea("This area is now unlocked."); area->locked = AreaData::LockStatus::FREE; arup(ARUPType::LOCKED, true); } diff --git a/src/server.cpp b/src/server.cpp index e89e884..23392d2 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -158,6 +158,14 @@ void Server::broadcast(AOPacket packet) } } +QString Server::getServerName() +{ + QSettings settings("config/config.ini", QSettings::IniFormat); + settings.beginGroup("Options"); + QString server_name = settings.value("server_name", "Akashi").toString(); + return server_name; +} + AOClient* Server::getClient(QString ipid) { for (AOClient* client : clients) { From 6a6029b6da15553ca05efaa20bf48b11be42c724 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sun, 28 Feb 2021 18:30:56 -0600 Subject: [PATCH 10/17] send player id --- src/packets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packets.cpp b/src/packets.cpp index 33e9ca9..3bc7f30 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -141,7 +141,7 @@ void AOClient::pktSelectChar(AreaData* area, int argc, QStringList argv, AOPacke pos = ""; server->updateCharsTaken(area); - sendPacket("PV", {"271828", "CID", argv[1]}); + sendPacket("PV", {QString::number(id), "CID", argv[1]}); fullArup(); } From 0b024abe5c9d1624458e6d40b1fee0984b83e01c Mon Sep 17 00:00:00 2001 From: in1tiate Date: Tue, 2 Mar 2021 20:45:01 -0600 Subject: [PATCH 11/17] hook into ACL system for CM shenanigans --- include/aoclient.h | 13 +++++++------ src/aoclient.cpp | 8 +++++++- src/commands.cpp | 38 +++++++------------------------------- 3 files changed, 21 insertions(+), 38 deletions(-) diff --git a/include/aoclient.h b/include/aoclient.h index a72f483..ec1fbc4 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -63,6 +63,7 @@ class AOClient : public QObject { {"BAN", 1ULL << 1}, {"BGLOCK", 1ULL << 2}, {"MODIFY_USERS", 1ULL << 3}, + {"CM", 1ULL << 4}, {"SUPER", ~0ULL} }; @@ -231,12 +232,12 @@ class AOClient : public QObject { {"doc", {ACLFlags.value("NONE"), 0, &AOClient::cmdDoc}}, {"cleardoc", {ACLFlags.value("NONE"), 0, &AOClient::cmdClearDoc}}, {"cm", {ACLFlags.value("NONE"), 0, &AOClient::cmdCM}}, - {"uncm", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnCM}}, - {"invite", {ACLFlags.value("NONE"), 1, &AOClient::cmdInvite}}, - {"uninvite", {ACLFlags.value("NONE"), 1, &AOClient::cmdUnInvite}}, - {"lock", {ACLFlags.value("NONE"), 0, &AOClient::cmdLock}}, - {"spectatable", {ACLFlags.value("NONE"), 0, &AOClient::cmdSpectatable}}, - {"unlock", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnLock}}, + {"uncm", {ACLFlags.value("CM"), 0, &AOClient::cmdUnCM}}, + {"invite", {ACLFlags.value("CM"), 1, &AOClient::cmdInvite}}, + {"uninvite", {ACLFlags.value("CM"), 1, &AOClient::cmdUnInvite}}, + {"lock", {ACLFlags.value("CM"), 0, &AOClient::cmdLock}}, + {"spectatable", {ACLFlags.value("CM"), 0, &AOClient::cmdSpectatable}}, + {"unlock", {ACLFlags.value("CM"), 0, &AOClient::cmdUnLock}}, }; diff --git a/src/aoclient.cpp b/src/aoclient.cpp index 075caaa..710247c 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -264,10 +264,16 @@ void AOClient::sendServerBroadcast(QString message) bool AOClient::checkAuth(unsigned long long acl_mask) { if (acl_mask != ACLFlags.value("NONE")) { - if (!authenticated) { + if (!authenticated && acl_mask != ACLFlags.value("CM")) { return false; } + if (acl_mask == ACLFlags.value("CM")) { + AreaData* area = server->areas[current_area]; + if (area->owners.contains(id)) + return true; + } + QSettings settings("config/config.ini", QSettings::IniFormat); settings.beginGroup("Options"); QString auth_type = settings.value("auth", "simple").toString(); diff --git a/src/commands.cpp b/src/commands.cpp index 46d19c0..facfb13 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -448,12 +448,8 @@ void AOClient::cmdUnCM(int argc, QStringList argv) AreaData* area = server->areas[current_area]; int removed = area->owners.removeAll(id); area->invited.removeAll(id); - if (removed == 0) - sendServerMessage("You are not a CM in this area."); - else { - sendServerMessage("You are no longer CM in this area."); - arup(ARUPType::CM, true); - } + sendServerMessage("You are no longer CM in this area."); + arup(ARUPType::CM, true); if (area->owners.isEmpty()) area->invited.clear(); } @@ -462,11 +458,7 @@ void AOClient::cmdInvite(int argc, QStringList argv) AreaData* area = server->areas[current_area]; bool ok; int invited_id = argv[0].toInt(&ok); - if (!area->owners.contains(id)) { - sendServerMessage("You are not a CM in this area."); - return; - } - else if (!ok) { + if (!ok) { sendServerMessage("That does not look like a valid ID."); return; } @@ -482,11 +474,7 @@ void AOClient::cmdUnInvite(int argc, QStringList argv) AreaData* area = server->areas[current_area]; bool ok; int uninvited_id = argv[0].toInt(&ok); - if (!area->owners.contains(id)) { - sendServerMessage("You are not a CM in this area."); - return; - } - else if (!ok) { + if (!ok) { sendServerMessage("That does not look like a valid ID."); return; } @@ -504,11 +492,7 @@ void AOClient::cmdUnInvite(int argc, QStringList argv) void AOClient::cmdLock(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (!area->owners.contains(id)) { - sendServerMessage("You are not a CM in this area."); - return; - } - else if (area->locked == AreaData::LockStatus::LOCKED) { + if (area->locked == AreaData::LockStatus::LOCKED) { sendServerMessage("This area is already locked."); return; } @@ -524,11 +508,7 @@ void AOClient::cmdLock(int argc, QStringList argv) void AOClient::cmdSpectatable(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (!area->owners.contains(id)) { - sendServerMessage("You are not a CM in this area."); - return; - } - else if (area->locked == AreaData::LockStatus::SPECTATABLE) { + if (area->locked == AreaData::LockStatus::SPECTATABLE) { sendServerMessage("This area is already in spectate mode."); return; } @@ -544,11 +524,7 @@ void AOClient::cmdSpectatable(int argc, QStringList argv) void AOClient::cmdUnLock(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (!area->owners.contains(id)) { - sendServerMessage("You are not a CM in this area."); - return; - } - else if (area->locked == AreaData::LockStatus::FREE) { + if (area->locked == AreaData::LockStatus::FREE) { sendServerMessage("This area is not locked."); return; } From f607be2d6cbb281880c3e56803b83314c647aad4 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Tue, 2 Mar 2021 21:44:08 -0600 Subject: [PATCH 12/17] fix crash in logger, add (nonfunctional) protected area flag --- include/area_data.h | 2 +- src/area_data.cpp | 1 + src/commands.cpp | 10 +++++++--- src/logger.cpp | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/area_data.h b/include/area_data.h index e284915..13d30d7 100644 --- a/include/area_data.h +++ b/include/area_data.h @@ -51,8 +51,8 @@ class AreaData { }; LockStatus locked; QString background; + bool is_protected; bool showname_allowed; - bool locking_allowed; bool iniswap_allowed; bool bg_locked; QString document; diff --git a/src/area_data.cpp b/src/area_data.cpp index b6916e9..3996c40 100644 --- a/src/area_data.cpp +++ b/src/area_data.cpp @@ -27,6 +27,7 @@ AreaData::AreaData(QStringList characters, QString p_name, int p_index) QSettings areas_ini("areas.ini", QSettings::IniFormat); areas_ini.beginGroup(p_name); background = areas_ini.value("background", "gs4").toString(); + is_protected = areas_ini.value("protected_area").toString().startsWith("true"); areas_ini.endGroup(); player_count = 0; locked = FREE; diff --git a/src/commands.cpp b/src/commands.cpp index facfb13..0b805de 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -415,16 +415,20 @@ void AOClient::cmdCM(int argc, QStringList argv) { QString sender_name = ooc_name; AreaData* area = server->areas[current_area]; - if (area->owners.isEmpty()) { + if (area->is_protected) { + sendServerMessage("This area is protected, you may not become CM."); + return; + } + else if (area->owners.isEmpty()) { // no one owns this area, and it's not protected area->owners.append(id); area->invited.append(id); sendServerMessageArea(sender_name + " is now CM in this area."); arup(ARUPType::CM, true); } - else if (!area->owners.contains(id)) { + else if (!area->owners.contains(id)) { // there is already a CM, and it isn't us sendServerMessage("You cannot become a CM in this area."); } - else if (argc == 1) { + else if (argc == 1) { // we are CM, and we want to make ID argv[0] also CM bool ok; AOClient* owner_candidate = server->getClientByID(argv[0].toInt(&ok)); if (!ok) { diff --git a/src/logger.cpp b/src/logger.cpp index 3dd5cf9..9e33240 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -51,7 +51,7 @@ void Logger::logCmd(AOClient *client, AOPacket *packet, QString cmd, QStringList else if (cmd == "rootpass") { addEntry(buildEntry(client, "USERS", "Root password created")); } - else if (cmd == "adduser") { + else if (cmd == "adduser" && !args.isEmpty()) { addEntry(buildEntry(client, "USERS", "Added user " + args[0])); } else From e30a91e8f7d52b07de4dcb7191e9eac43b4e0acc Mon Sep 17 00:00:00 2001 From: in1tiate Date: Tue, 2 Mar 2021 21:58:41 -0600 Subject: [PATCH 13/17] fix previously nonfunctional area protection --- src/area_data.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/area_data.cpp b/src/area_data.cpp index 3996c40..a3a8b6d 100644 --- a/src/area_data.cpp +++ b/src/area_data.cpp @@ -24,10 +24,10 @@ AreaData::AreaData(QStringList characters, QString p_name, int p_index) for (QString cur_char : characters) { characters_taken.insert(cur_char, false); } - QSettings areas_ini("areas.ini", QSettings::IniFormat); + QSettings areas_ini("config/areas.ini", QSettings::IniFormat); areas_ini.beginGroup(p_name); background = areas_ini.value("background", "gs4").toString(); - is_protected = areas_ini.value("protected_area").toString().startsWith("true"); + is_protected = areas_ini.value("protected_area").toBool(); areas_ini.endGroup(); player_count = 0; locked = FREE; From 954e64831c15ea0592e26a8c4ce893ae3b72c147 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Wed, 3 Mar 2021 01:44:41 -0600 Subject: [PATCH 14/17] fix some config shenanigans --- src/area_data.cpp | 1 + src/server.cpp | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/area_data.cpp b/src/area_data.cpp index a3a8b6d..a444c0a 100644 --- a/src/area_data.cpp +++ b/src/area_data.cpp @@ -39,6 +39,7 @@ AreaData::AreaData(QStringList characters, QString p_name, int p_index) QSettings config_ini("config/config.ini", QSettings::IniFormat); config_ini.beginGroup("Options"); int log_size = config_ini.value("logbuffer", 50).toInt(); + config_ini.endGroup(); if (log_size == 0) log_size = 500; logger = new Logger(log_size, this); diff --git a/src/server.cpp b/src/server.cpp index 23392d2..3996774 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -82,10 +82,6 @@ void Server::start() for (int i = 0; i < area_names.length(); i++) { QString area_name = area_names[i]; areas.insert(i, new AreaData(characters, area_name, i)); - areas_ini.beginGroup(area_name); - // TODO: more area config - areas[i]->background = areas_ini.value("background", "gs4").toString(); - areas_ini.endGroup(); } } From fb300e1b563e85d210fb0eb7a757b2a8feea2ba4 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Wed, 3 Mar 2021 01:56:26 -0600 Subject: [PATCH 15/17] "heads" not "head" --- src/commands.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands.cpp b/src/commands.cpp index 0b805de..6155d49 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -188,7 +188,7 @@ void AOClient::cmdSetBackground(int argc, QStringList argv) if (server->backgrounds.contains(argv[0])) { area->background = argv[0]; server->broadcast(AOPacket("BN", {argv[0]}), current_area); - server->broadcast(AOPacket("CT", {"Server", current_char + " changed the background to " + argv[0], "1"}), current_area); + sendServerMessageArea(current_char + " changed the background to " + argv[0]); } else { sendServerMessage("Invalid background name."); @@ -385,7 +385,7 @@ void AOClient::cmdNeed(int argc, QStringList argv) void AOClient::cmdFlip(int argc, QStringList argv) { QString sender_name = ooc_name; - QStringList faces = {"head","tails"}; + QStringList faces = {"heads","tails"}; QString face = faces[AOClient::genRand(0,1)]; sendServerMessage(sender_name + " flipped a coin and got " + face + "."); } From 3aa937f9084bfc7b37a500ba6b14346c2213aad8 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Thu, 4 Mar 2021 05:25:23 -0600 Subject: [PATCH 16/17] fix indentation --- src/aoclient.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aoclient.cpp b/src/aoclient.cpp index 710247c..0e7f1f3 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -171,10 +171,10 @@ void AOClient::arup(ARUPType type, bool broadcast) for (int owner_id : area->owners) { AOClient* owner = server->getClientByID(owner_id); area_owners.append("[" + QString::number(owner->id) + "] " + owner->current_char); - } - arup_data.append(area_owners.join(", ")); } + arup_data.append(area_owners.join(", ")); } + } else if (type == ARUPType::LOCKED) { QString lock_status; switch (area->locked) { From 62b3f8647f39ce70159a2e587067aebfa3a3cefd Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Thu, 4 Mar 2021 05:27:00 -0600 Subject: [PATCH 17/17] move CM check before auth check --- src/aoclient.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/aoclient.cpp b/src/aoclient.cpp index 0e7f1f3..344eebf 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -264,16 +264,14 @@ void AOClient::sendServerBroadcast(QString message) bool AOClient::checkAuth(unsigned long long acl_mask) { if (acl_mask != ACLFlags.value("NONE")) { - if (!authenticated && acl_mask != ACLFlags.value("CM")) { - return false; - } - if (acl_mask == ACLFlags.value("CM")) { AreaData* area = server->areas[current_area]; if (area->owners.contains(id)) return true; } - + else if (!authenticated) { + return false; + } QSettings settings("config/config.ini", QSettings::IniFormat); settings.beginGroup("Options"); QString auth_type = settings.value("auth", "simple").toString();