From f523fc6ec023b45e76be13135511da092b5b8bb1 Mon Sep 17 00:00:00 2001 From: Salanto <62221668+Salanto@users.noreply.github.com> Date: Sat, 11 Sep 2021 19:46:40 +0200 Subject: [PATCH] AOClient madness --- core/include/aoclient.h | 18 +- core/src/aoclient.cpp | 204 ++++---- core/src/commands/authentication.cpp | 126 ++--- core/src/commands/casing.cpp | 176 +++---- core/src/commands/command_helper.cpp | 125 +++-- core/src/commands/messaging.cpp | 298 ++++++------ core/src/commands/moderation.cpp | 368 +++++++-------- core/src/commands/music.cpp | 52 +-- core/src/commands/roleplay.cpp | 124 ++--- core/src/packets.cpp | 668 ++++++++++++++------------- core/src/server.cpp | 16 +- core/src/testimony_recorder.cpp | 6 +- 12 files changed, 1092 insertions(+), 1089 deletions(-) diff --git a/core/include/aoclient.h b/core/include/aoclient.h index 4d35cf9..baacc4a 100644 --- a/core/include/aoclient.h +++ b/core/include/aoclient.h @@ -34,6 +34,8 @@ #include #endif +class Server; + /** * @brief Represents a client connected to the server running Attorney Online 2 or one of its derivatives. */ @@ -51,7 +53,7 @@ class AOClient : public QObject { AOClient(Server* p_server, QTcpSocket* p_socket, QObject* parent = nullptr, int user_id = 0) : QObject(parent), m_id(user_id), m_remote_ip(p_socket->peerAddress()), m_password(""), m_joined(false), m_current_area(0), m_current_char(""), m_socket(p_socket), server(p_server), - is_partial(false), last_wtce_time(0) { + is_partial(false), m_last_wtce_time(0) { m_afk_timer = new QTimer; m_afk_timer->setSingleShot(true); connect(m_afk_timer, SIGNAL(timeout()), this, SLOT(onAfkTimeout())); @@ -1894,7 +1896,7 @@ class AOClient : public QObject { * @return The parsed text, converted into their respective durations, summed up, then converted into seconds. */ long long parseTime(QString input); - QString getReprimand(bool positive = false); + QString getReprimand(bool f_positive = false); /** * @brief Adds the last send IC-Message to QVector of the respective area. @@ -1935,7 +1937,7 @@ class AOClient : public QObject { * * @return True if the password meets the requirements, otherwise false. */ - bool checkPasswordRequirements(QString username, QString password); + bool checkPasswordRequirements(QString f_username, QString f_password); /** * @brief Sends a server notice. @@ -1944,7 +1946,7 @@ class AOClient : public QObject { * * @param global Whether or not the notice should be server-wide. */ - void sendNotice(QString notice, bool global = false); + void sendNotice(QString f_notice, bool f_global = false); /** @@ -2143,14 +2145,14 @@ class AOClient : public QObject { * @details Generated based on the client's own supplied hardware ID. * The client supplied hardware ID is generally a machine unique ID. */ - QString hwid; + QString m_hwid; /** * @brief The IPID of the client. * * @details Generated based on the client's IP, but cannot be reversed to identify the client's IP. */ - QString ipid; + QString m_ipid; /** * @brief The time in seconds since the client last sent a Witness Testimony / Cross Examination @@ -2158,14 +2160,14 @@ class AOClient : public QObject { * * @details Used to filter out potential spam. */ - long last_wtce_time; + long m_last_wtce_time; /** * @brief The text of the last in-character message that was sent by the client. * * @details Used to determine if the incoming message is a duplicate. */ - QString last_message; + QString m_last_message; /** * @brief A helper function to add recorded packets to an area's judgelog. diff --git a/core/src/aoclient.cpp b/core/src/aoclient.cpp index 61d6186..7b59c04 100644 --- a/core/src/aoclient.cpp +++ b/core/src/aoclient.cpp @@ -19,31 +19,31 @@ void AOClient::clientData() { - if (last_read + socket->bytesAvailable() > 30720) { // Client can send a max of 30KB to the server over two sequential reads - socket->close(); + if (last_read + m_socket->bytesAvailable() > 30720) { // Client can send a max of 30KB to the server over two sequential reads + m_socket->close(); } if (last_read == 0) { // i.e. this is the first packet we've been sent - if (!socket->waitForConnected(1000)) { - socket->close(); + if (!m_socket->waitForConnected(1000)) { + m_socket->close(); } } - QString data = QString::fromUtf8(socket->readAll()); - last_read = data.size(); + QString l_data = QString::fromUtf8(m_socket->readAll()); + last_read = l_data.size(); if (is_partial) { - data = partial_packet + data; + l_data = partial_packet + l_data; } - if (!data.endsWith("%")) { + if (!l_data.endsWith("%")) { is_partial = true; } - QStringList all_packets = data.split("%"); - all_packets.removeLast(); // Remove the entry after the last delimiter + QStringList l_all_packets = l_data.split("%"); + l_all_packets.removeLast(); // Remove the entry after the last delimiter - for (const QString &single_packet : qAsConst(all_packets)) { - AOPacket packet(single_packet); - handlePacket(packet); + for (const QString &l_single_packet : qAsConst(l_all_packets)) { + AOPacket l_packet(l_single_packet); + handlePacket(l_packet); } } @@ -52,20 +52,20 @@ void AOClient::clientDisconnected() #ifdef NET_DEBUG qDebug() << remote_ip.toString() << "disconnected"; #endif - if (joined) { + if (m_joined) { server->m_player_count--; - server->m_areas[current_area]->clientLeftArea(server->getCharID(current_char)); + server->m_areas[m_current_area]->clientLeftArea(server->getCharID(m_current_char)); arup(ARUPType::PLAYER_COUNT, true); } - if (current_char != "") { - server->updateCharsTaken(server->m_areas[current_area]); + if (m_current_char != "") { + server->updateCharsTaken(server->m_areas[m_current_area]); } bool l_updateLocks = false; - for (AreaData* area : qAsConst(server->m_areas)) { - l_updateLocks = l_updateLocks || area->removeOwner(id); + for (AreaData* l_area : qAsConst(server->m_areas)) { + l_updateLocks = l_updateLocks || l_area->removeOwner(m_id); } if (l_updateLocks) @@ -78,105 +78,105 @@ void AOClient::handlePacket(AOPacket packet) #ifdef NET_DEBUG qDebug() << "Received packet:" << packet.header << ":" << packet.contents << "args length:" << packet.contents.length(); #endif - AreaData* area = server->m_areas[current_area]; - PacketInfo info = packets.value(packet.header, {false, 0, &AOClient::pktDefault}); + AreaData* l_area = server->m_areas[m_current_area]; + PacketInfo l_info = packets.value(packet.header, {false, 0, &AOClient::pktDefault}); if (packet.contents.join("").size() > 16384) { return; } - if (!checkAuth(info.acl_mask)) { + if (!checkAuth(l_info.acl_mask)) { return; } if (packet.header != "CH") { - if (is_afk) + if (m_is_afk) sendServerMessage("You are no longer AFK."); - is_afk = false; - afk_timer->start(ConfigManager::afkTimeout() * 1000); + m_is_afk = false; + m_afk_timer->start(ConfigManager::afkTimeout() * 1000); } - if (packet.contents.length() < info.minArgs) { + if (packet.contents.length() < l_info.minArgs) { #ifdef NET_DEBUG qDebug() << "Invalid packet args length. Minimum is" << info.minArgs << "but only" << packet.contents.length() << "were given."; #endif return; } - (this->*(info.action))(area, packet.contents.length(), packet.contents, packet); + (this->*(l_info.action))(l_area, packet.contents.length(), packet.contents, packet); } void AOClient::changeArea(int new_area) { - if (current_area == new_area) { - sendServerMessage("You are already in area " + server->m_area_names[current_area]); + if (m_current_area == new_area) { + sendServerMessage("You are already in area " + server->m_area_names[m_current_area]); return; } - if (server->m_areas[new_area]->lockStatus() == AreaData::LockStatus::LOCKED && !server->m_areas[new_area]->invited().contains(id) && !checkAuth(ACLFlags.value("BYPASS_LOCKS"))) { + if (server->m_areas[new_area]->lockStatus() == AreaData::LockStatus::LOCKED && !server->m_areas[new_area]->invited().contains(m_id) && !checkAuth(ACLFlags.value("BYPASS_LOCKS"))) { sendServerMessage("Area " + server->m_area_names[new_area] + " is locked."); return; } - if (current_char != "") { - server->m_areas[current_area]->changeCharacter(server->getCharID(current_char), -1); - server->updateCharsTaken(server->m_areas[current_area]); + if (m_current_char != "") { + server->m_areas[m_current_area]->changeCharacter(server->getCharID(m_current_char), -1); + server->updateCharsTaken(server->m_areas[m_current_area]); } - server->m_areas[current_area]->clientLeftArea(char_id); - bool character_taken = false; - if (server->m_areas[new_area]->charactersTaken().contains(server->getCharID(current_char))) { - current_char = ""; - char_id = -1; - character_taken = true; + server->m_areas[m_current_area]->clientLeftArea(m_char_id); + bool l_character_taken = false; + if (server->m_areas[new_area]->charactersTaken().contains(server->getCharID(m_current_char))) { + m_current_char = ""; + m_char_id = -1; + l_character_taken = true; } - server->m_areas[new_area]->clientJoinedArea(char_id); - current_area = new_area; + server->m_areas[new_area]->clientJoinedArea(m_char_id); + m_current_area = new_area; arup(ARUPType::PLAYER_COUNT, true); sendEvidenceList(server->m_areas[new_area]); sendPacket("HP", {"1", QString::number(server->m_areas[new_area]->defHP())}); sendPacket("HP", {"2", QString::number(server->m_areas[new_area]->proHP())}); sendPacket("BN", {server->m_areas[new_area]->background()}); - if (character_taken) { + if (l_character_taken) { sendPacket("DONE"); } - const QList timers = server->m_areas[current_area]->timers(); - for (QTimer* timer : timers) { - int timer_id = server->m_areas[current_area]->timers().indexOf(timer) + 1; - if (timer->isActive()) { - sendPacket("TI", {QString::number(timer_id), "2"}); - sendPacket("TI", {QString::number(timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(timer->remainingTime())))}); + const QList l_timers = server->m_areas[m_current_area]->timers(); + for (QTimer* l_timer : l_timers) { + int l_timer_id = server->m_areas[m_current_area]->timers().indexOf(l_timer) + 1; + if (l_timer->isActive()) { + sendPacket("TI", {QString::number(l_timer_id), "2"}); + sendPacket("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(l_timer->remainingTime())))}); } else { - sendPacket("TI", {QString::number(timer_id), "3"}); + sendPacket("TI", {QString::number(l_timer_id), "3"}); } } - sendServerMessage("You moved to area " + server->m_area_names[current_area]); - if (server->m_areas[current_area]->lockStatus() == AreaData::LockStatus::SPECTATABLE) - sendServerMessage("Area " + server->m_area_names[current_area] + " is spectate-only; to chat IC you will need to be invited by the CM."); + sendServerMessage("You moved to area " + server->m_area_names[m_current_area]); + if (server->m_areas[m_current_area]->lockStatus() == AreaData::LockStatus::SPECTATABLE) + sendServerMessage("Area " + server->m_area_names[m_current_area] + " is spectate-only; to chat IC you will need to be invited by the CM."); } bool AOClient::changeCharacter(int char_id) { - AreaData* area = server->m_areas[current_area]; + AreaData* l_area = server->m_areas[m_current_area]; if(char_id >= server->m_characters.length()) return false; - if (is_charcursed && !charcurse_list.contains(char_id)) { + if (m_is_charcursed && !m_charcurse_list.contains(char_id)) { return false; } - bool l_successfulChange = area->changeCharacter(server->getCharID(current_char), char_id); + bool l_successfulChange = l_area->changeCharacter(server->getCharID(m_current_char), char_id); if (char_id < 0) { - current_char = ""; + m_current_char = ""; } if (l_successfulChange == true) { - QString char_selected = server->m_characters[char_id]; - current_char = char_selected; - pos = ""; - server->updateCharsTaken(area); - sendPacket("PV", {QString::number(id), "CID", QString::number(char_id)}); + QString l_char_selected = server->m_characters[char_id]; + m_current_char = l_char_selected; + m_pos = ""; + server->updateCharsTaken(l_area); + sendPacket("PV", {QString::number(m_id), "CID", QString::number(char_id)}); return true; } return false; @@ -184,60 +184,60 @@ bool AOClient::changeCharacter(int char_id) void AOClient::changePosition(QString new_pos) { - pos = new_pos; - sendServerMessage("Position changed to " + pos + "."); - sendPacket("SP", {pos}); + m_pos = new_pos; + sendServerMessage("Position changed to " + m_pos + "."); + sendPacket("SP", {m_pos}); } void AOClient::handleCommand(QString command, int argc, QStringList argv) { - CommandInfo info = commands.value(command, {false, -1, &AOClient::cmdDefault}); + CommandInfo l_info = commands.value(command, {false, -1, &AOClient::cmdDefault}); - if (!checkAuth(info.acl_mask)) { + if (!checkAuth(l_info.acl_mask)) { sendServerMessage("You do not have permission to use that command."); return; } - if (argc < info.minArgs) { + if (argc < l_info.minArgs) { sendServerMessage("Invalid command syntax."); return; } - (this->*(info.action))(argc, argv); + (this->*(l_info.action))(argc, argv); } void AOClient::arup(ARUPType type, bool broadcast) { - QStringList arup_data; - arup_data.append(QString::number(type)); - for (AreaData* area : qAsConst(server->m_areas)) { + QStringList l_arup_data; + l_arup_data.append(QString::number(type)); + for (AreaData* l_area : qAsConst(server->m_areas)) { switch(type) { case ARUPType::PLAYER_COUNT: { - arup_data.append(QString::number(area->playerCount())); + l_arup_data.append(QString::number(l_area->playerCount())); break; } case ARUPType::STATUS: { - QString area_status = QVariant::fromValue(area->status()).toString().replace("_", "-"); // LOOKING_FOR_PLAYERS to LOOKING-FOR-PLAYERS - arup_data.append(area_status); + QString l_area_status = QVariant::fromValue(l_area->status()).toString().replace("_", "-"); // LOOKING_FOR_PLAYERS to LOOKING-FOR-PLAYERS + l_arup_data.append(l_area_status); break; } case ARUPType::CM: { - if (area->owners().isEmpty()) - arup_data.append("FREE"); + if (l_area->owners().isEmpty()) + l_arup_data.append("FREE"); else { - QStringList area_owners; - const QList owner_ids = area->owners(); - for (int owner_id : owner_ids) { - AOClient* owner = server->getClientByID(owner_id); - area_owners.append("[" + QString::number(owner->id) + "] " + owner->current_char); + QStringList l_area_owners; + const QList l_owner_ids = l_area->owners(); + for (int l_owner_id : l_owner_ids) { + AOClient* l_owner = server->getClientByID(l_owner_id); + l_area_owners.append("[" + QString::number(l_owner->m_id) + "] " + l_owner->m_current_char); } - arup_data.append(area_owners.join(", ")); + l_arup_data.append(l_area_owners.join(", ")); } break; } case ARUPType::LOCKED: { - QString lock_status = QVariant::fromValue(area->lockStatus()).toString(); - arup_data.append(lock_status); + QString l_lock_status = QVariant::fromValue(l_area->lockStatus()).toString(); + l_arup_data.append(l_lock_status); break; } default: { @@ -246,9 +246,9 @@ void AOClient::arup(ARUPType type, bool broadcast) } } if (broadcast) - server->broadcast(AOPacket("ARUP", arup_data)); + server->broadcast(AOPacket("ARUP", l_arup_data)); else - sendPacket("ARUP", arup_data); + sendPacket("ARUP", l_arup_data); } void AOClient::fullArup() { @@ -268,8 +268,8 @@ void AOClient::sendPacket(AOPacket packet) .replaceInStrings("$", ""); if (packet.header != "LE") packet.contents.replaceInStrings("&", ""); - socket->write(packet.toUtf8()); - socket->flush(); + m_socket->write(packet.toUtf8()); + m_socket->flush(); } void AOClient::sendPacket(QString header, QStringList contents) @@ -292,9 +292,9 @@ void AOClient::calculateIpid() QCryptographicHash hash(QCryptographicHash::Md5); // Don't need security, just hashing for uniqueness - hash.addData(remote_ip.toString().toUtf8()); + hash.addData(m_remote_ip.toString().toUtf8()); - ipid = hash.result().toHex().right(8); // Use the last 8 characters (4 bytes) + m_ipid = hash.result().toHex().right(8); // Use the last 8 characters (4 bytes) } void AOClient::sendServerMessage(QString message) @@ -304,7 +304,7 @@ void AOClient::sendServerMessage(QString message) void AOClient::sendServerMessageArea(QString message) { - server->broadcast(AOPacket("CT", {ConfigManager::serverName(), message, "1"}), current_area); + server->broadcast(AOPacket("CT", {ConfigManager::serverName(), message, "1"}), m_current_area); } void AOClient::sendServerBroadcast(QString message) @@ -319,20 +319,20 @@ bool AOClient::checkAuth(unsigned long long acl_mask) #endif if (acl_mask != ACLFlags.value("NONE")) { if (acl_mask == ACLFlags.value("CM")) { - AreaData* area = server->m_areas[current_area]; - if (area->owners().contains(id)) + AreaData* l_area = server->m_areas[m_current_area]; + if (l_area->owners().contains(m_id)) return true; } - else if (!authenticated) { + else if (!m_authenticated) { return false; } switch (ConfigManager::authType()) { case DataTypes::AuthType::SIMPLE: - return authenticated; + return m_authenticated; break; case DataTypes::AuthType::ADVANCED: - unsigned long long user_acl = server->db_manager->getACL(moderator_name); - return (user_acl & acl_mask) != 0; + unsigned long long l_user_acl = server->db_manager->getACL(m_moderator_name); + return (l_user_acl & acl_mask) != 0; break; } } @@ -340,19 +340,19 @@ bool AOClient::checkAuth(unsigned long long acl_mask) } -QString AOClient::getIpid() const { return ipid; } +QString AOClient::getIpid() const { return m_ipid; } -QString AOClient::getHwid() const { return hwid; } +QString AOClient::getHwid() const { return m_hwid; } Server* AOClient::getServer() { return server; } void AOClient::onAfkTimeout() { - if (!is_afk) + if (!m_is_afk) sendServerMessage("You are now AFK."); - is_afk = true; + m_is_afk = true; } AOClient::~AOClient() { - socket->deleteLater(); + m_socket->deleteLater(); } diff --git a/core/src/commands/authentication.cpp b/core/src/commands/authentication.cpp index bb8a0a7..b0a5c3d 100644 --- a/core/src/commands/authentication.cpp +++ b/core/src/commands/authentication.cpp @@ -25,7 +25,7 @@ void AOClient::cmdLogin(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - if (authenticated) { + if (m_authenticated) { sendServerMessage("You are already logged in!"); return; } @@ -37,13 +37,13 @@ void AOClient::cmdLogin(int argc, QStringList argv) } else { sendServerMessage("Entering login prompt.\nPlease enter the server modpass."); - is_logging_in = true; + m_is_logging_in = true; return; } break; case DataTypes::AuthType::ADVANCED: sendServerMessage("Entering login prompt.\nPlease enter your username and password."); - is_logging_in = true; + m_is_logging_in = true; return; break; } @@ -73,20 +73,20 @@ void AOClient::cmdSetRootPass(int argc, QStringList argv) } sendServerMessage("Changing auth type and setting root password.\nLogin again with /login root [password]"); - authenticated = false; + m_authenticated = false; ConfigManager::setAuthType(DataTypes::AuthType::ADVANCED); #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) qsrand(QDateTime::currentMSecsSinceEpoch()); - quint32 upper_salt = qrand(); - quint32 lower_salt = qrand(); - quint64 salt_number = (upper_salt << 32) | lower_salt; + quint32 l_upper_salt = qrand(); + quint32 l_lower_salt = qrand(); + quint64 l_salt_number = (upper_salt << 32) | lower_salt; #else - quint64 salt_number = QRandomGenerator::system()->generate64(); + quint64 l_salt_number = QRandomGenerator::system()->generate64(); #endif - QString salt = QStringLiteral("%1").arg(salt_number, 16, 16, QLatin1Char('0')); + QString l_salt = QStringLiteral("%1").arg(l_salt_number, 16, 16, QLatin1Char('0')); - server->db_manager->createUser("root", salt, argv[0], ACLFlags.value("SUPER")); + server->db_manager->createUser("root", l_salt, argv[0], ACLFlags.value("SUPER")); } void AOClient::cmdAddUser(int argc, QStringList argv) @@ -99,15 +99,15 @@ void AOClient::cmdAddUser(int argc, QStringList argv) } #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) qsrand(QDateTime::currentMSecsSinceEpoch()); - quint32 upper_salt = qrand(); - quint32 lower_salt = qrand(); - quint64 salt_number = (upper_salt << 32) | lower_salt; + quint32 l_upper_salt = qrand(); + quint32 l_lower_salt = qrand(); + quint64 l_salt_number = (upper_salt << 32) | lower_salt; #else - quint64 salt_number = QRandomGenerator::system()->generate64(); + quint64 l_salt_number = QRandomGenerator::system()->generate64(); #endif - QString salt = QStringLiteral("%1").arg(salt_number, 16, 16, QLatin1Char('0')); + QString l_salt = QStringLiteral("%1").arg(l_salt_number, 16, 16, QLatin1Char('0')); - if (server->db_manager->createUser(argv[0], salt, argv[1], ACLFlags.value("NONE"))) + if (server->db_manager->createUser(argv[0], l_salt, argv[1], ACLFlags.value("NONE"))) sendServerMessage("Created user " + argv[0] + ".\nUse /addperm to modify their permissions."); else sendServerMessage("Unable to create user " + argv[0] + ".\nDoes a user with that name already exist?"); @@ -125,60 +125,60 @@ void AOClient::cmdRemoveUser(int argc, QStringList argv) void AOClient::cmdListPerms(int argc, QStringList argv) { - unsigned long long user_acl = server->db_manager->getACL(moderator_name); - QStringList message; - const QStringList keys = ACLFlags.keys(); + unsigned long long l_user_acl = server->db_manager->getACL(m_moderator_name); + QStringList l_message; + const QStringList l_keys = ACLFlags.keys(); if (argc == 0) { // Just print out all permissions available to the user. - message.append("You have been given the following permissions:"); - for (const QString &perm : keys) { - if (perm == "NONE"); // don't need to list this one - else if (perm == "SUPER") { - if (user_acl == ACLFlags.value("SUPER")) // This has to be checked separately, because SUPER & anything will always be truthy - message.append("SUPER (Be careful! This grants the user all permissions.)"); + l_message.append("You have been given the following permissions:"); + for (const QString &l_perm : l_keys) { + if (l_perm == "NONE"); // don't need to list this one + else if (l_perm == "SUPER") { + if (l_user_acl == ACLFlags.value("SUPER")) // This has to be checked separately, because SUPER & anything will always be truthy + l_message.append("SUPER (Be careful! This grants the user all permissions.)"); } - else if ((ACLFlags.value(perm) & user_acl) == 0); // user doesn't have this permission, don't print it + else if ((ACLFlags.value(l_perm) & l_user_acl) == 0); // user doesn't have this permission, don't print it else - message.append(perm); + l_message.append(l_perm); } } else { - if ((user_acl & ACLFlags.value("MODIFY_USERS")) == 0) { + if ((l_user_acl & ACLFlags.value("MODIFY_USERS")) == 0) { sendServerMessage("You do not have permission to view other users' permissions."); return; } - message.append("User " + argv[0] + " has the following permissions:"); - unsigned long long acl = server->db_manager->getACL(argv[0]); - if (acl == 0) { + l_message.append("User " + argv[0] + " has the following permissions:"); + unsigned long long l_acl = server->db_manager->getACL(argv[0]); + if (l_acl == 0) { sendServerMessage("This user either doesn't exist, or has no permissions set."); return; } - for (const QString &perm : keys) { - if ((ACLFlags.value(perm) & acl) != 0 && perm != "SUPER") { - message.append(perm); + for (const QString &l_perm : l_keys) { + if ((ACLFlags.value(l_perm) & l_acl) != 0 && l_perm != "SUPER") { + l_message.append(l_perm); } } } - sendServerMessage(message.join("\n")); + sendServerMessage(l_message.join("\n")); } void AOClient::cmdAddPerms(int argc, QStringList argv) { Q_UNUSED(argc); - unsigned long long user_acl = server->db_manager->getACL(moderator_name); + unsigned long long l_user_acl = server->db_manager->getACL(m_moderator_name); argv[1] = argv[1].toUpper(); - const QStringList keys = ACLFlags.keys(); + const QStringList l_keys = ACLFlags.keys(); - if (!keys.contains(argv[1])) { + if (!l_keys.contains(argv[1])) { sendServerMessage("That permission doesn't exist!"); return; } if (argv[1] == "SUPER") { - if (user_acl != ACLFlags.value("SUPER")) { + if (l_user_acl != ACLFlags.value("SUPER")) { // This has to be checked separately, because SUPER & anything will always be truthy sendServerMessage("You aren't allowed to add that permission!"); return; @@ -189,9 +189,9 @@ void AOClient::cmdAddPerms(int argc, QStringList argv) return; } - unsigned long long newperm = ACLFlags.value(argv[1]); - if ((newperm & user_acl) != 0) { - if (server->db_manager->updateACL(argv[0], newperm, true)) + unsigned long long l_newperm = ACLFlags.value(argv[1]); + if ((l_newperm & l_user_acl) != 0) { + if (server->db_manager->updateACL(argv[0], l_newperm, true)) sendServerMessage("Successfully added permission " + argv[1] + " to user " + argv[0]); else sendServerMessage(argv[0] + " wasn't found!"); @@ -205,12 +205,12 @@ void AOClient::cmdRemovePerms(int argc, QStringList argv) { Q_UNUSED(argc); - unsigned long long user_acl = server->db_manager->getACL(moderator_name); + unsigned long long l_user_acl = server->db_manager->getACL(m_moderator_name); argv[1] = argv[1].toUpper(); - const QStringList keys = ACLFlags.keys(); + const QStringList l_keys = ACLFlags.keys(); - if (!keys.contains(argv[1])) { + if (!l_keys.contains(argv[1])) { sendServerMessage("That permission doesn't exist!"); return; } @@ -221,7 +221,7 @@ void AOClient::cmdRemovePerms(int argc, QStringList argv) } if (argv[1] == "SUPER") { - if (user_acl != ACLFlags.value("SUPER")) { + if (l_user_acl != ACLFlags.value("SUPER")) { // This has to be checked separately, because SUPER & anything will always be truthy sendServerMessage("You aren't allowed to remove that permission!"); return; @@ -232,9 +232,9 @@ void AOClient::cmdRemovePerms(int argc, QStringList argv) return; } - unsigned long long newperm = ACLFlags.value(argv[1]); - if ((newperm & user_acl) != 0) { - if (server->db_manager->updateACL(argv[0], newperm, false)) + unsigned long long l_newperm = ACLFlags.value(argv[1]); + if ((l_newperm & l_user_acl) != 0) { + if (server->db_manager->updateACL(argv[0], l_newperm, false)) sendServerMessage("Successfully removed permission " + argv[1] + " from user " + argv[0]); else sendServerMessage(argv[0] + " wasn't found!"); @@ -249,8 +249,8 @@ void AOClient::cmdListUsers(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - QStringList users = server->db_manager->getUsers(); - sendServerMessage("All users:\n" + users.join("\n")); + QStringList l_users = server->db_manager->getUsers(); + sendServerMessage("All users:\n" + l_users.join("\n")); } void AOClient::cmdLogout(int argc, QStringList argv) @@ -258,42 +258,42 @@ void AOClient::cmdLogout(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - if (!authenticated) { + if (!m_authenticated) { sendServerMessage("You are not logged in!"); return; } - authenticated = false; - moderator_name = ""; + m_authenticated = false; + m_moderator_name = ""; sendPacket("AUTH", {"-1"}); // Client: "You were logged out." } void AOClient::cmdChangePassword(int argc, QStringList argv) { - QString username; - QString password; + QString l_username; + QString l_password; if (argc == 1) { - if (moderator_name.isEmpty()) { + if (m_moderator_name.isEmpty()) { sendServerMessage("You are not logged in."); return; } - username = moderator_name; - password = argv[0]; + l_username = m_moderator_name; + l_password = argv[0]; } else if (argc == 2 && checkAuth(ACLFlags.value("SUPER"))) { - username = argv[0]; - password = argv[1]; + l_username = argv[0]; + l_password = argv[1]; } else { sendServerMessage("Invalid command syntax."); return; } - if (!checkPasswordRequirements(username, password)) { + if (!checkPasswordRequirements(l_username, l_password)) { sendServerMessage("Password does not meet server requirements."); return; } - if (server->db_manager->updatePassword(username, password)) { + if (server->db_manager->updatePassword(l_username, l_password)) { sendServerMessage("Successfully changed password."); } else { diff --git a/core/src/commands/casing.cpp b/core/src/commands/casing.cpp index 688568e..d664bdb 100644 --- a/core/src/commands/casing.cpp +++ b/core/src/commands/casing.cpp @@ -22,14 +22,14 @@ void AOClient::cmdDoc(int argc, QStringList argv) { - QString sender_name = ooc_name; - AreaData* area = server->m_areas[current_area]; + QString l_sender_name = m_ooc_name; + AreaData* l_area = server->m_areas[m_current_area]; if (argc == 0) { - sendServerMessage("Document: " + area->document()); + sendServerMessage("Document: " + l_area->document()); } else { - area->changeDoc(argv.join(" ")); - sendServerMessageArea(sender_name + " changed the document."); + l_area->changeDoc(argv.join(" ")); + sendServerMessageArea(l_sender_name + " changed the document."); } } @@ -38,26 +38,26 @@ void AOClient::cmdClearDoc(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - QString sender_name = ooc_name; - AreaData* area = server->m_areas[current_area]; - area->changeDoc("No document."); - sendServerMessageArea(sender_name + " cleared the document."); + QString l_sender_name = m_ooc_name; + AreaData* l_area = server->m_areas[m_current_area]; + l_area->changeDoc("No document."); + sendServerMessageArea(l_sender_name + " cleared the document."); } void AOClient::cmdEvidenceMod(int argc, QStringList argv) { Q_UNUSED(argc); - AreaData* area = server->m_areas[current_area]; + AreaData* l_area = server->m_areas[m_current_area]; argv[0] = argv[0].toLower(); if (argv[0] == "cm") - area->setEviMod(AreaData::EvidenceMod::CM); + l_area->setEviMod(AreaData::EvidenceMod::CM); else if (argv[0] == "mod") - area->setEviMod(AreaData::EvidenceMod::MOD); + l_area->setEviMod(AreaData::EvidenceMod::MOD); else if (argv[0] == "hiddencm") - area->setEviMod(AreaData::EvidenceMod::HIDDEN_CM); + l_area->setEviMod(AreaData::EvidenceMod::HIDDEN_CM); else if (argv[0] == "ffa") - area->setEviMod(AreaData::EvidenceMod::FFA); + l_area->setEviMod(AreaData::EvidenceMod::FFA); else { sendServerMessage("Invalid evidence mod."); return; @@ -65,36 +65,36 @@ void AOClient::cmdEvidenceMod(int argc, QStringList argv) sendServerMessage("Changed evidence mod."); // Resend evidence lists to everyone in the area - sendEvidenceList(area); + sendEvidenceList(l_area); } void AOClient::cmdEvidence_Swap(int argc, QStringList argv) { Q_UNUSED(argc); - AreaData* area = server->m_areas[current_area]; - int ev_size = area->evidence().size() -1; + AreaData* l_area = server->m_areas[m_current_area]; + int l_ev_size = l_area->evidence().size() -1; - if (ev_size < 0) { + if (l_ev_size < 0) { sendServerMessage("No evidence in area."); return; } bool ok, ok2; - int ev_id1 = argv[0].toInt(&ok), ev_id2 = argv[1].toInt(&ok2); + int l_ev_id1 = argv[0].toInt(&ok), l_ev_id2 = argv[1].toInt(&ok2); if ((!ok || !ok2)) { sendServerMessage("Invalid evidence ID."); return; } - if ((ev_id1 < 0) || (ev_id2 < 0)) { + if ((l_ev_id1 < 0) || (l_ev_id2 < 0)) { sendServerMessage("Evidence ID can't be negative."); return; } - if ((ev_id2 <= ev_size) && (ev_id1 <= ev_size)) { - area->swapEvidence(ev_id1, ev_id2); - sendEvidenceList(area); - sendServerMessage("The evidence " + QString::number(ev_id1) + " and " + QString::number(ev_id2) + " have been swapped."); + if ((l_ev_id2 <= l_ev_size) && (l_ev_id1 <= l_ev_size)) { + l_area->swapEvidence(l_ev_id1, l_ev_id2); + sendEvidenceList(l_area); + sendServerMessage("The evidence " + QString::number(l_ev_id1) + " and " + QString::number(l_ev_id2) + " have been swapped."); } else { sendServerMessage("Unable to swap evidence. Evidence ID out of range."); @@ -106,13 +106,13 @@ void AOClient::cmdTestify(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - AreaData* area = server->m_areas[current_area]; - if (area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING) { + AreaData* l_area = server->m_areas[m_current_area]; + if (l_area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING) { sendServerMessage("Testimony recording is already in progress. Please stop it before starting a new one."); } else { clearTestimony(); - area->setTestimonyRecording(AreaData::TestimonyRecording::RECORDING); + l_area->setTestimonyRecording(AreaData::TestimonyRecording::RECORDING); sendServerMessage("Started testimony recording."); } } @@ -122,15 +122,15 @@ void AOClient::cmdExamine(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - AreaData* area = server->m_areas[current_area]; - if (area->testimony().size() -1 > 0) + AreaData* l_area = server->m_areas[m_current_area]; + if (l_area->testimony().size() -1 > 0) { - area->restartTestimony(); - server->broadcast(AOPacket("RT",{"testimony2"}), current_area); - server->broadcast(AOPacket("MS", {area->testimony()[0]}), current_area); + l_area->restartTestimony(); + server->broadcast(AOPacket("RT",{"testimony2"}), m_current_area); + server->broadcast(AOPacket("MS", {l_area->testimony()[0]}), m_current_area); return; } - if (area->testimonyRecording() == AreaData::TestimonyRecording::PLAYBACK) + if (l_area->testimonyRecording() == AreaData::TestimonyRecording::PLAYBACK) sendServerMessage("Unable to examine while another examination is running"); else sendServerMessage("Unable to start replay without prior examination."); @@ -141,20 +141,20 @@ void AOClient::cmdTestimony(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - AreaData* area = server->m_areas[current_area]; - if (area->testimony().size() -1 < 1) { + AreaData* l_area = server->m_areas[m_current_area]; + if (l_area->testimony().size() -1 < 1) { sendServerMessage("Unable to display empty testimony."); return; } - QString ooc_message; - for (int i = 1; i <= area->testimony().size() -1; i++) + QString l_ooc_message; + for (int i = 1; i <= l_area->testimony().size() -1; i++) { - QStringList packet = area->testimony().at(i); - QString ic_message = packet[4]; - ooc_message.append( "[" + QString::number(i) + "]" + ic_message + "\n"); + QStringList l_packet = l_area->testimony().at(i); + QString l_ic_message = l_packet[4]; + l_ooc_message.append( "[" + QString::number(i) + "]" + l_ic_message + "\n"); } - sendServerMessage(ooc_message); + sendServerMessage(l_ooc_message); } void AOClient::cmdDeleteStatement(int argc, QStringList argv) @@ -162,14 +162,14 @@ void AOClient::cmdDeleteStatement(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - AreaData* area = server->m_areas[current_area]; - int c_statement = area->statement(); - if (area->testimony().size() - 1 == 0) { + AreaData* l_area = server->m_areas[m_current_area]; + int l_c_statement = l_area->statement(); + if (l_area->testimony().size() - 1 == 0) { sendServerMessage("Unable to delete statement. No statements saved in this area."); } - if (c_statement > 0 && area->testimony().size() > 2) { - area->removeStatement(c_statement); - sendServerMessage("The statement with id " + QString::number(c_statement) + " has been deleted from the testimony."); + if (l_c_statement > 0 && l_area->testimony().size() > 2) { + l_area->removeStatement(l_c_statement); + sendServerMessage("The statement with id " + QString::number(l_c_statement) + " has been deleted from the testimony."); } } @@ -178,7 +178,7 @@ void AOClient::cmdUpdateStatement(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - server->m_areas[current_area]->setTestimonyRecording(AreaData::TestimonyRecording::UPDATE); + server->m_areas[m_current_area]->setTestimonyRecording(AreaData::TestimonyRecording::UPDATE); sendServerMessage("The next IC-Message will replace the last displayed replay message."); } @@ -187,9 +187,9 @@ void AOClient::cmdPauseTestimony(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - AreaData* area = server->m_areas[current_area]; - area->setTestimonyRecording(AreaData::TestimonyRecording::STOPPED); - server->broadcast(AOPacket("RT",{"testimony1", "1"}), current_area); + AreaData* l_area = server->m_areas[m_current_area]; + l_area->setTestimonyRecording(AreaData::TestimonyRecording::STOPPED); + server->broadcast(AOPacket("RT",{"testimony1", "1"}), m_current_area); sendServerMessage("Testimony has been stopped."); } @@ -198,8 +198,8 @@ void AOClient::cmdAddStatement(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - if (server->m_areas[current_area]->statement() < ConfigManager::maxStatements()) { - server->m_areas[current_area]->setTestimonyRecording(AreaData::TestimonyRecording::ADD); + if (server->m_areas[m_current_area]->statement() < ConfigManager::maxStatements()) { + server->m_areas[m_current_area]->setTestimonyRecording(AreaData::TestimonyRecording::ADD); sendServerMessage("The next IC-Message will be inserted into the testimony."); } else @@ -210,41 +210,41 @@ void AOClient::cmdSaveTestimony(int argc, QStringList argv) { Q_UNUSED(argc); - bool permission_found = false; + bool l_permission_found = false; if (checkAuth(ACLFlags.value("SAVETEST"))) - permission_found = true; + l_permission_found = true; - if (testimony_saving == true) - permission_found = true; + if (m_testimony_saving == true) + l_permission_found = true; - if (permission_found) { - AreaData* area = server->m_areas[current_area]; - if (area->testimony().size() -1 <= 0) { + if (l_permission_found) { + AreaData* l_area = server->m_areas[m_current_area]; + if (l_area->testimony().size() -1 <= 0) { sendServerMessage("Can't save an empty testimony."); return; } - QDir dir_testimony("storage/testimony"); - if (!dir_testimony.exists()) { - dir_testimony.mkpath("."); + QDir l_dir_testimony("storage/testimony"); + if (!l_dir_testimony.exists()) { + l_dir_testimony.mkpath("."); } - QString testimony_name = argv[0].trimmed().toLower().replace("..",""); // :) - QFile file("storage/testimony/" + testimony_name + ".txt"); - if (file.exists()) { + QString l_testimony_name = argv[0].trimmed().toLower().replace("..",""); // :) + QFile l_file("storage/testimony/" + l_testimony_name + ".txt"); + if (l_file.exists()) { sendServerMessage("Unable to save testimony. Testimony name already exists."); return; } - QTextStream out(&file); - out.setCodec("UTF-8"); - if(file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) { - for (int i = 0; i <= area->testimony().size() -1; i++) + QTextStream l_out(&l_file); + l_out.setCodec("UTF-8"); + if(l_file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) { + for (int i = 0; i <= l_area->testimony().size() -1; i++) { - out << area->testimony().at(i).join("#") << "\n"; + l_out << l_area->testimony().at(i).join("#") << "\n"; } - sendServerMessage("Testimony saved. To load it use /loadtestimony " + testimony_name); - testimony_saving = false; + sendServerMessage("Testimony saved. To load it use /loadtestimony " + l_testimony_name); + m_testimony_saving = false; } } else { @@ -257,34 +257,34 @@ void AOClient::cmdLoadTestimony(int argc, QStringList argv) { Q_UNUSED(argc); - AreaData* area = server->m_areas[current_area]; - QDir dir_testimony("storage/testimony"); - if (!dir_testimony.exists()) { + AreaData* l_area = server->m_areas[m_current_area]; + QDir l_dir_testimony("storage/testimony"); + if (!l_dir_testimony.exists()) { sendServerMessage("Unable to load testimonies. Testimony storage not found."); return; } - QString testimony_name = argv[0].trimmed().toLower().replace("..",""); // :) - QFile file("storage/testimony/" + testimony_name + ".txt"); - if (!file.exists()) { + QString l_testimony_name = argv[0].trimmed().toLower().replace("..",""); // :) + QFile l_file("storage/testimony/" + l_testimony_name + ".txt"); + if (!l_file.exists()) { sendServerMessage("Unable to load testimony. Testimony name not found."); return; } - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + if (!l_file.open(QIODevice::ReadOnly | QIODevice::Text)) { sendServerMessage("Unable to load testimony. Permission denied."); return; } clearTestimony(); - int testimony_lines = 0; - QTextStream in(&file); - in.setCodec("UTF-8"); - while (!in.atEnd()) { - if (testimony_lines <= ConfigManager::maxStatements()) { - QString line = in.readLine(); + int l_testimony_lines = 0; + QTextStream l_in(&l_file); + l_in.setCodec("UTF-8"); + while (!l_in.atEnd()) { + if (l_testimony_lines <= ConfigManager::maxStatements()) { + QString line = l_in.readLine(); QStringList packet = line.split("#"); - area->addStatement(area->testimony().size(), packet); - testimony_lines = testimony_lines + 1; + l_area->addStatement(l_area->testimony().size(), packet); + l_testimony_lines = l_testimony_lines + 1; } else { sendServerMessage("Testimony too large to be loaded."); diff --git a/core/src/commands/command_helper.cpp b/core/src/commands/command_helper.cpp index 3bbdf82..4a8537e 100644 --- a/core/src/commands/command_helper.cpp +++ b/core/src/commands/command_helper.cpp @@ -48,17 +48,17 @@ QStringList AOClient::buildAreaList(int area_idx) } entries.append("[" + QString::number(area->playerCount()) + " users][" + QVariant::fromValue(area->status()).toString().replace("_", "-") + "]"); for (AOClient* client : qAsConst(server->m_clients)) { - if (client->current_area == area_idx && client->joined) { - QString char_entry = "[" + QString::number(client->id) + "] " + client->current_char; - if (client->current_char == "") + if (client->m_current_area == area_idx && client->m_joined) { + QString char_entry = "[" + QString::number(client->m_id) + "] " + client->m_current_char; + if (client->m_current_char == "") char_entry += "Spectator"; - if (client->showname != "") - char_entry += " (" + client->showname + ")"; - if (area->owners().contains(client->id)) + if (client->m_showname != "") + char_entry += " (" + client->m_showname + ")"; + if (area->owners().contains(client->m_id)) char_entry.insert(0, "[CM] "); - if (authenticated) - char_entry += " (" + client->getIpid() + "): " + client->ooc_name; - if (client->is_afk) + if (m_authenticated) + char_entry += " (" + client->getIpid() + "): " + client->m_ooc_name; + if (client->m_is_afk) char_entry += " [AFK]"; entries.append(char_entry); } @@ -74,58 +74,57 @@ int AOClient::genRand(int min, int max) return random_number; #else - quint32 random_number = QRandomGenerator::system()->bounded(min, max + 1); - return random_number; + return QRandomGenerator::system()->bounded(min, max + 1); #endif } void AOClient::diceThrower(int argc, QStringList argv, bool p_roll) { - int sides = 6; - int dice = 1; + int l_sides = 6; + int l_dice = 1; QStringList results; if (argc >= 1) - sides = qBound(1, argv[0].toInt(), ConfigManager::diceMaxValue()); + l_sides = qBound(1, argv[0].toInt(), ConfigManager::diceMaxValue()); if (argc == 2) - dice = qBound(1, argv[1].toInt(), ConfigManager::diceMaxDice()); - for (int i = 1; i <= dice; i++) { - results.append(QString::number(AOClient::genRand(1, sides))); + l_dice = qBound(1, argv[1].toInt(), ConfigManager::diceMaxDice()); + for (int i = 1; i <= l_dice; i++) { + results.append(QString::number(AOClient::genRand(1, l_sides))); } QString total_results = results.join(" "); if (p_roll) { - sendServerMessage("You rolled a " + QString::number(dice) + "d" + QString::number(sides) + ". Results: " + total_results); + sendServerMessage("You rolled a " + QString::number(l_dice) + "d" + QString::number(l_sides) + ". Results: " + total_results); return; } - sendServerMessageArea(ooc_name + " rolled a " + QString::number(dice) + "d" + QString::number(sides) + ". Results: " + total_results); + sendServerMessageArea(m_ooc_name + " rolled a " + QString::number(l_dice) + "d" + QString::number(l_sides) + ". Results: " + total_results); } QString AOClient::getAreaTimer(int area_idx, int timer_idx) { - AreaData* area = server->m_areas[area_idx]; - QTimer* timer; - QString timer_name = (timer_idx == 0) ? "Global timer" : "Timer " + QString::number(timer_idx); + AreaData* l_area = server->m_areas[area_idx]; + QTimer* l_timer; + QString l_timer_name = (timer_idx == 0) ? "Global timer" : "Timer " + QString::number(timer_idx); if (timer_idx == 0) - timer = server->timer; + l_timer = server->timer; else if (timer_idx > 0 && timer_idx <= 4) - timer = area->timers().at(timer_idx - 1); + l_timer = l_area->timers().at(timer_idx - 1); else return "Invalid timer ID."; - if (timer->isActive()) { - QTime current_time = QTime(0,0).addMSecs(timer->remainingTime()); + if (l_timer->isActive()) { + QTime l_current_time = QTime(0,0).addMSecs(l_timer->remainingTime()); - return timer_name + " is at " + current_time.toString("hh:mm:ss.zzz"); + return l_timer_name + " is at " + l_current_time.toString("hh:mm:ss.zzz"); } else { - return timer_name + " is inactive."; + return l_timer_name + " is inactive."; } } long long AOClient::parseTime(QString input) { - QRegularExpression regex("(?:(?:(?.*?)y)*(?:(?.*?)w)*(?:(?.*?)d)*(?:(?
.*?)h)*(?:(?.*?)m)*(?:(?.*?)s)*)"); - QRegularExpressionMatch match = regex.match(input); + QRegularExpression l_regex("(?:(?:(?.*?)y)*(?:(?.*?)w)*(?:(?.*?)d)*(?:(?
.*?)h)*(?:(?.*?)m)*(?:(?.*?)s)*)"); + QRegularExpressionMatch match = l_regex.match(input); QString str_year, str_week, str_hour, str_day, str_minute, str_second; int year, week, day, hour, minute, second; @@ -136,11 +135,11 @@ long long AOClient::parseTime(QString input) str_minute = match.captured("min"); str_second = match.captured("sec"); - bool is_well_formed = false; + bool l_is_well_formed = false; QString concat_str(str_year + str_week + str_day + str_hour + str_minute + str_second); - concat_str.toInt(&is_well_formed); + concat_str.toInt(&l_is_well_formed); - if (!is_well_formed) { + if (!l_is_well_formed) { return -1; } @@ -151,23 +150,23 @@ long long AOClient::parseTime(QString input) minute = str_minute.toInt(); second = str_second.toInt(); - long long total = 0; - total += 31622400 * year; - total += 604800 * week; - total += 86400 * day; - total += 3600 * hour; - total += 60 * minute; - total += second; + long long l_total = 0; + l_total += 31622400 * year; + l_total += 604800 * week; + l_total += 86400 * day; + l_total += 3600 * hour; + l_total += 60 * minute; + l_total += second; - if (total < 0) + if (l_total < 0) return -1; - return total; + return l_total; } -QString AOClient::getReprimand(bool positive) +QString AOClient::getReprimand(bool f_positive) { - if (positive) { + if (f_positive) { return ConfigManager::praiseList().at(genRand(0, ConfigManager::praiseList().size() - 1)); } else { @@ -175,53 +174,53 @@ QString AOClient::getReprimand(bool positive) } } -bool AOClient::checkPasswordRequirements(QString username, QString password) +bool AOClient::checkPasswordRequirements(QString f_username, QString f_password) { - QString decoded_password = decodeMessage(password); + QString l_decoded_password = decodeMessage(f_password); if (!ConfigManager::passwordRequirements()) return true; - if (ConfigManager::passwordMinLength() > decoded_password.length()) + if (ConfigManager::passwordMinLength() > l_decoded_password.length()) return false; - if (ConfigManager::passwordMaxLength() < decoded_password.length() && ConfigManager::passwordMaxLength() != 0) + if (ConfigManager::passwordMaxLength() < l_decoded_password.length() && ConfigManager::passwordMaxLength() != 0) return false; else if (ConfigManager::passwordRequireMixCase()) { - if (decoded_password.toLower() == decoded_password) + if (l_decoded_password.toLower() == l_decoded_password) return false; - if (decoded_password.toUpper() == decoded_password) + if (l_decoded_password.toUpper() == l_decoded_password) return false; } else if (ConfigManager::passwordRequireNumbers()) { QRegularExpression regex("[0123456789]"); - QRegularExpressionMatch match = regex.match(decoded_password); + QRegularExpressionMatch match = regex.match(l_decoded_password); if (!match.hasMatch()) return false; } else if (ConfigManager::passwordRequireSpecialCharacters()) { QRegularExpression regex("[~!@#$%^&*_-+=`|\\(){}\[]:;\"'<>,.?/]"); - QRegularExpressionMatch match = regex.match(decoded_password); + QRegularExpressionMatch match = regex.match(l_decoded_password); if (!match.hasMatch()) return false; } else if (!ConfigManager::passwordCanContainUsername()) { - if (decoded_password.contains(username)) + if (l_decoded_password.contains(f_username)) return false; } return true; } -void AOClient::sendNotice(QString notice, bool global) +void AOClient::sendNotice(QString f_notice, bool f_global) { - QString message = "A moderator sent this "; - if (global) - message += "server-wide "; - message += "notice:\n\n" + notice; - sendServerMessageArea(message); - AOPacket packet("BB", {message}); - if (global) - server->broadcast(packet); + QString l_message = "A moderator sent this "; + if (f_global) + l_message += "server-wide "; + l_message += "notice:\n\n" + f_notice; + sendServerMessageArea(l_message); + AOPacket l_packet("BB", {l_message}); + if (f_global) + server->broadcast(l_packet); else - server->broadcast(packet, current_area); + server->broadcast(l_packet, m_current_area); } diff --git a/core/src/commands/messaging.cpp b/core/src/commands/messaging.cpp index 4149193..dcdfc37 100644 --- a/core/src/commands/messaging.cpp +++ b/core/src/commands/messaging.cpp @@ -25,7 +25,7 @@ void AOClient::cmdPos(int argc, QStringList argv) Q_UNUSED(argc); changePosition(argv[0]); - updateEvidenceList(server->m_areas[current_area]); + updateEvidenceList(server->m_areas[m_current_area]); } void AOClient::cmdForcePos(int argc, QStringList argv) @@ -33,17 +33,17 @@ void AOClient::cmdForcePos(int argc, QStringList argv) Q_UNUSED(argc); bool ok; - QList targets; - int target_id = argv[1].toInt(&ok); - int forced_clients = 0; + QList l_targets; + int l_target_id = argv[1].toInt(&ok); + int l_forced_clients = 0; if (!ok && argv[1] != "*") { sendServerMessage("That does not look like a valid ID."); return; } else if (ok) { - AOClient* target_client = server->getClientByID(target_id); - if (target_client != nullptr) - targets.append(target_client); + AOClient* l_target_client = server->getClientByID(l_target_id); + if (l_target_client != nullptr) + l_targets.append(l_target_client); else { sendServerMessage("Target ID not found!"); return; @@ -52,28 +52,28 @@ void AOClient::cmdForcePos(int argc, QStringList argv) else if (argv[1] == "*") { // force all clients in the area for (AOClient* client : qAsConst(server->m_clients)) { - if (client->current_area == current_area) - targets.append(client); + if (client->m_current_area == m_current_area) + l_targets.append(client); } } - for (AOClient* target : targets) { - target->sendServerMessage("Position forcibly changed by CM."); - target->changePosition(argv[0]); - forced_clients++; + for (AOClient* l_target : l_targets) { + l_target->sendServerMessage("Position forcibly changed by CM."); + l_target->changePosition(argv[0]); + l_forced_clients++; } - sendServerMessage("Forced " + QString::number(forced_clients) + " into pos " + argv[0] + "."); + sendServerMessage("Forced " + QString::number(l_forced_clients) + " into pos " + argv[0] + "."); } void AOClient::cmdG(int argc, QStringList argv) { Q_UNUSED(argc); - QString sender_name = ooc_name; - QString sender_area = server->m_area_names.value(current_area); - QString sender_message = argv.join(" "); - for (AOClient* client : qAsConst(server->m_clients)) { - if (client->global_enabled) - client->sendPacket("CT", {"[G][" + sender_area + "]" + sender_name, sender_message}); + QString l_sender_name = m_ooc_name; + QString l_sender_area = server->m_area_names.value(m_current_area); + QString l_sender_message = argv.join(" "); + for (AOClient* l_client : qAsConst(server->m_clients)) { + if (l_client->m_global_enabled) + l_client->sendPacket("CT", {"[G][" + l_sender_area + "]" + l_sender_name, l_sender_message}); } return; } @@ -82,11 +82,11 @@ void AOClient::cmdNeed(int argc, QStringList argv) { Q_UNUSED(argc); - QString sender_area = server->m_area_names.value(current_area); - QString sender_message = argv.join(" "); - for (AOClient* client : qAsConst(server->m_clients)) { - if (client->advert_enabled) { - client->sendServerMessage({"=== Advert ===\n[" + sender_area + "] needs " + sender_message+ "."}); + QString l_sender_area = server->m_area_names.value(m_current_area); + QString l_sender_message = argv.join(" "); + for (AOClient* l_client : qAsConst(server->m_clients)) { + if (l_client->m_advert_enabled) { + l_client->sendServerMessage({"=== Advert ===\n[" + l_sender_area + "] needs " + l_sender_message+ "."}); } } } @@ -95,13 +95,13 @@ void AOClient::cmdSwitch(int argc, QStringList argv) { Q_UNUSED(argc); - int selected_char_id = server->getCharID(argv.join(" ")); - if (selected_char_id == -1) { + int l_selected_char_id = server->getCharID(argv.join(" ")); + if (l_selected_char_id == -1) { sendServerMessage("That does not look like a valid character."); return; } - if (changeCharacter(selected_char_id)) { - char_id = selected_char_id; + if (changeCharacter(l_selected_char_id)) { + m_char_id = l_selected_char_id; } else { sendServerMessage("The character you picked is either taken or invalid."); @@ -113,17 +113,17 @@ void AOClient::cmdRandomChar(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - AreaData* area = server->m_areas[current_area]; - int selected_char_id; - bool taken = true; - while (taken) { - selected_char_id = genRand(0, server->m_characters.size() - 1); - if (!area->charactersTaken().contains(selected_char_id)) { - taken = false; + AreaData* l_area = server->m_areas[m_current_area]; + int l_selected_char_id; + bool l_taken = true; + while (l_taken) { + l_selected_char_id = genRand(0, server->m_characters.size() - 1); + if (!l_area->charactersTaken().contains(l_selected_char_id)) { + l_taken = false; } } - if (changeCharacter(selected_char_id)) { - char_id = selected_char_id; + if (changeCharacter(l_selected_char_id)) { + m_char_id = l_selected_char_id; } } @@ -132,9 +132,9 @@ void AOClient::cmdToggleGlobal(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - global_enabled = !global_enabled; - QString str_en = global_enabled ? "shown" : "hidden"; - sendServerMessage("Global chat set to " + str_en); + m_global_enabled = !m_global_enabled; + QString l_str_en = m_global_enabled ? "shown" : "hidden"; + sendServerMessage("Global chat set to " + l_str_en); } void AOClient::cmdPM(int argc, QStringList argv) @@ -142,23 +142,23 @@ void AOClient::cmdPM(int argc, QStringList argv) Q_UNUSED(argc); bool ok; - int target_id = argv.takeFirst().toInt(&ok); // using takeFirst removes the ID from our list of arguments... + int l_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) { + AOClient* l_target_client = server->getClientByID(l_target_id); + if (l_target_client == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (target_client->pm_mute) { + if (l_target_client->m_pm_mute) { sendServerMessage("That user is not recieving PMs."); 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); - sendServerMessage("PM sent to " + QString::number(target_id) +". Message: " + message); + QString l_message = argv.join(" "); //...which means it will not end up as part of the message + l_target_client->sendServerMessage("Message from " + m_ooc_name + " (" + QString::number(m_id) + "): " + l_message); + sendServerMessage("PM sent to " + QString::number(l_target_id) +". Message: " + l_message); } void AOClient::cmdAnnounce(int argc, QStringList argv) @@ -172,11 +172,11 @@ void AOClient::cmdM(int argc, QStringList argv) { Q_UNUSED(argc); - QString sender_name = ooc_name; - QString sender_message = argv.join(" "); + QString l_sender_name = m_ooc_name; + QString l_sender_message = argv.join(" "); for (AOClient* client : qAsConst(server->m_clients)) { if (client->checkAuth(ACLFlags.value("MODCHAT"))) - client->sendPacket("CT", {"[M]" + sender_name, sender_message}); + client->sendPacket("CT", {"[M]" + l_sender_name, l_sender_message}); } return; } @@ -185,12 +185,12 @@ void AOClient::cmdGM(int argc, QStringList argv) { Q_UNUSED(argc); - QString sender_name = ooc_name; - QString sender_area = server->m_area_names.value(current_area); - QString sender_message = argv.join(" "); - for (AOClient* client : qAsConst(server->m_clients)) { - if (client->global_enabled) { - client->sendPacket("CT", {"[G][" + sender_area + "]" + "["+sender_name+"][M]", sender_message}); + QString l_sender_name = m_ooc_name; + QString l_sender_area = server->m_area_names.value(m_current_area); + QString l_sender_message = argv.join(" "); + for (AOClient* l_client : qAsConst(server->m_clients)) { + if (l_client->m_global_enabled) { + l_client->sendPacket("CT", {"[G][" + l_sender_area + "]" + "["+ l_sender_name+"][M]", l_sender_message}); } } } @@ -199,9 +199,9 @@ void AOClient::cmdLM(int argc, QStringList argv) { Q_UNUSED(argc); - QString sender_name = ooc_name; - QString sender_message = argv.join(" "); - server->broadcast(AOPacket("CT", {"["+sender_name+"][M]", sender_message}), current_area); + QString l_sender_name = m_ooc_name; + QString l_sender_message = argv.join(" "); + server->broadcast(AOPacket("CT", {"["+ l_sender_name +"][M]", l_sender_message}), m_current_area); } void AOClient::cmdGimp(int argc, QStringList argv) @@ -209,26 +209,26 @@ void AOClient::cmdGimp(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (target->is_gimped) + if (l_target->m_is_gimped) sendServerMessage("That player is already gimped!"); else { sendServerMessage("Gimped player."); - target->sendServerMessage("You have been gimped! " + getReprimand()); + l_target->sendServerMessage("You have been gimped! " + getReprimand()); } - target->is_gimped = true; + l_target->m_is_gimped = true; } void AOClient::cmdUnGimp(int argc, QStringList argv) @@ -236,26 +236,26 @@ void AOClient::cmdUnGimp(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (!(target->is_gimped)) + if (!(l_target->m_is_gimped)) sendServerMessage("That player is not gimped!"); else { sendServerMessage("Ungimped player."); - target->sendServerMessage("A moderator has ungimped you! " + getReprimand(true)); + l_target->sendServerMessage("A moderator has ungimped you! " + getReprimand(true)); } - target->is_gimped = false; + l_target->m_is_gimped = false; } void AOClient::cmdDisemvowel(int argc, QStringList argv) @@ -263,26 +263,26 @@ void AOClient::cmdDisemvowel(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (target->is_disemvoweled) + if (l_target->m_is_disemvoweled) sendServerMessage("That player is already disemvoweled!"); else { sendServerMessage("Disemvoweled player."); - target->sendServerMessage("You have been disemvoweled! " + getReprimand()); + l_target->sendServerMessage("You have been disemvoweled! " + getReprimand()); } - target->is_disemvoweled = true; + l_target->m_is_disemvoweled = true; } void AOClient::cmdUnDisemvowel(int argc, QStringList argv) @@ -290,26 +290,26 @@ void AOClient::cmdUnDisemvowel(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (!(target->is_disemvoweled)) + if (!(l_target->m_is_disemvoweled)) sendServerMessage("That player is not disemvoweled!"); else { sendServerMessage("Undisemvoweled player."); - target->sendServerMessage("A moderator has undisemvoweled you! " + getReprimand(true)); + l_target->sendServerMessage("A moderator has undisemvoweled you! " + getReprimand(true)); } - target->is_disemvoweled = false; + l_target->m_is_disemvoweled = false; } void AOClient::cmdShake(int argc, QStringList argv) @@ -317,26 +317,26 @@ void AOClient::cmdShake(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (target->is_shaken) + if (l_target->m_is_shaken) sendServerMessage("That player is already shaken!"); else { sendServerMessage("Shook player."); - target->sendServerMessage("A moderator has shaken your words! " + getReprimand()); + l_target->sendServerMessage("A moderator has shaken your words! " + getReprimand()); } - target->is_shaken = true; + l_target->m_is_shaken = true; } void AOClient::cmdUnShake(int argc, QStringList argv) @@ -344,26 +344,26 @@ void AOClient::cmdUnShake(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (!(target->is_shaken)) + if (!(l_target->m_is_shaken)) sendServerMessage("That player is not shaken!"); else { sendServerMessage("Unshook player."); - target->sendServerMessage("A moderator has unshook you! " + getReprimand(true)); + l_target->sendServerMessage("A moderator has unshook you! " + getReprimand(true)); } - target->is_shaken = false; + l_target->m_is_shaken = false; } void AOClient::cmdMutePM(int argc, QStringList argv) @@ -371,9 +371,9 @@ void AOClient::cmdMutePM(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - pm_mute = !pm_mute; - QString str_en = pm_mute ? "muted" : "unmuted"; - sendServerMessage("PM's are now " + str_en); + m_pm_mute = !m_pm_mute; + QString l_str_en = m_pm_mute ? "muted" : "unmuted"; + sendServerMessage("PM's are now " + l_str_en); } void AOClient::cmdToggleAdverts(int argc, QStringList argv) @@ -381,9 +381,9 @@ void AOClient::cmdToggleAdverts(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - advert_enabled = !advert_enabled; - QString str_en = advert_enabled ? "on" : "off"; - sendServerMessage("Advertisements turned " + str_en); + m_advert_enabled = !m_advert_enabled; + QString l_str_en = m_advert_enabled ? "on" : "off"; + sendServerMessage("Advertisements turned " + l_str_en); } void AOClient::cmdAfk(int argc, QStringList argv) @@ -391,62 +391,62 @@ void AOClient::cmdAfk(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - is_afk = true; + m_is_afk = true; sendServerMessage("You are now AFK."); } void AOClient::cmdCharCurse(int argc, QStringList argv) { bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (target->is_charcursed) { + if (l_target->m_is_charcursed) { sendServerMessage("That player is already charcursed!"); return; } if (argc == 1) { - target->charcurse_list.append(server->getCharID(target->current_char)); + l_target->m_charcurse_list.append(server->getCharID(l_target->m_current_char)); } else { argv.removeFirst(); - QStringList char_names = argv.join(" ").split(","); + QStringList l_char_names = argv.join(" ").split(","); - target->charcurse_list.clear(); - for (const QString &char_name : qAsConst(char_names)) { - int char_id = server->getCharID(char_name); + l_target->m_charcurse_list.clear(); + for (const QString &l_char_name : qAsConst(l_char_names)) { + int char_id = server->getCharID(l_char_name); if (char_id == -1) { - sendServerMessage("Could not find character: " + char_name); + sendServerMessage("Could not find character: " + l_char_name); return; } - target->charcurse_list.append(char_id); + l_target->m_charcurse_list.append(char_id); } } - target->is_charcursed = true; + l_target->m_is_charcursed = true; //Kick back to char select screen - if (!target->charcurse_list.contains(server->getCharID(target->current_char))) { - target->changeCharacter(-1); - server->updateCharsTaken(server->m_areas.value(current_area)); - target->sendPacket("DONE"); + if (!l_target->m_charcurse_list.contains(server->getCharID(l_target->m_current_char))) { + l_target->changeCharacter(-1); + server->updateCharsTaken(server->m_areas.value(m_current_area)); + l_target->sendPacket("DONE"); } else { - server->updateCharsTaken(server->m_areas.value(current_area)); + server->updateCharsTaken(server->m_areas.value(m_current_area)); } - target->sendServerMessage("You have been charcursed!"); + l_target->sendServerMessage("You have been charcursed!"); sendServerMessage("Charcursed player."); } @@ -455,28 +455,28 @@ void AOClient::cmdUnCharCurse(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (!target->is_charcursed) { + if (!l_target->m_is_charcursed) { sendServerMessage("That player is not charcursed!"); return; } - target->is_charcursed = false; - target->charcurse_list.clear(); - server->updateCharsTaken(server->m_areas.value(current_area)); + l_target->m_is_charcursed = false; + l_target->m_charcurse_list.clear(); + server->updateCharsTaken(server->m_areas.value(m_current_area)); sendServerMessage("Uncharcursed player."); - target->sendServerMessage("You were uncharcursed."); + l_target->sendServerMessage("You were uncharcursed."); } void AOClient::cmdCharSelect(int argc, QStringList argv) @@ -492,17 +492,17 @@ void AOClient::cmdCharSelect(int argc, QStringList argv) } bool ok = false; - int target_id = argv[0].toInt(&ok); + int l_target_id = argv[0].toInt(&ok); if (!ok) return; - AOClient* target = server->getClientByID(target_id); + AOClient* l_target = server->getClientByID(l_target_id); - if (target == nullptr) + if (l_target == nullptr) return; - target->changeCharacter(-1); - target->sendPacket("DONE"); + l_target->changeCharacter(-1); + l_target->sendPacket("DONE"); } } @@ -511,35 +511,35 @@ void AOClient::cmdA(int argc, QStringList argv) Q_UNUSED(argc); bool ok; - int area_id = argv[0].toInt(&ok); + int l_area_id = argv[0].toInt(&ok); if (!ok) { sendServerMessage("This does not look like a valid AreaID."); return; } - AreaData* area = server->m_areas[area_id]; - if (!area->owners().contains(id)) { + AreaData* l_area = server->m_areas[l_area_id]; + if (!l_area->owners().contains(m_id)) { sendServerMessage("You are not CM in that area."); return; } argv.removeAt(0); - QString sender_name = ooc_name; - QString ooc_message = argv.join(" "); - server->broadcast(AOPacket("CT", {"[CM]" + sender_name, ooc_message}), area_id); + QString l_sender_name = m_ooc_name; + QString l_ooc_message = argv.join(" "); + server->broadcast(AOPacket("CT", {"[CM]" + l_sender_name, l_ooc_message}), l_area_id); } void AOClient::cmdS(int argc, QStringList argv) { Q_UNUSED(argc); - int all_areas = server->m_areas.size() - 1; - QString sender_name = ooc_name; - QString ooc_message = argv.join(" "); + int l_all_areas = server->m_areas.size() - 1; + QString l_sender_name = m_ooc_name; + QString l_ooc_message = argv.join(" "); - for (int i = 0; i <= all_areas; i++) { - if (server->m_areas[i]->owners().contains(id)) - server->broadcast(AOPacket("CT", {"[CM]" + sender_name, ooc_message}), i); + for (int i = 0; i <= l_all_areas; i++) { + if (server->m_areas[i]->owners().contains(m_id)) + server->broadcast(AOPacket("CT", {"[CM]" + l_sender_name, l_ooc_message}), i); } } @@ -548,7 +548,7 @@ void AOClient::cmdFirstPerson(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - first_person = !first_person; - QString str_en = first_person ? "enabled" : "disabled"; - sendServerMessage("First person mode " + str_en + "."); + m_first_person = !m_first_person; + QString l_str_en = m_first_person ? "enabled" : "disabled"; + sendServerMessage("First person mode " + l_str_en + "."); } diff --git a/core/src/commands/moderation.cpp b/core/src/commands/moderation.cpp index 610626a..fa466dc 100644 --- a/core/src/commands/moderation.cpp +++ b/core/src/commands/moderation.cpp @@ -22,104 +22,104 @@ void AOClient::cmdBan(int argc, QStringList argv) { - QString args_str = argv[2]; + QString l_args_str = argv[2]; if (argc > 3) { for (int i = 3; i < argc; i++) - args_str += " " + argv[i]; + l_args_str += " " + argv[i]; } - DBManager::BanInfo ban; + DBManager::BanInfo l_ban; - long long duration_seconds = 0; + long long l_duration_seconds = 0; if (argv[1] == "perma") - duration_seconds = -2; + l_duration_seconds = -2; else - duration_seconds = parseTime(argv[1]); + l_duration_seconds = parseTime(argv[1]); - if (duration_seconds == -1) { + if (l_duration_seconds == -1) { sendServerMessage("Invalid time format. Format example: 1h30m"); return; } - ban.duration = duration_seconds; - ban.ipid = argv[0]; - ban.reason = args_str; - ban.time = QDateTime::currentDateTime().toSecsSinceEpoch(); - bool ban_logged = false; - int kick_counter = 0; + l_ban.duration = l_duration_seconds; + l_ban.ipid = argv[0]; + l_ban.reason = l_args_str; + l_ban.time = QDateTime::currentDateTime().toSecsSinceEpoch(); + bool l_ban_logged = false; + int l_kick_counter = 0; switch (ConfigManager::authType()) { case DataTypes::AuthType::SIMPLE: - ban.moderator = "moderator"; + l_ban.moderator = "moderator"; break; case DataTypes::AuthType::ADVANCED: - ban.moderator = moderator_name; + l_ban.moderator = m_moderator_name; break; } - const QList targets = server->getClientsByIpid(ban.ipid); - for (AOClient* client : targets) { - if (!ban_logged) { - ban.ip = client->remote_ip; - ban.hdid = client->hwid; - server->db_manager->addBan(ban); - sendServerMessage("Banned user with ipid " + ban.ipid + " for reason: " + ban.reason); - ban_logged = true; + const QList l_targets = server->getClientsByIpid(l_ban.ipid); + for (AOClient* client : l_targets) { + if (!l_ban_logged) { + l_ban.ip = client->m_remote_ip; + l_ban.hdid = client->m_hwid; + server->db_manager->addBan(l_ban); + sendServerMessage("Banned user with ipid " + l_ban.ipid + " for reason: " + l_ban.reason); + l_ban_logged = true; } - QString ban_duration; - if (!(ban.duration == -2)) { - ban_duration = QDateTime::fromSecsSinceEpoch(ban.time).addSecs(ban.duration).toString("MM/dd/yyyy, hh:mm"); + QString l_ban_duration; + if (!(l_ban.duration == -2)) { + l_ban_duration = QDateTime::fromSecsSinceEpoch(l_ban.time).addSecs(l_ban.duration).toString("MM/dd/yyyy, hh:mm"); } else { - ban_duration = "The heat death of the universe."; + l_ban_duration = "The heat death of the universe."; } - int ban_id = server->db_manager->getBanID(ban.ip); - client->sendPacket("KB", {ban.reason + "\nID: " + QString::number(ban_id) + "\nUntil: " + ban_duration}); - client->socket->close(); - kick_counter++; + int l_ban_id = server->db_manager->getBanID(l_ban.ip); + client->sendPacket("KB", {l_ban.reason + "\nID: " + QString::number(l_ban_id) + "\nUntil: " + l_ban_duration}); + client->m_socket->close(); + l_kick_counter++; - emit logBan(ban.moderator,ban.ipid,ban_duration,ban.reason); + emit logBan(l_ban.moderator,l_ban.ipid,l_ban_duration,l_ban.reason); if (ConfigManager::discordBanWebhookEnabled()) - emit server->banWebhookRequest(ban.ipid, ban.moderator, ban_duration, ban.reason, ban_id); + emit server->banWebhookRequest(l_ban.ipid, l_ban.moderator, l_ban_duration, l_ban.reason, l_ban_id); } - if (kick_counter > 1) - sendServerMessage("Kicked " + QString::number(kick_counter) + " clients with matching ipids."); + if (l_kick_counter > 1) + sendServerMessage("Kicked " + QString::number(l_kick_counter) + " clients with matching ipids."); // We're banning someone not connected. - if (!ban_logged) { - server->db_manager->addBan(ban); - sendServerMessage("Banned " + ban.ipid + " for reason: " + ban.reason); + if (!l_ban_logged) { + server->db_manager->addBan(l_ban); + sendServerMessage("Banned " + l_ban.ipid + " for reason: " + l_ban.reason); } } void AOClient::cmdKick(int argc, QStringList argv) { - QString target_ipid = argv[0]; - QString reason = argv[1]; - int kick_counter = 0; + QString l_target_ipid = argv[0]; + QString l_reason = argv[1]; + int l_kick_counter = 0; if (argc > 2) { for (int i = 2; i < argv.length(); i++) { - reason += " " + argv[i]; + l_reason += " " + argv[i]; } } - const QList targets = server->getClientsByIpid(target_ipid); - for (AOClient* client : targets) { - client->sendPacket("KK", {reason}); - client->socket->close(); - kick_counter++; + const QList l_targets = server->getClientsByIpid(l_target_ipid); + for (AOClient* client : l_targets) { + client->sendPacket("KK", {l_reason}); + client->m_socket->close(); + l_kick_counter++; } - if (kick_counter > 0) { + if (l_kick_counter > 0) { if (ConfigManager::authType() == DataTypes::AuthType::ADVANCED){ - emit logKick(moderator_name, target_ipid, reason); + emit logKick(m_moderator_name, l_target_ipid, l_reason); } else { - emit logKick("Moderator",target_ipid,reason); + emit logKick("Moderator", l_target_ipid, l_reason); } - sendServerMessage("Kicked " + QString::number(kick_counter) + " client(s) with ipid " + target_ipid + " for reason: " + reason); + sendServerMessage("Kicked " + QString::number(l_kick_counter) + " client(s) with ipid " + l_target_ipid + " for reason: " + l_reason); } else sendServerMessage("User with ipid not found!"); @@ -130,23 +130,23 @@ void AOClient::cmdMods(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - QStringList entries; - int online_count = 0; - for (AOClient* client : qAsConst(server->m_clients)) { - if (client->authenticated) { - entries << "---"; + QStringList l_entries; + int l_online_count = 0; + for (AOClient* l_client : qAsConst(server->m_clients)) { + if (l_client->m_authenticated) { + l_entries << "---"; if (ConfigManager::authType() != DataTypes::AuthType::SIMPLE) - entries << "Moderator: " + client->moderator_name; - entries << "OOC name: " + client->ooc_name; - entries << "ID: " + QString::number(client->id); - entries << "Area: " + QString::number(client->current_area); - entries << "Character: " + client->current_char; - online_count++; + l_entries << "Moderator: " + l_client->m_moderator_name; + l_entries << "OOC name: " + l_client->m_ooc_name; + l_entries << "ID: " + QString::number(l_client->m_id); + l_entries << "Area: " + QString::number(l_client->m_current_area); + l_entries << "Character: " + l_client->m_current_char; + l_online_count++; } } - entries << "---"; - entries << "Total online: " << QString::number(online_count); - sendServerMessage(entries.join("\n")); + l_entries << "---"; + l_entries << "Total online: " << QString::number(l_online_count); + sendServerMessage(l_entries.join("\n")); } void AOClient::cmdHelp(int argc, QStringList argv) @@ -154,16 +154,16 @@ void AOClient::cmdHelp(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - QStringList entries; - entries << "Allowed commands:"; + QStringList l_entries; + l_entries << "Allowed commands:"; QMap::const_iterator i; for (i = commands.constBegin(); i!= commands.constEnd(); ++i) { CommandInfo info = i.value(); if (checkAuth(info.acl_mask)) { // if we are allowed to use this command - entries << "/" + i.key(); + l_entries << "/" + i.key(); } } - sendServerMessage(entries.join("\n")); + sendServerMessage(l_entries.join("\n")); } void AOClient::cmdMOTD(int argc, QStringList argv) @@ -173,8 +173,8 @@ void AOClient::cmdMOTD(int argc, QStringList argv) } else if (argc > 0) { if (checkAuth(ACLFlags.value("MOTD"))) { - QString MOTD = argv.join(" "); - ConfigManager::setMotd(MOTD); + QString l_MOTD = argv.join(" "); + ConfigManager::setMotd(l_MOTD); sendServerMessage("MOTD has been changed."); } else { @@ -188,26 +188,26 @@ void AOClient::cmdBans(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - QStringList recent_bans; - recent_bans << "Last 5 bans:"; - recent_bans << "-----"; - const QList bans_list = server->db_manager->getRecentBans(); - for (const DBManager::BanInfo &ban : bans_list) { - QString banned_until; - if (ban.duration == -2) - banned_until = "The heat death of the universe"; + QStringList l_recent_bans; + l_recent_bans << "Last 5 bans:"; + l_recent_bans << "-----"; + const QList l_bans_list = server->db_manager->getRecentBans(); + for (const DBManager::BanInfo &l_ban : l_bans_list) { + QString l_banned_until; + if (l_ban.duration == -2) + l_banned_until = "The heat death of the universe"; else - banned_until = QDateTime::fromSecsSinceEpoch(ban.time).addSecs(ban.duration).toString("MM/dd/yyyy, hh:mm"); - recent_bans << "Ban ID: " + QString::number(ban.id); - recent_bans << "Affected IPID: " + ban.ipid; - recent_bans << "Affected HDID: " + ban.hdid; - recent_bans << "Reason for ban: " + ban.reason; - recent_bans << "Date of ban: " + QDateTime::fromSecsSinceEpoch(ban.time).toString("MM/dd/yyyy, hh:mm"); - recent_bans << "Ban lasts until: " + banned_until; - recent_bans << "Moderator: " + ban.moderator; - recent_bans << "-----"; + l_banned_until = QDateTime::fromSecsSinceEpoch(l_ban.time).addSecs(l_ban.duration).toString("MM/dd/yyyy, hh:mm"); + l_recent_bans << "Ban ID: " + QString::number(l_ban.id); + l_recent_bans << "Affected IPID: " + l_ban.ipid; + l_recent_bans << "Affected HDID: " + l_ban.hdid; + l_recent_bans << "Reason for ban: " + l_ban.reason; + l_recent_bans << "Date of ban: " + QDateTime::fromSecsSinceEpoch(l_ban.time).toString("MM/dd/yyyy, hh:mm"); + l_recent_bans << "Ban lasts until: " + l_banned_until; + l_recent_bans << "Moderator: " + l_ban.moderator; + l_recent_bans << "-----"; } - sendServerMessage(recent_bans.join("\n")); + sendServerMessage(l_recent_bans.join("\n")); } void AOClient::cmdUnBan(int argc, QStringList argv) @@ -215,12 +215,12 @@ void AOClient::cmdUnBan(int argc, QStringList argv) Q_UNUSED(argc); bool ok; - int target_ban = argv[0].toInt(&ok); + int l_target_ban = argv[0].toInt(&ok); if (!ok) { sendServerMessage("Invalid ban ID."); return; } - else if (server->db_manager->invalidateBan(target_ban)) + else if (server->db_manager->invalidateBan(l_target_ban)) sendServerMessage("Successfully invalidated ban " + argv[0] + "."); else sendServerMessage("Couldn't invalidate ban " + argv[0] + ", are you sure it exists?"); @@ -239,26 +239,26 @@ void AOClient::cmdMute(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* target = server->getClientByID(l_uid); if (target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (target->is_muted) + if (target->m_is_muted) sendServerMessage("That player is already muted!"); else { sendServerMessage("Muted player."); target->sendServerMessage("You were muted by a moderator. " + getReprimand()); } - target->is_muted = true; + target->m_is_muted = true; } void AOClient::cmdUnMute(int argc, QStringList argv) @@ -266,26 +266,26 @@ void AOClient::cmdUnMute(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (!target->is_muted) + if (!l_target->m_is_muted) sendServerMessage("That player is not muted!"); else { sendServerMessage("Unmuted player."); - target->sendServerMessage("You were unmuted by a moderator. " + getReprimand(true)); + l_target->sendServerMessage("You were unmuted by a moderator. " + getReprimand(true)); } - target->is_muted = false; + l_target->m_is_muted = false; } void AOClient::cmdOocMute(int argc, QStringList argv) @@ -293,26 +293,26 @@ void AOClient::cmdOocMute(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (target->is_ooc_muted) + if (l_target->m_is_ooc_muted) sendServerMessage("That player is already OOC muted!"); else { sendServerMessage("OOC muted player."); - target->sendServerMessage("You were OOC muted by a moderator. " + getReprimand()); + l_target->sendServerMessage("You were OOC muted by a moderator. " + getReprimand()); } - target->is_ooc_muted = true; + l_target->m_is_ooc_muted = true; } void AOClient::cmdOocUnMute(int argc, QStringList argv) @@ -320,26 +320,26 @@ void AOClient::cmdOocUnMute(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (!target->is_ooc_muted) + if (!l_target->m_is_ooc_muted) sendServerMessage("That player is not OOC muted!"); else { sendServerMessage("OOC unmuted player."); - target->sendServerMessage("You were OOC unmuted by a moderator. " + getReprimand(true)); + l_target->sendServerMessage("You were OOC unmuted by a moderator. " + getReprimand(true)); } - target->is_ooc_muted = false; + l_target->m_is_ooc_muted = false; } void AOClient::cmdBlockWtce(int argc, QStringList argv) @@ -347,26 +347,26 @@ void AOClient::cmdBlockWtce(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (target->is_wtce_blocked) + if (l_target->m_is_wtce_blocked) sendServerMessage("That player is already judge blocked!"); else { sendServerMessage("Revoked player's access to judge controls."); - target->sendServerMessage("A moderator revoked your judge controls access. " + getReprimand()); + l_target->sendServerMessage("A moderator revoked your judge controls access. " + getReprimand()); } - target->is_wtce_blocked = true; + l_target->m_is_wtce_blocked = true; } void AOClient::cmdUnBlockWtce(int argc, QStringList argv) @@ -374,26 +374,26 @@ void AOClient::cmdUnBlockWtce(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (!target->is_wtce_blocked) + if (!l_target->m_is_wtce_blocked) sendServerMessage("That player is not judge blocked!"); else { sendServerMessage("Restored player's access to judge controls."); - target->sendServerMessage("A moderator restored your judge controls access. " + getReprimand(true)); + l_target->sendServerMessage("A moderator restored your judge controls access. " + getReprimand(true)); } - target->is_wtce_blocked = false; + l_target->m_is_wtce_blocked = false; } void AOClient::cmdAllowBlankposting(int argc, QStringList argv) @@ -401,30 +401,30 @@ void AOClient::cmdAllowBlankposting(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - QString sender_name = ooc_name; - AreaData* area = server->m_areas[current_area]; - area->toggleBlankposting(); - if (area->blankpostingAllowed() == false) { - sendServerMessageArea(sender_name + " has set blankposting in the area to forbidden."); + QString l_sender_name = m_ooc_name; + AreaData* l_area = server->m_areas[m_current_area]; + l_area->toggleBlankposting(); + if (l_area->blankpostingAllowed() == false) { + sendServerMessageArea(l_sender_name + " has set blankposting in the area to forbidden."); } else { - sendServerMessageArea(sender_name + " has set blankposting in the area to allowed."); + sendServerMessageArea(l_sender_name + " has set blankposting in the area to allowed."); } } void AOClient::cmdBanInfo(int argc, QStringList argv) { - QStringList ban_info; - ban_info << ("Ban Info for " + argv[0]); - ban_info << "-----"; - QString lookup_type; + QStringList l_ban_info; + l_ban_info << ("Ban Info for " + argv[0]); + l_ban_info << "-----"; + QString l_lookup_type; if (argc == 1) { - lookup_type = "banid"; + l_lookup_type = "banid"; } else if (argc == 2) { - lookup_type = argv[1]; - if (!((lookup_type == "banid") || (lookup_type == "ipid") || (lookup_type == "hdid"))) { + l_lookup_type = argv[1]; + if (!((l_lookup_type == "banid") || (l_lookup_type == "ipid") || (l_lookup_type == "hdid"))) { sendServerMessage("Invalid ID type."); return; } @@ -433,24 +433,24 @@ void AOClient::cmdBanInfo(int argc, QStringList argv) sendServerMessage("Invalid command."); return; } - QString id = argv[0]; - const QList bans = server->db_manager->getBanInfo(lookup_type, id); - for (const DBManager::BanInfo &ban : bans) { - QString banned_until; - if (ban.duration == -2) - banned_until = "The heat death of the universe"; + QString l_id = argv[0]; + const QList l_bans = server->db_manager->getBanInfo(l_lookup_type, l_id); + for (const DBManager::BanInfo &l_ban : l_bans) { + QString l_banned_until; + if (l_ban.duration == -2) + l_banned_until = "The heat death of the universe"; else - banned_until = QDateTime::fromSecsSinceEpoch(ban.time).addSecs(ban.duration).toString("MM/dd/yyyy, hh:mm"); - ban_info << "Ban ID: " + QString::number(ban.id); - ban_info << "Affected IPID: " + ban.ipid; - ban_info << "Affected HDID: " + ban.hdid; - ban_info << "Reason for ban: " + ban.reason; - ban_info << "Date of ban: " + QDateTime::fromSecsSinceEpoch(ban.time).toString("MM/dd/yyyy, hh:mm"); - ban_info << "Ban lasts until: " + banned_until; - ban_info << "Moderator: " + ban.moderator; - ban_info << "-----"; + l_banned_until = QDateTime::fromSecsSinceEpoch(l_ban.time).addSecs(l_ban.duration).toString("MM/dd/yyyy, hh:mm"); + l_ban_info << "Ban ID: " + QString::number(l_ban.id); + l_ban_info << "Affected IPID: " + l_ban.ipid; + l_ban_info << "Affected HDID: " + l_ban.hdid; + l_ban_info << "Reason for ban: " + l_ban.reason; + l_ban_info << "Date of ban: " + QDateTime::fromSecsSinceEpoch(l_ban.time).toString("MM/dd/yyyy, hh:mm"); + l_ban_info << "Ban lasts until: " + l_banned_until; + l_ban_info << "Moderator: " + l_ban.moderator; + l_ban_info << "-----"; } - sendServerMessage(ban_info.join("\n")); + sendServerMessage(l_ban_info.join("\n")); } void AOClient::cmdReload(int argc, QStringList argv) @@ -470,10 +470,10 @@ void AOClient::cmdForceImmediate(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - AreaData* area = server->m_areas[current_area]; - area->toggleImmediate(); - QString state = area->forceImmediate() ? "on." : "off."; - sendServerMessage("Forced immediate text processing in this area is now " + state); + AreaData* l_area = server->m_areas[m_current_area]; + l_area->toggleImmediate(); + QString l_state = l_area->forceImmediate() ? "on." : "off."; + sendServerMessage("Forced immediate text processing in this area is now " + l_state); } void AOClient::cmdAllowIniswap(int argc, QStringList argv) @@ -481,9 +481,9 @@ void AOClient::cmdAllowIniswap(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - AreaData* area = server->m_areas[current_area]; - area->toggleIniswap(); - QString state = area->iniswapAllowed() ? "allowed." : "disallowed."; + AreaData* l_area = server->m_areas[m_current_area]; + l_area->toggleIniswap(); + QString state = l_area->iniswapAllowed() ? "allowed." : "disallowed."; sendServerMessage("Iniswapping in this area is now " + state); } @@ -491,77 +491,77 @@ void AOClient::cmdPermitSaving(int argc, QStringList argv) { Q_UNUSED(argc); - AOClient* client = server->getClientByID(argv[0].toInt()); - if (client == nullptr) { + AOClient* l_client = server->getClientByID(argv[0].toInt()); + if (l_client == nullptr) { sendServerMessage("Invalid ID."); return; } - client->testimony_saving = true; + l_client->m_testimony_saving = true; + sendServerMessage("Testimony saving has been enabled for client " + QString::number(l_client->m_id)); } void AOClient::cmdKickUid(int argc, QStringList argv) { - QString reason = argv[1]; + QString l_reason = argv[1]; if (argc > 2) { for (int i = 2; i < argv.length(); i++) { - reason += " " + argv[i]; + l_reason += " " + argv[i]; } } bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); - if (target == nullptr) { + AOClient* l_target = server->getClientByID(l_uid); + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - target->sendPacket("KK", {reason}); - target->socket->close(); - sendServerMessage("Kicked client with UID " + argv[0] + " for reason: " + reason); + l_target->sendPacket("KK", {l_reason}); + l_target->m_socket->close(); + sendServerMessage("Kicked client with UID " + argv[0] + " for reason: " + l_reason); } void AOClient::cmdUpdateBan(int argc, QStringList argv) { bool conv_ok = false; - int ban_id = argv[0].toInt(&conv_ok); + int l_ban_id = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid ban ID."); return; } - QVariant updated_info; + QVariant l_updated_info; if (argv[1] == "duration") { - long long duration_seconds = 0; + long long l_duration_seconds = 0; if (argv[2] == "perma") - duration_seconds = -2; + l_duration_seconds = -2; else - duration_seconds = parseTime(argv[2]); - - if (duration_seconds == -1) { + l_duration_seconds = parseTime(argv[2]); + if (l_duration_seconds == -1) { sendServerMessage("Invalid time format. Format example: 1h30m"); return; } - updated_info = QVariant(duration_seconds); + l_updated_info = QVariant(l_duration_seconds); } else if (argv[1] == "reason") { - QString args_str = argv[2]; + QString l_args_str = argv[2]; if (argc > 3) { for (int i = 3; i < argc; i++) - args_str += " " + argv[i]; + l_args_str += " " + argv[i]; } - updated_info = QVariant(args_str); + l_updated_info = QVariant(l_args_str); } else { sendServerMessage("Invalid update type."); return; } - if (!server->db_manager->updateBan(ban_id, argv[1], updated_info)) { + if (!server->db_manager->updateBan(l_ban_id, argv[1], l_updated_info)) { sendServerMessage("There was an error updating the ban. Please confirm the ban ID is valid."); return; } diff --git a/core/src/commands/music.cpp b/core/src/commands/music.cpp index eb3635b..35fec63 100644 --- a/core/src/commands/music.cpp +++ b/core/src/commands/music.cpp @@ -24,16 +24,16 @@ void AOClient::cmdPlay(int argc, QStringList argv) { Q_UNUSED(argc); - if (is_dj_blocked) { + if (m_is_dj_blocked) { sendServerMessage("You are blocked from changing the music."); return; } - AreaData* area = server->m_areas[current_area]; - QString song = argv.join(" "); - area->currentMusic() = song; - area->musicPlayerBy() = showname; - AOPacket music_change("MC", {song, QString::number(server->getCharID(current_char)), showname, "1", "0"}); - server->broadcast(music_change, current_area); + AreaData* l_area = server->m_areas[m_current_area]; + QString l_song = argv.join(" "); + l_area->currentMusic() = l_song; + l_area->musicPlayerBy() = m_showname; + AOPacket music_change("MC", {l_song, QString::number(server->getCharID(m_current_char)), m_showname, "1", "0"}); + server->broadcast(music_change, m_current_area); } void AOClient::cmdCurrentMusic(int argc, QStringList argv) @@ -41,9 +41,9 @@ void AOClient::cmdCurrentMusic(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - AreaData* area = server->m_areas[current_area]; - if (area->currentMusic() != "" && area->currentMusic() != "~stop.mp3") // dummy track for stopping music - sendServerMessage("The current song is " + area->currentMusic() + " played by " + area->musicPlayerBy()); + AreaData* l_area = server->m_areas[m_current_area]; + if (l_area->currentMusic() != "" && l_area->currentMusic() != "~stop.mp3") // dummy track for stopping music + sendServerMessage("The current song is " + l_area->currentMusic() + " played by " + l_area->musicPlayerBy()); else sendServerMessage("There is no music playing."); } @@ -53,26 +53,26 @@ void AOClient::cmdBlockDj(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (target->is_dj_blocked) + if (l_target->m_is_dj_blocked) sendServerMessage("That player is already DJ blocked!"); else { sendServerMessage("DJ blocked player."); - target->sendServerMessage("You were blocked from changing the music by a moderator. " + getReprimand()); + l_target->sendServerMessage("You were blocked from changing the music by a moderator. " + getReprimand()); } - target->is_dj_blocked = true; + l_target->m_is_dj_blocked = true; } void AOClient::cmdUnBlockDj(int argc, QStringList argv) @@ -80,26 +80,26 @@ void AOClient::cmdUnBlockDj(int argc, QStringList argv) Q_UNUSED(argc); bool conv_ok = false; - int uid = argv[0].toInt(&conv_ok); + int l_uid = argv[0].toInt(&conv_ok); if (!conv_ok) { sendServerMessage("Invalid user ID."); return; } - AOClient* target = server->getClientByID(uid); + AOClient* l_target = server->getClientByID(l_uid); - if (target == nullptr) { + if (l_target == nullptr) { sendServerMessage("No client with that ID found."); return; } - if (!target->is_dj_blocked) + if (!l_target->m_is_dj_blocked) sendServerMessage("That player is not DJ blocked!"); else { sendServerMessage("DJ permissions restored to player."); - target->sendServerMessage("A moderator restored your music permissions. " + getReprimand(true)); + l_target->sendServerMessage("A moderator restored your music permissions. " + getReprimand(true)); } - target->is_dj_blocked = false; + l_target->m_is_dj_blocked = false; } void AOClient::cmdToggleMusic(int argc, QStringList argv) @@ -107,8 +107,8 @@ void AOClient::cmdToggleMusic(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - AreaData* area = server->m_areas[current_area]; - area->toggleMusic(); - QString state = area->isMusicAllowed() ? "allowed." : "disallowed."; - sendServerMessage("Music in this area is now " + state); + AreaData* l_area = server->m_areas[m_current_area]; + l_area->toggleMusic(); + QString l_state = l_area->isMusicAllowed() ? "allowed." : "disallowed."; + sendServerMessage("Music in this area is now " + l_state); } diff --git a/core/src/commands/roleplay.cpp b/core/src/commands/roleplay.cpp index 684576e..5d8881f 100644 --- a/core/src/commands/roleplay.cpp +++ b/core/src/commands/roleplay.cpp @@ -25,10 +25,10 @@ void AOClient::cmdFlip(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - QString sender_name = ooc_name; - QStringList faces = {"heads","tails"}; - QString face = faces[AOClient::genRand(0,1)]; - sendServerMessageArea(sender_name + " flipped a coin and got " + face + "."); + QString l_sender_name = m_ooc_name; + QStringList l_faces = {"heads","tails"}; + QString l_face = l_faces[AOClient::genRand(0,1)]; + sendServerMessageArea(l_sender_name + " flipped a coin and got " + l_face + "."); } void AOClient::cmdRoll(int argc, QStringList argv) @@ -43,24 +43,24 @@ void AOClient::cmdRollP(int argc, QStringList argv) void AOClient::cmdTimer(int argc, QStringList argv) { - AreaData* area = server->m_areas[current_area]; + AreaData* l_area = server->m_areas[m_current_area]; // Called without arguments // Shows a brief of all timers if (argc == 0) { - QStringList timers; - timers.append("Currently active timers:"); + QStringList l_timers; + l_timers.append("Currently active timers:"); for (int i = 0; i <= 4; i++) { - timers.append(getAreaTimer(area->index(), i)); + l_timers.append(getAreaTimer(l_area->index(), i)); } - sendServerMessage(timers.join("\n")); + sendServerMessage(l_timers.join("\n")); return; } // Called with more than one argument bool ok; - int timer_id = argv[0].toInt(&ok); - if (!ok || timer_id < 0 || timer_id > 4) { + int l_timer_id = argv[0].toInt(&ok); + if (!ok || l_timer_id < 0 || l_timer_id > 4) { sendServerMessage("Invalid timer ID. Timer ID must be a whole number between 0 and 4."); return; } @@ -68,7 +68,7 @@ void AOClient::cmdTimer(int argc, QStringList argv) // Called with one argument // Shows the status of one timer if (argc == 1) { - sendServerMessage(getAreaTimer(area->index(), timer_id)); + sendServerMessage(getAreaTimer(l_area->index(), l_timer_id)); return; } @@ -77,55 +77,55 @@ void AOClient::cmdTimer(int argc, QStringList argv) // Select the proper timer // Check against permissions if global timer is selected - QTimer* requested_timer; - if (timer_id == 0) { + QTimer* l_requested_timer; + if (l_timer_id == 0) { if (!checkAuth(ACLFlags.value("GLOBAL_TIMER"))) { sendServerMessage("You are not authorized to alter the global timer."); return; } - requested_timer = server->timer; + l_requested_timer = server->timer; } else - requested_timer = area->timers().at(timer_id - 1); + l_requested_timer = l_area->timers().at(l_timer_id - 1); - AOPacket show_timer("TI", {QString::number(timer_id), "2"}); - AOPacket hide_timer("TI", {QString::number(timer_id), "3"}); - bool is_global = timer_id == 0; + AOPacket l_show_timer("TI", {QString::number(l_timer_id), "2"}); + AOPacket l_hide_timer("TI", {QString::number(l_timer_id), "3"}); + bool l_is_global = l_timer_id == 0; // Set the timer's time remaining if the second // argument is a valid time - QTime requested_time = QTime::fromString(argv[1], "hh:mm:ss"); - if (requested_time.isValid()) { - requested_timer->setInterval(QTime(0,0).msecsTo(requested_time)); - requested_timer->start(); - sendServerMessage("Set timer " + QString::number(timer_id) + " to " + argv[1] + "."); - AOPacket update_timer("TI", {QString::number(timer_id), "0", QString::number(QTime(0,0).msecsTo(requested_time))}); - is_global ? server->broadcast(show_timer) : server->broadcast(show_timer, current_area); // Show the timer - is_global ? server->broadcast(update_timer) : server->broadcast(update_timer, current_area); + QTime l_requested_time = QTime::fromString(argv[1], "hh:mm:ss"); + if (l_requested_time.isValid()) { + l_requested_timer->setInterval(QTime(0,0).msecsTo(l_requested_time)); + l_requested_timer->start(); + sendServerMessage("Set timer " + QString::number(l_timer_id) + " to " + argv[1] + "."); + AOPacket l_update_timer("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0,0).msecsTo(l_requested_time))}); + l_is_global ? server->broadcast(l_show_timer) : server->broadcast(l_show_timer, m_current_area); // Show the timer + l_is_global ? server->broadcast(l_update_timer) : server->broadcast(l_update_timer, m_current_area); return; } // Otherwise, update the state of the timer else { if (argv[1] == "start") { - requested_timer->start(); - sendServerMessage("Started timer " + QString::number(timer_id) + "."); - AOPacket update_timer("TI", {QString::number(timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(requested_timer->remainingTime())))}); - is_global ? server->broadcast(show_timer) : server->broadcast(show_timer, current_area); - is_global ? server->broadcast(update_timer) : server->broadcast(update_timer, current_area); + l_requested_timer->start(); + sendServerMessage("Started timer " + QString::number(l_timer_id) + "."); + AOPacket l_update_timer("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(l_requested_timer->remainingTime())))}); + l_is_global ? server->broadcast(l_show_timer) : server->broadcast(l_show_timer, m_current_area); + l_is_global ? server->broadcast(l_update_timer) : server->broadcast(l_update_timer, m_current_area); } else if (argv[1] == "pause" || argv[1] == "stop") { - requested_timer->setInterval(requested_timer->remainingTime()); - requested_timer->stop(); - sendServerMessage("Stopped timer " + QString::number(timer_id) + "."); - AOPacket update_timer("TI", {QString::number(timer_id), "1", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(requested_timer->interval())))}); - is_global ? server->broadcast(update_timer) : server->broadcast(update_timer, current_area); + l_requested_timer->setInterval(l_requested_timer->remainingTime()); + l_requested_timer->stop(); + sendServerMessage("Stopped timer " + QString::number(l_timer_id) + "."); + AOPacket l_update_timer("TI", {QString::number(l_timer_id), "1", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(l_requested_timer->interval())))}); + l_is_global ? server->broadcast(l_update_timer) : server->broadcast(l_update_timer, m_current_area); } else if (argv[1] == "hide" || argv[1] == "unset") { - requested_timer->setInterval(0); - requested_timer->stop(); - sendServerMessage("Hid timer " + QString::number(timer_id) + "."); + l_requested_timer->setInterval(0); + l_requested_timer->stop(); + sendServerMessage("Hid timer " + QString::number(l_timer_id) + "."); // Hide the timer - is_global ? server->broadcast(hide_timer) : server->broadcast(hide_timer, current_area); + l_is_global ? server->broadcast(l_hide_timer) : server->broadcast(l_hide_timer, m_current_area); } } } @@ -134,10 +134,10 @@ void AOClient::cmdNoteCard(int argc, QStringList argv) { Q_UNUSED(argc); - AreaData* area = server->m_areas[current_area]; - QString notecard = argv.join(" "); - area->addNotecard(current_char, notecard); - sendServerMessageArea(current_char + " wrote a note card."); + AreaData* l_area = server->m_areas[m_current_area]; + QString l_notecard = argv.join(" "); + l_area->addNotecard(m_current_char, l_notecard); + sendServerMessageArea(m_current_char + " wrote a note card."); } void AOClient::cmdNoteCardClear(int argc, QStringList argv) @@ -145,9 +145,9 @@ void AOClient::cmdNoteCardClear(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - AreaData* area = server->m_areas[current_area]; - if (!area->addNotecard(current_char, QString())) { - sendServerMessageArea(current_char + " erased their note card."); + AreaData* l_area = server->m_areas[m_current_area]; + if (!l_area->addNotecard(m_current_char, QString())) { + sendServerMessageArea(m_current_char + " erased their note card."); } } @@ -156,18 +156,18 @@ void AOClient::cmdNoteCardReveal(int argc, QStringList argv) Q_UNUSED(argc); Q_UNUSED(argv); - AreaData* area = server->m_areas[current_area]; - const QStringList l_notecards = area->getNotecards(); + AreaData* l_area = server->m_areas[m_current_area]; + const QStringList l_notecards = l_area->getNotecards(); if (l_notecards.isEmpty()) { sendServerMessage("There are no cards to reveal in this area."); return; } - QString message("Note cards have been revealed.\n"); - message.append(l_notecards.join("\n") + "\n"); + QString l_message("Note cards have been revealed.\n"); + l_message.append(l_notecards.join("\n") + "\n"); - sendServerMessageArea(message); + sendServerMessageArea(l_message); } void AOClient::cmd8Ball(int argc, QStringList argv) @@ -179,11 +179,11 @@ void AOClient::cmd8Ball(int argc, QStringList argv) sendServerMessage("8ball.txt is empty."); } else { - QString response = ConfigManager::magic8BallAnswers().at((genRand(1, ConfigManager::magic8BallAnswers().size() - 1))); - QString sender_name = ooc_name; - QString sender_message = argv.join(" "); + QString l_response = ConfigManager::magic8BallAnswers().at((genRand(1, ConfigManager::magic8BallAnswers().size() - 1))); + QString l_sender_name = m_ooc_name; + QString l_sender_message = argv.join(" "); - sendServerMessageArea(sender_name + " asked the magic 8-ball, \"" + sender_message + "\" and the answer is: " + response); + sendServerMessageArea(l_sender_name + " asked the magic 8-ball, \"" + l_sender_message + "\" and the answer is: " + l_response); } } @@ -191,10 +191,10 @@ void AOClient::cmdSubTheme(int argc, QStringList argv) { Q_UNUSED(argc); - QString subtheme = argv.join(" "); - for (AOClient* client : qAsConst(server->m_clients)) { - if (client->current_area == current_area) - client->sendPacket("ST", {subtheme, "1"}); + QString l_subtheme = argv.join(" "); + for (AOClient* l_client : qAsConst(server->m_clients)) { + if (l_client->m_current_area == m_current_area) + l_client->sendPacket("ST", {l_subtheme, "1"}); } - sendServerMessageArea("Subtheme was set to " + subtheme); + sendServerMessageArea("Subtheme was set to " + l_subtheme); } diff --git a/core/src/packets.cpp b/core/src/packets.cpp index 2423d75..b6fceba 100644 --- a/core/src/packets.cpp +++ b/core/src/packets.cpp @@ -35,15 +35,15 @@ void AOClient::pktHardwareId(AreaData* area, int argc, QStringList argv, AOPacke Q_UNUSED(argc); Q_UNUSED(packet); - hwid = argv[0]; - emit server->logConnectionAttempt(remote_ip.toString(), ipid, hwid); - auto ban = server->db_manager->isHDIDBanned(hwid); - if (ban.first) { - sendPacket("BD", {ban.second + "\nBan ID: " + QString::number(server->db_manager->getBanID(hwid))}); - socket->close(); + m_hwid = argv[0]; + emit server->logConnectionAttempt(m_remote_ip.toString(), m_ipid, m_hwid); + auto l_ban = server->db_manager->isHDIDBanned(m_hwid); + if (l_ban.first) { + sendPacket("BD", {l_ban.second + "\nBan ID: " + QString::number(server->db_manager->getBanID(m_hwid))}); + m_socket->close(); return; } - sendPacket("ID", {QString::number(id), "akashi", QCoreApplication::applicationVersion()}); + sendPacket("ID", {QString::number(m_id), "akashi", QCoreApplication::applicationVersion()}); } void AOClient::pktSoftwareId(AreaData* area, int argc, QStringList argv, AOPacket packet) @@ -55,7 +55,7 @@ void AOClient::pktSoftwareId(AreaData* area, int argc, QStringList argv, AOPacke // Full feature list as of AO 2.8.5 // The only ones that are critical to ensuring the server works are // "noencryption" and "fastloading" - QStringList feature_list = { + QStringList l_feature_list = { "noencryption", "yellowtext", "prezoom", "flipping", "customobjections", "fastloading", "deskmod", "evidence", "cccc_ic_support", @@ -65,21 +65,21 @@ void AOClient::pktSoftwareId(AreaData* area, int argc, QStringList argv, AOPacke }; - version.string = argv[1]; + m_version.string = argv[1]; QRegularExpression rx("\\b(\\d+)\\.(\\d+)\\.(\\d+)\\b"); // matches X.X.X (e.g. 2.9.0, 2.4.10, etc.) - QRegularExpressionMatch match = rx.match(version.string); - if (match.hasMatch()) { - version.release = match.captured(1).toInt(); - version.major = match.captured(2).toInt(); - version.minor = match.captured(3).toInt(); + QRegularExpressionMatch l_match = rx.match(m_version.string); + if (l_match.hasMatch()) { + m_version.release = l_match.captured(1).toInt(); + m_version.major = l_match.captured(2).toInt(); + m_version.minor = l_match.captured(3).toInt(); } sendPacket("PN", {QString::number(server->m_player_count), QString::number(ConfigManager::maxPlayers())}); - sendPacket("FL", feature_list); + sendPacket("FL", l_feature_list); if (ConfigManager::assetUrl().isValid()) { - QByteArray asset_url = ConfigManager::assetUrl().toEncoded(QUrl::EncodeSpaces); - sendPacket("ASS", {asset_url}); + QByteArray l_asset_url = ConfigManager::assetUrl().toEncoded(QUrl::EncodeSpaces); + sendPacket("ASS", {l_asset_url}); } } @@ -122,19 +122,19 @@ void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPack Q_UNUSED(argv); Q_UNUSED(packet); - if (hwid == "") { + if (m_hwid == "") { // No early connecting! - socket->close(); + m_socket->close(); return; } - if (joined) { + if (m_joined) { return; } server->m_player_count++; area->clientJoinedArea(); - joined = true; + m_joined = true; server->updateCharsTaken(area); arup(ARUPType::PLAYER_COUNT, true); // Tell everyone there is a new player @@ -157,15 +157,15 @@ void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPack else { sendPacket("TI", {"0", "3"}); } - const QList timers = area->timers(); - for (QTimer* timer : timers) { - int timer_id = area->timers().indexOf(timer) + 1; - if (timer->isActive()) { - sendPacket("TI", {QString::number(timer_id), "2"}); - sendPacket("TI", {QString::number(timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(timer->remainingTime())))}); + const QList l_timers = area->timers(); + for (QTimer* l_timer : l_timers) { + int l_timer_id = area->timers().indexOf(l_timer) + 1; + if (l_timer->isActive()) { + sendPacket("TI", {QString::number(l_timer_id), "2"}); + sendPacket("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(l_timer->remainingTime())))}); } else { - sendPacket("TI", {QString::number(timer_id), "3"}); + sendPacket("TI", {QString::number(l_timer_id), "3"}); } } } @@ -176,7 +176,7 @@ void AOClient::pktCharPassword(AreaData* area, int argc, QStringList argv, AOPac Q_UNUSED(argc); Q_UNUSED(packet); - password = argv[0]; + m_password = argv[0]; } void AOClient::pktSelectChar(AreaData* area, int argc, QStringList argv, AOPacket packet) @@ -186,13 +186,13 @@ void AOClient::pktSelectChar(AreaData* area, int argc, QStringList argv, AOPacke Q_UNUSED(packet); bool argument_ok; - int selected_char_id = argv[1].toInt(&argument_ok); + int l_selected_char_id = argv[1].toInt(&argument_ok); if (!argument_ok) { - selected_char_id = -1; + l_selected_char_id = -1; } - if (changeCharacter(selected_char_id)) - char_id = selected_char_id; + if (changeCharacter(l_selected_char_id)) + m_char_id = l_selected_char_id; } void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket packet) @@ -200,7 +200,7 @@ void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket pa Q_UNUSED(argc); Q_UNUSED(argv); - if (is_muted) { + if (m_is_muted) { sendServerMessage("You cannot speak while muted."); return; } @@ -213,11 +213,11 @@ void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket pa if (validated_packet.header == "INVALID") return; - if (pos != "") - validated_packet.contents[5] = pos; + if (m_pos != "") + validated_packet.contents[5] = m_pos; - server->broadcast(validated_packet, current_area); - emit logIC((current_char + " " + showname), ooc_name,ipid,server->m_areas[current_area]->name(),last_message); + server->broadcast(validated_packet, m_current_area); + emit logIC((m_current_char + " " + m_showname), m_ooc_name, m_ipid,server->m_areas[m_current_area]->name(), m_last_message); area->updateLastICMessage(validated_packet.contents); server->can_send_ic_messages = false; @@ -229,48 +229,48 @@ void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket p Q_UNUSED(argc); Q_UNUSED(packet); - if (is_ooc_muted) { + if (m_is_ooc_muted) { sendServerMessage("You are OOC muted, and cannot speak."); return; } - ooc_name = dezalgo(argv[0]).replace(QRegExp("\\[|\\]|\\{|\\}|\\#|\\$|\\%|\\&"), ""); // no fucky wucky shit here - if (ooc_name.isEmpty() || ooc_name == ConfigManager::serverName()) // impersonation & empty name protection + m_ooc_name = dezalgo(argv[0]).replace(QRegExp("\\[|\\]|\\{|\\}|\\#|\\$|\\%|\\&"), ""); // no fucky wucky shit here + if (m_ooc_name.isEmpty() || m_ooc_name == ConfigManager::serverName()) // impersonation & empty name protection return; - if (ooc_name.length() > 30) { + if (m_ooc_name.length() > 30) { sendServerMessage("Your name is too long! Please limit it to under 30 characters."); return; } - if (is_logging_in) { + if (m_is_logging_in) { loginAttempt(argv[1]); return; } - QString message = dezalgo(argv[1]); - if (message.length() == 0 || message.length() > ConfigManager::maxCharacters()) + QString l_message = dezalgo(argv[1]); + if (l_message.length() == 0 || l_message.length() > ConfigManager::maxCharacters()) return; - AOPacket final_packet("CT", {ooc_name, message, "0"}); - if(message.at(0) == '/') { + AOPacket final_packet("CT", {m_ooc_name, l_message, "0"}); + if(l_message.at(0) == '/') { #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - QStringList cmd_argv = message.split(" ", QString::SplitBehavior::SkipEmptyParts); + QStringList l_cmd_argv = l_message.split(" ", QString::SplitBehavior::SkipEmptyParts); #else - QStringList cmd_argv = message.split(" ", Qt::SkipEmptyParts); + QStringList l_cmd_argv = l_message.split(" ", Qt::SkipEmptyParts); #endif - QString command = cmd_argv[0].trimmed().toLower(); - command = command.right(command.length() - 1); - cmd_argv.removeFirst(); - int cmd_argc = cmd_argv.length(); + QString l_command = l_cmd_argv[0].trimmed().toLower(); + l_command = l_command.right(l_command.length() - 1); + l_cmd_argv.removeFirst(); + int l_cmd_argc = l_cmd_argv.length(); - handleCommand(command, cmd_argc, cmd_argv); - emit logCMD((current_char + " " + showname),ipid, ooc_name,command,cmd_argv,server->m_areas[current_area]->name()); + handleCommand(l_command, l_cmd_argc, l_cmd_argv); + emit logCMD((m_current_char + " " + m_showname), m_ipid, m_ooc_name, l_command, l_cmd_argv,server->m_areas[m_current_area]->name()); return; } else { - server->broadcast(final_packet, current_area); + server->broadcast(final_packet, m_current_area); } - emit logOOC((current_char + " " + showname), ooc_name, ipid,area->name(),message); + emit logOOC((m_current_char + " " + m_showname), m_ooc_name, m_ipid, area->name(), l_message); } void AOClient::pktPing(AreaData* area, int argc, QStringList argv, AOPacket packet) @@ -296,12 +296,12 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack // First, we check if the provided // argument is a valid song - QString argument = argv[0]; + QString l_argument = argv[0]; - for (const QString &song : qAsConst(server->m_music_list)) { - if (song == argument || song == "~stop.mp3") { // ~stop.mp3 is a dummy track used by 2.9+ + for (const QString &l_song : qAsConst(server->m_music_list)) { + if (l_song == l_argument || l_song == "~stop.mp3") { // ~stop.mp3 is a dummy track used by 2.9+ // We have a song here - if (is_dj_blocked) { + if (m_is_dj_blocked) { sendServerMessage("You are blocked from changing the music."); return; } @@ -309,27 +309,27 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack sendServerMessage("Music is disabled in this area."); return; } - QString effects; + QString l_effects; if (argc >= 4) - effects = argv[3]; + l_effects = argv[3]; else - effects = "0"; - QString final_song; - if (!argument.contains(".")) - final_song = "~stop.mp3"; + l_effects = "0"; + QString l_final_song; + if (!l_argument.contains(".")) + l_final_song = "~stop.mp3"; else - final_song = argument; - AOPacket music_change("MC", {final_song, argv[1], showname, "1", "0", effects}); - area->currentMusic() = final_song; - area->musicPlayerBy() = showname; - server->broadcast(music_change, current_area); + l_final_song = l_argument; + AOPacket l_music_change("MC", {l_final_song, argv[1], m_showname, "1", "0", l_effects}); + area->currentMusic() = l_final_song; + area->musicPlayerBy() = m_showname; + server->broadcast(l_music_change, m_current_area); return; } } for (int i = 0; i < server->m_area_names.length(); i++) { - QString area = server->m_area_names[i]; - if(area == argument) { + QString l_area = server->m_area_names[i]; + if(l_area == l_argument) { changeArea(i); break; } @@ -341,14 +341,14 @@ void AOClient::pktWtCe(AreaData* area, int argc, QStringList argv, AOPacket pack Q_UNUSED(argc); Q_UNUSED(argv); - if (is_wtce_blocked) { + if (m_is_wtce_blocked) { sendServerMessage("You are blocked from using the judge controls."); return; } - if (QDateTime::currentDateTime().toSecsSinceEpoch() - last_wtce_time <= 5) + if (QDateTime::currentDateTime().toSecsSinceEpoch() - m_last_wtce_time <= 5) return; - last_wtce_time = QDateTime::currentDateTime().toSecsSinceEpoch(); - server->broadcast(packet, current_area); + m_last_wtce_time = QDateTime::currentDateTime().toSecsSinceEpoch(); + server->broadcast(packet, m_current_area); updateJudgeLog(area, this, "WT/CE"); } @@ -357,7 +357,7 @@ void AOClient::pktHpBar(AreaData* area, int argc, QStringList argv, AOPacket pac Q_UNUSED(argc); Q_UNUSED(packet); - if (is_wtce_blocked) { + if (m_is_wtce_blocked) { sendServerMessage("You are blocked from using the judge controls."); return; } @@ -384,27 +384,27 @@ void AOClient::pktWebSocketIp(AreaData* area, int argc, QStringList argv, AOPack // Special packet to set remote IP from the webao proxy // Only valid if from a local ip - if (remote_ip.isLoopback()) { + if (m_remote_ip.isLoopback()) { #ifdef NET_DEBUG qDebug() << "ws ip set to" << argv[0]; #endif - remote_ip = QHostAddress(argv[0]); + m_remote_ip = QHostAddress(argv[0]); calculateIpid(); - auto ban = server->db_manager->isIPBanned(ipid); - if (ban.first) { - sendPacket("BD", {ban.second}); - socket->close(); + auto l_ban = server->db_manager->isIPBanned(m_ipid); + if (l_ban.first) { + sendPacket("BD", {l_ban.second}); + m_socket->close(); return; } - int multiclient_count = 0; - for (AOClient* joined_client : qAsConst(server->m_clients)) { - if (remote_ip.isEqual(joined_client->remote_ip)) - multiclient_count++; + int l_multiclient_count = 0; + for (AOClient* l_joined_client : qAsConst(server->m_clients)) { + if (m_remote_ip.isEqual(l_joined_client->m_remote_ip)) + l_multiclient_count++; } - if (multiclient_count > ConfigManager::multiClientLimit()) { - socket->close(); + if (l_multiclient_count > ConfigManager::multiClientLimit()) { + m_socket->close(); return; } } @@ -416,18 +416,18 @@ void AOClient::pktModCall(AreaData* area, int argc, QStringList argv, AOPacket p Q_UNUSED(argv); for (AOClient* client : qAsConst(server->m_clients)) { - if (client->authenticated) + if (client->m_authenticated) client->sendPacket(packet); } - emit logModcall((current_char + " " + showname),ipid, ooc_name, server->m_areas[current_area]->name()); + emit logModcall((m_current_char + " " + m_showname), m_ipid, m_ooc_name, server->m_areas[m_current_area]->name()); if (ConfigManager::discordModcallWebhookEnabled()) { - QString name = ooc_name; - if (ooc_name.isEmpty()) - name = current_char; + QString l_name = m_ooc_name; + if (m_ooc_name.isEmpty()) + l_name = m_current_char; QString l_areaName = area->name(); - emit server->modcallWebhookRequest(name, l_areaName, packet.contents[0],server->getAreaBuffer(l_areaName)); + emit server->modcallWebhookRequest(l_name, l_areaName, packet.contents[0],server->getAreaBuffer(l_areaName)); } } @@ -438,8 +438,8 @@ void AOClient::pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPack if (!checkEvidenceAccess(area)) return; - AreaData::Evidence evi = {argv[0], argv[1], argv[2]}; - area->appendEvidence(evi); + AreaData::Evidence l_evi = {argv[0], argv[1], argv[2]}; + area->appendEvidence(l_evi); sendEvidenceList(area); } @@ -451,9 +451,9 @@ void AOClient::pktRemoveEvidence(AreaData* area, int argc, QStringList argv, AOP if (!checkEvidenceAccess(area)) return; bool is_int = false; - int idx = argv[0].toInt(&is_int); - if (is_int && idx < area->evidence().size() && idx >= 0) { - area->deleteEvidence(idx); + int l_idx = argv[0].toInt(&is_int); + if (is_int && l_idx < area->evidence().size() && l_idx >= 0) { + area->deleteEvidence(l_idx); } sendEvidenceList(area); } @@ -466,10 +466,10 @@ void AOClient::pktEditEvidence(AreaData* area, int argc, QStringList argv, AOPac if (!checkEvidenceAccess(area)) return; bool is_int = false; - int idx = argv[0].toInt(&is_int); - AreaData::Evidence evi = {argv[1], argv[2], argv[3]}; - if (is_int && idx < area->evidence().size() && idx >= 0) { - area->replaceEvidence(idx, evi); + int l_idx = argv[0].toInt(&is_int); + AreaData::Evidence l_evi = {argv[1], argv[2], argv[3]}; + if (is_int && l_idx < area->evidence().size() && l_idx >= 0) { + area->replaceEvidence(l_idx, l_evi); } sendEvidenceList(area); } @@ -480,15 +480,15 @@ void AOClient::pktSetCase(AreaData* area, int argc, QStringList argv, AOPacket p Q_UNUSED(argc); Q_UNUSED(packet); - QList prefs_list; + QList l_prefs_list; for (int i = 2; i <=6; i++) { bool is_int = false; bool pref = argv[i].toInt(&is_int); if (!is_int) return; - prefs_list.append(pref); + l_prefs_list.append(pref); } - casing_preferences = prefs_list; + m_casing_preferences = l_prefs_list; } void AOClient::pktAnnounceCase(AreaData* area, int argc, QStringList argv, AOPacket packet) @@ -497,46 +497,46 @@ void AOClient::pktAnnounceCase(AreaData* area, int argc, QStringList argv, AOPac Q_UNUSED(argc); Q_UNUSED(packet); - QString case_title = argv[0]; - QStringList needed_roles; - QList needs_list; + QString l_case_title = argv[0]; + QStringList l_needed_roles; + QList l_needs_list; for (int i = 1; i <=5; i++) { bool is_int = false; bool need = argv[i].toInt(&is_int); if (!is_int) return; - needs_list.append(need); + l_needs_list.append(need); } - QStringList roles = {"defense attorney", "prosecutor", "judge", "jurors", "stenographer"}; + QStringList l_roles = {"defense attorney", "prosecutor", "judge", "jurors", "stenographer"}; for (int i = 0; i < 5; i++) { - if (needs_list[i]) - needed_roles.append(roles[i]); + if (l_needs_list[i]) + l_needed_roles.append(l_roles[i]); } - if (needed_roles.isEmpty()) + if (l_needed_roles.isEmpty()) return; - QString message = "=== Case Announcement ===\r\n" + (ooc_name == "" ? current_char : ooc_name) + " needs " + needed_roles.join(", ") + " for " + (case_title == "" ? "a case" : case_title) + "!"; + QString l_message = "=== Case Announcement ===\r\n" + (m_ooc_name == "" ? m_current_char : m_ooc_name) + " needs " + l_needed_roles.join(", ") + " for " + (l_case_title == "" ? "a case" : l_case_title) + "!"; - QList clients_to_alert; + QList l_clients_to_alert; // here lies morton, RIP #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - QSet needs_set(needs_list.begin(), needs_list.end()); + QSet l_needs_set(l_needs_list.begin(), l_needs_list.end()); #else - QSet needs_set = needs_list.toSet(); + QSet l_needs_set = l_needs_list.toSet(); #endif - for (AOClient* client : qAsConst(server->m_clients)) { + for (AOClient* l_client : qAsConst(server->m_clients)) { #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - QSet matches(client->casing_preferences.begin(), client->casing_preferences.end()); - matches.intersect(needs_set); + QSet l_matches(l_client->m_casing_preferences.begin(), l_client->m_casing_preferences.end()); + l_matches.intersect(l_needs_set); #else QSet matches = client->casing_preferences.toSet().intersect(needs_set); #endif - if (!matches.isEmpty() && !clients_to_alert.contains(client)) - clients_to_alert.append(client); + if (!l_matches.isEmpty() && !l_clients_to_alert.contains(l_client)) + l_clients_to_alert.append(l_client); } - for (AOClient* client : clients_to_alert) { - client->sendPacket(AOPacket("CASEA", {message, argv[1], argv[2], argv[3], argv[4], argv[5], "1"})); + for (AOClient* l_client : l_clients_to_alert) { + l_client->sendPacket(AOPacket("CASEA", {l_message, argv[1], argv[2], argv[3], argv[4], argv[5], "1"})); // you may be thinking, "hey wait a minute the network protocol documentation doesn't mention that last argument!" // if you are in fact thinking that, you are correct! it is not in the documentation! // however for some inscrutable reason Attorney Online 2 will outright reject a CASEA packet that does not have @@ -546,34 +546,34 @@ void AOClient::pktAnnounceCase(AreaData* area, int argc, QStringList argv, AOPac void AOClient::sendEvidenceList(AreaData* area) { - for (AOClient* client : qAsConst(server->m_clients)) { - if (client->current_area == current_area) - client->updateEvidenceList(area); + for (AOClient* l_client : qAsConst(server->m_clients)) { + if (l_client->m_current_area == m_current_area) + l_client->updateEvidenceList(area); } } void AOClient::updateEvidenceList(AreaData* area) { - QStringList evidence_list; - QString evidence_format("%1&%2&%3"); + QStringList l_evidence_list; + QString l_evidence_format("%1&%2&%3"); - const QList area_evidence = area->evidence(); - for (const AreaData::Evidence &evidence : area_evidence) { + const QList l_area_evidence = area->evidence(); + for (const AreaData::Evidence &evidence : l_area_evidence) { if (!checkAuth(ACLFlags.value("CM")) && area->eviMod() == AreaData::EvidenceMod::HIDDEN_CM) { - QRegularExpression regex(""); - QRegularExpressionMatch match = regex.match(evidence.description); - if (match.hasMatch()) { - QStringList owners = match.captured(1).split(","); - if (!owners.contains("all", Qt::CaseSensitivity::CaseInsensitive) && !owners.contains(pos, Qt::CaseSensitivity::CaseInsensitive)) { + QRegularExpression l_regex(""); + QRegularExpressionMatch l_match = l_regex.match(evidence.description); + if (l_match.hasMatch()) { + QStringList owners = l_match.captured(1).split(","); + if (!owners.contains("all", Qt::CaseSensitivity::CaseInsensitive) && !owners.contains(m_pos, Qt::CaseSensitivity::CaseInsensitive)) { continue; } } // no match = show it to all } - evidence_list.append(evidence_format.arg(evidence.name, evidence.description, evidence.image)); + l_evidence_list.append(l_evidence_format.arg(evidence.name, evidence.description, evidence.image)); } - sendPacket(AOPacket("LE", evidence_list)); + sendPacket(AOPacket("LE", l_evidence_list)); } AOPacket AOClient::validateIcPacket(AOPacket packet) @@ -585,96 +585,96 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) // in typical AO fasion, the indicies for the incoming // and outgoing packets are different. Just RTFM. - AOPacket invalid("INVALID", {}); - QStringList args; - if (current_char == "" || !joined) + AOPacket l_invalid("INVALID", {}); + QStringList l_args; + if (m_current_char == "" || !m_joined) // Spectators cannot use IC - return invalid; - AreaData* area = server->m_areas[current_area]; - if (area->lockStatus() == AreaData::LockStatus::SPECTATABLE && !area->invited().contains(id) && !checkAuth(ACLFlags.value("BYPASS_LOCKS"))) + return l_invalid; + AreaData* area = server->m_areas[m_current_area]; + if (area->lockStatus() == AreaData::LockStatus::SPECTATABLE && !area->invited().contains(m_id) && !checkAuth(ACLFlags.value("BYPASS_LOCKS"))) // Non-invited players cannot speak in spectatable areas - return invalid; + return l_invalid; - QList incoming_args; - for (const QString &arg : qAsConst(packet.contents)) { - incoming_args.append(QVariant(arg)); + QList l_incoming_args; + for (const QString &l_arg : qAsConst(packet.contents)) { + l_incoming_args.append(QVariant(l_arg)); } // desk modifier QStringList allowed_desk_mods; allowed_desk_mods << "chat" << "0" << "1" << "2" << "3" << "4" << "5"; - if (allowed_desk_mods.contains(incoming_args[0].toString())) { - args.append(incoming_args[0].toString()); + if (allowed_desk_mods.contains(l_incoming_args[0].toString())) { + l_args.append(l_incoming_args[0].toString()); } else - return invalid; + return l_invalid; // preanim - args.append(incoming_args[1].toString()); + l_args.append(l_incoming_args[1].toString()); // char name - if (current_char.toLower() != incoming_args[2].toString().toLower()) { + if (m_current_char.toLower() != l_incoming_args[2].toString().toLower()) { // Selected char is different from supplied folder name // This means the user is INI-swapped if (!area->iniswapAllowed()) { - if (!server->m_characters.contains(incoming_args[2].toString(), Qt::CaseInsensitive)) - return invalid; + if (!server->m_characters.contains(l_incoming_args[2].toString(), Qt::CaseInsensitive)) + return l_invalid; } qDebug() << "INI swap detected from " << getIpid(); } - current_iniswap = incoming_args[2].toString(); - args.append(incoming_args[2].toString()); + m_current_iniswap = l_incoming_args[2].toString(); + l_args.append(l_incoming_args[2].toString()); // emote - emote = incoming_args[3].toString(); - if (first_person) - emote = ""; - args.append(emote); + m_emote = l_incoming_args[3].toString(); + if (m_first_person) + m_emote = ""; + l_args.append(m_emote); // message text - if (incoming_args[4].toString().size() > ConfigManager::maxCharacters()) - return invalid; + if (l_incoming_args[4].toString().size() > ConfigManager::maxCharacters()) + return l_invalid; - QString incoming_msg = dezalgo(incoming_args[4].toString().trimmed()); + QString l_incoming_msg = dezalgo(l_incoming_args[4].toString().trimmed()); if (!area->lastICMessage().isEmpty() - && incoming_msg == area->lastICMessage()[4] - && incoming_msg != "") - return invalid; + && l_incoming_msg == area->lastICMessage()[4] + && l_incoming_msg != "") + return l_invalid; - if (incoming_msg == "" && area->blankpostingAllowed() == false) { + if (l_incoming_msg == "" && area->blankpostingAllowed() == false) { sendServerMessage("Blankposting has been forbidden in this area."); - return invalid; + return l_invalid; } - if (is_gimped) { - QString gimp_message = ConfigManager::gimpList().at((genRand(1, ConfigManager::gimpList().size() - 1))); - incoming_msg = gimp_message; + if (m_is_gimped) { + QString l_gimp_message = ConfigManager::gimpList().at((genRand(1, ConfigManager::gimpList().size() - 1))); + l_incoming_msg = l_gimp_message; } - if (is_shaken) { - QStringList parts = incoming_msg.split(" "); - std::random_shuffle(parts.begin(), parts.end()); - incoming_msg = parts.join(" "); + if (m_is_shaken) { + QStringList l_parts = l_incoming_msg.split(" "); + std::random_shuffle(l_parts.begin(), l_parts.end()); + l_incoming_msg = l_parts.join(" "); } - if (is_disemvoweled) { - QString disemvoweled_message = incoming_msg.remove(QRegExp("[AEIOUaeiou]")); - incoming_msg = disemvoweled_message; + if (m_is_disemvoweled) { + QString l_disemvoweled_message = l_incoming_msg.remove(QRegExp("[AEIOUaeiou]")); + l_incoming_msg = l_disemvoweled_message; } - last_message = incoming_msg; - args.append(incoming_msg); + m_last_message = l_incoming_msg; + l_args.append(l_incoming_msg); // side // this is validated clientside so w/e - args.append(incoming_args[5].toString()); - if (pos != incoming_args[5].toString()) { - pos = incoming_args[5].toString(); - updateEvidenceList(server->m_areas[current_area]); + l_args.append(l_incoming_args[5].toString()); + if (m_pos != l_incoming_args[5].toString()) { + m_pos = l_incoming_args[5].toString(); + updateEvidenceList(server->m_areas[m_current_area]); } // sfx name - args.append(incoming_args[6].toString()); + l_args.append(l_incoming_args[6].toString()); // emote modifier // Now, gather round, y'all. Here is a story that is truly a microcosm of the AO dev experience. @@ -684,218 +684,218 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) // This would crash everyone else's client, and the feature had to be disabled // But, for some reason, nobody traced the cause of this issue for many many years. // The serverside fix is needed to ensure invalid values are not sent, because the client sucks - int emote_mod = incoming_args[7].toInt(); + int emote_mod = l_incoming_args[7].toInt(); if (emote_mod == 4) emote_mod = 6; if (emote_mod != 0 && emote_mod != 1 && emote_mod != 2 && emote_mod != 5 && emote_mod != 6) - return invalid; - args.append(QString::number(emote_mod)); + return l_invalid; + l_args.append(QString::number(emote_mod)); // char id - if (incoming_args[8].toInt() != char_id) - return invalid; - args.append(incoming_args[8].toString()); + if (l_incoming_args[8].toInt() != m_char_id) + return l_invalid; + l_args.append(l_incoming_args[8].toString()); // sfx delay - args.append(incoming_args[9].toString()); + l_args.append(l_incoming_args[9].toString()); // objection modifier - if (incoming_args[10].toString().contains("4")) { + if (l_incoming_args[10].toString().contains("4")) { // custom shout includes text metadata - args.append(incoming_args[10].toString()); + l_args.append(l_incoming_args[10].toString()); } else { - int obj_mod = incoming_args[10].toInt(); - if (obj_mod != 0 && obj_mod != 1 && obj_mod != 2 && obj_mod != 3) - return invalid; - args.append(QString::number(obj_mod)); + int l_obj_mod = l_incoming_args[10].toInt(); + if (l_obj_mod != 0 && l_obj_mod != 1 && l_obj_mod != 2 && l_obj_mod != 3) + return l_invalid; + l_args.append(QString::number(l_obj_mod)); } // evidence - int evi_idx = incoming_args[11].toInt(); + int evi_idx = l_incoming_args[11].toInt(); if (evi_idx > area->evidence().length()) - return invalid; - args.append(QString::number(evi_idx)); + return l_invalid; + l_args.append(QString::number(evi_idx)); // flipping - int flip = incoming_args[12].toInt(); - if (flip != 0 && flip != 1) - return invalid; - flipping = QString::number(flip); - args.append(flipping); + int l_flip = l_incoming_args[12].toInt(); + if (l_flip != 0 && l_flip != 1) + return l_invalid; + m_flipping = QString::number(l_flip); + l_args.append(m_flipping); // realization - int realization = incoming_args[13].toInt(); + int realization = l_incoming_args[13].toInt(); if (realization != 0 && realization != 1) - return invalid; - args.append(QString::number(realization)); + return l_invalid; + l_args.append(QString::number(realization)); // text color - int text_color = incoming_args[14].toInt(); + int text_color = l_incoming_args[14].toInt(); if (text_color < 0 || text_color > 11) - return invalid; - args.append(QString::number(text_color)); + return l_invalid; + l_args.append(QString::number(text_color)); // 2.6 packet extensions - if (incoming_args.length() > 15) { + if (l_incoming_args.length() > 15) { // showname - QString incoming_showname = dezalgo(incoming_args[15].toString().trimmed()); - if (!(incoming_showname == current_char || incoming_showname.isEmpty()) && !area->shownameAllowed()) { + QString l_incoming_showname = dezalgo(l_incoming_args[15].toString().trimmed()); + if (!(l_incoming_showname == m_current_char || l_incoming_showname.isEmpty()) && !area->shownameAllowed()) { sendServerMessage("Shownames are not allowed in this area!"); - return invalid; + return l_invalid; } - if (incoming_showname.length() > 30) { + if (l_incoming_showname.length() > 30) { sendServerMessage("Your showname is too long! Please limit it to under 30 characters"); - return invalid; + return l_invalid; } // if the raw input is not empty but the trimmed input is, use a single space - if (incoming_showname.isEmpty() && !incoming_args[15].toString().isEmpty()) - incoming_showname = " "; - args.append(incoming_showname); - showname = incoming_showname; + if (l_incoming_showname.isEmpty() && !l_incoming_args[15].toString().isEmpty()) + l_incoming_showname = " "; + l_args.append(l_incoming_showname); + m_showname = l_incoming_showname; // other char id // things get a bit hairy here // don't ask me how this works, because i don't know either - QStringList pair_data = incoming_args[16].toString().split("^"); - pairing_with = pair_data[0].toInt(); - QString front_back = ""; - if (pair_data.length() > 1) - front_back = "^" + pair_data[1]; - int other_charid = pairing_with; - bool pairing = false; - QString other_name = "0"; - QString other_emote = "0"; - QString other_offset = "0"; - QString other_flip = "0"; - for (AOClient* client : qAsConst(server->m_clients)) { - if (client->pairing_with == char_id - && other_charid != char_id - && client->char_id == pairing_with - && client->pos == pos) { - other_name = client->current_iniswap; - other_emote = client->emote; - other_offset = client->offset; - other_flip = client->flipping; - pairing = true; + QStringList l_pair_data = l_incoming_args[16].toString().split("^"); + m_pairing_with = l_pair_data[0].toInt(); + QString l_front_back = ""; + if (l_pair_data.length() > 1) + l_front_back = "^" + l_pair_data[1]; + int l_other_charid = m_pairing_with; + bool l_pairing = false; + QString l_other_name = "0"; + QString l_other_emote = "0"; + QString l_other_offset = "0"; + QString l_other_flip = "0"; + for (AOClient* l_client : qAsConst(server->m_clients)) { + if (l_client->m_pairing_with == m_char_id + && l_other_charid != m_char_id + && l_client->m_char_id == m_pairing_with + && l_client->m_pos == m_pos) { + l_other_name = l_client->m_current_iniswap; + l_other_emote = l_client->m_emote; + l_other_offset = l_client->m_offset; + l_other_flip = l_client->m_flipping; + l_pairing = true; } } - if (!pairing) { - other_charid = -1; - front_back = ""; + if (!l_pairing) { + l_other_charid = -1; + l_front_back = ""; } - args.append(QString::number(other_charid) + front_back); - args.append(other_name); - args.append(other_emote); + l_args.append(QString::number(l_other_charid) + l_front_back); + l_args.append(l_other_name); + l_args.append(l_other_emote); // self offset - offset = incoming_args[17].toString(); + m_offset = l_incoming_args[17].toString(); // versions 2.6-2.8 cannot validate y-offset so we send them just the x-offset - if ((version.release == 2) && (version.major == 6 || version.major == 7 || version.major == 8)) { - QString x_offset = offset.split("&")[0]; - args.append(x_offset); - QString other_x_offset = other_offset.split("&")[0]; - args.append(other_x_offset); + if ((m_version.release == 2) && (m_version.major == 6 || m_version.major == 7 || m_version.major == 8)) { + QString l_x_offset = m_offset.split("&")[0]; + l_args.append(l_x_offset); + QString l_other_x_offset = l_other_offset.split("&")[0]; + l_args.append(l_other_x_offset); } else { - args.append(offset); - args.append(other_offset); + l_args.append(m_offset); + l_args.append(l_other_offset); } - args.append(other_flip); + l_args.append(l_other_flip); // immediate text processing - int immediate = incoming_args[18].toInt(); + int l_immediate = l_incoming_args[18].toInt(); if (area->forceImmediate()) { - if (args[7] == "1" || args[7] == "2") { - args[7] = "0"; - immediate = 1; + if (l_args[7] == "1" || l_args[7] == "2") { + l_args[7] = "0"; + l_immediate = 1; } - else if (args[7] == "6") { - args[7] = "5"; - immediate = 1; + else if (l_args[7] == "6") { + l_args[7] = "5"; + l_immediate = 1; } } - if (immediate != 1 && immediate != 0) - return invalid; - args.append(QString::number(immediate)); + if (l_immediate != 1 && l_immediate != 0) + return l_invalid; + l_args.append(QString::number(l_immediate)); } // 2.8 packet extensions - if (incoming_args.length() > 19) { + if (l_incoming_args.length() > 19) { // sfx looping - int sfx_loop = incoming_args[19].toInt(); - if (sfx_loop != 0 && sfx_loop != 1) - return invalid; - args.append(QString::number(sfx_loop)); + int l_sfx_loop = l_incoming_args[19].toInt(); + if (l_sfx_loop != 0 && l_sfx_loop != 1) + return l_invalid; + l_args.append(QString::number(l_sfx_loop)); // screenshake - int screenshake = incoming_args[20].toInt(); - if (screenshake != 0 && screenshake != 1) - return invalid; - args.append(QString::number(screenshake)); + int l_screenshake = l_incoming_args[20].toInt(); + if (l_screenshake != 0 && l_screenshake != 1) + return l_invalid; + l_args.append(QString::number(l_screenshake)); // frames shake - args.append(incoming_args[21].toString()); + l_args.append(l_incoming_args[21].toString()); // frames realization - args.append(incoming_args[22].toString()); + l_args.append(l_incoming_args[22].toString()); // frames sfx - args.append(incoming_args[23].toString()); + l_args.append(l_incoming_args[23].toString()); // additive - int additive = incoming_args[24].toInt(); - if (additive != 0 && additive != 1) - return invalid; + int l_additive = l_incoming_args[24].toInt(); + if (l_additive != 0 && l_additive != 1) + return l_invalid; else if (area->lastICMessage().isEmpty()){ - additive = 0; + l_additive = 0; } - else if (!(char_id == area->lastICMessage()[8].toInt())) { - additive = 0; + else if (!(m_char_id == area->lastICMessage()[8].toInt())) { + l_additive = 0; } - else if (additive == 1) { - args[4].insert(0, " "); + else if (l_additive == 1) { + l_args[4].insert(0, " "); } - args.append(QString::number(additive)); + l_args.append(QString::number(l_additive)); // effect - args.append(incoming_args[25].toString()); + l_args.append(l_incoming_args[25].toString()); } //Testimony playback if (area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING || area->testimonyRecording() == AreaData::TestimonyRecording::ADD) { - if (args[5] != "wit") - return AOPacket("MS", args); + if (l_args[5] != "wit") + return AOPacket("MS", l_args); if (area->statement() == -1) { - args[4] = "~~\\n-- " + args[4] + " --"; - args[14] = "3"; - server->broadcast(AOPacket("RT",{"testimony1"}), current_area); + l_args[4] = "~~\\n-- " + l_args[4] + " --"; + l_args[14] = "3"; + server->broadcast(AOPacket("RT",{"testimony1"}), m_current_area); } - addStatement(args); + addStatement(l_args); } else if (area->testimonyRecording() == AreaData::TestimonyRecording::UPDATE) { - args = updateStatement(args); + l_args = updateStatement(l_args); } else if (area->testimonyRecording() == AreaData::TestimonyRecording::PLAYBACK) { AreaData::TestimonyProgress l_progress; - if (args[4] == ">") { - pos = "wit"; + if (l_args[4] == ">") { + m_pos = "wit"; auto l_statement = area->jumpToStatement(area->statement() +1); - args = l_statement.first; + l_args = l_statement.first; l_progress = l_statement.second; if (l_progress == AreaData::TestimonyProgress::LOOPED) { sendServerMessageArea("Last statement reached. Looping to first statement."); } } - if (args[4] == "<") { - pos = "wit"; + if (l_args[4] == "<") { + m_pos = "wit"; auto l_statement = area->jumpToStatement(area->statement() - 1); - args = l_statement.first; + l_args = l_statement.first; l_progress = l_statement.second; if (l_progress == AreaData::TestimonyProgress::STAYED_AT_FIRST) { @@ -903,13 +903,13 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) } } - QString decoded_message = decodeMessage(args[4]); //Get rid of that pesky encoding first. + QString l_decoded_message = decodeMessage(l_args[4]); //Get rid of that pesky encoding first. QRegularExpression jump("(?>)(?[0,1,2,3,4,5,6,7,8,9]+)"); - QRegularExpressionMatch match = jump.match(decoded_message); + QRegularExpressionMatch match = jump.match(l_decoded_message); if (match.hasMatch()) { - pos = "wit"; + m_pos = "wit"; auto l_statement = area->jumpToStatement(match.captured("int").toInt()); - args = l_statement.first; + l_args = l_statement.first; l_progress = l_statement.second; @@ -932,7 +932,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) } } - return AOPacket("MS", args); + return AOPacket("MS", l_args); } QString AOClient::dezalgo(QString p_text) @@ -951,7 +951,7 @@ bool AOClient::checkEvidenceAccess(AreaData *area) case AreaData::EvidenceMod::HIDDEN_CM: return checkAuth(ACLFlags.value("CM")); case AreaData::EvidenceMod::MOD: - return authenticated; + return m_authenticated; default: return false; } @@ -959,13 +959,13 @@ bool AOClient::checkEvidenceAccess(AreaData *area) void AOClient::updateJudgeLog(AreaData* area, AOClient* client, QString action) { - QString timestamp = QTime::currentTime().toString("hh:mm:ss"); - QString uid = QString::number(client->id); - QString char_name = client->current_char; - QString ipid = client->getIpid(); - QString message = action; - QString logmessage = QString("[%1]: [%2] %3 (%4) %5").arg(timestamp, uid, char_name, ipid, message); - area->appendJudgelog(logmessage); + QString l_timestamp = QTime::currentTime().toString("hh:mm:ss"); + QString l_uid = QString::number(client->m_id); + QString l_char_name = client->m_current_char; + QString l_ipid = client->getIpid(); + QString l_message = action; + QString l_logmessage = QString("[%1]: [%2] %3 (%4) %5").arg(l_timestamp, l_uid, l_char_name, l_ipid, l_message); + area->appendJudgelog(l_logmessage); } QString AOClient::decodeMessage(QString incoming_message) @@ -984,29 +984,30 @@ void AOClient::loginAttempt(QString message) if (message == ConfigManager::modpass()) { sendPacket("AUTH", {"1"}); // Client: "You were granted the Disable Modcalls button." sendServerMessage("Logged in as a moderator."); // pre-2.9.1 clients are hardcoded to display the mod UI when this string is sent in OOC - authenticated = true; + m_authenticated = true; } else { sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful." sendServerMessage("Incorrect password."); } - emit logLogin((current_char + " " + showname),ooc_name,"Moderator", ipid, server->m_areas.value(current_area)->name(),authenticated); + emit logLogin((m_current_char + " " + m_showname), m_ooc_name,"Moderator", + m_ipid, server->m_areas.value(m_current_area)->name(), m_authenticated); break; case DataTypes::AuthType::ADVANCED: - QStringList login = message.split(" "); - if (login.size() < 2) { + QStringList l_login = message.split(" "); + if (l_login.size() < 2) { sendServerMessage("You must specify a username and a password"); sendServerMessage("Exiting login prompt."); - is_logging_in = false; + m_is_logging_in = false; return; } - QString username = login[0]; - QString password = login[1]; + QString username = l_login[0]; + QString password = l_login[1]; if (server->db_manager->authenticate(username, password)) { - moderator_name = username; - authenticated = true; + m_moderator_name = username; + m_authenticated = true; sendPacket("AUTH", {"1"}); // Client: "You were granted the Disable Modcalls button." - if (version.release <= 2 && version.major <= 9 && version.minor <= 0) + if (m_version.release <= 2 && m_version.major <= 9 && m_version.minor <= 0) sendServerMessage("Logged in as a moderator."); // pre-2.9.1 clients are hardcoded to display the mod UI when this string is sent in OOC sendServerMessage("Welcome, " + username); } @@ -1014,11 +1015,12 @@ void AOClient::loginAttempt(QString message) sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful." sendServerMessage("Incorrect password."); } - emit logLogin((current_char + " " + showname),ooc_name, username, ipid, server->m_areas.value(current_area)->name(),authenticated); + emit logLogin((m_current_char + " " + m_showname), m_ooc_name, username, m_ipid, + server->m_areas.value(m_current_area)->name(), m_authenticated); break; } sendServerMessage("Exiting login prompt."); - is_logging_in = false; + m_is_logging_in = false; return; } diff --git a/core/src/server.cpp b/core/src/server.cpp index 41a9568..e9f0ab4 100644 --- a/core/src/server.cpp +++ b/core/src/server.cpp @@ -104,7 +104,7 @@ void Server::clientConnected() int user_id; QList user_ids; for (AOClient* client : qAsConst(m_clients)) { - user_ids.append(client->id); + user_ids.append(client->m_id); } for (user_id = 0; user_id <= m_player_count; user_id++) { if (user_ids.contains(user_id)) @@ -120,11 +120,11 @@ void Server::clientConnected() auto ban = db_manager->isIPBanned(client->getIpid()); bool is_banned = ban.first; for (AOClient* joined_client : qAsConst(m_clients)) { - if (client->remote_ip.isEqual(joined_client->remote_ip)) + if (client->m_remote_ip.isEqual(joined_client->m_remote_ip)) multiclient_count++; } - if (multiclient_count > ConfigManager::multiClientLimit() && !client->remote_ip.isLoopback()) // TODO: make this configurable + if (multiclient_count > ConfigManager::multiClientLimit() && !client->m_remote_ip.isLoopback()) // TODO: make this configurable is_at_multiclient_limit = true; if (is_banned) { @@ -170,8 +170,8 @@ void Server::updateCharsTaken(AreaData* area) AOPacket response_cc("CharsCheck", chars_taken); for (AOClient* client : qAsConst(m_clients)) { - if (client->current_area == area->index()){ - if (!client->is_charcursed) + if (client->m_current_area == area->index()){ + if (!client->m_is_charcursed) client->sendPacket(response_cc); else { QStringList chars_taken_cursed = getCursedCharsTaken(client, chars_taken); @@ -186,7 +186,7 @@ QStringList Server::getCursedCharsTaken(AOClient* client, QStringList chars_take { QStringList chars_taken_cursed; for (int i = 0; i < chars_taken.length(); i++) { - if (!client->charcurse_list.contains(i)) + if (!client->m_charcurse_list.contains(i)) chars_taken_cursed.append("-1"); else chars_taken_cursed.append(chars_taken.value(i)); @@ -197,7 +197,7 @@ QStringList Server::getCursedCharsTaken(AOClient* client, QStringList chars_take void Server::broadcast(AOPacket packet, int area_index) { for (AOClient* client : qAsConst(m_clients)) { - if (client->current_area == area_index) + if (client->m_current_area == area_index) client->sendPacket(packet); } } @@ -222,7 +222,7 @@ QList Server::getClientsByIpid(QString ipid) AOClient* Server::getClientByID(int id) { for (AOClient* client : qAsConst(m_clients)) { - if (client->id == id) + if (client->m_id == id) return client; } return nullptr; diff --git a/core/src/testimony_recorder.cpp b/core/src/testimony_recorder.cpp index c460f07..c626b67 100644 --- a/core/src/testimony_recorder.cpp +++ b/core/src/testimony_recorder.cpp @@ -22,7 +22,7 @@ void AOClient::addStatement(QStringList packet) if (checkTestimonySymbols(packet[4])) { return; } - AreaData* area = server->m_areas[current_area]; + AreaData* area = server->m_areas[m_current_area]; int c_statement = area->statement(); if (c_statement >= -1) { if (area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING) { @@ -55,7 +55,7 @@ QStringList AOClient::updateStatement(QStringList packet) if (checkTestimonySymbols(packet[4])) { return packet; } - AreaData* area = server->m_areas[current_area]; + AreaData* area = server->m_areas[m_current_area]; int c_statement = area->statement(); area->setTestimonyRecording(AreaData::TestimonyRecording::PLAYBACK); if (c_statement <= 0 || area->testimony()[c_statement].empty()) @@ -71,7 +71,7 @@ QStringList AOClient::updateStatement(QStringList packet) void AOClient::clearTestimony() { - AreaData* area = server->m_areas[current_area]; + AreaData* area = server->m_areas[m_current_area]; area->clearTestimony(); }