From f607be2d6cbb281880c3e56803b83314c647aad4 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Tue, 2 Mar 2021 21:44:08 -0600 Subject: [PATCH] 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