diff --git a/core/include/area_data.h b/core/include/area_data.h index 8b17e2a..b0cc75a 100644 --- a/core/include/area_data.h +++ b/core/include/area_data.h @@ -53,40 +53,6 @@ class AreaData : public QObject { QString image; //!< A path originating from `base/evidence/` that points to an image file. }; - /** - * @brief The list of timers available in the area. - */ - QList timers; - - /** - * @brief The user-facing and internal name of the area. - */ - QString name; - - /** - * @brief The index of the area in the server's area list. - */ - int index; - - /** - * @brief A list of the character IDs of all characters taken. - */ - QList characters_taken; - - /** - * @brief A list of Evidence currently available in the area's court record. - * - * @details This contains *all* evidence, not just the ones a given side can see. - * - * @see HIDDEN_CM - */ - QList evidence; - - /** - * @brief The amount of clients inside the area. - */ - int player_count; - /** * @brief The status of an area. * @@ -105,25 +71,6 @@ class AreaData : public QObject { /// Exposes the metadata of the Status enum. Q_ENUM(Status); - /** - * @brief The status of the area. - * - * @see Status - */ - Status status; - - /** - * @brief The IDs of all the owners (or Case Makers / CMs) of the area. - */ - QList owners; - - /** - * @brief The list of clients invited to the area. - * - * @see LOCKED and SPECTATABLE for the benefits of being invited. - */ - QList invited; - /** * @brief Determines who may traverse and communicate in the area. */ @@ -157,86 +104,6 @@ class AreaData : public QObject { /// Exposes the metadata of the LockStatus enum. Q_ENUM(LockStatus); - /** - * @brief The status of the area's accessibility to clients. - * - * @see LockStatus - */ - LockStatus locked; - - /** - * @brief The background of the area. - * - * @details Represents a directory's name in `base/background/` clientside. - */ - QString background; - - /** - * @brief If true, nobody may become the CM of this area. - */ - bool is_protected; - - /** - * @brief If true, clients are allowed to put on "shownames", custom names - * in place of their character's normally displayed name. - */ - bool showname_allowed; - - /** - * @brief If true, clients are allowed to use the cursed art of iniswapping in the area. - */ - bool iniswap_allowed; - - /** - * @brief If true, clients are allowed to send empty IC messages - */ - bool blankposting_allowed; - - /** - * @brief If true, the background of the area cannot be changed except by a moderator. - */ - bool bg_locked; - - /** - * @brief The hyperlink to the document of the area. - * - * @details Documents are generally used for cases or roleplays, where they contain the related game's - * rules. #document can also be something like "None" if there is no case or roleplay being run. - */ - QString document; - - /** - * @brief The Confidence Gauge's value for the Defence side. - * - * @details Unit is 10%, and the values range from 0 (= 0%) to 10 (= 100%). - */ - int def_hp; - - /** - * @brief The Confidence Gauge's value for the Prosecutor side. - * - * @copydetails #def_hp - */ - int pro_hp; - - /** - * @brief The title of the music currently being played in the area. - * - * @details Title is a path to the music file, with the starting point on - * `base/sounds/music/` clientside, with file extension. - */ - QString current_music; - - /** - * @brief The name of the client (or client's character) that started the currently playing music. - */ - QString music_played_by; - - /** - * @brief A pointer to a Logger, used to send requests to log data. - */ - Logger* logger; - /** * @brief The level of "authorisation" needed to be able to modify, add, and remove evidence in the area. */ @@ -270,14 +137,6 @@ class AreaData : public QObject { * where `XXX` is either a position, of a list of positions separated by `,`. */ - /** - * @brief The evidence mod of the area. - * - * @see EvidenceMod - */ - EvidenceMod evi_mod; - QMap notecards; - /** * @brief The five "states" the testimony recording system can have in an area. */ @@ -322,38 +181,215 @@ class AreaData : public QObject { /// Exposes the metadata of the TestimonyRecording enum. Q_ENUM(TestimonyRecording); - TestimonyRecording test_rec; + + /** + * @brief A client in the area has left the area. + * + * @details This function counts down the playercount and removes the character from the list of taken characters. + * + * @param f_charId The character ID of the area. + */ + void clientLeftArea(int f_charId); + + QList owners() const; + + void addOwner(int f_clientId); + + /** + * @brief Removes the target client from the list of owners. + * + * @param f_clientId The ID of the client to remove from the owners. + * + * @return True if because of this removal, an ARUP message must be sent out about the locks. + * + * @note This function *does not* imply that the client also left the area, only that they are no longer its owner. + * See clientLeftArea() for that. + */ + bool removeOwner(int f_clientId); + + bool blankpostingAllowed() const; + + bool isProtected() const; + + LockStatus lockStatus() const; + + /** + * @brief invite + * @param f_clientId + * @return True if the client was successfully invited. False if they were already in the list of invited people. + */ + bool invite(int f_clientId); + +private: + /** + * @brief The list of timers available in the area. + */ + QList m_timers; + + /** + * @brief The user-facing and internal name of the area. + */ + QString m_name; + + /** + * @brief The index of the area in the server's area list. + */ + int m_index; + + /** + * @brief A list of the character IDs of all characters taken. + */ + QList m_charactersTaken; + + /** + * @brief A list of Evidence currently available in the area's court record. + * + * @details This contains *all* evidence, not just the ones a given side can see. + * + * @see HIDDEN_CM + */ + QList m_evidence; + + /** + * @brief The amount of clients inside the area. + */ + int m_playerCount; + + /** + * @brief The status of the area. + * + * @see Status + */ + Status m_status; + + /** + * @brief The IDs of all the owners (or Case Makers / CMs) of the area. + */ + QList m_owners; + + /** + * @brief The list of clients invited to the area. + * + * @see LOCKED and SPECTATABLE for the benefits of being invited. + */ + QList m_invited; + + /** + * @brief The status of the area's accessibility to clients. + * + * @see LockStatus + */ + LockStatus m_locked; + + /** + * @brief The background of the area. + * + * @details Represents a directory's name in `base/background/` clientside. + */ + QString m_background; + + /** + * @brief If true, nobody may become the CM of this area. + */ + bool m_isProtected; + + /** + * @brief If true, clients are allowed to put on "shownames", custom names + * in place of their character's normally displayed name. + */ + bool m_shownameAllowed; + + /** + * @brief If true, clients are allowed to use the cursed art of iniswapping in the area. + */ + bool m_iniswapAllowed; + + /** + * @brief If true, clients are allowed to send empty IC messages + */ + bool m_blankpostingAllowed; + + /** + * @brief If true, the background of the area cannot be changed except by a moderator. + */ + bool m_bgLocked; + + /** + * @brief The hyperlink to the document of the area. + * + * @details Documents are generally used for cases or roleplays, where they contain the related game's + * rules. #document can also be something like "None" if there is no case or roleplay being run. + */ + QString m_document; + + /** + * @brief The Confidence Gauge's value for the Defence side. + * + * @details Unit is 10%, and the values range from 0 (= 0%) to 10 (= 100%). + */ + int m_defHP; + + /** + * @brief The Confidence Gauge's value for the Prosecutor side. + * + * @copydetails #def_hp + */ + int m_proHP; + + /** + * @brief The title of the music currently being played in the area. + * + * @details Title is a path to the music file, with the starting point on + * `base/sounds/music/` clientside, with file extension. + */ + QString m_currentMusic; + + /** + * @brief The name of the client (or client's character) that started the currently playing music. + */ + QString m_musicPlayerBy; + + /** + * @brief A pointer to a Logger, used to send requests to log data. + */ + Logger* m_logger; + + /** + * @brief The evidence mod of the area. + * + * @see EvidenceMod + */ + EvidenceMod m_eviMod; + QMap m_notecards; + + TestimonyRecording m_testimonyRecording; - QVector testimony; //!< Vector of all statements saved. Index 0 is always the title of the testimony. - int statement; //!< Keeps track of the currently played statement. + QVector m_testimony; //!< Vector of all statements saved. Index 0 is always the title of the testimony. + int m_statement; //!< Keeps track of the currently played statement. /** * @brief The judgelog of an area. * * @details This list contains up to 10 recorded packets of the most recent judge actions (WT/CE or penalty updates) in an area. */ - QStringList judgelog; + QStringList m_judgelog; /** * @brief The last IC packet sent in an area. */ - QStringList last_ic_message; + QStringList m_lastICMessage; - /** - * @brief The value of logger in config.ini. - */ - QString log_type; /** * @brief Whether or not to force immediate text processing in this area. */ - bool force_immediate; + bool m_forceImmediate; /** * @brief Whether or not music is allowed in this area. If false, only CMs can change the music. */ - bool toggle_music; + bool m_toggleMusic; }; #endif // AREA_DATA_H diff --git a/core/include/logger.h b/core/include/logger.h index e73d77f..933650d 100644 --- a/core/include/logger.h +++ b/core/include/logger.h @@ -18,19 +18,12 @@ #ifndef LOGGER_H #define LOGGER_H -#include "include/aoclient.h" -#include "include/aopacket.h" -#include "include/area_data.h" - #include #include #include #include #include -class AOClient; -class AreaData; - /** * @brief A class associated with an AreaData class to log various events happening inside the latter. */ @@ -40,34 +33,40 @@ public: /** * @brief Constructs a Logger instance. * - * @param p_max_length The maximum amount of entries the Logger can store at once. - * @param p_area The area associated with the Logger from which it should log entries. + * @param f_max_length The maximum amount of entries the Logger can store at once. */ - Logger(int p_max_length, AreaData* p_area) : max_length(p_max_length), area(p_area) {}; + Logger(int f_max_length, const QString& f_logType_r) : m_maxLength(f_max_length), m_logType(f_logType_r) {}; +public slots: /** * @brief Logs an IC message. * - * @param client The client who sent the IC message. - * @param packet The IC packet itself, used to grab the text of the IC message. + * @param f_areaName_r The name of the area where the event happened. + * @param f_charName_r The character name of the client who sent the IC message. + * @param f_ipid_r The IPID of the aforementioned client. + * @param f_message_r The text of the IC message. */ - void logIC(AOClient* client, AOPacket* packet); + void logIC(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, const QString& f_message_r); /** * @brief Logs an OOC message. * - * @param client The client who sent the OOC message. - * @param packet The OOC packet itself, used to grab the text of the OOC message. + * @param f_areaName_r The name of the area where the event happened. + * @param f_charName_r The character name of the client who sent the OOC message. + * @param f_ipid_r The IPID of the aforementioned client. + * @param f_message_r The text of the OOC message. */ - void logOOC(AOClient* client, AOPacket* packet); + void logOOC(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, const QString& f_message_r); /** * @brief Logs a mod call message. * - * @param client The client who sent the mod call. - * @param packet The ZZ packet itself, used to grab the reason field of the modcall. + * @param f_areaName_r The name of the area where the event happened. + * @param f_charName_r The character name of the client who sent the mod call. + * @param f_ipid_r The IPID of the aforementioned client. + * @param f_modcallReason_r The reason for the modcall. */ - void logModcall(AOClient* client, AOPacket* packet); + void logModcall(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, const QString& f_modcallReason_r); /** * @brief Logs a command called in OOC. @@ -75,69 +74,67 @@ public: * @details If the command is not one of any of the 'special' ones, it defaults to logOOC(). * The only thing that makes a command 'special' if it is handled differently in here. * - * @param client The client who sent the command. - * @param packet The OOC packet. Passed to logOOC() if the command is not 'special' (see details). - * @param cmd The command called in the OOC -- this is the first word after the `/` character. - * @param args The arguments interpreted for the command, every word separated by a whitespace. + * @param f_areaName_r The name of the area where the event happened. + * @param f_charName_r The character name of the client who sent the command. + * @param f_ipid_r The IPID of the aforementioned client. + * @param f_oocMessage_r The text of the OOC message. Passed to logOOC() if the command is not 'special' (see details). + * @param f_cmd_r The command called in the OOC -- this is the first word after the `/` character. + * @param f_cmdArgs_r The arguments interpreted for the command, every word separated by a whitespace. */ - void logCmd(AOClient* client, AOPacket* packet, QString cmd, QStringList args); + void logCmd(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, + const QString& f_oocMessage_r, const QString& f_cmd_r, const QStringList& f_cmdArgs_r); /** * @brief Logs a login attempt. * - * @param client The client that attempted to login. + * @param f_areaName_r The name of the area where the event happened. + * @param f_charName_r The character name of the client that attempted to login. + * @param f_ipid_r The IPID of the aforementioned client. * @param success True if the client successfully authenticated as a mod. - * @param modname If the client logged in with a modname, then this is it. Otherwise, it's `"moderator"`. - * - * @note Why does this exist? logCmd() already does this in part. + * @param f_modname_r If the client logged in with a modname, then this is it. Otherwise, it's `"moderator"`. */ - void logLogin(AOClient* client, bool success, QString modname); + void logLogin(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, bool success, const QString& f_modname_r); /** * @brief Appends the contents of #buffer into `config/server.log`, emptying the former. + * + * @param f_areaName_r The name of the area where the event happened. */ - void flush(); + void flush(const QString& f_areaName_r); + + /** + * @brief Contains entries that have not yet been flushed out into a log file. + */ + QQueue m_buffer; private: - /** - * @brief Convenience function to format entries to the acceptable standard for logging. - * - * @param client The client who 'caused' the source event for the entry to happen. - * @param type The type of entry that is being built, something that uniquely identifies entries of similar being. - * @param message Any additional information related to the entry. - * - * @return A formatted string representation of the entry. - */ - QString buildEntry(AOClient* client, QString type, QString message); - /** * @brief Convenience function to add an entry to #buffer. * * @details If the buffer's size is equal to #max_length, the first entry in the queue is removed, * and the newest entry is added to the end. * - * @param entry The string representation of the entry to add. - * - * @pre You would probably call buildEntry() to format the entry before adding it to the buffer. + * @param f_areaName_r The name of the area where the loggable entry happened. + * @param f_charName_r The character name of the client who 'caused' the source event for the entry to happen. + * @param f_ipid_r The IPID of the aforementioned client. + * @param f_type_r The type of entry that is being built, something that uniquely identifies entries of similar being. + * @param f_message_r Any additional information related to the entry. */ - void addEntry(QString entry); + void addEntry(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, + const QString& f_type_r, const QString& f_message_r); /** * @brief The max amount of entries that may be contained in #buffer. */ - int max_length; + int m_maxLength; /** - * @brief Contains entries that have not yet been flushed out into a log file. - */ - QQueue buffer; - - /** - * @brief A pointer to the area this logger is associated with. + * @brief Determines what kind of logging happens, `"full"` or `"modcall"`. * - * @details Used for logging in what area did a given packet event happen. + * @details This largely influences the resulting log file's name, and in case of a `"full"` setup, + * the in-memory buffer is auto-dumped to said file if full. */ - AreaData* area; + QString m_logType; }; #endif // LOGGER_H diff --git a/core/src/aoclient.cpp b/core/src/aoclient.cpp index 1fc9c92..32d2ead 100644 --- a/core/src/aoclient.cpp +++ b/core/src/aoclient.cpp @@ -49,23 +49,21 @@ void AOClient::clientDisconnected() #endif if (joined) { server->player_count--; - server->areas[current_area]->player_count--; + server->areas[current_area]->clientLeftArea(server->getCharID(current_char)); arup(ARUPType::PLAYER_COUNT, true); } + if (current_char != "") { - server->areas[current_area]->characters_taken.removeAll(server->getCharID(current_char)); server->updateCharsTaken(server->areas[current_area]); } - bool update_locks; + + bool l_updateLocks = false; + for (AreaData* area : server->areas) { - area->owners.removeAll(id); - area->invited.removeAll(id); - if (area->owners.isEmpty() && area->locked != AreaData::FREE) { - area->locked = AreaData::FREE; - update_locks = true; - } + l_updateLocks = l_updateLocks || area->removeOwner(id); } - if (update_locks) + + if (l_updateLocks) arup(ARUPType::LOCKED, true); arup(ARUPType::CM, true); } @@ -109,34 +107,34 @@ void AOClient::changeArea(int new_area) sendServerMessage("You are already in area " + server->area_names[current_area]); return; } - if (server->areas[new_area]->locked == AreaData::LockStatus::LOCKED && !server->areas[new_area]->invited.contains(id)) { + if (server->areas[new_area]->m_locked == AreaData::LockStatus::LOCKED && !server->areas[new_area]->m_invited.contains(id)) { sendServerMessage("Area " + server->area_names[new_area] + " is locked."); return; } if (current_char != "") { - server->areas[current_area]->characters_taken.removeAll(server->getCharID(current_char)); + server->areas[current_area]->m_charactersTaken.removeAll(server->getCharID(current_char)); server->updateCharsTaken(server->areas[current_area]); } - server->areas[new_area]->player_count++; - server->areas[current_area]->player_count--; + server->areas[new_area]->m_playerCount++; + server->areas[current_area]->m_playerCount--; current_area = new_area; arup(ARUPType::PLAYER_COUNT, true); sendEvidenceList(server->areas[new_area]); - sendPacket("HP", {"1", QString::number(server->areas[new_area]->def_hp)}); - sendPacket("HP", {"2", QString::number(server->areas[new_area]->pro_hp)}); - sendPacket("BN", {server->areas[new_area]->background}); - if (server->areas[current_area]->characters_taken.contains(server->getCharID(current_char))) { + sendPacket("HP", {"1", QString::number(server->areas[new_area]->m_defHP)}); + sendPacket("HP", {"2", QString::number(server->areas[new_area]->m_proHP)}); + sendPacket("BN", {server->areas[new_area]->m_background}); + if (server->areas[current_area]->m_charactersTaken.contains(server->getCharID(current_char))) { server->updateCharsTaken(server->areas[current_area]); current_char = ""; sendPacket("DONE"); } else { - server->areas[current_area]->characters_taken.append(server->getCharID(current_char)); + server->areas[current_area]->m_charactersTaken.append(server->getCharID(current_char)); server->updateCharsTaken(server->areas[current_area]); } - for (QTimer* timer : server->areas[current_area]->timers) { - int timer_id = server->areas[current_area]->timers.indexOf(timer) + 1; + for (QTimer* timer : server->areas[current_area]->m_timer) { + int timer_id = server->areas[current_area]->m_timer.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())))}); @@ -146,7 +144,7 @@ void AOClient::changeArea(int new_area) } } sendServerMessage("You moved to area " + server->area_names[current_area]); - if (server->areas[current_area]->locked == AreaData::LockStatus::SPECTATABLE) + if (server->areas[current_area]->m_locked == AreaData::LockStatus::SPECTATABLE) sendServerMessage("Area " + server->area_names[current_area] + " is spectate-only; to chat IC you will need to be invited by the CM."); } @@ -162,16 +160,16 @@ bool AOClient::changeCharacter(int char_id) } if (current_char != "") { - area->characters_taken.removeAll(server->getCharID(current_char)); + area->m_charactersTaken.removeAll(server->getCharID(current_char)); } if (char_id >= 0) { QString char_selected = server->characters[char_id]; - bool taken = area->characters_taken.contains(char_id); + bool taken = area->m_charactersTaken.contains(char_id); if (taken || char_selected == "") return false; - area->characters_taken.append(char_id); + area->m_charactersTaken.append(char_id); current_char = char_selected; } else { @@ -216,20 +214,20 @@ void AOClient::arup(ARUPType type, bool broadcast) for (AreaData* area : server->areas) { switch(type) { case ARUPType::PLAYER_COUNT: { - arup_data.append(QString::number(area->player_count)); + arup_data.append(QString::number(area->m_playerCount)); break; } case ARUPType::STATUS: { - QString area_status = QVariant::fromValue(area->status).toString().replace("_", "-"); // LOOKING_FOR_PLAYERS to LOOKING-FOR-PLAYERS + QString area_status = QVariant::fromValue(area->m_status).toString().replace("_", "-"); // LOOKING_FOR_PLAYERS to LOOKING-FOR-PLAYERS arup_data.append(area_status); break; } case ARUPType::CM: { - if (area->owners.isEmpty()) + if (area->m_owners.isEmpty()) arup_data.append("FREE"); else { QStringList area_owners; - for (int owner_id : area->owners) { + for (int owner_id : area->m_owners) { AOClient* owner = server->getClientByID(owner_id); area_owners.append("[" + QString::number(owner->id) + "] " + owner->current_char); } @@ -238,7 +236,7 @@ void AOClient::arup(ARUPType type, bool broadcast) break; } case ARUPType::LOCKED: { - QString lock_status = QVariant::fromValue(area->locked).toString(); + QString lock_status = QVariant::fromValue(area->m_locked).toString(); arup_data.append(lock_status); break; } @@ -314,7 +312,7 @@ bool AOClient::checkAuth(unsigned long long acl_mask) if (acl_mask != ACLFlags.value("NONE")) { if (acl_mask == ACLFlags.value("CM")) { AreaData* area = server->areas[current_area]; - if (area->owners.contains(id)) + if (area->m_owners.contains(id)) return true; } else if (!authenticated) { diff --git a/core/src/area_data.cpp b/core/src/area_data.cpp index dfedd32..0c8f97f 100644 --- a/core/src/area_data.cpp +++ b/core/src/area_data.cpp @@ -18,56 +18,123 @@ #include "include/area_data.h" AreaData::AreaData(QString p_name, int p_index) : - index(p_index), - player_count(0), - status(IDLE), - locked(FREE), - document("No document."), - def_hp(10), - pro_hp(10), - judgelog(), - last_ic_message() + m_index(p_index), + m_playerCount(0), + m_status(IDLE), + m_locked(FREE), + m_document("No document."), + m_defHP(10), + m_proHP(10), + m_judgelog(), + m_lastICMessage() { QStringList name_split = p_name.split(":"); name_split.removeFirst(); - name = name_split.join(":"); + m_name = name_split.join(":"); QSettings areas_ini("config/areas.ini", QSettings::IniFormat); areas_ini.setIniCodec("UTF-8"); areas_ini.beginGroup(p_name); - background = areas_ini.value("background", "gs4").toString(); - is_protected = areas_ini.value("protected_area", "false").toBool(); - iniswap_allowed = areas_ini.value("iniswap_allowed", "true").toBool(); - bg_locked = areas_ini.value("bg_locked", "false").toBool(); + m_background = areas_ini.value("background", "gs4").toString(); + m_isProtected = areas_ini.value("protected_area", "false").toBool(); + m_iniswapAllowed = areas_ini.value("iniswap_allowed", "true").toBool(); + m_bgLocked = areas_ini.value("bg_locked", "false").toBool(); QString configured_evi_mod = areas_ini.value("evidence_mod", "FFA").toString().toLower(); - blankposting_allowed = areas_ini.value("blankposting_allowed","true").toBool(); - force_immediate = areas_ini.value("force_immediate", "false").toBool(); - toggle_music = areas_ini.value("toggle_music", "true").toBool(); - showname_allowed = areas_ini.value("shownames_allowed", "true").toBool(); + m_blankpostingAllowed = areas_ini.value("blankposting_allowed","true").toBool(); + m_forceImmediate = areas_ini.value("force_immediate", "false").toBool(); + m_toggleMusic = areas_ini.value("toggle_music", "true").toBool(); + m_shownameAllowed = areas_ini.value("shownames_allowed", "true").toBool(); areas_ini.endGroup(); QSettings config_ini("config/config.ini", QSettings::IniFormat); config_ini.setIniCodec("UTF-8"); config_ini.beginGroup("Options"); int log_size = config_ini.value("logbuffer", 50).toInt(); - log_type = config_ini.value("logger","modcall").toString(); + QString l_logType = config_ini.value("logger","modcall").toString(); config_ini.endGroup(); if (log_size == 0) log_size = 500; - logger = new Logger(log_size, this); + m_logger = new Logger(log_size, l_logType); QTimer* timer1 = new QTimer(); - timers.append(timer1); + m_timers.append(timer1); QTimer* timer2 = new QTimer(); - timers.append(timer2); + m_timers.append(timer2); QTimer* timer3 = new QTimer(); - timers.append(timer3); + m_timers.append(timer3); QTimer* timer4 = new QTimer(); - timers.append(timer4); + m_timers.append(timer4); if (configured_evi_mod == "cm") - evi_mod = EvidenceMod::CM; + m_eviMod = EvidenceMod::CM; else if (configured_evi_mod == "mod") - evi_mod = EvidenceMod::MOD; + m_eviMod = EvidenceMod::MOD; else if (configured_evi_mod == "hiddencm") - evi_mod = EvidenceMod::HIDDEN_CM; + m_eviMod = EvidenceMod::HIDDEN_CM; else - evi_mod = EvidenceMod::FFA; + m_eviMod = EvidenceMod::FFA; +} + +void AreaData::clientLeftArea(int f_charId) +{ + --m_playerCount; + m_charactersTaken.removeAll(f_charId); +} + +QList AreaData::owners() const +{ + QString l_test; + const auto& l_buffer = m_logger->m_buffer; + for (const auto& l_item : l_buffer) + { + l_test.append(l_item + "\n"); + } + + return m_owners; +} + +void AreaData::addOwner(int f_clientId) +{ + m_owners.append(f_clientId); + m_invited.append(f_clientId); +} + +bool AreaData::removeOwner(int f_clientId) +{ + m_owners.removeAll(f_clientId); + m_invited.removeAll(f_clientId); + + if (m_owners.isEmpty() && m_locked != AreaData::FREE) { + m_locked = AreaData::FREE; + return true; + } + + return false; +} + +bool AreaData::blankpostingAllowed() const +{ + return m_blankpostingAllowed; +} + +bool AreaData::isProtected() const +{ + return m_isProtected; +} + +AreaData::LockStatus AreaData::lockStatus() const +{ + return m_locked; +} + +bool AreaData::invite(int f_clientId) +{ + if (m_invited.contains(f_clientId)) { + return false; + } + + m_invited.append(f_clientId); + return true; +} + +int AreaData::playerCount() const +{ + return m_playerCount; } diff --git a/core/src/commands/area.cpp b/core/src/commands/area.cpp index 8ae19af..2740d31 100644 --- a/core/src/commands/area.cpp +++ b/core/src/commands/area.cpp @@ -25,17 +25,16 @@ void AOClient::cmdCM(int argc, QStringList argv) { QString sender_name = ooc_name; AreaData* area = server->areas[current_area]; - if (area->is_protected) { + if (area->isProtected()) { sendServerMessage("This area is protected, you may not become CM."); return; } - else if (area->owners.isEmpty()) { // no one owns this area, and it's not protected - area->owners.append(id); - area->invited.append(id); + else if (area->owners().isEmpty()) { // no one owns this area, and it's not protected + area->addOwner(id); sendServerMessageArea(sender_name + " is now CM in this area."); arup(ARUPType::CM, true); } - else if (!area->owners.contains(id)) { // there is already a CM, and it isn't us + else if (!area->owners().contains(id)) { // there is already a CM, and it isn't us sendServerMessage("You cannot become a CM in this area."); } else if (argc == 1) { // we are CM, and we want to make ID argv[0] also CM @@ -49,7 +48,7 @@ void AOClient::cmdCM(int argc, QStringList argv) sendServerMessage("Unable to find client with ID " + argv[0] + "."); return; } - area->owners.append(owner_candidate->id); + area->addOwner(owner_candidate->id); sendServerMessageArea(owner_candidate->ooc_name + " is now CM in this area."); arup(ARUPType::CM, true); } @@ -63,7 +62,7 @@ void AOClient::cmdUnCM(int argc, QStringList argv) AreaData* area = server->areas[current_area]; int uid; - if (area->owners.isEmpty()) { + if (area->owners().isEmpty()) { sendServerMessage("There are no CMs in this area."); return; } @@ -78,7 +77,7 @@ void AOClient::cmdUnCM(int argc, QStringList argv) sendServerMessage("Invalid user ID."); return; } - if (!area->owners.contains(uid)) { + if (!area->owners().contains(uid)) { sendServerMessage("That user is not CMed."); return; } @@ -89,16 +88,12 @@ void AOClient::cmdUnCM(int argc, QStringList argv) sendServerMessage("Invalid command."); return; } - area->owners.removeAll(uid); - area->invited.removeAll(uid); - arup(ARUPType::CM, true); - if (area->owners.isEmpty()) { - area->invited.clear(); - if (area->locked != AreaData::FREE) { - area->locked = AreaData::FREE; - arup(ARUPType::LOCKED, true); - } + + if (area->removeOwner(uid)) { + arup(ARUPType::LOCKED, true); } + + arup(ARUPType::CM, true); } void AOClient::cmdInvite(int argc, QStringList argv) @@ -114,11 +109,10 @@ void AOClient::cmdInvite(int argc, QStringList argv) sendServerMessage("No client with that ID found."); return; } - else if (area->invited.contains(invited_id)) { + else if (!area->invite(invited_id)) { sendServerMessage("That ID is already on the invite list."); return; } - area->invited.append(invited_id); sendServerMessage("You invited ID " + argv[0]); } @@ -135,30 +129,30 @@ void AOClient::cmdUnInvite(int argc, QStringList argv) sendServerMessage("No client with that ID found."); return; } - else if (area->owners.contains(uninvited_id)) { + else if (area->owners().contains(uninvited_id)) { sendServerMessage("You cannot uninvite a CM!"); return; } - else if (!area->invited.contains(uninvited_id)) { + else if (!area->m_invited.contains(uninvited_id)) { sendServerMessage("That ID is not on the invite list."); return; } - area->invited.removeAll(uninvited_id); + area->m_invited.removeAll(uninvited_id); sendServerMessage("You uninvited ID " + argv[0]); } void AOClient::cmdLock(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (area->locked == AreaData::LockStatus::LOCKED) { + if (area->lockStatus() == AreaData::LockStatus::LOCKED) { sendServerMessage("This area is already locked."); return; } sendServerMessageArea("This area is now locked."); - area->locked = AreaData::LockStatus::LOCKED; + area->m_locked = AreaData::LockStatus::LOCKED; for (AOClient* client : server->clients) { if (client->current_area == current_area && client->joined) { - area->invited.append(client->id); + area->m_invited.append(client->id); } } arup(ARUPType::LOCKED, true); @@ -167,15 +161,15 @@ void AOClient::cmdLock(int argc, QStringList argv) void AOClient::cmdSpectatable(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (area->locked == AreaData::LockStatus::SPECTATABLE) { + if (area->lockStatus() == AreaData::LockStatus::SPECTATABLE) { sendServerMessage("This area is already in spectate mode."); return; } sendServerMessageArea("This area is now spectatable."); - area->locked = AreaData::LockStatus::SPECTATABLE; + area->m_locked = AreaData::LockStatus::SPECTATABLE; for (AOClient* client : server->clients) { if (client->current_area == current_area && client->joined) { - area->invited.append(client->id); + area->m_invited.append(client->id); } } arup(ARUPType::LOCKED, true); @@ -184,12 +178,12 @@ void AOClient::cmdSpectatable(int argc, QStringList argv) void AOClient::cmdUnLock(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (area->locked == AreaData::LockStatus::FREE) { + if (area->m_locked == AreaData::LockStatus::FREE) { sendServerMessage("This area is not locked."); return; } sendServerMessageArea("This area is now unlocked."); - area->locked = AreaData::LockStatus::FREE; + area->m_locked = AreaData::LockStatus::FREE; arup(ARUPType::LOCKED, true); } @@ -241,9 +235,9 @@ void AOClient::cmdAreaKick(int argc, QStringList argv) void AOClient::cmdSetBackground(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (authenticated || !area->bg_locked) { + if (authenticated || !area->m_bgLocked) { if (server->backgrounds.contains(argv[0])) { - area->background = argv[0]; + area->m_background = argv[0]; server->broadcast(AOPacket("BN", {argv[0]}), current_area); sendServerMessageArea(current_char + " changed the background to " + argv[0]); } @@ -259,14 +253,14 @@ void AOClient::cmdSetBackground(int argc, QStringList argv) void AOClient::cmdBgLock(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - area->bg_locked = true; + area->m_bgLocked = true; server->broadcast(AOPacket("CT", {"Server", current_char + " locked the background.", "1"}), current_area); } void AOClient::cmdBgUnlock(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - area->bg_locked = false; + area->m_bgLocked = false; server->broadcast(AOPacket("CT", {"Server", current_char + " unlocked the background.", "1"}), current_area); } @@ -275,17 +269,17 @@ void AOClient::cmdStatus(int argc, QStringList argv) AreaData* area = server->areas[current_area]; QString arg = argv[0].toLower(); if (arg == "idle") - area->status = AreaData::IDLE; + area->m_status = AreaData::IDLE; else if (arg == "rp") - area->status = AreaData::RP; + area->m_status = AreaData::RP; else if (arg == "casing") - area->status = AreaData::CASING; + area->m_status = AreaData::CASING; else if (arg == "looking-for-players" || arg == "lfp") - area->status = AreaData::LOOKING_FOR_PLAYERS; + area->m_status = AreaData::LOOKING_FOR_PLAYERS; else if (arg == "recess") - area->status = AreaData::RECESS; + area->m_status = AreaData::RECESS; else if (arg == "gaming") - area->status = AreaData::GAMING; + area->m_status = AreaData::GAMING; else { sendServerMessage("That does not look like a valid status. Valid statuses are idle, rp, casing, lfp, recess, gaming"); return; @@ -297,11 +291,11 @@ void AOClient::cmdStatus(int argc, QStringList argv) void AOClient::cmdJudgeLog(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (area->judgelog.isEmpty()) { + if (area->m_judgelog.isEmpty()) { sendServerMessage("There have been no judge actions in this area."); return; } - QString message = area->judgelog.join("\n"); + QString message = area->m_judgelog.join("\n"); //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) { sendServerMessage(message); diff --git a/core/src/commands/authentication.cpp b/core/src/commands/authentication.cpp index 1aeb24d..d53b0dc 100644 --- a/core/src/commands/authentication.cpp +++ b/core/src/commands/authentication.cpp @@ -40,7 +40,7 @@ void AOClient::cmdLogin(int argc, QStringList argv) sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful." sendServerMessage("Incorrect password."); } - server->areas.value(current_area)->logger->logLogin(this, authenticated, "moderator"); + server->areas.value(current_area)->m_logger->logLogin(this, authenticated, "moderator"); } else if (server->auth_type == "advanced") { if (argc < 2) { @@ -61,7 +61,7 @@ void AOClient::cmdLogin(int argc, QStringList argv) sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful." sendServerMessage("Incorrect password."); } - server->areas.value(current_area)->logger->logLogin(this, authenticated, username); + server->areas.value(current_area)->m_logger->logLogin(this, authenticated, username); } else { qWarning() << "config.ini has an unrecognized auth_type!"; diff --git a/core/src/commands/casing.cpp b/core/src/commands/casing.cpp index a83cb94..393ccbc 100644 --- a/core/src/commands/casing.cpp +++ b/core/src/commands/casing.cpp @@ -25,10 +25,10 @@ void AOClient::cmdDoc(int argc, QStringList argv) QString sender_name = ooc_name; AreaData* area = server->areas[current_area]; if (argc == 0) { - sendServerMessage("Document: " + area->document); + sendServerMessage("Document: " + area->m_document); } else { - area->document = argv.join(" "); + area->m_document = argv.join(" "); sendServerMessageArea(sender_name + " changed the document."); } } @@ -37,7 +37,7 @@ void AOClient::cmdClearDoc(int argc, QStringList argv) { QString sender_name = ooc_name; AreaData* area = server->areas[current_area]; - area->document = "No document."; + area->m_document = "No document."; sendServerMessageArea(sender_name + " cleared the document."); } @@ -46,13 +46,13 @@ void AOClient::cmdEvidenceMod(int argc, QStringList argv) AreaData* area = server->areas[current_area]; argv[0] = argv[0].toLower(); if (argv[0] == "cm") - area->evi_mod = AreaData::EvidenceMod::CM; + area->m_eviMod = AreaData::EvidenceMod::CM; else if (argv[0] == "mod") - area->evi_mod = AreaData::EvidenceMod::MOD; + area->m_eviMod = AreaData::EvidenceMod::MOD; else if (argv[0] == "hiddencm") - area->evi_mod = AreaData::EvidenceMod::HIDDEN_CM; + area->m_eviMod = AreaData::EvidenceMod::HIDDEN_CM; else if (argv[0] == "ffa") - area->evi_mod = AreaData::EvidenceMod::FFA; + area->m_eviMod = AreaData::EvidenceMod::FFA; else { sendServerMessage("Invalid evidence mod."); return; @@ -66,7 +66,7 @@ void AOClient::cmdEvidenceMod(int argc, QStringList argv) void AOClient::cmdEvidence_Swap(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - int ev_size = area->evidence.size() -1; + int ev_size = area->m_evidence.size() -1; if (ev_size < 0) { sendServerMessage("No evidence in area."); @@ -89,7 +89,7 @@ void AOClient::cmdEvidence_Swap(int argc, QStringList argv) //swapItemsAt does not exist in Qt older than 5.13 area->evidence.swap(ev_id1, ev_id2); #else - area->evidence.swapItemsAt(ev_id1, ev_id2); + area->m_evidence.swapItemsAt(ev_id1, ev_id2); #endif sendEvidenceList(area); sendServerMessage("The evidence " + QString::number(ev_id1) + " and " + QString::number(ev_id2) + " have been swapped."); @@ -102,12 +102,12 @@ void AOClient::cmdEvidence_Swap(int argc, QStringList argv) void AOClient::cmdTestify(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (area->test_rec == AreaData::TestimonyRecording::RECORDING) { + if (area->m_testimonyRecording == AreaData::TestimonyRecording::RECORDING) { sendServerMessage("Testimony recording is already in progress. Please stop it before starting a new one."); } else { clearTestimony(); - area->test_rec = AreaData::TestimonyRecording::RECORDING; + area->m_testimonyRecording = AreaData::TestimonyRecording::RECORDING; sendServerMessage("Started testimony recording."); } } @@ -115,15 +115,15 @@ void AOClient::cmdTestify(int argc, QStringList argv) void AOClient::cmdExamine(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (area->testimony.size() -1 > 0) + if (area->m_testimony.size() -1 > 0) { - area->test_rec = AreaData::TestimonyRecording::PLAYBACK; + area->m_testimonyRecording = AreaData::TestimonyRecording::PLAYBACK; server->broadcast(AOPacket("RT",{"testimony2"}), current_area); - server->broadcast(AOPacket("MS", {area->testimony[0]}), current_area); - area->statement = 0; + server->broadcast(AOPacket("MS", {area->m_testimony[0]}), current_area); + area->m_statement = 0; return; } - if (area->test_rec == AreaData::TestimonyRecording::PLAYBACK) + if (area->m_testimonyRecording == AreaData::TestimonyRecording::PLAYBACK) sendServerMessage("Unable to examine while another examination is running"); else sendServerMessage("Unable to start replay without prior examination."); @@ -132,15 +132,15 @@ void AOClient::cmdExamine(int argc, QStringList argv) void AOClient::cmdTestimony(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (area->testimony.size() -1 < 1) { + if (area->m_testimony.size() -1 < 1) { sendServerMessage("Unable to display empty testimony."); return; } QString ooc_message; - for (int i = 1; i <= area->testimony.size() -1; i++) + for (int i = 1; i <= area->m_testimony.size() -1; i++) { - QStringList packet = area->testimony.at(i); + QStringList packet = area->m_testimony.at(i); QString ic_message = packet[4]; ooc_message.append( "[" + QString::number(i) + "]" + ic_message + "\n"); } @@ -150,35 +150,35 @@ void AOClient::cmdTestimony(int argc, QStringList argv) void AOClient::cmdDeleteStatement(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - int c_statement = area->statement; - if (area->testimony.size() - 1 == 0) { + int c_statement = area->m_statement; + if (area->m_testimony.size() - 1 == 0) { sendServerMessage("Unable to delete statement. No statements saved in this area."); } - if (c_statement > 0 && area->testimony.size() > 2) { - area->testimony.remove(c_statement); - area->statement = c_statement - 1; + if (c_statement > 0 && area->m_testimony.size() > 2) { + area->m_testimony.remove(c_statement); + area->m_statement = c_statement - 1; sendServerMessage("The statement with id " + QString::number(c_statement) + " has been deleted from the testimony."); } } void AOClient::cmdUpdateStatement(int argc, QStringList argv) { - server->areas[current_area]->test_rec = AreaData::TestimonyRecording::UPDATE; + server->areas[current_area]->m_testimonyRecording = AreaData::TestimonyRecording::UPDATE; sendServerMessage("The next IC-Message will replace the last displayed replay message."); } void AOClient::cmdPauseTestimony(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - area->test_rec = AreaData::TestimonyRecording::STOPPED; + area->m_testimonyRecording = AreaData::TestimonyRecording::STOPPED; server->broadcast(AOPacket("RT",{"testimony1#1"}), current_area); sendServerMessage("Testimony has been stopped."); } void AOClient::cmdAddStatement(int argc, QStringList argv) { - if (server->areas[current_area]->statement < server->maximum_statements) { - server->areas[current_area]->test_rec = AreaData::TestimonyRecording::ADD; + if (server->areas[current_area]->m_statement < server->maximum_statements) { + server->areas[current_area]->m_testimonyRecording = AreaData::TestimonyRecording::ADD; sendServerMessage("The next IC-Message will be inserted into the testimony."); } else @@ -196,7 +196,7 @@ void AOClient::cmdSaveTestimony(int argc, QStringList argv) if (permission_found) { AreaData* area = server->areas[current_area]; - if (area->testimony.size() -1 <= 0) { + if (area->m_testimony.size() -1 <= 0) { sendServerMessage("Can't save an empty testimony."); return; } @@ -216,9 +216,9 @@ void AOClient::cmdSaveTestimony(int argc, QStringList argv) 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++) + for (int i = 0; i <= area->m_testimony.size() -1; i++) { - out << area->testimony.at(i).join("#") << "\n"; + out << area->m_testimony.at(i).join("#") << "\n"; } sendServerMessage("Testimony saved. To load it use /loadtestimony " + testimony_name); testimony_saving = false; @@ -258,7 +258,7 @@ void AOClient::cmdLoadTestimony(int argc, QStringList argv) if (testimony_lines <= server->maximum_statements) { QString line = in.readLine(); QStringList packet = line.split("#"); - area->testimony.append(packet); + area->m_testimony.append(packet); testimony_lines = testimony_lines + 1; } else { diff --git a/core/src/commands/command_helper.cpp b/core/src/commands/command_helper.cpp index 6fb8665..d9f77c3 100644 --- a/core/src/commands/command_helper.cpp +++ b/core/src/commands/command_helper.cpp @@ -32,7 +32,7 @@ QStringList AOClient::buildAreaList(int area_idx) QString area_name = server->area_names[area_idx]; AreaData* area = server->areas[area_idx]; entries.append("=== " + area_name + " ==="); - switch (area->locked) { + switch (area->locked()) { case AreaData::LockStatus::LOCKED: entries.append("[LOCKED]"); break; @@ -43,13 +43,13 @@ QStringList AOClient::buildAreaList(int area_idx) default: break; } - entries.append("[" + QString::number(area->player_count) + " users][" + QVariant::fromValue(area->status).toString().replace("_", "-") + "]"); + entries.append("[" + QString::number(area->m_playerCount) + " users][" + QVariant::fromValue(area->m_status).toString().replace("_", "-") + "]"); for (AOClient* client : server->clients) { if (client->current_area == area_idx && client->joined) { QString char_entry = "[" + QString::number(client->id) + "] " + client->current_char; if (client->current_char == "") char_entry += "Spectator"; - if (area->owners.contains(client->id)) + if (area->m_owners.contains(client->id)) char_entry.insert(0, "[CM] "); if (authenticated) char_entry += " (" + client->getIpid() + "): " + client->ooc_name; @@ -103,7 +103,7 @@ QString AOClient::getAreaTimer(int area_idx, int timer_idx) if (timer_idx == 0) timer = server->timer; else if (timer_idx > 0 && timer_idx <= 4) - timer = area->timers[timer_idx - 1]; + timer = area->m_timer[timer_idx - 1]; else return "Invalid timer ID."; diff --git a/core/src/commands/messaging.cpp b/core/src/commands/messaging.cpp index 044169d..4e5b70f 100644 --- a/core/src/commands/messaging.cpp +++ b/core/src/commands/messaging.cpp @@ -106,7 +106,7 @@ void AOClient::cmdRandomChar(int argc, QStringList argv) bool taken = true; while (taken) { selected_char_id = genRand(0, server->characters.size() - 1); - if (!area->characters_taken.contains(selected_char_id)) { + if (!area->m_charactersTaken.contains(selected_char_id)) { taken = false; } } @@ -423,7 +423,7 @@ void AOClient::cmdA(int argc, QStringList argv) } AreaData* area = server->areas[area_id]; - if (!area->owners.contains(id)) { + if (!area->m_owners.contains(id)) { sendServerMessage("You are not CM in that area."); return; } @@ -441,7 +441,7 @@ void AOClient::cmdS(int argc, QStringList argv) QString ooc_message = argv.join(" "); for (int i = 0; i <= all_areas; i++) { - if (server->areas[i]->owners.contains(id)) + if (server->areas[i]->m_owners.contains(id)) server->broadcast(AOPacket("CT", {"[CM]" + sender_name, ooc_message}), i); } } diff --git a/core/src/commands/moderation.cpp b/core/src/commands/moderation.cpp index e0fc24a..3330ea9 100644 --- a/core/src/commands/moderation.cpp +++ b/core/src/commands/moderation.cpp @@ -333,8 +333,8 @@ void AOClient::cmdAllowBlankposting(int argc, QStringList argv) { QString sender_name = ooc_name; AreaData* area = server->areas[current_area]; - area->blankposting_allowed = !area->blankposting_allowed; - if (area->blankposting_allowed == false) { + area->m_blankpostingAllowed = !area->m_blankpostingAllowed; + if (area->blankpostingAllowed() == false) { sendServerMessageArea(sender_name + " has set blankposting in the area to forbidden."); } else { @@ -391,16 +391,16 @@ void AOClient::cmdReload(int argc, QStringList argv) void AOClient::cmdForceImmediate(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - area->force_immediate = !area->force_immediate; - QString state = area->force_immediate ? "on." : "off."; + area->m_forceImmediate = !area->m_forceImmediate; + QString state = area->m_forceImmediate ? "on." : "off."; sendServerMessage("Forced immediate text processing in this area is now " + state); } void AOClient::cmdAllowIniswap(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - area->iniswap_allowed = !area->iniswap_allowed; - QString state = area->iniswap_allowed ? "allowed." : "disallowed."; + area->m_iniswapAllowed = !area->m_iniswapAllowed; + QString state = area->m_iniswapAllowed ? "allowed." : "disallowed."; sendServerMessage("Iniswapping in this area is now " + state); } diff --git a/core/src/commands/music.cpp b/core/src/commands/music.cpp index 5500b78..b8b6e35 100644 --- a/core/src/commands/music.cpp +++ b/core/src/commands/music.cpp @@ -28,8 +28,8 @@ void AOClient::cmdPlay(int argc, QStringList argv) } AreaData* area = server->areas[current_area]; QString song = argv.join(" "); - area->current_music = song; - area->music_played_by = showname; + area->m_currentMusic = song; + area->m_musicPlayerBy = showname; AOPacket music_change("MC", {song, QString::number(server->getCharID(current_char)), showname, "1", "0"}); server->broadcast(music_change, current_area); } @@ -37,8 +37,8 @@ void AOClient::cmdPlay(int argc, QStringList argv) void AOClient::cmdCurrentMusic(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (area->current_music != "" && area->current_music != "~stop.mp3") // dummy track for stopping music - sendServerMessage("The current song is " + area->current_music + " played by " + area->music_played_by); + if (area->m_currentMusic != "" && area->m_currentMusic != "~stop.mp3") // dummy track for stopping music + sendServerMessage("The current song is " + area->m_currentMusic + " played by " + area->m_musicPlayerBy); else sendServerMessage("There is no music playing."); } @@ -86,7 +86,7 @@ void AOClient::cmdUnBlockDj(int argc, QStringList argv) void AOClient::cmdToggleMusic(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - area->toggle_music = !area->toggle_music; - QString state = area->toggle_music ? "allowed." : "disallowed."; + area->m_toggleMusic = !area->m_toggleMusic; + QString state = area->m_toggleMusic ? "allowed." : "disallowed."; sendServerMessage("Music in this area is now " + state); } diff --git a/core/src/commands/roleplay.cpp b/core/src/commands/roleplay.cpp index ef27f72..d401dc6 100644 --- a/core/src/commands/roleplay.cpp +++ b/core/src/commands/roleplay.cpp @@ -48,7 +48,7 @@ void AOClient::cmdTimer(int argc, QStringList argv) QStringList timers; timers.append("Currently active timers:"); for (int i = 0; i <= 4; i++) { - timers.append(getAreaTimer(area->index, i)); + timers.append(getAreaTimer(area->m_index, i)); } sendServerMessage(timers.join("\n")); return; @@ -65,7 +65,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(area->m_index, timer_id)); return; } @@ -83,7 +83,7 @@ void AOClient::cmdTimer(int argc, QStringList argv) requested_timer = server->timer; } else - requested_timer = area->timers[timer_id - 1]; + requested_timer = area->m_timers[timer_id - 1]; AOPacket show_timer("TI", {QString::number(timer_id), "2"}); AOPacket hide_timer("TI", {QString::number(timer_id), "3"}); @@ -130,18 +130,18 @@ void AOClient::cmdTimer(int argc, QStringList argv) void AOClient::cmdNoteCard(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (area->notecards.keys().contains(current_char)) - area->notecards.remove(current_char); + if (area->m_notecards.keys().contains(current_char)) + area->m_notecards.remove(current_char); QString notecard = argv.join(" "); - area->notecards[current_char] = notecard; + area->m_notecards[current_char] = notecard; sendServerMessageArea(current_char + " wrote a note card."); } void AOClient::cmdNoteCardClear(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (area->notecards.keys().contains(current_char)) { - area->notecards.remove(current_char); + if (area->m_notecards.keys().contains(current_char)) { + area->m_notecards.remove(current_char); sendServerMessageArea(current_char + " erased their note card."); } else @@ -151,17 +151,17 @@ void AOClient::cmdNoteCardClear(int argc, QStringList argv) void AOClient::cmdNoteCardReveal(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (area->notecards.isEmpty()) { + if (area->m_notecards.isEmpty()) { sendServerMessage("There are no cards to reveal in this area."); return; } QStringList message; message << "Note cards have been revealed."; QMap::iterator i; - for (i = area->notecards.begin(); i != area->notecards.end(); ++i) + for (i = area->m_notecards.begin(); i != area->m_notecards.end(); ++i) message << i.key() + ": " + i.value(); sendServerMessageArea(message.join("\n")); - area->notecards.clear(); + area->m_notecards.clear(); } void AOClient::cmd8Ball(int argc, QStringList argv) diff --git a/core/src/logger.cpp b/core/src/logger.cpp index 96ea2c6..5f84134 100644 --- a/core/src/logger.cpp +++ b/core/src/logger.cpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////////////// // akashi - a server for Attorney Online 2 // -// Copyright (C) 2020 scatterflower // +// Copyright (C) 2020 scatterflower // // // // This program is free software: you can redistribute it and/or modify // // it under the terms of the GNU Affero General Public License as // @@ -15,101 +15,101 @@ // You should have received a copy of the GNU Affero General Public License // // along with this program. If not, see . // ////////////////////////////////////////////////////////////////////////////////////// + +#include + #include "include/logger.h" -void Logger::logIC(AOClient *client, AOPacket *packet) +void Logger::logIC(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, const QString& f_message_r) { - QString message = packet->contents[4]; - addEntry(buildEntry(client, "IC", message)); + addEntry(f_areaName_r, f_charName_r, f_ipid_r, "IC", f_message_r); } -void Logger::logOOC(AOClient* client, AOPacket* packet) +void Logger::logOOC(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, const QString& f_message_r) { - QString message = packet->contents[1]; - addEntry(buildEntry(client, "OOC", message)); + addEntry(f_areaName_r, f_charName_r, f_ipid_r, "OOC", f_message_r); } -void Logger::logModcall(AOClient* client, AOPacket* packet) +void Logger::logModcall(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, const QString& f_modcallReason_r) { - QString message = packet->contents[0]; - addEntry(buildEntry(client, "MODCALL", message)); + addEntry(f_areaName_r, f_charName_r, f_ipid_r, "MODCALL", f_modcallReason_r); } -void Logger::logCmd(AOClient *client, AOPacket *packet, QString cmd, QStringList args) +void Logger::logCmd(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, + const QString& f_oocMessage_r, const QString& f_cmd_r, const QStringList& f_cmdArgs_r) { // Some commands contain sensitive data, like passwords // These must be filtered out - if (cmd == "login") { - addEntry(buildEntry(client, "LOGIN", "Attempted login")); + if (f_cmd_r == "login") { + addEntry(f_areaName_r, f_charName_r, f_ipid_r, "LOGIN", "Attempted login"); } - else if (cmd == "rootpass") { - addEntry(buildEntry(client, "USERS", "Root password created")); + else if (f_cmd_r == "rootpass") { + addEntry(f_areaName_r, f_charName_r, f_ipid_r, "USERS", "Root password created"); } - else if (cmd == "adduser" && !args.isEmpty()) { - addEntry(buildEntry(client, "USERS", "Added user " + args[0])); + else if (f_cmd_r == "adduser" && !f_cmdArgs_r.isEmpty()) { + addEntry(f_areaName_r, f_charName_r, f_ipid_r, "USERS", "Added user " + f_cmdArgs_r[0]); + } + else { + logOOC(f_areaName_r, f_charName_r, f_ipid_r, f_oocMessage_r); } - else - logOOC(client, packet); } -void Logger::logLogin(AOClient *client, bool success, QString modname) +void Logger::logLogin(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, bool success, const QString& f_modname_r) { - QString message = success ? "Logged in as " + modname : "Failed to log in as " + modname; - addEntry(buildEntry(client, "LOGIN", message)); + QString l_message = success ? "Logged in as " + f_modname_r : "Failed to log in as " + f_modname_r; + addEntry(f_areaName_r, f_charName_r, f_ipid_r, "LOGIN", l_message); } -QString Logger::buildEntry(AOClient *client, QString type, QString message) +void Logger::addEntry( + const QString& f_areaName_r, + const QString& f_charName_r, + const QString& f_ipid_r, + const QString& f_type_r, + const QString& f_message_r) { - QString time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss"); - QString area_name = area->name; - QString char_name = client->current_char; - QString ipid = client->getIpid(); + QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss"); - QString log_entry = QStringLiteral("[%1][%2][%6] %3(%4): %5\n") - .arg(time) - .arg(area_name) - .arg(char_name) - .arg(ipid) - .arg(message) - .arg(type); - return log_entry; -} + QString l_logEntry = QStringLiteral("[%1][%2][%6] %3(%4): %5\n") + .arg(l_time, f_areaName_r, f_charName_r, f_ipid_r, f_message_r, f_type_r); -void Logger::addEntry(QString entry) -{ - if (buffer.length() < max_length) { - buffer.enqueue(entry); - if (area->log_type == "full") { - flush(); + if (m_buffer.length() < m_maxLength) { + m_buffer.enqueue(l_logEntry); + + if (m_logType == "full") { + flush(f_areaName_r); } } else { - buffer.dequeue(); - buffer.enqueue(entry); + m_buffer.dequeue(); + m_buffer.enqueue(l_logEntry); } } -void Logger::flush() +void Logger::flush(const QString& f_areaName_r) { - QDir dir("logs/"); - if (!dir.exists()) { - dir.mkpath("."); + QDir l_dir("logs/"); + if (!l_dir.exists()) { + l_dir.mkpath("."); } - QFile logfile; - if (area->log_type == "modcall") { - logfile.setFileName(QString("logs/report_%1_%2.log").arg((area->name), (QDateTime::currentDateTime().toString("yyyy-MM-dd_hhmmss")))); + QFile l_logfile; + + if (m_logType == "modcall") { + l_logfile.setFileName(QString("logs/report_%1_%2.log").arg(f_areaName_r, (QDateTime::currentDateTime().toString("yyyy-MM-dd_hhmmss")))); } - else if (area->log_type == "full") { - logfile.setFileName(QString("logs/%1.log").arg(QDate::currentDate().toString("yyyy-MM-dd"))); + else if (m_logType == "full") { + l_logfile.setFileName(QString("logs/%1.log").arg(QDate::currentDate().toString("yyyy-MM-dd"))); } else { qCritical("Invalid logger set!"); } - if (logfile.open(QIODevice::WriteOnly | QIODevice::Append)) { - QTextStream file_stream(&logfile); - while (!buffer.isEmpty()) - file_stream << buffer.dequeue(); - } - logfile.close(); + + if (l_logfile.open(QIODevice::WriteOnly | QIODevice::Append)) { + QTextStream file_stream(&l_logfile); + + while (!m_buffer.isEmpty()) + file_stream << m_buffer.dequeue(); + } + + l_logfile.close(); } diff --git a/core/src/packets.cpp b/core/src/packets.cpp index 10f25c7..9fec53d 100644 --- a/core/src/packets.cpp +++ b/core/src/packets.cpp @@ -96,19 +96,19 @@ void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPack } server->player_count++; - area->player_count++; + area->m_playerCount++; joined = true; server->updateCharsTaken(area); arup(ARUPType::PLAYER_COUNT, true); // Tell everyone there is a new player sendEvidenceList(area); - sendPacket("HP", {"1", QString::number(area->def_hp)}); - sendPacket("HP", {"2", QString::number(area->pro_hp)}); + sendPacket("HP", {"1", QString::number(area->m_defHP)}); + sendPacket("HP", {"2", QString::number(area->m_proHP)}); sendPacket("FA", server->area_names); sendPacket("OPPASS", {"DEADBEEF"}); sendPacket("DONE"); - sendPacket("BN", {area->background}); + sendPacket("BN", {area->m_background}); sendServerMessage("=== MOTD ===\r\n" + server->MOTD + "\r\n============="); @@ -120,8 +120,8 @@ void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPack else { sendPacket("TI", {"0", "3"}); } - for (QTimer* timer : area->timers) { - int timer_id = area->timers.indexOf(timer) + 1; + for (QTimer* timer : area->m_timer) { + int timer_id = area->m_timer.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())))}); @@ -164,10 +164,10 @@ void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket pa if (pos != "") validated_packet.contents[5] = pos; - area->logger->logIC(this, &validated_packet); + area->m_logger->logIC(this, &validated_packet); server->broadcast(validated_packet, current_area); - area->last_ic_message.clear(); - area->last_ic_message.append(validated_packet.contents); + area->m_lastICMessage.clear(); + area->m_lastICMessage.append(validated_packet.contents); } void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket packet) @@ -196,12 +196,12 @@ void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket p command = command.right(command.length() - 1); cmd_argv.removeFirst(); int cmd_argc = cmd_argv.length(); - area->logger->logCmd(this, &final_packet, command, cmd_argv); + area->m_logger->logCmd(this, &final_packet, command, cmd_argv); handleCommand(command, cmd_argc, cmd_argv); } else { server->broadcast(final_packet, current_area); - area->logger->logOOC(this, &final_packet); + area->m_logger->logOOC(this, &final_packet); } } @@ -230,7 +230,7 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack sendServerMessage("You are blocked from changing the music."); return; } - if (!area->toggle_music && !checkAuth(ACLFlags.value("CM"))) { + if (!area->m_toggleMusic && !checkAuth(ACLFlags.value("CM"))) { sendServerMessage("Music is disabled in this area."); return; } @@ -245,8 +245,8 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack else final_song = argument; AOPacket music_change("MC", {final_song, argv[1], showname, "1", "0", effects}); - area->current_music = final_song; - area->music_played_by = showname; + area->m_currentMusic = final_song; + area->m_musicPlayerBy = showname; server->broadcast(music_change, current_area); return; } @@ -281,13 +281,13 @@ void AOClient::pktHpBar(AreaData* area, int argc, QStringList argv, AOPacket pac return; } if (argv[0] == "1") { - area->def_hp = std::min(std::max(0, argv[1].toInt()), 10); + area->m_defHP = std::min(std::max(0, argv[1].toInt()), 10); } else if (argv[0] == "2") { - area->pro_hp = std::min(std::max(0, argv[1].toInt()), 10); + area->m_proHP = std::min(std::max(0, argv[1].toInt()), 10); } - server->broadcast(AOPacket("HP", {"1", QString::number(area->def_hp)}), area->index); - server->broadcast(AOPacket("HP", {"2", QString::number(area->pro_hp)}), area->index); + server->broadcast(AOPacket("HP", {"1", QString::number(area->m_defHP)}), area->m_index); + server->broadcast(AOPacket("HP", {"2", QString::number(area->m_proHP)}), area->m_index); updateJudgeLog(area, this, "updated the penalties"); } @@ -326,8 +326,8 @@ void AOClient::pktModCall(AreaData* area, int argc, QStringList argv, AOPacket p if (client->authenticated) client->sendPacket(packet); } - area->logger->logModcall(this, &packet); - area->logger->flush(); + area->m_logger->logModcall(this, &packet); + area->m_logger->flush(); } void AOClient::pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet) @@ -335,7 +335,7 @@ void AOClient::pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPack if (!checkEvidenceAccess(area)) return; AreaData::Evidence evi = {argv[0], argv[1], argv[2]}; - area->evidence.append(evi); + area->m_evidence.append(evi); sendEvidenceList(area); } @@ -345,8 +345,8 @@ void AOClient::pktRemoveEvidence(AreaData* area, int argc, QStringList argv, AOP return; bool is_int = false; int idx = argv[0].toInt(&is_int); - if (is_int && idx <= area->evidence.size() && idx >= 0) { - area->evidence.removeAt(idx); + if (is_int && idx <= area->m_evidence.size() && idx >= 0) { + area->m_evidence.removeAt(idx); } sendEvidenceList(area); } @@ -358,8 +358,8 @@ void AOClient::pktEditEvidence(AreaData* area, int argc, QStringList argv, AOPac 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->evidence.replace(idx, evi); + if (is_int && idx <= area->m_evidence.size() && idx >= 0) { + area->m_evidence.replace(idx, evi); } sendEvidenceList(area); } @@ -430,8 +430,8 @@ void AOClient::updateEvidenceList(AreaData* area) QStringList evidence_list; QString evidence_format("%1&%2&%3"); - for (AreaData::Evidence evidence : area->evidence) { - if (!checkAuth(ACLFlags.value("CM")) && area->evi_mod == AreaData::EvidenceMod::HIDDEN_CM) { + for (AreaData::Evidence evidence : area->m_evidence) { + if (!checkAuth(ACLFlags.value("CM")) && area->m_eviMod == AreaData::EvidenceMod::HIDDEN_CM) { QRegularExpression regex(""); QRegularExpressionMatch match = regex.match(evidence.description); if (match.hasMatch()) { @@ -466,7 +466,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) // Spectators cannot use IC return invalid; AreaData* area = server->areas[current_area]; - if (area->locked == AreaData::LockStatus::SPECTATABLE && !area->invited.contains(id)) + if (area->m_locked == AreaData::LockStatus::SPECTATABLE && !area->m_invited.contains(id)) // Non-invited players cannot speak in spectatable areas return invalid; @@ -491,7 +491,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) if (current_char != incoming_args[2].toString()) { // Selected char is different from supplied folder name // This means the user is INI-swapped - if (!area->iniswap_allowed) { + if (!area->m_iniswapAllowed) { if (!server->characters.contains(incoming_args[2].toString())) return invalid; } @@ -509,12 +509,12 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) return invalid; QString incoming_msg = dezalgo(incoming_args[4].toString().trimmed()); - if (!area->last_ic_message.isEmpty() - && incoming_msg == area->last_ic_message[4] + if (!area->m_lastICMessage.isEmpty() + && incoming_msg == area->m_lastICMessage[4] && incoming_msg != "") return invalid; - if (incoming_msg == "" && area->blankposting_allowed == false) { + if (incoming_msg == "" && area->m_blankpostingAllowed == false) { sendServerMessage("Blankposting has been forbidden in this area."); return invalid; } @@ -587,7 +587,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) // evidence int evi_idx = incoming_args[11].toInt(); - if (evi_idx > area->evidence.length()) + if (evi_idx > area->m_evidence.length()) return invalid; args.append(QString::number(evi_idx)); @@ -614,7 +614,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) if (incoming_args.length() > 15) { // showname QString incoming_showname = dezalgo(incoming_args[15].toString().trimmed()); - if (!(incoming_showname == current_char || incoming_showname.isEmpty()) && !area->showname_allowed) { + if (!(incoming_showname == current_char || incoming_showname.isEmpty()) && !area->m_shownameAllowed) { sendServerMessage("Shownames are not allowed in this area!"); return invalid; } @@ -680,7 +680,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) // immediate text processing int immediate = incoming_args[18].toInt(); - if (area->force_immediate) + if (area->m_forceImmediate) immediate = 1; if (immediate != 1 && immediate != 0) return invalid; @@ -714,10 +714,10 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) int additive = incoming_args[24].toInt(); if (additive != 0 && additive != 1) return invalid; - else if (area->last_ic_message.isEmpty()){ + else if (area->m_lastICMessage.isEmpty()){ additive = 0; } - else if (!(char_id == area->last_ic_message[8].toInt())) { + else if (!(char_id == area->m_lastICMessage[8].toInt())) { additive = 0; } else if (additive == 1) { @@ -730,29 +730,29 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) } //Testimony playback - if (area->test_rec == AreaData::TestimonyRecording::RECORDING || area->test_rec == AreaData::TestimonyRecording::ADD) { + if (area->m_testimonyRecording == AreaData::TestimonyRecording::RECORDING || area->m_testimonyRecording == AreaData::TestimonyRecording::ADD) { if (args[5] != "wit") return AOPacket("MS", args); - if (area->statement == -1) { + if (area->m_statement == -1) { args[4] = "~~\\n-- " + args[4] + " --"; args[14] = "3"; server->broadcast(AOPacket("RT",{"testimony1"}), current_area); } addStatement(args); } - else if (area->test_rec == AreaData::TestimonyRecording::UPDATE) { + else if (area->m_testimonyRecording == AreaData::TestimonyRecording::UPDATE) { args = updateStatement(args); } - else if (area->test_rec == AreaData::TestimonyRecording::PLAYBACK) { + else if (area->m_testimonyRecording == AreaData::TestimonyRecording::PLAYBACK) { if (args[4] == ">") { pos = "wit"; - area->statement = area->statement + 1; + area->m_statement = area->m_statement + 1; args = playTestimony(); } if (args[4] == "<") { pos = "wit"; - area->statement = area->statement - 1; + area->m_statement = area->m_statement - 1; args = playTestimony(); } QString decoded_message = decodeMessage(args[4]); //Get rid of that pesky encoding first. @@ -760,7 +760,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) QRegularExpressionMatch match = jump.match(decoded_message); if (match.hasMatch()) { pos = "wit"; - area->statement = match.captured("int").toInt(); + area->m_statement = match.captured("int").toInt(); args= playTestimony(); } } @@ -777,7 +777,7 @@ QString AOClient::dezalgo(QString p_text) bool AOClient::checkEvidenceAccess(AreaData *area) { - switch(area->evi_mod) { + switch(area->m_eviMod) { case AreaData::EvidenceMod::FFA: return true; case AreaData::EvidenceMod::CM: @@ -798,12 +798,12 @@ void AOClient::updateJudgeLog(AreaData* area, AOClient* client, QString action) QString ipid = client->getIpid(); QString message = action; QString logmessage = QString("[%1]: [%2] %3 (%4) %5").arg(timestamp, uid, char_name, ipid, message); - int size = area->judgelog.size(); + int size = area->m_judgelog.size(); if (size == 10) { - area->judgelog.removeFirst(); - area->judgelog.append(logmessage); + area->m_judgelog.removeFirst(); + area->m_judgelog.append(logmessage); } - else area->judgelog.append(logmessage); + else area->m_judgelog.append(logmessage); } QString AOClient::decodeMessage(QString incoming_message) diff --git a/core/src/server.cpp b/core/src/server.cpp index 727a71b..71b8c29 100644 --- a/core/src/server.cpp +++ b/core/src/server.cpp @@ -160,7 +160,7 @@ void Server::updateCharsTaken(AreaData* area) { QStringList chars_taken; for (QString cur_char : characters) { - chars_taken.append(area->characters_taken.contains(getCharID(cur_char)) + chars_taken.append(area->m_charactersTaken.contains(getCharID(cur_char)) ? QStringLiteral("-1") : QStringLiteral("0")); } @@ -168,7 +168,7 @@ void Server::updateCharsTaken(AreaData* area) AOPacket response_cc("CharsCheck", chars_taken); for (AOClient* client : clients) { - if (client->current_area == area->index){ + if (client->current_area == area->m_index){ if (!client->is_charcursed) client->sendPacket(response_cc); else { diff --git a/core/src/testimony_recorder.cpp b/core/src/testimony_recorder.cpp index 312ebf9..12b83bf 100644 --- a/core/src/testimony_recorder.cpp +++ b/core/src/testimony_recorder.cpp @@ -22,30 +22,30 @@ void AOClient::addStatement(QStringList packet) { AreaData* area = server->areas[current_area]; - int c_statement = area->statement; + int c_statement = area->m_statement; if (c_statement >= -1) { - if (area->test_rec == AreaData::TestimonyRecording::RECORDING) { + if (area->m_testimonyRecording == AreaData::TestimonyRecording::RECORDING) { if (c_statement <= server->maximum_statements) { if (c_statement == -1) packet[14] = "3"; else packet[14] = "1"; - area->statement = c_statement + 1; - area->testimony.append(packet); + area->m_statement = c_statement + 1; + area->m_testimony.append(packet); return; } else { sendServerMessage("Unable to add more statements. The maximum amount of statements has been reached."); } } - else if (area->test_rec == AreaData::TestimonyRecording::ADD) { + else if (area->m_testimonyRecording == AreaData::TestimonyRecording::ADD) { packet[14] = "1"; - area->testimony.insert(c_statement,packet); - area->test_rec = AreaData::TestimonyRecording::PLAYBACK; + area->m_testimony.insert(c_statement,packet); + area->m_testimonyRecording = AreaData::TestimonyRecording::PLAYBACK; } else { sendServerMessage("Unable to add more statements. The maximum amount of statements has been reached."); - area->test_rec = AreaData::TestimonyRecording::PLAYBACK; + area->m_testimonyRecording = AreaData::TestimonyRecording::PLAYBACK; } } } @@ -53,15 +53,15 @@ void AOClient::addStatement(QStringList packet) QStringList AOClient::updateStatement(QStringList packet) { AreaData* area = server->areas[current_area]; - int c_statement = area->statement; - area->test_rec = AreaData::TestimonyRecording::PLAYBACK; - if (c_statement <= 0 || area->testimony[c_statement].empty()) + int c_statement = area->m_statement; + area->m_testimonyRecording = AreaData::TestimonyRecording::PLAYBACK; + if (c_statement <= 0 || area->m_testimony[c_statement].empty()) sendServerMessage("Unable to update an empty statement. Please use /addtestimony."); else { packet[14] = "1"; - area->testimony.replace(c_statement, packet); + area->m_testimony.replace(c_statement, packet); sendServerMessage("Updated current statement."); - return area->testimony[c_statement]; + return area->m_testimony[c_statement]; } return packet; } @@ -69,28 +69,28 @@ QStringList AOClient::updateStatement(QStringList packet) void AOClient::clearTestimony() { AreaData* area = server->areas[current_area]; - area->test_rec = AreaData::TestimonyRecording::STOPPED; - area->statement = -1; - area->testimony.clear(); //!< Empty out the QVector - area->testimony.squeeze(); //!< Release memory. Good idea? God knows, I do not. + area->m_testimonyRecording = AreaData::TestimonyRecording::STOPPED; + area->m_statement = -1; + area->m_testimony.clear(); //!< Empty out the QVector + area->m_testimony.squeeze(); //!< Release memory. Good idea? God knows, I do not. } QStringList AOClient::playTestimony() { AreaData* area = server->areas[current_area]; - int c_statement = area->statement; - if (c_statement > area->testimony.size() - 1) { + int c_statement = area->m_statement; + if (c_statement > area->m_testimony.size() - 1) { sendServerMessageArea("Last statement reached. Looping to first statement."); - area->statement = 1; - return area->testimony[area->statement]; + area->m_statement = 1; + return area->m_testimony[area->m_statement]; } if (c_statement <= 0) { sendServerMessage("First statement reached."); - area->statement = 1; - return area->testimony[area->statement = 1]; + area->m_statement = 1; + return area->m_testimony[area->m_statement = 1]; } else { - return area->testimony[c_statement]; + return area->m_testimony[c_statement]; } }