Rename AOClient member variables

Cleanup a lot of of the variables naming inside area.cpp
This commit is contained in:
Salanto 2021-09-11 17:33:46 +02:00
parent b22a83658a
commit 318d12eb7d
2 changed files with 128 additions and 130 deletions

View File

@ -34,8 +34,6 @@
#include <QRandomGenerator> #include <QRandomGenerator>
#endif #endif
class Server;
/** /**
* @brief Represents a client connected to the server running Attorney Online 2 or one of its derivatives. * @brief Represents a client connected to the server running Attorney Online 2 or one of its derivatives.
*/ */
@ -51,12 +49,12 @@ class AOClient : public QObject {
* @param parent Qt-based parent, passed along to inherited constructor from QObject. * @param parent Qt-based parent, passed along to inherited constructor from QObject.
*/ */
AOClient(Server* p_server, QTcpSocket* p_socket, QObject* parent = nullptr, int user_id = 0) AOClient(Server* p_server, QTcpSocket* p_socket, QObject* parent = nullptr, int user_id = 0)
: QObject(parent), id(user_id), remote_ip(p_socket->peerAddress()), password(""), : QObject(parent), m_id(user_id), m_remote_ip(p_socket->peerAddress()), m_password(""),
joined(false), current_area(0), current_char(""), socket(p_socket), server(p_server), 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), last_wtce_time(0) {
afk_timer = new QTimer; m_afk_timer = new QTimer;
afk_timer->setSingleShot(true); m_afk_timer->setSingleShot(true);
connect(afk_timer, SIGNAL(timeout()), this, SLOT(onAfkTimeout())); connect(m_afk_timer, SIGNAL(timeout()), this, SLOT(onAfkTimeout()));
}; };
/** /**
@ -103,17 +101,17 @@ class AOClient : public QObject {
/** /**
* @brief The user ID of the client. * @brief The user ID of the client.
*/ */
int id; int m_id;
/** /**
* @brief The IP address of the client. * @brief The IP address of the client.
*/ */
QHostAddress remote_ip; QHostAddress m_remote_ip;
/** /**
* @brief The stored character password for the client, used to be able to select passworded characters. * @brief The stored character password for the client, used to be able to select passworded characters.
*/ */
QString password; QString m_password;
/** /**
* @brief True if the client is actually in the server. * @brief True if the client is actually in the server.
@ -124,78 +122,78 @@ class AOClient : public QObject {
* The purpose of this variable is to determine if the user isn't just doing that, but has actually double-clicked the server, and * The purpose of this variable is to determine if the user isn't just doing that, but has actually double-clicked the server, and
* its client has sent the standard handshake packets, which does signify that the client intended to 'join' this server. * its client has sent the standard handshake packets, which does signify that the client intended to 'join' this server.
*/ */
bool joined; bool m_joined;
/** /**
* @brief The ID of the area the client is currently in. * @brief The ID of the area the client is currently in.
*/ */
int current_area; int m_current_area;
/** /**
* @brief The internal name of the character the client is currently using. * @brief The internal name of the character the client is currently using.
*/ */
QString current_char; QString m_current_char;
/** /**
* @brief The internal name of the character the client is iniswapped to. * @brief The internal name of the character the client is iniswapped to.
* *
* @note This will be the same as current_char if the client is not iniswapped. * @note This will be the same as current_char if the client is not iniswapped.
*/ */
QString current_iniswap; QString m_current_iniswap;
/** /**
* @brief If true, the client is a logged-in moderator. * @brief If true, the client is a logged-in moderator.
*/ */
bool authenticated = false; bool m_authenticated = false;
/** /**
* @brief If using advanced authentication, this is the moderator name that the client has logged in with. * @brief If using advanced authentication, this is the moderator name that the client has logged in with.
*/ */
QString moderator_name = ""; QString m_moderator_name = "";
/** /**
* @brief The out-of-character name of the client, generally the nickname of the user themself. * @brief The out-of-character name of the client, generally the nickname of the user themself.
*/ */
QString ooc_name = ""; QString m_ooc_name = "";
/** /**
* @brief The custom showname of the client, used when "renaming" already existing characters in-character. * @brief The custom showname of the client, used when "renaming" already existing characters in-character.
*/ */
QString showname = ""; QString m_showname = "";
/** /**
* @brief If true, the client is willing to receive global messages. * @brief If true, the client is willing to receive global messages.
* *
* @see AOClient::cmdG and AOClient::cmdToggleGlobal * @see AOClient::cmdG and AOClient::cmdToggleGlobal
*/ */
bool global_enabled = true; bool m_global_enabled = true;
/** /**
* @brief If true, the client's messages will be sent in first-person mode. * @brief If true, the client's messages will be sent in first-person mode.
* *
* @see AOClient::cmdFirstPerson * @see AOClient::cmdFirstPerson
*/ */
bool first_person = false; bool m_first_person = false;
/** /**
* @brief If true, the client may not use in-character chat. * @brief If true, the client may not use in-character chat.
*/ */
bool is_muted = false; bool m_is_muted = false;
/** /**
* @brief If true, the client may not use out-of-character chat. * @brief If true, the client may not use out-of-character chat.
*/ */
bool is_ooc_muted = false; bool m_is_ooc_muted = false;
/** /**
* @brief If true, the client may not use the music list. * @brief If true, the client may not use the music list.
*/ */
bool is_dj_blocked = false; bool m_is_dj_blocked = false;
/** /**
* @brief If true, the client may not use the judge controls. * @brief If true, the client may not use the judge controls.
*/ */
bool is_wtce_blocked = false; bool m_is_wtce_blocked = false;
/** /**
* @brief Represents the client's client software, and its version. * @brief Represents the client's client software, and its version.
@ -215,7 +213,7 @@ class AOClient : public QObject {
* *
* @see The struct itself for more details. * @see The struct itself for more details.
*/ */
ClientVersion version; ClientVersion m_version;
/** /**
* @brief The authorisation bitflag, representing what permissions a client can have. * @brief The authorisation bitflag, representing what permissions a client can have.
@ -248,63 +246,63 @@ class AOClient : public QObject {
/** /**
* @brief A list of 5 casing preferences (def, pro, judge, jury, steno) * @brief A list of 5 casing preferences (def, pro, judge, jury, steno)
*/ */
QList<bool> casing_preferences = {false, false, false, false, false}; QList<bool> m_casing_preferences = {false, false, false, false, false};
/** /**
* @brief If true, the client's in-character messages will have their word order randomised. * @brief If true, the client's in-character messages will have their word order randomised.
*/ */
bool is_shaken = false; bool m_is_shaken = false;
/** /**
* @brief If true, the client's in-character messages will have their vowels (English alphabet only) removed. * @brief If true, the client's in-character messages will have their vowels (English alphabet only) removed.
*/ */
bool is_disemvoweled = false; bool m_is_disemvoweled = false;
/** /**
* @brief If true, the client's in-character messages will be overwritten by a randomly picked predetermined message. * @brief If true, the client's in-character messages will be overwritten by a randomly picked predetermined message.
*/ */
bool is_gimped = false; bool m_is_gimped = false;
/** /**
* @brief If true, the client will be marked as AFK in /getarea. Automatically applied when a configurable * @brief If true, the client will be marked as AFK in /getarea. Automatically applied when a configurable
* amount of time has passed since the last interaction, or manually applied by /afk. * amount of time has passed since the last interaction, or manually applied by /afk.
*/ */
bool is_afk = false; bool m_is_afk = false;
/** /**
* @brief If true, the client will not recieve PM messages. * @brief If true, the client will not recieve PM messages.
*/ */
bool pm_mute = false; bool m_pm_mute = false;
/** /**
* @brief If true, the client will recieve advertisements. * @brief If true, the client will recieve advertisements.
*/ */
bool advert_enabled = true; bool m_advert_enabled = true;
/** /**
* @brief If true, the client is restricted to only changing into certain characters. * @brief If true, the client is restricted to only changing into certain characters.
*/ */
bool is_charcursed = false; bool m_is_charcursed = false;
/** /**
* @brief Timer for tracking user interaction. Automatically restarted whenever a user interacts (i.e. sends any packet besides CH) * @brief Timer for tracking user interaction. Automatically restarted whenever a user interacts (i.e. sends any packet besides CH)
*/ */
QTimer* afk_timer; QTimer* m_afk_timer;
/** /**
* @brief The list of char IDs a charcursed player is allowed to switch to. * @brief The list of char IDs a charcursed player is allowed to switch to.
*/ */
QList<int> charcurse_list; QList<int> m_charcurse_list;
/** /**
* @brief Temporary client permission if client is allowed to save a testimony to server storage. * @brief Temporary client permission if client is allowed to save a testimony to server storage.
*/ */
bool testimony_saving = false; bool m_testimony_saving = false;
/** /**
* @brief If true, the client's next OOC message will be interpreted as a moderator login. * @brief If true, the client's next OOC message will be interpreted as a moderator login.
*/ */
bool is_logging_in = false; bool m_is_logging_in = false;
public slots: public slots:
/** /**
@ -343,7 +341,7 @@ class AOClient : public QObject {
/** /**
* @brief The TCP socket used to communicate with the client. * @brief The TCP socket used to communicate with the client.
*/ */
QTcpSocket* socket; QTcpSocket* m_socket;
/** /**
* @brief A pointer to the Server, used for updating server variables that depend on the client (e.g. amount of players in an area). * @brief A pointer to the Server, used for updating server variables that depend on the client (e.g. amount of players in an area).
@ -609,7 +607,7 @@ class AOClient : public QObject {
* *
* In general, the client assumes that this is a continuous block starting from 0. * In general, the client assumes that this is a continuous block starting from 0.
*/ */
int char_id = -1; int m_char_id = -1;
/** /**
* @brief The character ID of the other character that the client wants to pair up with. * @brief The character ID of the other character that the client wants to pair up with.
@ -618,7 +616,7 @@ class AOClient : public QObject {
* Furthermore, the owner of that character ID must also do the reverse to this client, making their `pairing_with` equal * Furthermore, the owner of that character ID must also do the reverse to this client, making their `pairing_with` equal
* to this client's character ID. * to this client's character ID.
*/ */
int pairing_with = -1; int m_pairing_with = -1;
/** /**
* @brief The name of the emote last used by the client. No extension. * @brief The name of the emote last used by the client. No extension.
@ -626,7 +624,7 @@ class AOClient : public QObject {
* @details This is used for pairing mainly, for the server to be able to craft a smooth-looking transition from one * @details This is used for pairing mainly, for the server to be able to craft a smooth-looking transition from one
* paired-up client talking to the next. * paired-up client talking to the next.
*/ */
QString emote = ""; QString m_emote = "";
/** /**
* @brief The amount the client was last offset by. * @brief The amount the client was last offset by.
@ -634,17 +632,17 @@ class AOClient : public QObject {
* @details This used to be just a plain number ranging from -100 to 100, but then Crystal mangled it by building some extra data into it. * @details This used to be just a plain number ranging from -100 to 100, but then Crystal mangled it by building some extra data into it.
* Cheers, love. * Cheers, love.
*/ */
QString offset = ""; QString m_offset = "";
/** /**
* @brief The last flipped state of the client. * @brief The last flipped state of the client.
*/ */
QString flipping = ""; QString m_flipping = "";
/** /**
* @brief The last reported position of the client. * @brief The last reported position of the client.
*/ */
QString pos = ""; QString m_pos = "";
///@} ///@}

