From 243caf4292ddad6f52f3488d0ae9d17d8213601c Mon Sep 17 00:00:00 2001 From: Cerapter Date: Sat, 13 Mar 2021 16:35:58 +0100 Subject: [PATCH] Add docuumentation to AreaData Also patch up a few errors with the ConfigManager documentation. --- include/area_data.h | 211 +++++++++++++++++++++++++++++++++++++-- include/config_manager.h | 2 +- src/area_data.cpp | 18 ++-- src/config_manager.cpp | 4 +- 4 files changed, 213 insertions(+), 22 deletions(-) diff --git a/include/area_data.h b/include/area_data.h index a70553a..9a196ef 100644 --- a/include/area_data.h +++ b/include/area_data.h @@ -28,58 +28,251 @@ #include class Logger; + +/** + * @brief Represents an area on the server, a distinct "room" for people to chat in. + */ class AreaData : public QObject { Q_OBJECT public: + + /** + * @brief Creates an area. + * + * @param p_characters A list of characters that may be selected in the area. + * @param p_name The name of the area. + * @param p_index The index of the area. + */ AreaData(QStringList p_characters, QString p_name, int p_index); + /** + * @brief The data for evidence in the area. + */ struct Evidence { - QString name; - QString description; - QString image; + QString name; //!< The name of the evidence, shown when hovered over clientside. + QString description; //!< The longer description of the evidence, when the user opens the evidence window. + 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 map of characters' names and whether they are taken or not. + * + * @details The key for the map the given characters' internal names (i.e., the name of their directory + * in `base/characters/` clientside), while the values are true if they are already taken in the area, + * false if not. + */ QMap 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. + * + * @details This is purely aesthetic, and serves no functional purpose from a gameplay perspective. + * It's only benefit is giving the users a rough idea as to what is going on in an area. + */ enum Status { - IDLE, - RP, - CASING, - LOOKING_FOR_PLAYERS, - RECESS, - GAMING + IDLE, //!< The area is currently not busy with anything, or the area is empty. + RP, //!< There is some (non-Ace Attorney-related) roleplay going on in the area. + CASING, //!< An Ace Attorney or Danganronpa-styled case is currently being held in the area. + LOOKING_FOR_PLAYERS, //!< Something is being planned in the area, but it needs more players. + RECESS, //!< The area is currently taking a break from casing, but will continue later. + GAMING //!< The users inside the area are playing some game outside of AO, and are using the area to communicate. }; + 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. + */ enum LockStatus { FREE, LOCKED, SPECTATABLE }; + + /** + * @var LockStatus FREE + * Anyone may enter the area, and there are no restrictions on communicating in-character. + */ + + /** + * @var LockStatus LOCKED + * Only invited clients may enter the area, but those who are invited are free to communicate in-character. + * + * When an area transitions from FREE to LOCKED, anyone present in the area + * at the time of the transition is considered invited. + */ + + /** + * @var LockStatus SPECTATABLE + * Anyone may enter the area, but only invited clients may communicate in-character. + * + * When an area transitions from FREE to SPECTATABLE, anyone present in the area + * at the time of the transition is considered invited. + */ + 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, 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. + */ enum EvidenceMod{ FFA, MOD, CM, HIDDEN_CM }; + + /** + * @var EvidenceMod FFA + * "Free-for-all" -- anyone can add, remove or modify evidence. + */ + + /** + * @var EvidenceMod MOD + * Only mods can add, remove or modify evidence. + */ + + /** + * @var EvidenceMod CM + * Only Case Makers and Mods can add, remove or modify evidence. + */ + + /** + * @var EvidenceMod HIDDEN_CM + * Only Case Makers and Mods can add, remove or modify evidence. + * + * CMs can also hide evidence from various sides by putting `` into the evidence's description, + * 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; }; diff --git a/include/config_manager.h b/include/config_manager.h index 052598b..d13d359 100644 --- a/include/config_manager.h +++ b/include/config_manager.h @@ -74,7 +74,7 @@ class ConfigManager { /** * @brief Loads the server settings into the given struct from the config file. * - * @param[out] settings Pointer to a #server_settings file to be filled with data. + * @param[out] settings Pointer to a server_settings file to be filled with data. * * @return False if any of the ports (the master server connection port, * the TCP port used by clients, or the WebSocket port used by WebAO) failed diff --git a/src/area_data.cpp b/src/area_data.cpp index c85ea25..2d4893c 100644 --- a/src/area_data.cpp +++ b/src/area_data.cpp @@ -17,10 +17,16 @@ ////////////////////////////////////////////////////////////////////////////////////// #include "include/area_data.h" -AreaData::AreaData(QStringList characters, QString p_name, int p_index) +AreaData::AreaData(QStringList characters, QString p_name, int p_index) : + name(p_name), + index(p_index), + player_count(0), + status(IDLE), + locked(FREE), + document("No document."), + def_hp(10), + pro_hp(10) { - name = p_name; - index = p_index; for (QString cur_char : characters) { characters_taken.insert(cur_char, false); } @@ -32,12 +38,6 @@ AreaData::AreaData(QStringList characters, QString p_name, int p_index) bg_locked = areas_ini.value("bg_locked", "false").toBool(); QString configured_evi_mod = areas_ini.value("evidence_mod", "FFA").toString().toLower(); areas_ini.endGroup(); - player_count = 0; - locked = FREE; - status = IDLE; - def_hp = 10; - pro_hp = 10; - document = "No document."; QSettings config_ini("config/config.ini", QSettings::IniFormat); config_ini.beginGroup("Options"); int log_size = config_ini.value("logbuffer", 50).toInt(); diff --git a/src/config_manager.cpp b/src/config_manager.cpp index 7f0f93a..57f5f7f 100644 --- a/src/config_manager.cpp +++ b/src/config_manager.cpp @@ -17,8 +17,6 @@ ////////////////////////////////////////////////////////////////////////////////////// #include "include/config_manager.h" -ConfigManager::ConfigManager() { } - // Validate and set up the config bool ConfigManager::initConfig() { @@ -145,7 +143,7 @@ bool ConfigManager::loadServerSettings(server_settings* settings) settings->description = config.value("server_description", "This is my flashy new server") .toString(); - settings->zalgo_tolerance = + settings->zalgo_tolerance = config.value("zalgo_tolerance", "3").toInt(&zalgo_tolerance_conversion_success); config.endGroup(); if (!port_conversion_success || !ws_port_conversion_success ||