View File

@ -23,33 +23,33 @@
void AOClient::cmdCM(int argc, QStringList argv) void AOClient::cmdCM(int argc, QStringList argv)
{ {
QString sender_name = ooc_name; QString l_sender_name = m_ooc_name;
AreaData* area = server->m_areas[current_area]; AreaData* l_area = server->m_areas[m_current_area];
if (area->isProtected()) { if (l_area->isProtected()) {
sendServerMessage("This area is protected, you may not become CM."); sendServerMessage("This area is protected, you may not become CM.");
return; return;
} }
else if (area->owners().isEmpty()) { // no one owns this area, and it's not protected else if (l_area->owners().isEmpty()) { // no one owns this area, and it's not protected
area->addOwner(id); l_area->addOwner(m_id);
sendServerMessageArea(sender_name + " is now CM in this area."); sendServerMessageArea(l_sender_name + " is now CM in this area.");
arup(ARUPType::CM, true); arup(ARUPType::CM, true);
} }
else if (!area->owners().contains(id)) { // there is already a CM, and it isn't us else if (!l_area->owners().contains(m_id)) { // there is already a CM, and it isn't us
sendServerMessage("You cannot become a CM in this area."); sendServerMessage("You cannot become a CM in this area.");
} }
else if (argc == 1) { // we are CM, and we want to make ID argv[0] also CM else if (argc == 1) { // we are CM, and we want to make ID argv[0] also CM
bool ok; bool ok;
AOClient* owner_candidate = server->getClientByID(argv[0].toInt(&ok)); AOClient* l_owner_candidate = server->getClientByID(argv[0].toInt(&ok));
if (!ok) { if (!ok) {
sendServerMessage("That doesn't look like a valid ID."); sendServerMessage("That doesn't look like a valid ID.");
return; return;
} }
if (owner_candidate == nullptr) { if (l_owner_candidate == nullptr) {
sendServerMessage("Unable to find client with ID " + argv[0] + "."); sendServerMessage("Unable to find client with ID " + argv[0] + ".");
return; return;
} }
area->addOwner(owner_candidate->id); l_area->addOwner(l_owner_candidate->m_id);
sendServerMessageArea(owner_candidate->ooc_name + " is now CM in this area."); sendServerMessageArea(l_owner_candidate->m_ooc_name + " is now CM in this area.");
arup(ARUPType::CM, true); arup(ARUPType::CM, true);
} }
else { else {
@ -59,41 +59,41 @@ void AOClient::cmdCM(int argc, QStringList argv)
void AOClient::cmdUnCM(int argc, QStringList argv) void AOClient::cmdUnCM(int argc, QStringList argv)
{ {
AreaData* area = server->m_areas[current_area]; AreaData* l_area = server->m_areas[m_current_area];
int uid; int l_uid;
if (area->owners().isEmpty()) { if (l_area->owners().isEmpty()) {
sendServerMessage("There are no CMs in this area."); sendServerMessage("There are no CMs in this area.");
return; return;
} }
else if (argc == 0) { else if (argc == 0) {
uid = id; l_uid = m_id;
sendServerMessage("You are no longer CM in this area."); sendServerMessage("You are no longer CM in this area.");
} }
else if (checkAuth(ACLFlags.value("UNCM")) && argc == 1) { else if (checkAuth(ACLFlags.value("UNCM")) && argc == 1) {
bool conv_ok = false; bool conv_ok = false;
uid = argv[0].toInt(&conv_ok); l_uid = argv[0].toInt(&conv_ok);
if (!conv_ok) { if (!conv_ok) {
sendServerMessage("Invalid user ID."); sendServerMessage("Invalid user ID.");
return; return;
} }
if (!area->owners().contains(uid)) { if (!l_area->owners().contains(l_uid)) {
sendServerMessage("That user is not CMed."); sendServerMessage("That user is not CMed.");
return; 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."); sendServerMessage("No client with that ID found.");
return; return;
} }
target->sendServerMessage("You have been unCMed by a moderator."); l_target->sendServerMessage("You have been unCMed by a moderator.");
} }
else { else {
sendServerMessage("Invalid command."); sendServerMessage("Invalid command.");
return; return;
} }
if (area->removeOwner(uid)) { if (l_area->removeOwner(l_uid)) {
arup(ARUPType::LOCKED, true); arup(ARUPType::LOCKED, true);
} }
@ -104,54 +104,54 @@ void AOClient::cmdInvite(int argc, QStringList argv)
{ {
Q_UNUSED(argc); Q_UNUSED(argc);
AreaData* area = server->m_areas[current_area]; AreaData* l_area = server->m_areas[m_current_area];
bool ok; bool ok;
int invited_id = argv[0].toInt(&ok); int l_invited_id = argv[0].toInt(&ok);
if (!ok) { if (!ok) {
sendServerMessage("That does not look like a valid ID."); sendServerMessage("That does not look like a valid ID.");
return; return;
} }
AOClient* target_client = server->getClientByID(invited_id); AOClient* target_client = server->getClientByID(l_invited_id);
if (target_client == nullptr) { if (target_client == nullptr) {
sendServerMessage("No client with that ID found."); sendServerMessage("No client with that ID found.");
return; return;
} }
else if (!area->invite(invited_id)) { else if (!l_area->invite(l_invited_id)) {
sendServerMessage("That ID is already on the invite list."); sendServerMessage("That ID is already on the invite list.");
return; return;
} }
sendServerMessage("You invited ID " + argv[0]); sendServerMessage("You invited ID " + argv[0]);
target_client->sendServerMessage("You were invited and given access to " + area->name()); target_client->sendServerMessage("You were invited and given access to " + l_area->name());
} }
void AOClient::cmdUnInvite(int argc, QStringList argv) void AOClient::cmdUnInvite(int argc, QStringList argv)
{ {
Q_UNUSED(argc); Q_UNUSED(argc);
AreaData* area = server->m_areas[current_area]; AreaData* l_area = server->m_areas[m_current_area];
bool ok; bool ok;
int uninvited_id = argv[0].toInt(&ok); int l_uninvited_id = argv[0].toInt(&ok);
if (!ok) { if (!ok) {
sendServerMessage("That does not look like a valid ID."); sendServerMessage("That does not look like a valid ID.");
return; return;
} }
AOClient* target_client = server->getClientByID(uninvited_id); AOClient* target_client = server->getClientByID(l_uninvited_id);
if (target_client == nullptr) { if (target_client == nullptr) {
sendServerMessage("No client with that ID found."); sendServerMessage("No client with that ID found.");
return; return;
} }
else if (area->owners().contains(uninvited_id)) { else if (l_area->owners().contains(l_uninvited_id)) {
sendServerMessage("You cannot uninvite a CM!"); sendServerMessage("You cannot uninvite a CM!");
return; return;
} }
else if (!area->uninvite(uninvited_id)) { else if (!l_area->uninvite(l_uninvited_id)) {
sendServerMessage("That ID is not on the invite list."); sendServerMessage("That ID is not on the invite list.");
return; return;
} }
sendServerMessage("You uninvited ID " + argv[0]); sendServerMessage("You uninvited ID " + argv[0]);
target_client->sendServerMessage("You were uninvited from " + area->name()); target_client->sendServerMessage("You were uninvited from " + l_area->name());
} }
void AOClient::cmdLock(int argc, QStringList argv) void AOClient::cmdLock(int argc, QStringList argv)
@ -159,7 +159,7 @@ void AOClient::cmdLock(int argc, QStringList argv)
Q_UNUSED(argc); Q_UNUSED(argc);
Q_UNUSED(argv); Q_UNUSED(argv);
AreaData* area = server->m_areas[current_area]; AreaData* area = server->m_areas[m_current_area];
if (area->lockStatus() == AreaData::LockStatus::LOCKED) { if (area->lockStatus() == AreaData::LockStatus::LOCKED) {
sendServerMessage("This area is already locked."); sendServerMessage("This area is already locked.");
return; return;
@ -167,8 +167,8 @@ void AOClient::cmdLock(int argc, QStringList argv)
sendServerMessageArea("This area is now locked."); sendServerMessageArea("This area is now locked.");
area->lock(); area->lock();
for (AOClient* client : qAsConst(server->m_clients)) { // qAsConst here avoids detaching the container for (AOClient* client : qAsConst(server->m_clients)) { // qAsConst here avoids detaching the container
if (client->current_area == current_area && client->joined) { if (client->m_current_area == m_current_area && client->m_joined) {
area->invite(client->id); area->invite(client->m_id);
} }
} }
arup(ARUPType::LOCKED, true); arup(ARUPType::LOCKED, true);
@ -179,16 +179,16 @@ void AOClient::cmdSpectatable(int argc, QStringList argv)
Q_UNUSED(argc); Q_UNUSED(argc);
Q_UNUSED(argv); Q_UNUSED(argv);
AreaData* area = server->m_areas[current_area]; AreaData* l_area = server->m_areas[m_current_area];
if (area->lockStatus() == AreaData::LockStatus::SPECTATABLE) { if (l_area->lockStatus() == AreaData::LockStatus::SPECTATABLE) {
sendServerMessage("This area is already in spectate mode."); sendServerMessage("This area is already in spectate mode.");
return; return;
} }
sendServerMessageArea("This area is now spectatable."); sendServerMessageArea("This area is now spectatable.");
area->spectatable(); l_area->spectatable();
for (AOClient* client : qAsConst(server->m_clients)) { for (AOClient* client : qAsConst(server->m_clients)) {
if (client->current_area == current_area && client->joined) { if (client->m_current_area == m_current_area && client->m_joined) {
area->invite(client->id); l_area->invite(client->m_id);
} }
} }
arup(ARUPType::LOCKED, true); arup(ARUPType::LOCKED, true);
@ -199,13 +199,13 @@ void AOClient::cmdUnLock(int argc, QStringList argv)
Q_UNUSED(argc); Q_UNUSED(argc);
Q_UNUSED(argv); Q_UNUSED(argv);
AreaData* area = server->m_areas[current_area]; AreaData* l_area = server->m_areas[m_current_area];
if (area->lockStatus() == AreaData::LockStatus::FREE) { if (l_area->lockStatus() == AreaData::LockStatus::FREE) {
sendServerMessage("This area is not locked."); sendServerMessage("This area is not locked.");
return; return;
} }
sendServerMessageArea("This area is now unlocked."); sendServerMessageArea("This area is now unlocked.");
area->unlock(); l_area->unlock();
arup(ARUPType::LOCKED, true); arup(ARUPType::LOCKED, true);
} }
@ -214,13 +214,13 @@ void AOClient::cmdGetAreas(int argc, QStringList argv)
Q_UNUSED(argc); Q_UNUSED(argc);
Q_UNUSED(argv); Q_UNUSED(argv);
QStringList entries; QStringList l_entries;
entries.append("== Area List =="); l_entries.append("== Area List ==");
for (int i = 0; i < server->m_area_names.length(); i++) { for (int i = 0; i < server->m_area_names.length(); i++) {
QStringList cur_area_lines = buildAreaList(i); QStringList l_cur_area_lines = buildAreaList(i);
entries.append(cur_area_lines); l_entries.append(l_cur_area_lines);
} }
sendServerMessage(entries.join("\n")); sendServerMessage(l_entries.join("\n"));
} }
void AOClient::cmdGetArea(int argc, QStringList argv) void AOClient::cmdGetArea(int argc, QStringList argv)
@ -228,8 +228,8 @@ void AOClient::cmdGetArea(int argc, QStringList argv)
Q_UNUSED(argc); Q_UNUSED(argc);
Q_UNUSED(argv); Q_UNUSED(argv);
QStringList entries = buildAreaList(current_area); QStringList l_entries = buildAreaList(m_current_area);
sendServerMessage(entries.join("\n")); sendServerMessage(l_entries.join("\n"));
} }
void AOClient::cmdArea(int argc, QStringList argv) void AOClient::cmdArea(int argc, QStringList argv)
@ -237,41 +237,41 @@ void AOClient::cmdArea(int argc, QStringList argv)
Q_UNUSED(argc); Q_UNUSED(argc);
bool ok; bool ok;
int new_area = argv[0].toInt(&ok); int l_new_area = argv[0].toInt(&ok);
if (!ok || new_area >= server->m_areas.size() || new_area < 0) { if (!ok || l_new_area >= server->m_areas.size() || l_new_area < 0) {
sendServerMessage("That does not look like a valid area ID."); sendServerMessage("That does not look like a valid area ID.");
return; return;
} }
changeArea(new_area); changeArea(l_new_area);
} }
void AOClient::cmdAreaKick(int argc, QStringList argv) void AOClient::cmdAreaKick(int argc, QStringList argv)
{ {
Q_UNUSED(argc); Q_UNUSED(argc);
AreaData* area = server->m_areas[current_area]; AreaData* l_area = server->m_areas[m_current_area];
bool ok; bool ok;
int idx = argv[0].toInt(&ok); int l_idx = argv[0].toInt(&ok);
if (!ok) { if (!ok) {
sendServerMessage("That does not look like a valid ID."); sendServerMessage("That does not look like a valid ID.");
return; return;
} }
if (server->m_areas[current_area]->owners().contains(idx)) { if (server->m_areas[m_current_area]->owners().contains(l_idx)) {
sendServerMessage("You cannot kick another CM!"); sendServerMessage("You cannot kick another CM!");
return; return;
} }
AOClient* client_to_kick = server->getClientByID(idx); AOClient* l_client_to_kick = server->getClientByID(l_idx);
if (client_to_kick == nullptr) { if (l_client_to_kick == nullptr) {
sendServerMessage("No client with that ID found."); sendServerMessage("No client with that ID found.");
return; return;
} }
else if (client_to_kick->current_area != current_area) { else if (l_client_to_kick->m_current_area != m_current_area) {
sendServerMessage("That client is not in this area."); sendServerMessage("That client is not in this area.");
return; return;
} }
client_to_kick->changeArea(0); l_client_to_kick->changeArea(0);
area->uninvite(client_to_kick->id); l_area->uninvite(l_client_to_kick->m_id);
sendServerMessage("Client " + argv[0] + " kicked back to area 0."); sendServerMessage("Client " + argv[0] + " kicked back to area 0.");
} }
@ -281,12 +281,12 @@ void AOClient::cmdSetBackground(int argc, QStringList argv)
Q_UNUSED(argc); Q_UNUSED(argc);
QString f_background = argv.join(" "); QString f_background = argv.join(" ");
AreaData* area = server->m_areas[current_area]; AreaData* area = server->m_areas[m_current_area];
if (authenticated || !area->bgLocked()) { if (m_authenticated || !area->bgLocked()) {
if (server->m_backgrounds.contains(f_background, Qt::CaseInsensitive) || area->ignoreBgList() == true) { if (server->m_backgrounds.contains(f_background, Qt::CaseInsensitive) || area->ignoreBgList() == true) {
area->setBackground(f_background); area->setBackground(f_background);
server->broadcast(AOPacket("BN", {f_background}), current_area); server->broadcast(AOPacket("BN", {f_background}), m_current_area);
sendServerMessageArea(current_char + " changed the background to " + f_background); sendServerMessageArea(m_current_char + " changed the background to " + f_background);
} }
else { else {
sendServerMessage("Invalid background name."); sendServerMessage("Invalid background name.");
@ -302,13 +302,13 @@ void AOClient::cmdBgLock(int argc, QStringList argv)
Q_UNUSED(argc); Q_UNUSED(argc);
Q_UNUSED(argv); Q_UNUSED(argv);
AreaData* area = server->m_areas[current_area]; AreaData* l_area = server->m_areas[m_current_area];
if (area->bgLocked() == false) { if (l_area->bgLocked() == false) {
area->toggleBgLock(); l_area->toggleBgLock();
}; };
server->broadcast(AOPacket("CT", {ConfigManager::serverName(), current_char + " locked the background.", "1"}), current_area); server->broadcast(AOPacket("CT", {ConfigManager::serverName(), m_current_char + " locked the background.", "1"}), m_current_area);
} }
void AOClient::cmdBgUnlock(int argc, QStringList argv) void AOClient::cmdBgUnlock(int argc, QStringList argv)
@ -316,25 +316,25 @@ void AOClient::cmdBgUnlock(int argc, QStringList argv)
Q_UNUSED(argc); Q_UNUSED(argc);
Q_UNUSED(argv); Q_UNUSED(argv);
AreaData* area = server->m_areas[current_area]; AreaData* l_area = server->m_areas[m_current_area];
if (area->bgLocked() == true) { if (l_area->bgLocked() == true) {
area->toggleBgLock(); l_area->toggleBgLock();
}; };
server->broadcast(AOPacket("CT", {ConfigManager::serverName(), current_char + " unlocked the background.", "1"}), current_area); server->broadcast(AOPacket("CT", {ConfigManager::serverName(), m_current_char + " unlocked the background.", "1"}), m_current_area);
} }
void AOClient::cmdStatus(int argc, QStringList argv) void AOClient::cmdStatus(int argc, QStringList argv)
{ {
Q_UNUSED(argc); Q_UNUSED(argc);
AreaData* area = server->m_areas[current_area]; AreaData* l_area = server->m_areas[m_current_area];
QString arg = argv[0].toLower(); QString l_arg = argv[0].toLower();
if (area->changeStatus(arg)) { if (l_area->changeStatus(l_arg)) {
arup(ARUPType::STATUS, true); arup(ARUPType::STATUS, true);
server->broadcast(AOPacket("CT", {ConfigManager::serverName(), current_char + " changed status to " + arg.toUpper(), "1"}), current_area); server->broadcast(AOPacket("CT", {ConfigManager::serverName(), m_current_char + " changed status to " + l_arg.toUpper(), "1"}), m_current_area);
} else { } else {
const QStringList keys = AreaData::map_statuses.keys(); const QStringList keys = AreaData::map_statuses.keys();
sendServerMessage("That does not look like a valid status. Valid statuses are " + keys.join(", ")); sendServerMessage("That does not look like a valid status. Valid statuses are " + keys.join(", "));
@ -346,18 +346,18 @@ void AOClient::cmdJudgeLog(int argc, QStringList argv)
Q_UNUSED(argc); Q_UNUSED(argc);
Q_UNUSED(argv); Q_UNUSED(argv);
AreaData* area = server->m_areas[current_area]; AreaData* l_area = server->m_areas[m_current_area];
if (area->judgelog().isEmpty()) { if (l_area->judgelog().isEmpty()) {
sendServerMessage("There have been no judge actions in this area."); sendServerMessage("There have been no judge actions in this area.");
return; return;
} }
QString message = area->judgelog().join("\n"); QString l_message = l_area->judgelog().join("\n");
//Judgelog contains an IPID, so we shouldn't send that unless the caller has appropriate permissions //Judgelog contains an IPID, so we shouldn't send that unless the caller has appropriate permissions
if (checkAuth(ACLFlags.value("KICK")) == 1 || checkAuth(ACLFlags.value("BAN")) == 1) { if (checkAuth(ACLFlags.value("KICK")) == 1 || checkAuth(ACLFlags.value("BAN")) == 1) {
sendServerMessage(message); sendServerMessage(l_message);
} }
else { else {
QString filteredmessage = message.remove(QRegularExpression("[(].*[)]")); //Filter out anything between two parentheses. This should only ever be the IPID QString filteredmessage = l_message.remove(QRegularExpression("[(].*[)]")); //Filter out anything between two parentheses. This should only ever be the IPID
sendServerMessage(filteredmessage); sendServerMessage(filteredmessage);
} }
} }
@ -367,8 +367,8 @@ void AOClient::cmdIgnoreBgList(int argc, QStringList argv)
Q_UNUSED(argc); Q_UNUSED(argc);
Q_UNUSED(argv); Q_UNUSED(argv);
AreaData* area = server->m_areas[current_area]; AreaData* l_area = server->m_areas[m_current_area];
area->toggleIgnoreBgList(); l_area->toggleIgnoreBgList();
QString state = area->ignoreBgList() ? "ignored." : "enforced."; QString l_state = l_area->ignoreBgList() ? "ignored." : "enforced.";
sendServerMessage("BG list in this area is now " + state); sendServerMessage("BG list in this area is now " + l_state);
} }