diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..f0b9f11
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,21 @@
+AllowShortBlocksOnASingleLine: Empty
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortEnumsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: All
+BreakBeforeBraces: Custom
+BreakConstructorInitializers: AfterColon
+BraceWrapping:
+ AfterCaseLabel: true
+ AfterClass: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterStruct: true
+ AfterExternBlock: true
+ BeforeElse: true
+ SplitEmptyFunction: false
+ColumnLimit: 0
+EmptyLineAfterAccessModifier: Never
+EmptyLineBeforeAccessModifier: Always
+FixNamespaceComments: false
+IndentWidth: 4
+PackConstructorInitializers: CurrentLine
diff --git a/akashi/main.cpp b/akashi/main.cpp
index 4b9ecc0..dbf02ad 100644
--- a/akashi/main.cpp
+++ b/akashi/main.cpp
@@ -15,21 +15,22 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see . //
//////////////////////////////////////////////////////////////////////////////////////
-#include
#include
+#include
#include
#include
#include
-Server* server;
+Server *server;
-void cleanup() {
+void cleanup()
+{
server->deleteLater();
}
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QCoreApplication::setApplicationName("akashi");
diff --git a/core/core.pro b/core/core.pro
index 1dfddf8..650e51a 100644
--- a/core/core.pro
+++ b/core/core.pro
@@ -58,6 +58,7 @@ HEADERS += include/aoclient.h \
include/db_manager.h \
include/discord.h \
include/server.h \
+ include/typedefs.h \
include/ws_client.h \
include/ws_proxy.h \
include/advertiser.h \
diff --git a/core/include/advertiser.h b/core/include/advertiser.h
index 63e7d99..e95a37f 100644
--- a/core/include/advertiser.h
+++ b/core/include/advertiser.h
@@ -18,9 +18,8 @@
#ifndef ADVERTISER_H
#define ADVERTISER_H
-#include
#include
-#include "include/config_manager.h"
+#include
/**
* @brief Represents the advertiser of the server. Sends current server information to masterserver.
@@ -28,19 +27,19 @@
class Advertiser : public QObject
{
Q_OBJECT
-public:
+
+ public:
/**
* @brief Constructor for the HTTP_Advertiser class.
*/
explicit Advertiser();
-
/**
* @brief Deconstructor for the HTTP_Advertiser class. Yes, that's it. Can't say more about it.
*/
~Advertiser();
-public slots:
+ public slots:
/**
* @brief Establishes a connection with masterserver to register or update the listing on the masterserver.
@@ -63,12 +62,11 @@ public slots:
*/
void updateAdvertiserSettings();
-private:
-
+ private:
/**
* @brief Pointer to the network manager, necessary to execute POST requests to the masterserver.
*/
- QNetworkAccessManager* m_manager;
+ QNetworkAccessManager *m_manager;
/**
* @brief Name of the server send to the masterserver. Changing this will change the display name in the serverlist
diff --git a/core/include/aoclient.h b/core/include/aoclient.h
index 5ce0cc4..f9245d4 100644
--- a/core/include/aoclient.h
+++ b/core/include/aoclient.h
@@ -18,30 +18,32 @@
#ifndef AOCLIENT_H
#define AOCLIENT_H
-#include "include/aopacket.h"
-#include "include/server.h"
-#include "include/area_data.h"
-#include "include/db_manager.h"
-#include "include/music_manager.h"
-
#include
-#include
-#include
#include
+#include
#include
+#include
#include
+#include
#if QT_VERSION > QT_VERSION_CHECK(5, 10, 0)
#include
#endif
+#include "include/aopacket.h"
+
+class AreaData;
+class DBManager;
+class MusicManager;
class Server;
/**
* @brief Represents a client connected to the server running Attorney Online 2 or one of its derivatives.
*/
-class AOClient : public QObject {
+class AOClient : public QObject
+{
Q_OBJECT
+
public:
/**
* @brief Creates an instance of the AOClient class.
@@ -51,13 +53,13 @@ class AOClient : public QObject {
* @param user_id The user ID of the client.
* @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, MusicManager* p_manager = nullptr);;
+ AOClient(Server *p_server, QTcpSocket *p_socket, QObject *parent = nullptr, int user_id = 0, MusicManager *p_manager = nullptr);
/**
- * @brief Destructor for the AOClient instance.
- *
- * @details Sets the socket to delete later.
- */
+ * @brief Destructor for the AOClient instance.
+ *
+ * @details Sets the socket to delete later.
+ */
~AOClient();
/**
@@ -78,6 +80,13 @@ class AOClient : public QObject {
*/
QString getHwid() const;
+ /**
+ * @brief Returns true if the client has completed the participation handshake. False otherwise.
+ *
+ * @return True if the client has completed the participation handshake. False otherwise.
+ */
+ bool hasJoined() const;
+
/**
* @brief Calculates the client's IPID based on a hashed version of its IP.
*/
@@ -92,7 +101,7 @@ class AOClient : public QObject {
*
* @see #server
*/
- Server* getServer();
+ Server *getServer();
/**
* @brief The user ID of the client.
@@ -175,33 +184,34 @@ class AOClient : public QObject {
* @brief If true, the client may not use in-character chat.
*/
bool m_is_muted = false;
-
+
/**
* @brief If true, the client may not use out-of-character chat.
*/
bool m_is_ooc_muted = false;
-
+
/**
* @brief If true, the client may not use the music list.
*/
bool m_is_dj_blocked = false;
-
+
/**
* @brief If true, the client may not use the judge controls.
*/
bool m_is_wtce_blocked = false;
-
+
/**
* @brief Represents the client's client software, and its version.
*
* @note Though the version number and naming scheme looks vaguely semver-like,
* do not be misled into thinking it is that.
*/
- struct ClientVersion {
- QString string; //!< The name of the client software, for example, `AO2`.
- int release = -1; //!< The 'release' part of the version number. In Attorney Online's case, this is fixed at `2`.
- int major = -1; //!< The 'major' part of the version number. In Attorney Online's case, this increases when a new feature is introduced (generally).
- int minor = -1; //!< The 'minor' part of the version number. In Attorney Online's case, this increases for bugfix releases (generally).
+ struct ClientVersion
+ {
+ QString string; //!< The name of the client software, for example, `AO2`.
+ int release = -1; //!< The 'release' part of the version number. In Attorney Online's case, this is fixed at `2`.
+ int major = -1; //!< The 'major' part of the version number. In Attorney Online's case, this increases when a new feature is introduced (generally).
+ int minor = -1; //!< The 'minor' part of the version number. In Attorney Online's case, this increases for bugfix releases (generally).
};
/**
@@ -212,33 +222,31 @@ class AOClient : public QObject {
ClientVersion m_version;
/**
- * @brief The authorisation bitflag, representing what permissions a client can have.
- *
- * @showinitializer
- */
- QMap ACLFlags {
- {"NONE", 0ULL },
- {"KICK", 1ULL << 0 },
- {"BAN", 1ULL << 1 },
- {"BGLOCK", 1ULL << 2 },
- {"MODIFY_USERS", 1ULL << 3 },
- {"CM", 1ULL << 4 },
- {"GLOBAL_TIMER", 1ULL << 5 },
- {"EVI_MOD", 1ULL << 6 },
- {"MOTD", 1ULL << 7 },
- {"ANNOUNCE", 1ULL << 8 },
- {"MODCHAT", 1ULL << 9 },
- {"MUTE", 1ULL << 10},
- {"UNCM", 1ULL << 11},
- {"SAVETEST", 1ULL << 12},
- {"FORCE_CHARSELECT",1ULL << 13},
- {"BYPASS_LOCKS", 1ULL << 14},
- {"IGNORE_BGLIST", 1ULL << 15},
- {"SEND_NOTICE", 1ULL << 16},
- {"JUKEBOX", 1ULL << 17},
- {"SUPER", ~0ULL }
- };
-
+ * @brief The authorisation bitflag, representing what permissions a client can have.
+ *
+ * @showinitializer
+ */
+ QMap ACLFlags{
+ {"NONE", 0ULL},
+ {"KICK", 1ULL << 0},
+ {"BAN", 1ULL << 1},
+ {"BGLOCK", 1ULL << 2},
+ {"MODIFY_USERS", 1ULL << 3},
+ {"CM", 1ULL << 4},
+ {"GLOBAL_TIMER", 1ULL << 5},
+ {"EVI_MOD", 1ULL << 6},
+ {"MOTD", 1ULL << 7},
+ {"ANNOUNCE", 1ULL << 8},
+ {"MODCHAT", 1ULL << 9},
+ {"MUTE", 1ULL << 10},
+ {"UNCM", 1ULL << 11},
+ {"SAVETEST", 1ULL << 12},
+ {"FORCE_CHARSELECT", 1ULL << 13},
+ {"BYPASS_LOCKS", 1ULL << 14},
+ {"IGNORE_BGLIST", 1ULL << 15},
+ {"SEND_NOTICE", 1ULL << 16},
+ {"JUKEBOX", 1ULL << 17},
+ {"SUPER", ~0ULL}};
/**
* @brief A list of 5 casing preferences (def, pro, judge, jury, steno)
@@ -284,7 +292,7 @@ class AOClient : public QObject {
/**
* @brief Timer for tracking user interaction. Automatically restarted whenever a user interacts (i.e. sends any packet besides CH)
*/
- QTimer* m_afk_timer;
+ QTimer *m_afk_timer;
/**
* @brief The list of char IDs a charcursed player is allowed to switch to.
@@ -344,25 +352,32 @@ class AOClient : public QObject {
*/
void onAfkTimeout();
+ signals:
+ /**
+ * @brief This signal is emitted when the client has completed the participation handshake.
+ */
+ void joined();
+
private:
/**
* @brief The TCP socket used to communicate with the client.
*/
- QTcpSocket* m_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).
*/
- Server* server;
+ Server *server;
/**
* @brief The type of area update, used for area update (ARUP) packets.
*/
- enum ARUPType {
+ enum ARUPType
+ {
PLAYER_COUNT, //!< The packet contains player count updates.
- STATUS, //!< The packet contains area status updates.
- CM, //!< The packet contains updates about who's the CM of what area.
- LOCKED //!< The packet contains updates about what areas are locked.
+ STATUS, //!< The packet contains area status updates.
+ CM, //!< The packet contains updates about who's the CM of what area.
+ LOCKED //!< The packet contains updates about what areas are locked.
};
/**
@@ -438,113 +453,112 @@ class AOClient : public QObject {
void sendServerBroadcast(QString message);
/**
- * @name Packet headers
- *
- * @details These functions implement the AO2-style packet handling.
- * As these should generally be the same across server software, I see no reason to document them specifically.
- *
- * You can check out the AO2 network protocol for explanations.
- *
- * All packet handling functions share the same parameters:
- *
- * @param area The area the client is in. Some packets make use of the client's current area.
- * @param argc The amount of arguments in the packet, not counting the header. Same as `argv.size()`.
- * @param argv The arguments in the packet, once again, not counting the header.
- * @param packet The... arguments in the packet. Yes, exactly the same as `argv`, just packed into an AOPacket.
- *
- * @see https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md for the AO2 network protocol.
- */
+ * @name Packet headers
+ *
+ * @details These functions implement the AO2-style packet handling.
+ * As these should generally be the same across server software, I see no reason to document them specifically.
+ *
+ * You can check out the AO2 network protocol for explanations.
+ *
+ * All packet handling functions share the same parameters:
+ *
+ * @param area The area the client is in. Some packets make use of the client's current area.
+ * @param argc The amount of arguments in the packet, not counting the header. Same as `argv.size()`.
+ * @param argv The arguments in the packet, once again, not counting the header.
+ * @param packet The... arguments in the packet. Yes, exactly the same as `argv`, just packed into an AOPacket.
+ *
+ * @see https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md for the AO2 network protocol.
+ */
///@{
/// A "default" packet handler, to be used for error checking and copying other packet handlers.
- void pktDefault(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktDefault(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [hardware ID](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#hard-drive-id).
- void pktHardwareId(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktHardwareId(AreaData *area, int argc, QStringList argv, AOPacket packet);
/**
* @brief Implements [feature list](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#feature-list) and
* [player count](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#player-count).
*/
- void pktSoftwareId(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktSoftwareId(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [resource counts](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#resource-counts).
- void pktBeginLoad(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktBeginLoad(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [character list](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#character-list).
- void pktRequestChars(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktRequestChars(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [music list](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#music-list).
- void pktRequestMusic(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktRequestMusic(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [the final loading confirmation](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#final-confirmation).
- void pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktLoadingDone(AreaData *area, int argc, QStringList argv, AOPacket packet);
/**
- * @brief Implements character passwording. This is not on the netcode documentation as of writing.
- *
- * @todo Link packet details when it gets into the netcode documentation.
- */
- void pktCharPassword(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ * @brief Implements character passwording. This is not on the netcode documentation as of writing.
+ *
+ * @todo Link packet details when it gets into the netcode documentation.
+ */
+ void pktCharPassword(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [character selection](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#choose-character).
- void pktSelectChar(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktSelectChar(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [the in-character messaging hell](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#in-character-message).
- void pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktIcChat(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [out-of-character messages](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#out-of-character-message).
- void pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktOocChat(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [the keepalive packet](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#keep-alive).
- void pktPing(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktPing(AreaData *area, int argc, QStringList argv, AOPacket packet);
/**
- * @brief Implements [music](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#music) and
- * [area changing](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#switch-area).
- */
- void pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPacket packet);
-
+ * @brief Implements [music](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#music) and
+ * [area changing](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#switch-area).
+ */
+ void pktChangeMusic(AreaData *area, int argc, QStringList argv, AOPacket packet);
/**
- * @brief Implements [the witness testimony / cross examination / judge decision popups]
- * (https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#witness-testimonycross-examination-wtce).
- */
- void pktWtCe(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ * @brief Implements [the witness testimony / cross examination / judge decision popups]
+ * (https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#witness-testimonycross-examination-wtce).
+ */
+ void pktWtCe(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [penalty bars](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#penalty-health-bars).
- void pktHpBar(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktHpBar(AreaData *area, int argc, QStringList argv, AOPacket packet);
/**
- * @brief Implements WebSocket IP handling. This is not on the netcode documentation as of writing.
- *
- * @todo Link packet details when it gets into the netcode documentation.
- */
- void pktWebSocketIp(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ * @brief Implements WebSocket IP handling. This is not on the netcode documentation as of writing.
+ *
+ * @todo Link packet details when it gets into the netcode documentation.
+ */
+ void pktWebSocketIp(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [moderator calling](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#call-mod).
- void pktModCall(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktModCall(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [adding evidence](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#add).
- void pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktAddEvidence(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [removing evidence](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#remove).
- void pktRemoveEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktRemoveEvidence(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [editing evidence](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#edit).
- void pktEditEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktEditEvidence(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [updating casing preferences](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#case-preferences-update).
- void pktSetCase(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktSetCase(AreaData *area, int argc, QStringList argv, AOPacket packet);
/// Implements [announcing a case](https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md#case-alert).
- void pktAnnounceCase(AreaData* area, int argc, QStringList argv, AOPacket packet);
+ void pktAnnounceCase(AreaData *area, int argc, QStringList argv, AOPacket packet);
///@}
/**
- * @name Packet helper functions
- */
+ * @name Packet helper functions
+ */
///@{
/**
@@ -552,14 +566,14 @@ class AOClient : public QObject {
*
* @param area The current client's area.
*/
- void sendEvidenceList(AreaData* area);
+ void sendEvidenceList(AreaData *area);
/**
* @brief Updates the evidence list in the area for the client.
*
* @param area The client's area.
*/
- void updateEvidenceList(AreaData* area);
+ void updateEvidenceList(AreaData *area);
/**
* @brief Attempts to validate that hellish abomination that Attorney Online 2 calls an in-character packet.
@@ -588,13 +602,13 @@ class AOClient : public QObject {
*
* @return True if the client can modify the evidence, false if not.
*/
- bool checkEvidenceAccess(AreaData* area);
+ bool checkEvidenceAccess(AreaData *area);
///@}
/**
- * @name Packet helper global variables
- */
+ * @name Packet helper global variables
+ */
///@{
/**
@@ -644,59 +658,60 @@ class AOClient : public QObject {
///@}
/// Describes a packet's interpretation details.
- struct PacketInfo {
+ struct PacketInfo
+ {
unsigned long long acl_mask; //!< The permissions necessary for the packet.
- int minArgs; //!< The minimum arguments needed for the packet to be interpreted correctly / make sense.
- void (AOClient::*action)(AreaData*, int, QStringList, AOPacket);
+ int minArgs; //!< The minimum arguments needed for the packet to be interpreted correctly / make sense.
+ void (AOClient::*action)(AreaData *, int, QStringList, AOPacket);
};
/**
- * @property PacketInfo::action
- *
- * @brief A function reference that contains what the packet actually does.
- *
- * @param AreaData This is always just a reference to the data of the area the sender client is in. Used by some packets.
- * @param int When called, this parameter will be filled with the argument count.
- * @param QStringList When called, this parameter will be filled the list of arguments.
- * @param AOPacket This is a duplicated version of the QStringList above, containing the same data.
- */
+ * @property PacketInfo::action
+ *
+ * @brief A function reference that contains what the packet actually does.
+ *
+ * @param AreaData This is always just a reference to the data of the area the sender client is in. Used by some packets.
+ * @param int When called, this parameter will be filled with the argument count.
+ * @param QStringList When called, this parameter will be filled the list of arguments.
+ * @param AOPacket This is a duplicated version of the QStringList above, containing the same data.
+ */
/**
- * @brief The list of packets that the server can interpret.
- *
- * @showinitializer
- *
- * @tparam QString The header of the packet that uniquely identifies it.
- * @tparam PacketInfo The details of the packet.
- * See @ref PacketInfo "the type's documentation" for more details.
- */
- const QMap packets {
- {"HI", {ACLFlags.value("NONE"), 1, &AOClient::pktHardwareId }},
- {"ID", {ACLFlags.value("NONE"), 2, &AOClient::pktSoftwareId }},
- {"askchaa", {ACLFlags.value("NONE"), 0, &AOClient::pktBeginLoad }},
- {"RC", {ACLFlags.value("NONE"), 0, &AOClient::pktRequestChars }},
- {"RM", {ACLFlags.value("NONE"), 0, &AOClient::pktRequestMusic }},
- {"RD", {ACLFlags.value("NONE"), 0, &AOClient::pktLoadingDone }},
- {"PW", {ACLFlags.value("NONE"), 1, &AOClient::pktCharPassword }},
- {"CC", {ACLFlags.value("NONE"), 3, &AOClient::pktSelectChar }},
- {"MS", {ACLFlags.value("NONE"), 15, &AOClient::pktIcChat }},
- {"CT", {ACLFlags.value("NONE"), 2, &AOClient::pktOocChat }},
- {"CH", {ACLFlags.value("NONE"), 1, &AOClient::pktPing }},
- {"MC", {ACLFlags.value("NONE"), 2, &AOClient::pktChangeMusic }},
- {"RT", {ACLFlags.value("NONE"), 1, &AOClient::pktWtCe }},
- {"HP", {ACLFlags.value("NONE"), 2, &AOClient::pktHpBar }},
- {"WSIP", {ACLFlags.value("NONE"), 1, &AOClient::pktWebSocketIp }},
- {"ZZ", {ACLFlags.value("NONE"), 0, &AOClient::pktModCall }},
- {"PE", {ACLFlags.value("NONE"), 3, &AOClient::pktAddEvidence }},
- {"DE", {ACLFlags.value("NONE"), 1, &AOClient::pktRemoveEvidence }},
- {"EE", {ACLFlags.value("NONE"), 4, &AOClient::pktEditEvidence }},
- {"SETCASE", {ACLFlags.value("NONE"), 7, &AOClient::pktSetCase }},
- {"CASEA", {ACLFlags.value("NONE"), 6, &AOClient::pktAnnounceCase }},
+ * @brief The list of packets that the server can interpret.
+ *
+ * @showinitializer
+ *
+ * @tparam QString The header of the packet that uniquely identifies it.
+ * @tparam PacketInfo The details of the packet.
+ * See @ref PacketInfo "the type's documentation" for more details.
+ */
+ const QMap packets{
+ {"HI", {ACLFlags.value("NONE"), 1, &AOClient::pktHardwareId}},
+ {"ID", {ACLFlags.value("NONE"), 2, &AOClient::pktSoftwareId}},
+ {"askchaa", {ACLFlags.value("NONE"), 0, &AOClient::pktBeginLoad}},
+ {"RC", {ACLFlags.value("NONE"), 0, &AOClient::pktRequestChars}},
+ {"RM", {ACLFlags.value("NONE"), 0, &AOClient::pktRequestMusic}},
+ {"RD", {ACLFlags.value("NONE"), 0, &AOClient::pktLoadingDone}},
+ {"PW", {ACLFlags.value("NONE"), 1, &AOClient::pktCharPassword}},
+ {"CC", {ACLFlags.value("NONE"), 3, &AOClient::pktSelectChar}},
+ {"MS", {ACLFlags.value("NONE"), 15, &AOClient::pktIcChat}},
+ {"CT", {ACLFlags.value("NONE"), 2, &AOClient::pktOocChat}},
+ {"CH", {ACLFlags.value("NONE"), 1, &AOClient::pktPing}},
+ {"MC", {ACLFlags.value("NONE"), 2, &AOClient::pktChangeMusic}},
+ {"RT", {ACLFlags.value("NONE"), 1, &AOClient::pktWtCe}},
+ {"HP", {ACLFlags.value("NONE"), 2, &AOClient::pktHpBar}},
+ {"WSIP", {ACLFlags.value("NONE"), 1, &AOClient::pktWebSocketIp}},
+ {"ZZ", {ACLFlags.value("NONE"), 0, &AOClient::pktModCall}},
+ {"PE", {ACLFlags.value("NONE"), 3, &AOClient::pktAddEvidence}},
+ {"DE", {ACLFlags.value("NONE"), 1, &AOClient::pktRemoveEvidence}},
+ {"EE", {ACLFlags.value("NONE"), 4, &AOClient::pktEditEvidence}},
+ {"SETCASE", {ACLFlags.value("NONE"), 7, &AOClient::pktSetCase}},
+ {"CASEA", {ACLFlags.value("NONE"), 6, &AOClient::pktAnnounceCase}},
};
/**
- * @name Authentication
- */
+ * @name Authentication
+ */
///@{
/**
@@ -806,11 +821,11 @@ class AOClient : public QObject {
///@}
/**
- * @name Areas
- *
- * @brief All functions that detail the actions of commands,
- * that are also related to area management.
- */
+ * @name Areas
+ *
+ * @brief All functions that detail the actions of commands,
+ * that are also related to area management.
+ */
///@{
/**
@@ -961,12 +976,12 @@ class AOClient : public QObject {
void cmdStatus(int argc, QStringList argv);
/**
- * @brief Sends an out-of-character message with the judgelog of an area.
- *
- * @details No arguments.
- *
- * @iscommand
- */
+ * @brief Sends an out-of-character message with the judgelog of an area.
+ *
+ * @details No arguments.
+ *
+ * @iscommand
+ */
void cmdJudgeLog(int argc, QStringList argv);
/**
@@ -1008,11 +1023,11 @@ class AOClient : public QObject {
///@}
/**
- * @name Moderation
- *
- * @brief All functions that detail the actions of commands,
- * that are also related to the moderation and administration of the server.
- */
+ * @name Moderation
+ *
+ * @brief All functions that detail the actions of commands,
+ * that are also related to the moderation and administration of the server.
+ */
///@{
/**
@@ -1064,7 +1079,7 @@ class AOClient : public QObject {
* @brief Bans a client from the server, forcibly severing its connection to the server,
* and disallowing their return.
*
- * @details The first argument is the **target's IPID**, the second is the **duration**,
+ * @details The first argument is the **target's IPID**, the second is the **duration**,
* and the third is the **reason** why the client was banned.
*
* The duration can be `perma`, meaning a forever ban, otherwise, it must be given in the format of `YYyWWwDDdHHhMMmSSs` to
@@ -1135,7 +1150,7 @@ class AOClient : public QObject {
* @see #is_ooc_muted
*/
void cmdOocMute(int argc, QStringList argv);
-
+
/**
* @brief Removes the OOC-muted status from a client.
*
@@ -1146,7 +1161,7 @@ class AOClient : public QObject {
* @see #is_ooc_muted
*/
void cmdOocUnMute(int argc, QStringList argv);
-
+
/**
* @brief WTCE-blocks a client.
*
@@ -1157,7 +1172,7 @@ class AOClient : public QObject {
* @see #is_wtce_blocked
*/
void cmdBlockWtce(int argc, QStringList argv);
-
+
/**
* @brief Removes the WTCE-blocked status from a client.
*
@@ -1168,7 +1183,7 @@ class AOClient : public QObject {
* @see #is_wtce_blocked
*/
void cmdUnBlockWtce(int argc, QStringList argv);
-
+
/**
* @brief Lists the last five bans made on the server.
*
@@ -1178,7 +1193,6 @@ class AOClient : public QObject {
*/
void cmdBans(int argc, QStringList argv);
-
/**
* @brief Toggle whether or not in-character messages purely consisting of spaces are allowed.
*
@@ -1210,31 +1224,31 @@ class AOClient : public QObject {
void cmdReload(int argc, QStringList argv);
/**
- * @brief Toggles immediate text processing in the current area.
- *
- * @details No arguments.
- *
- * @iscommand
- */
+ * @brief Toggles immediate text processing in the current area.
+ *
+ * @details No arguments.
+ *
+ * @iscommand
+ */
void cmdForceImmediate(int argc, QStringList argv);
/**
- * @brief Toggles whether iniswaps are allowed in the current area.
- *
- * @details No arguments.
- *
- * @iscommand
- */
+ * @brief Toggles whether iniswaps are allowed in the current area.
+ *
+ * @details No arguments.
+ *
+ * @iscommand
+ */
void cmdAllowIniswap(int argc, QStringList argv);
/**
- * @brief Grants a client the temporary permission to save a testimony.
- *
- * @details ClientID as the target of permission
- *
- * @iscommand
- *
- */
+ * @brief Grants a client the temporary permission to save a testimony.
+ *
+ * @details ClientID as the target of permission
+ *
+ * @iscommand
+ *
+ */
void cmdPermitSaving(int argc, QStringList argv);
/**
@@ -1298,11 +1312,11 @@ class AOClient : public QObject {
///@}
/**
- * @name Roleplay
- *
- * @brief All functions that detail the actions of commands,
- * that are also related to various kinds of roleplay actions in some way.
- */
+ * @name Roleplay
+ *
+ * @brief All functions that detail the actions of commands,
+ * that are also related to various kinds of roleplay actions in some way.
+ */
///@{
/**
@@ -1365,7 +1379,7 @@ class AOClient : public QObject {
*/
void cmdSubTheme(int argc, QStringList argv);
-
+
/**
* @brief Writes a "note card" in the current area.
*
@@ -1375,14 +1389,14 @@ class AOClient : public QObject {
* @iscommand
*/
void cmdNoteCard(int argc, QStringList argv);
-
+
/**
* @brief Reveals all note cards in the current area.
*
* @iscommand
*/
void cmdNoteCardReveal(int argc, QStringList argv);
-
+
/**
* @brief Erases the client's note card from the area's list of cards.
*
@@ -1400,15 +1414,15 @@ class AOClient : public QObject {
* @iscommand
*/
void cmd8Ball(int argc, QStringList argv);
-
+
///@}
/**
- * @name Messaging
- *
- * @brief All functions that detail the actions of commands,
- * that are also related to messages or the client's self-management in some way.
- */
+ * @name Messaging
+ *
+ * @brief All functions that detail the actions of commands,
+ * that are also related to messages or the client's self-management in some way.
+ */
///@{
/**
@@ -1607,12 +1621,12 @@ class AOClient : public QObject {
void cmdToggleAdverts(int argc, QStringList argv);
/**
- * @brief Toggles whether this client is considered AFK.
- *
- * @details No arguments.
- *
- * @iscommand
- */
+ * @brief Toggles whether this client is considered AFK.
+ *
+ * @details No arguments.
+ *
+ * @iscommand
+ */
void cmdAfk(int argc, QStringList argv);
/**
@@ -1674,11 +1688,11 @@ class AOClient : public QObject {
///@}
/**
- * @name Casing
- *
- * @brief All functions that detail the actions of commands,
- * that are related to casing.
- */
+ * @name Casing
+ *
+ * @brief All functions that detail the actions of commands,
+ * that are related to casing.
+ */
///@{
/**
@@ -1766,7 +1780,6 @@ class AOClient : public QObject {
*/
void cmdAddStatement(int argc, QStringList argv);
-
/**
* @brief Sends a list of the testimony to OOC of the requesting client
*
@@ -1797,11 +1810,11 @@ class AOClient : public QObject {
///@}
/**
- * @name Music
- *
- * @brief All functions that detail the actions of commands,
- * that are also related to music in some way.
- */
+ * @name Music
+ *
+ * @brief All functions that detail the actions of commands,
+ * that are also related to music in some way.
+ */
///@{
/**
@@ -1890,12 +1903,12 @@ class AOClient : public QObject {
///@}
/**
- * @name Command helper functions
- *
- * @brief A collection of functions of shared behaviour between command functions,
- * allowing the abstraction of technical details in the command function definition,
- * or the avoidance of repetition over multiple definitions.
- */
+ * @name Command helper functions
+ *
+ * @brief A collection of functions of shared behaviour between command functions,
+ * allowing the abstraction of technical details in the command function definition,
+ * or the avoidance of repetition over multiple definitions.
+ */
///@{
/**
@@ -2026,7 +2039,6 @@ class AOClient : public QObject {
*/
void sendNotice(QString f_notice, bool f_global = false);
-
/**
* @brief Checks if a testimony contains '<' or '>'.
*
@@ -2034,7 +2046,7 @@ class AOClient : public QObject {
*
* @return True if it contains '<' or '>' symbols, otherwise false.
*/
- bool checkTestimonySymbols(const QString& message);
+ bool checkTestimonySymbols(const QString &message);
///@}
/**
@@ -2048,172 +2060,172 @@ class AOClient : public QObject {
/**
* @brief Describes a command's details.
*/
- struct CommandInfo {
+ struct CommandInfo
+ {
unsigned long long acl_mask; //!< The permissions necessary to be able to run the command. @see ACLFlags.
- int minArgs; //!< The minimum mandatory arguments needed for the command to function.
+ int minArgs; //!< The minimum mandatory arguments needed for the command to function.
void (AOClient::*action)(int, QStringList);
};
/**
- * @property CommandInfo::action
- *
- * @brief A function reference that contains what the command actually does.
- *
- * @param int When called, this parameter will be filled with the argument count. @anchor commandArgc
- * @param QStringList When called, this parameter will be filled the list of arguments. @anchor commandArgv
- */
+ * @property CommandInfo::action
+ *
+ * @brief A function reference that contains what the command actually does.
+ *
+ * @param int When called, this parameter will be filled with the argument count. @anchor commandArgc
+ * @param QStringList When called, this parameter will be filled the list of arguments. @anchor commandArgv
+ */
/**
- * @brief The list of commands available on the server.
- *
- * @details Generally called with the format of `/command parameters` in the out-of-character chat.
- * @showinitializer
- *
- * @tparam QString The name of the command, without the leading slash.
- * @tparam CommandInfo The details of the command.
- * See @ref CommandInfo "the type's documentation" for more details.
- */
- const QMap commands {
- {"login", {ACLFlags.value("NONE"), 0, &AOClient::cmdLogin}},
- {"getareas", {ACLFlags.value("NONE"), 0, &AOClient::cmdGetAreas}},
- {"gas", {ACLFlags.value("NONE"), 0, &AOClient::cmdGetAreas}},
- {"getarea", {ACLFlags.value("NONE"), 0, &AOClient::cmdGetArea}},
- {"ga", {ACLFlags.value("NONE"), 0, &AOClient::cmdGetArea}},
- {"ban", {ACLFlags.value("BAN"), 3, &AOClient::cmdBan}},
- {"kick", {ACLFlags.value("KICK"), 2, &AOClient::cmdKick}},
- {"changeauth", {ACLFlags.value("SUPER"), 0, &AOClient::cmdChangeAuth}},
- {"rootpass", {ACLFlags.value("SUPER"), 1, &AOClient::cmdSetRootPass}},
- {"background", {ACLFlags.value("NONE"), 1, &AOClient::cmdSetBackground}},
- {"bg", {ACLFlags.value("NONE"), 1, &AOClient::cmdSetBackground}},
- {"bglock", {ACLFlags.value("BGLOCK"), 0, &AOClient::cmdBgLock}},
- {"bgunlock", {ACLFlags.value("BGLOCK"), 0, &AOClient::cmdBgUnlock}},
- {"adduser", {ACLFlags.value("MODIFY_USERS"), 2, &AOClient::cmdAddUser}},
- {"listperms", {ACLFlags.value("NONE"), 0, &AOClient::cmdListPerms}},
- {"addperm", {ACLFlags.value("MODIFY_USERS"), 2, &AOClient::cmdAddPerms}},
- {"removeperm", {ACLFlags.value("MODIFY_USERS"), 2, &AOClient::cmdRemovePerms}},
- {"listusers", {ACLFlags.value("MODIFY_USERS"), 0, &AOClient::cmdListUsers}},
- {"logout", {ACLFlags.value("NONE"), 0, &AOClient::cmdLogout}},
- {"pos", {ACLFlags.value("NONE"), 1, &AOClient::cmdPos}},
- {"g", {ACLFlags.value("NONE"), 1, &AOClient::cmdG}},
- {"need", {ACLFlags.value("NONE"), 1, &AOClient::cmdNeed}},
- {"coinflip", {ACLFlags.value("NONE"), 0, &AOClient::cmdFlip}},
- {"roll", {ACLFlags.value("NONE"), 0, &AOClient::cmdRoll}},
- {"r", {ACLFlags.value("NONE"), 0, &AOClient::cmdRoll}},
- {"rollp", {ACLFlags.value("NONE"), 0, &AOClient::cmdRollP}},
- {"doc", {ACLFlags.value("NONE"), 0, &AOClient::cmdDoc}},
- {"cleardoc", {ACLFlags.value("NONE"), 0, &AOClient::cmdClearDoc}},
- {"cm", {ACLFlags.value("NONE"), 0, &AOClient::cmdCM}},
- {"uncm", {ACLFlags.value("CM"), 0, &AOClient::cmdUnCM}},
- {"invite", {ACLFlags.value("CM"), 1, &AOClient::cmdInvite}},
- {"uninvite", {ACLFlags.value("CM"), 1, &AOClient::cmdUnInvite}},
- {"lock", {ACLFlags.value("CM"), 0, &AOClient::cmdLock}},
- {"area_lock", {ACLFlags.value("CM"), 0, &AOClient::cmdLock}},
- {"spectatable", {ACLFlags.value("CM"), 0, &AOClient::cmdSpectatable}},
- {"area_spectate", {ACLFlags.value("CM"), 0, &AOClient::cmdSpectatable}},
- {"unlock", {ACLFlags.value("CM"), 0, &AOClient::cmdUnLock}},
- {"area_unlock", {ACLFlags.value("CM"), 0, &AOClient::cmdUnLock}},
- {"timer", {ACLFlags.value("CM"), 0, &AOClient::cmdTimer}},
- {"area", {ACLFlags.value("NONE"), 1, &AOClient::cmdArea}},
- {"play", {ACLFlags.value("CM"), 1, &AOClient::cmdPlay}},
- {"areakick", {ACLFlags.value("CM"), 1, &AOClient::cmdAreaKick}},
- {"area_kick", {ACLFlags.value("CM"), 1, &AOClient::cmdAreaKick}},
- {"randomchar", {ACLFlags.value("NONE"), 0, &AOClient::cmdRandomChar}},
- {"switch", {ACLFlags.value("NONE"), 1, &AOClient::cmdSwitch}},
- {"toggleglobal", {ACLFlags.value("NONE"), 0, &AOClient::cmdToggleGlobal}},
- {"mods", {ACLFlags.value("NONE"), 0, &AOClient::cmdMods}},
- {"commands", {ACLFlags.value("NONE"), 0, &AOClient::cmdCommands}},
- {"status", {ACLFlags.value("NONE"), 1, &AOClient::cmdStatus}},
- {"forcepos", {ACLFlags.value("CM"), 2, &AOClient::cmdForcePos}},
- {"currentmusic", {ACLFlags.value("NONE"), 0, &AOClient::cmdCurrentMusic}},
- {"pm", {ACLFlags.value("NONE"), 2, &AOClient::cmdPM}},
- {"evidence_mod", {ACLFlags.value("EVI_MOD"), 1, &AOClient::cmdEvidenceMod}},
- {"motd", {ACLFlags.value("NONE"), 0, &AOClient::cmdMOTD}},
- {"announce", {ACLFlags.value("ANNOUNCE"), 1, &AOClient::cmdAnnounce}},
- {"m", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdM}},
- {"gm", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdGM}},
- {"mute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdMute}},
- {"unmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnMute}},
- {"bans", {ACLFlags.value("BAN"), 0, &AOClient::cmdBans}},
- {"unban", {ACLFlags.value("BAN"), 1, &AOClient::cmdUnBan}},
- {"removeuser", {ACLFlags.value("MODIFY_USERS"), 1, &AOClient::cmdRemoveUser}},
- {"subtheme", {ACLFlags.value("CM"), 1, &AOClient::cmdSubTheme}},
- {"about", {ACLFlags.value("NONE"), 0, &AOClient::cmdAbout}},
- {"evidence_swap", {ACLFlags.value("CM"), 2, &AOClient::cmdEvidence_Swap}},
- {"notecard", {ACLFlags.value("NONE"), 1, &AOClient::cmdNoteCard}},
- {"notecardreveal", {ACLFlags.value("CM"), 0, &AOClient::cmdNoteCardReveal}},
- {"notecard_reveal", {ACLFlags.value("CM"), 0, &AOClient::cmdNoteCardReveal}},
- {"notecardclear", {ACLFlags.value("NONE"), 0, &AOClient::cmdNoteCardClear}},
- {"notecard_clear", {ACLFlags.value("NONE"), 0, &AOClient::cmdNoteCardClear}},
- {"8ball", {ACLFlags.value("NONE"), 1, &AOClient::cmd8Ball}},
- {"lm", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdLM}},
- {"judgelog", {ACLFlags.value("CM"), 0, &AOClient::cmdJudgeLog}},
- {"allowblankposting", {ACLFlags.value("MODCHAT"), 0, &AOClient::cmdAllowBlankposting}},
- {"allow_blankposting", {ACLFlags.value("MODCHAT"), 0, &AOClient::cmdAllowBlankposting}},
- {"gimp", {ACLFlags.value("MUTE"), 1, &AOClient::cmdGimp}},
- {"ungimp", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnGimp}},
- {"baninfo", {ACLFlags.value("BAN"), 1, &AOClient::cmdBanInfo}},
- {"testify", {ACLFlags.value("CM"), 0, &AOClient::cmdTestify}},
- {"testimony", {ACLFlags.value("NONE"), 0, &AOClient::cmdTestimony}},
- {"examine", {ACLFlags.value("CM"), 0, &AOClient::cmdExamine}},
- {"pause", {ACLFlags.value("CM"), 0, &AOClient::cmdPauseTestimony}},
- {"delete", {ACLFlags.value("CM"), 0, &AOClient::cmdDeleteStatement}},
- {"update", {ACLFlags.value("CM"), 0, &AOClient::cmdUpdateStatement}},
- {"add", {ACLFlags.value("CM"), 0, &AOClient::cmdAddStatement}},
- {"reload", {ACLFlags.value("SUPER"), 0, &AOClient::cmdReload}},
- {"disemvowel", {ACLFlags.value("MUTE"), 1, &AOClient::cmdDisemvowel}},
- {"undisemvowel", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnDisemvowel}},
- {"shake", {ACLFlags.value("MUTE"), 1, &AOClient::cmdShake}},
- {"unshake", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnShake}},
- {"forceimmediate", {ACLFlags.value("CM"), 0, &AOClient::cmdForceImmediate}},
- {"force_noint_pres", {ACLFlags.value("CM"), 0, &AOClient::cmdForceImmediate}},
- {"allowiniswap", {ACLFlags.value("CM"), 0, &AOClient::cmdAllowIniswap}},
- {"allow_iniswap", {ACLFlags.value("CM"), 0, &AOClient::cmdAllowIniswap}},
- {"afk", {ACLFlags.value("NONE"), 0, &AOClient::cmdAfk}},
- {"savetestimony", {ACLFlags.value("NONE"), 1, &AOClient::cmdSaveTestimony}},
- {"loadtestimony", {ACLFlags.value("CM"), 1, &AOClient::cmdLoadTestimony}},
- {"permitsaving", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdPermitSaving}},
- {"mutepm", {ACLFlags.value("NONE"), 0, &AOClient::cmdMutePM}},
- {"toggleadverts", {ACLFlags.value("NONE"), 0, &AOClient::cmdToggleAdverts}},
- {"oocmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocMute}},
- {"ooc_mute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocMute}},
- {"oocunmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocUnMute}},
- {"ooc_unmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocUnMute}},
- {"blockwtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockWtce}},
- {"block_wtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockWtce}},
- {"unblockwtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockWtce}},
- {"unblock_wtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockWtce}},
- {"blockdj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockDj}},
- {"block_dj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockDj}},
- {"unblockdj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockDj}},
- {"unblock_dj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockDj}},
- {"charcurse", {ACLFlags.value("MUTE"), 1, &AOClient::cmdCharCurse}},
- {"uncharcurse", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnCharCurse}},
- {"charselect", {ACLFlags.value("NONE"), 0, &AOClient::cmdCharSelect}},
- {"togglemusic", {ACLFlags.value("CM"), 0, &AOClient::cmdToggleMusic}},
- {"a", {ACLFlags.value("NONE"), 2, &AOClient::cmdA}},
- {"s", {ACLFlags.value("NONE"), 0, &AOClient::cmdS}},
- {"kickuid", {ACLFlags.value("KICK"), 2, &AOClient::cmdKickUid}},
- {"kick_uid", {ACLFlags.value("KICK"), 2, &AOClient::cmdKickUid}},
- {"firstperson", {ACLFlags.value("NONE"), 0, &AOClient::cmdFirstPerson}},
- {"updateban", {ACLFlags.value("BAN"), 3, &AOClient::cmdUpdateBan}},
- {"update_ban", {ACLFlags.value("BAN"), 3, &AOClient::cmdUpdateBan}},
- {"changepass", {ACLFlags.value("NONE"), 1, &AOClient::cmdChangePassword}},
- {"ignorebglist", {ACLFlags.value("IGNORE_BGLIST"),0, &AOClient::cmdIgnoreBgList}},
- {"ignore_bglist", {ACLFlags.value("IGNORE_BGLIST"),0, &AOClient::cmdIgnoreBgList}},
- {"notice", {ACLFlags.value("SEND_NOTICE"), 1, &AOClient::cmdNotice}},
- {"noticeg", {ACLFlags.value("SEND_NOTICE"), 1, &AOClient::cmdNoticeGlobal}},
- {"togglejukebox", {ACLFlags.value("None"), 0, &AOClient::cmdToggleJukebox}},
- {"help", {ACLFlags.value("NONE"), 1, &AOClient::cmdHelp}},
- {"clearcm", {ACLFlags.value("KICK"), 0, &AOClient::cmdClearCM}},
- {"togglemessage", {ACLFlags.value("CM"), 0, &AOClient::cmdToggleAreaMessageOnJoin}},
- {"clearmessage", {ACLFlags.value("CM"), 0, &AOClient::cmdClearAreaMessage}},
- {"areamessage", {ACLFlags.value("CM"), 0, &AOClient::cmdAreaMessage}},
- {"addsong", {ACLFlags.value("CM"), 1, &AOClient::cmdAddSong}},
- {"addcategory", {ACLFlags.value("CM"), 1, &AOClient::cmdAddCategory}},
- {"removeentry", {ACLFlags.value("CM"), 1, &AOClient::cmdRemoveCategorySong}},
- {"toggleroot", {ACLFlags.value("CM"), 0, &AOClient::cmdToggleRootlist}},
- {"clearcustom", {ACLFlags.value("CM"), 0, &AOClient::cmdClearCustom}}
- };
+ * @brief The list of commands available on the server.
+ *
+ * @details Generally called with the format of `/command parameters` in the out-of-character chat.
+ * @showinitializer
+ *
+ * @tparam QString The name of the command, without the leading slash.
+ * @tparam CommandInfo The details of the command.
+ * See @ref CommandInfo "the type's documentation" for more details.
+ */
+ const QMap commands{
+ {"login", {ACLFlags.value("NONE"), 0, &AOClient::cmdLogin}},
+ {"getareas", {ACLFlags.value("NONE"), 0, &AOClient::cmdGetAreas}},
+ {"gas", {ACLFlags.value("NONE"), 0, &AOClient::cmdGetAreas}},
+ {"getarea", {ACLFlags.value("NONE"), 0, &AOClient::cmdGetArea}},
+ {"ga", {ACLFlags.value("NONE"), 0, &AOClient::cmdGetArea}},
+ {"ban", {ACLFlags.value("BAN"), 3, &AOClient::cmdBan}},
+ {"kick", {ACLFlags.value("KICK"), 2, &AOClient::cmdKick}},
+ {"changeauth", {ACLFlags.value("SUPER"), 0, &AOClient::cmdChangeAuth}},
+ {"rootpass", {ACLFlags.value("SUPER"), 1, &AOClient::cmdSetRootPass}},
+ {"background", {ACLFlags.value("NONE"), 1, &AOClient::cmdSetBackground}},
+ {"bg", {ACLFlags.value("NONE"), 1, &AOClient::cmdSetBackground}},
+ {"bglock", {ACLFlags.value("BGLOCK"), 0, &AOClient::cmdBgLock}},
+ {"bgunlock", {ACLFlags.value("BGLOCK"), 0, &AOClient::cmdBgUnlock}},
+ {"adduser", {ACLFlags.value("MODIFY_USERS"), 2, &AOClient::cmdAddUser}},
+ {"listperms", {ACLFlags.value("NONE"), 0, &AOClient::cmdListPerms}},
+ {"addperm", {ACLFlags.value("MODIFY_USERS"), 2, &AOClient::cmdAddPerms}},
+ {"removeperm", {ACLFlags.value("MODIFY_USERS"), 2, &AOClient::cmdRemovePerms}},
+ {"listusers", {ACLFlags.value("MODIFY_USERS"), 0, &AOClient::cmdListUsers}},
+ {"logout", {ACLFlags.value("NONE"), 0, &AOClient::cmdLogout}},
+ {"pos", {ACLFlags.value("NONE"), 1, &AOClient::cmdPos}},
+ {"g", {ACLFlags.value("NONE"), 1, &AOClient::cmdG}},
+ {"need", {ACLFlags.value("NONE"), 1, &AOClient::cmdNeed}},
+ {"coinflip", {ACLFlags.value("NONE"), 0, &AOClient::cmdFlip}},
+ {"roll", {ACLFlags.value("NONE"), 0, &AOClient::cmdRoll}},
+ {"r", {ACLFlags.value("NONE"), 0, &AOClient::cmdRoll}},
+ {"rollp", {ACLFlags.value("NONE"), 0, &AOClient::cmdRollP}},
+ {"doc", {ACLFlags.value("NONE"), 0, &AOClient::cmdDoc}},
+ {"cleardoc", {ACLFlags.value("NONE"), 0, &AOClient::cmdClearDoc}},
+ {"cm", {ACLFlags.value("NONE"), 0, &AOClient::cmdCM}},
+ {"uncm", {ACLFlags.value("CM"), 0, &AOClient::cmdUnCM}},
+ {"invite", {ACLFlags.value("CM"), 1, &AOClient::cmdInvite}},
+ {"uninvite", {ACLFlags.value("CM"), 1, &AOClient::cmdUnInvite}},
+ {"lock", {ACLFlags.value("CM"), 0, &AOClient::cmdLock}},
+ {"area_lock", {ACLFlags.value("CM"), 0, &AOClient::cmdLock}},
+ {"spectatable", {ACLFlags.value("CM"), 0, &AOClient::cmdSpectatable}},
+ {"area_spectate", {ACLFlags.value("CM"), 0, &AOClient::cmdSpectatable}},
+ {"unlock", {ACLFlags.value("CM"), 0, &AOClient::cmdUnLock}},
+ {"area_unlock", {ACLFlags.value("CM"), 0, &AOClient::cmdUnLock}},
+ {"timer", {ACLFlags.value("CM"), 0, &AOClient::cmdTimer}},
+ {"area", {ACLFlags.value("NONE"), 1, &AOClient::cmdArea}},
+ {"play", {ACLFlags.value("CM"), 1, &AOClient::cmdPlay}},
+ {"areakick", {ACLFlags.value("CM"), 1, &AOClient::cmdAreaKick}},
+ {"area_kick", {ACLFlags.value("CM"), 1, &AOClient::cmdAreaKick}},
+ {"randomchar", {ACLFlags.value("NONE"), 0, &AOClient::cmdRandomChar}},
+ {"switch", {ACLFlags.value("NONE"), 1, &AOClient::cmdSwitch}},
+ {"toggleglobal", {ACLFlags.value("NONE"), 0, &AOClient::cmdToggleGlobal}},
+ {"mods", {ACLFlags.value("NONE"), 0, &AOClient::cmdMods}},
+ {"commands", {ACLFlags.value("NONE"), 0, &AOClient::cmdCommands}},
+ {"status", {ACLFlags.value("NONE"), 1, &AOClient::cmdStatus}},
+ {"forcepos", {ACLFlags.value("CM"), 2, &AOClient::cmdForcePos}},
+ {"currentmusic", {ACLFlags.value("NONE"), 0, &AOClient::cmdCurrentMusic}},
+ {"pm", {ACLFlags.value("NONE"), 2, &AOClient::cmdPM}},
+ {"evidence_mod", {ACLFlags.value("EVI_MOD"), 1, &AOClient::cmdEvidenceMod}},
+ {"motd", {ACLFlags.value("NONE"), 0, &AOClient::cmdMOTD}},
+ {"announce", {ACLFlags.value("ANNOUNCE"), 1, &AOClient::cmdAnnounce}},
+ {"m", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdM}},
+ {"gm", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdGM}},
+ {"mute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdMute}},
+ {"unmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnMute}},
+ {"bans", {ACLFlags.value("BAN"), 0, &AOClient::cmdBans}},
+ {"unban", {ACLFlags.value("BAN"), 1, &AOClient::cmdUnBan}},
+ {"removeuser", {ACLFlags.value("MODIFY_USERS"), 1, &AOClient::cmdRemoveUser}},
+ {"subtheme", {ACLFlags.value("CM"), 1, &AOClient::cmdSubTheme}},
+ {"about", {ACLFlags.value("NONE"), 0, &AOClient::cmdAbout}},
+ {"evidence_swap", {ACLFlags.value("CM"), 2, &AOClient::cmdEvidence_Swap}},
+ {"notecard", {ACLFlags.value("NONE"), 1, &AOClient::cmdNoteCard}},
+ {"notecardreveal", {ACLFlags.value("CM"), 0, &AOClient::cmdNoteCardReveal}},
+ {"notecard_reveal", {ACLFlags.value("CM"), 0, &AOClient::cmdNoteCardReveal}},
+ {"notecardclear", {ACLFlags.value("NONE"), 0, &AOClient::cmdNoteCardClear}},
+ {"notecard_clear", {ACLFlags.value("NONE"), 0, &AOClient::cmdNoteCardClear}},
+ {"8ball", {ACLFlags.value("NONE"), 1, &AOClient::cmd8Ball}},
+ {"lm", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdLM}},
+ {"judgelog", {ACLFlags.value("CM"), 0, &AOClient::cmdJudgeLog}},
+ {"allowblankposting", {ACLFlags.value("MODCHAT"), 0, &AOClient::cmdAllowBlankposting}},
+ {"allow_blankposting", {ACLFlags.value("MODCHAT"), 0, &AOClient::cmdAllowBlankposting}},
+ {"gimp", {ACLFlags.value("MUTE"), 1, &AOClient::cmdGimp}},
+ {"ungimp", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnGimp}},
+ {"baninfo", {ACLFlags.value("BAN"), 1, &AOClient::cmdBanInfo}},
+ {"testify", {ACLFlags.value("CM"), 0, &AOClient::cmdTestify}},
+ {"testimony", {ACLFlags.value("NONE"), 0, &AOClient::cmdTestimony}},
+ {"examine", {ACLFlags.value("CM"), 0, &AOClient::cmdExamine}},
+ {"pause", {ACLFlags.value("CM"), 0, &AOClient::cmdPauseTestimony}},
+ {"delete", {ACLFlags.value("CM"), 0, &AOClient::cmdDeleteStatement}},
+ {"update", {ACLFlags.value("CM"), 0, &AOClient::cmdUpdateStatement}},
+ {"add", {ACLFlags.value("CM"), 0, &AOClient::cmdAddStatement}},
+ {"reload", {ACLFlags.value("SUPER"), 0, &AOClient::cmdReload}},
+ {"disemvowel", {ACLFlags.value("MUTE"), 1, &AOClient::cmdDisemvowel}},
+ {"undisemvowel", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnDisemvowel}},
+ {"shake", {ACLFlags.value("MUTE"), 1, &AOClient::cmdShake}},
+ {"unshake", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnShake}},
+ {"forceimmediate", {ACLFlags.value("CM"), 0, &AOClient::cmdForceImmediate}},
+ {"force_noint_pres", {ACLFlags.value("CM"), 0, &AOClient::cmdForceImmediate}},
+ {"allowiniswap", {ACLFlags.value("CM"), 0, &AOClient::cmdAllowIniswap}},
+ {"allow_iniswap", {ACLFlags.value("CM"), 0, &AOClient::cmdAllowIniswap}},
+ {"afk", {ACLFlags.value("NONE"), 0, &AOClient::cmdAfk}},
+ {"savetestimony", {ACLFlags.value("NONE"), 1, &AOClient::cmdSaveTestimony}},
+ {"loadtestimony", {ACLFlags.value("CM"), 1, &AOClient::cmdLoadTestimony}},
+ {"permitsaving", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdPermitSaving}},
+ {"mutepm", {ACLFlags.value("NONE"), 0, &AOClient::cmdMutePM}},
+ {"toggleadverts", {ACLFlags.value("NONE"), 0, &AOClient::cmdToggleAdverts}},
+ {"oocmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocMute}},
+ {"ooc_mute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocMute}},
+ {"oocunmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocUnMute}},
+ {"ooc_unmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocUnMute}},
+ {"blockwtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockWtce}},
+ {"block_wtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockWtce}},
+ {"unblockwtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockWtce}},
+ {"unblock_wtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockWtce}},
+ {"blockdj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockDj}},
+ {"block_dj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockDj}},
+ {"unblockdj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockDj}},
+ {"unblock_dj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockDj}},
+ {"charcurse", {ACLFlags.value("MUTE"), 1, &AOClient::cmdCharCurse}},
+ {"uncharcurse", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnCharCurse}},
+ {"charselect", {ACLFlags.value("NONE"), 0, &AOClient::cmdCharSelect}},
+ {"togglemusic", {ACLFlags.value("CM"), 0, &AOClient::cmdToggleMusic}},
+ {"a", {ACLFlags.value("NONE"), 2, &AOClient::cmdA}},
+ {"s", {ACLFlags.value("NONE"), 0, &AOClient::cmdS}},
+ {"kickuid", {ACLFlags.value("KICK"), 2, &AOClient::cmdKickUid}},
+ {"kick_uid", {ACLFlags.value("KICK"), 2, &AOClient::cmdKickUid}},
+ {"firstperson", {ACLFlags.value("NONE"), 0, &AOClient::cmdFirstPerson}},
+ {"updateban", {ACLFlags.value("BAN"), 3, &AOClient::cmdUpdateBan}},
+ {"update_ban", {ACLFlags.value("BAN"), 3, &AOClient::cmdUpdateBan}},
+ {"changepass", {ACLFlags.value("NONE"), 1, &AOClient::cmdChangePassword}},
+ {"ignorebglist", {ACLFlags.value("IGNORE_BGLIST"), 0, &AOClient::cmdIgnoreBgList}},
+ {"ignore_bglist", {ACLFlags.value("IGNORE_BGLIST"), 0, &AOClient::cmdIgnoreBgList}},
+ {"notice", {ACLFlags.value("SEND_NOTICE"), 1, &AOClient::cmdNotice}},
+ {"noticeg", {ACLFlags.value("SEND_NOTICE"), 1, &AOClient::cmdNoticeGlobal}},
+ {"togglejukebox", {ACLFlags.value("None"), 0, &AOClient::cmdToggleJukebox}},
+ {"help", {ACLFlags.value("NONE"), 1, &AOClient::cmdHelp}},
+ {"clearcm", {ACLFlags.value("KICK"), 0, &AOClient::cmdClearCM}},
+ {"togglemessage", {ACLFlags.value("CM"), 0, &AOClient::cmdToggleAreaMessageOnJoin}},
+ {"clearmessage", {ACLFlags.value("CM"), 0, &AOClient::cmdClearAreaMessage}},
+ {"areamessage", {ACLFlags.value("CM"), 0, &AOClient::cmdAreaMessage}},
+ {"addsong", {ACLFlags.value("CM"), 1, &AOClient::cmdAddSong}},
+ {"addcategory", {ACLFlags.value("CM"), 1, &AOClient::cmdAddCategory}},
+ {"removeentry", {ACLFlags.value("CM"), 1, &AOClient::cmdRemoveCategorySong}},
+ {"toggleroot", {ACLFlags.value("CM"), 0, &AOClient::cmdToggleRootlist}},
+ {"clearcustom", {ACLFlags.value("CM"), 0, &AOClient::cmdClearCustom}}};
/**
* @brief Filled with part of a packet if said packet could not be read fully from the client's socket.
@@ -2264,7 +2276,7 @@ class AOClient : public QObject {
/**
* @brief Pointer to the servers music manager instance.
*/
- MusicManager* m_music_manager;
+ MusicManager *m_music_manager;
/**
* @brief A helper function to add recorded packets to an area's judgelog.
@@ -2275,7 +2287,7 @@ class AOClient : public QObject {
*
* @param action String containing the info that is being recorded.
*/
- void updateJudgeLog(AreaData* area, AOClient* client, QString action);
+ void updateJudgeLog(AreaData *area, AOClient *client, QString action);
/**
* @brief A helper function for decoding AO encoding from a QString.
@@ -2301,47 +2313,47 @@ class AOClient : public QObject {
/**
* @brief Signal connected to universal logger. Sends IC chat usage to the logger.
*/
- void logIC(const QString& f_charName, const QString& f_oocName, const QString& f_ipid,
- const QString& f_areaName, const QString &f_message);
+ void logIC(const QString &f_charName, const QString &f_oocName, const QString &f_ipid,
+ const QString &f_areaName, const QString &f_message);
/**
* @brief Signal connected to universal logger. Sends OOC chat usage to the logger.
*/
- void logOOC(const QString& f_charName, const QString& f_oocName, const QString& f_ipid,
- const QString& f_areaName, const QString& f_message);
+ void logOOC(const QString &f_charName, const QString &f_oocName, const QString &f_ipid,
+ const QString &f_areaName, const QString &f_message);
/**
* @brief Signal connected to universal logger. Sends login attempt to the logger.
*/
- void logLogin(const QString& f_charName, const QString& f_oocName, const QString& f_moderatorName,
- const QString& f_ipid, const QString &f_areaName, const bool& f_success);
+ void logLogin(const QString &f_charName, const QString &f_oocName, const QString &f_moderatorName,
+ const QString &f_ipid, const QString &f_areaName, const bool &f_success);
/**
* @brief Signal connected to universal logger. Sends command usage to the logger.
*/
- void logCMD(const QString& f_charName, const QString &f_ipid, const QString& f_oocName, const QString f_command,
+ void logCMD(const QString &f_charName, const QString &f_ipid, const QString &f_oocName, const QString f_command,
const QStringList f_args, const QString f_areaName);
/**
* @brief Signal connected to universal logger. Sends player kick information to the logger.
*/
- void logKick(const QString& f_moderator, const QString& f_targetIPID, const QString& f_reason);
+ void logKick(const QString &f_moderator, const QString &f_targetIPID, const QString &f_reason);
/**
* @brief Signal connected to universal logger. Sends ban information to the logger.
*/
- void logBan(const QString& f_moderator, const QString& f_targetIPID, const QString &f_duration, const QString& f_reason);
+ void logBan(const QString &f_moderator, const QString &f_targetIPID, const QString &f_duration, const QString &f_reason);
/**
* @brief Signal connected to universal logger. Sends modcall information to the logger, triggering a write of the buffer
* when modcall logging is used.
*/
- void logModcall(const QString& f_charName, const QString &f_ipid, const QString& f_oocName, const QString& f_areaName);
+ void logModcall(const QString &f_charName, const QString &f_ipid, const QString &f_oocName, const QString &f_areaName);
/**
* @brief Signals the server that the client has disconnected and marks its userID as free again.
*/
- void clientSuccessfullyDisconnected(const int& f_user_id);
+ void clientSuccessfullyDisconnected(const int &f_user_id);
};
#endif // AOCLIENT_H
diff --git a/core/include/aopacket.h b/core/include/aopacket.h
index 3510687..41f9932 100644
--- a/core/include/aopacket.h
+++ b/core/include/aopacket.h
@@ -29,7 +29,8 @@
* @see https://github.com/AttorneyOnline/docs/blob/master/docs/development/network.md for a general explanation
* on Attorney Online 2's network protocol.
*/
-class AOPacket {
+class AOPacket
+{
public:
/**
* @brief Creates an AOPacket with the given header and contents.
diff --git a/core/include/area_data.h b/core/include/area_data.h
index 24959de..216e978 100644
--- a/core/include/area_data.h
+++ b/core/include/area_data.h
@@ -18,25 +18,27 @@
#ifndef AREA_DATA_H
#define AREA_DATA_H
-#include "aopacket.h"
-#include "config_manager.h"
-#include "music_manager.h"
-
-#include
-#include
-#include
#include
-#include
#include
+#include
#include
+#include
+#include
+#include
+#include "include/aopacket.h"
+
+class ConfigManager;
class Logger;
+class MusicManager;
/**
* @brief Represents an area on the server, a distinct "room" for people to chat in.
*/
-class AreaData : public QObject {
- Q_OBJECT
+class AreaData : public QObject
+{
+ Q_OBJECT
+
public:
/**
* @brief Constructor for the AreaData class.
@@ -45,15 +47,16 @@ class AreaData : public QObject {
* and `YYYYYY` is the actual name of the area.
* @param p_index The index of the area in the area list.
*/
- AreaData(QString p_name, int p_index, MusicManager* p_music_manager);
+ AreaData(QString p_name, int p_index, MusicManager *p_music_manager);
/**
* @brief The data for evidence in the area.
*/
- struct Evidence {
- QString name; //!< The name of the evidence, shown when hovered over clientside.
+ struct Evidence
+ {
+ 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.
+ QString image; //!< A path originating from `base/evidence/` that points to an image file.
};
/**
@@ -62,13 +65,14 @@ class AreaData : public QObject {
* @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, //!< 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.
+ enum Status
+ {
+ 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.
};
/// Exposes the metadata of the Status enum.
@@ -77,10 +81,11 @@ class AreaData : public QObject {
/**
* @brief Determines who may traverse and communicate in the area.
*/
- enum LockStatus {
- FREE,
- LOCKED,
- SPECTATABLE
+ enum LockStatus
+ {
+ FREE,
+ LOCKED,
+ SPECTATABLE
};
/**
@@ -110,7 +115,8 @@ class AreaData : public QObject {
/**
* @brief The level of "authorisation" needed to be able to modify, add, and remove evidence in the area.
*/
- enum class EvidenceMod{
+ enum class EvidenceMod
+ {
FFA,
MOD,
CM,
@@ -144,7 +150,8 @@ class AreaData : public QObject {
/**
* @brief The five "states" the testimony recording system can have in an area.
*/
- enum TestimonyRecording{
+ enum TestimonyRecording
+ {
STOPPED,
RECORDING,
UPDATE,
@@ -190,17 +197,19 @@ class AreaData : public QObject {
* @brief Determines how the testimony progressed after advancement was called in a direction
* (Either to next or previous statement).
*/
- enum class TestimonyProgress {
- OK, //!< The expected statement was selected.
- LOOPED, //!< The "next" statement would have been beyond the testimony's limits, so the first one was selected.
+ enum class TestimonyProgress
+ {
+ OK, //!< The expected statement was selected.
+ LOOPED, //!< The "next" statement would have been beyond the testimony's limits, so the first one was selected.
STAYED_AT_FIRST, //!< The "previous" statement would have been before the first, so the selection stayed at the first.
};
/**
* @brief Determines a side. Self-explanatory.
*/
- enum class Side {
- DEFENCE, //!< Self-explanatory.
+ enum class Side
+ {
+ DEFENCE, //!< Self-explanatory.
PROSECUTOR, //!< Self-explanatory.
};
@@ -411,7 +420,7 @@ class AreaData : public QObject {
*
* @param f_evi_r The evidence to append.
*/
- void appendEvidence(const Evidence& f_evi_r);
+ void appendEvidence(const Evidence &f_evi_r);
/**
* @brief Deletes a piece of evidence from the list of evidence.
@@ -426,7 +435,7 @@ class AreaData : public QObject {
* @param f_eviId The ID of the evidence to replace.
* @param f_newEvi_r The new piece of evidence that will replace the aforementioned one.
*/
- void replaceEvidence(int f_eviId, const Evidence& f_newEvi_r);
+ void replaceEvidence(int f_eviId, const Evidence &f_newEvi_r);
/**
* @brief Returns the status of the area.
@@ -444,7 +453,7 @@ class AreaData : public QObject {
*
* @see #map_statuses
*/
- bool changeStatus(const QString& f_newStatus_r);
+ bool changeStatus(const QString &f_newStatus_r);
/**
* @brief Returns a copy of the list of invited clients.
@@ -546,7 +555,7 @@ class AreaData : public QObject {
*
* @see #m_document
*/
- void changeDoc(const QString& f_newDoc_r);
+ void changeDoc(const QString &f_newDoc_r);
/**
* @brief Returns the message of the area.
@@ -569,7 +578,12 @@ class AreaData : public QObject {
*
* @param f_newMessage_r The new message.
*/
- void changeAreaMessage(const QString& f_newMessage_r);
+ void changeAreaMessage(const QString &f_newMessage_r);
+
+ /**
+ * @brief Clear the area message in the area.
+ */
+ void clearAreaMessage();
/**
* @brief Returns the value of the Confidence bar for the defence's side.
@@ -632,7 +646,7 @@ class AreaData : public QObject {
*
* @see #m_musicPlayedBy
*/
- void setMusicPlayedBy(const QString& f_music_player);
+ void setMusicPlayedBy(const QString &f_music_player);
/**
* @brief Changes the music being played in the area.
@@ -640,7 +654,7 @@ class AreaData : public QObject {
* @param f_source_r The showname of the client who initiated the music change.
* @param f_newSong_r The name of the new song that is going to be played in the area.
*/
- void changeMusic(const QString& f_source_r, const QString& f_newSong_r);
+ void changeMusic(const QString &f_source_r, const QString &f_newSong_r);
/**
* @brief Returns the evidence mod in the area.
@@ -666,7 +680,7 @@ class AreaData : public QObject {
*
* @return True if the notecard didn't replace a previous one, false if it did.
*/
- bool addNotecard(const QString& f_owner_r, const QString& f_notecard_r);
+ bool addNotecard(const QString &f_owner_r, const QString &f_notecard_r);
/**
* @brief Returns the list of notecards recorded in the area.
@@ -708,7 +722,7 @@ class AreaData : public QObject {
*
* @note Unlike most other getters, this one returns a reference, as it is expected to be used frequently.
*/
- const QVector& testimony() const;
+ const QVector &testimony() const;
/**
* @brief Returns the index of the currently examined statement in the testimony.
@@ -722,7 +736,7 @@ class AreaData : public QObject {
*
* @param f_newStatement_r The IC message packet to append to the testimony vector.
*/
- void recordStatement(const QStringList& f_newStatement_r);
+ void recordStatement(const QStringList &f_newStatement_r);
/**
* @brief Adds a statement into the testimony to a given position.
@@ -730,7 +744,7 @@ class AreaData : public QObject {
* @param f_position The index to insert the statement to.
* @param f_newStatement_r The IC message packet to insert.
*/
- void addStatement(int f_position, const QStringList& f_newStatement_r);
+ void addStatement(int f_position, const QStringList &f_newStatement_r);
/**
* @brief Replaces an already existing statement in the testimony in a given position with a new one.
@@ -738,7 +752,7 @@ class AreaData : public QObject {
* @param f_position The index of the statement to replace.
* @param f_newStatement_r The IC message packet to insert in the old one's stead.
*/
- void replaceStatement(int f_position, const QStringList& f_newStatement_r);
+ void replaceStatement(int f_position, const QStringList &f_newStatement_r);
/**
* @brief Removes a statement from the testimony at a given position, and moves the statement index one backward.
@@ -780,21 +794,21 @@ class AreaData : public QObject {
*
* @param f_newLog_r The new line to append to the judgelog.
*/
- void appendJudgelog(const QString& f_newLog_r);
+ void appendJudgelog(const QString &f_newLog_r);
/**
* @brief Returns the last IC message sent in the area.
*
* @return See short description.
*/
- const QStringList& lastICMessage() const;
+ const QStringList &lastICMessage() const;
/**
* @brief Updates the last IC message sent in the area.
*
* @param f_lastMessage_r The new last IC message.
*/
- void updateLastICMessage(const QStringList& f_lastMessage_r);
+ void updateLastICMessage(const QStringList &f_lastMessage_r);
/**
* @brief Returns whether ~~non-interrupting~~ immediate messages are forced in the area.
@@ -856,7 +870,7 @@ class AreaData : public QObject {
*/
QVector joinedIDs() const;
-public slots:
+ public slots:
/**
* @brief Plays a random song from the jukebox. Plays the same if only one is left.
@@ -891,11 +905,11 @@ public slots:
*/
void userJoinedArea(int f_area_index, int f_user_id);
-private:
+ private:
/**
* @brief The list of timers available in the area.
*/
- QList m_timers;
+ QList m_timers;
/**
* @brief The user-facing and internal name of the area.
@@ -910,7 +924,7 @@ private:
/**
* @brief Pointer to the global music manager.
*/
- MusicManager* m_music_manager;
+ MusicManager *m_music_manager;
/**
* @brief A list of the character IDs of all characters taken.
@@ -1036,7 +1050,7 @@ private:
/**
* @brief A pointer to a Logger, used to send requests to log data.
*/
- Logger* m_logger;
+ Logger *m_logger;
/**
* @brief The evidence mod of the area.
@@ -1061,15 +1075,14 @@ private:
*/
TestimonyRecording m_testimonyRecording;
-
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.
+ 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.
- */
+ * @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 m_judgelog;
/**
@@ -1077,7 +1090,6 @@ private:
*/
QStringList m_lastICMessage;
-
/**
* @brief Whether or not to force immediate text processing in this area.
*/
@@ -1118,7 +1130,7 @@ private:
* @details While this may be considered bad design, I do not care.
* It triggers a direct broadcast of the MC packet in the area.
*/
- QTimer* m_jukebox_timer;
+ QTimer *m_jukebox_timer;
/**
* @brief Wether or not the jukebox is enabled in this area.
diff --git a/core/include/config_manager.h b/core/include/config_manager.h
index 263087d..04463c5 100644
--- a/core/include/config_manager.h
+++ b/core/include/config_manager.h
@@ -20,29 +20,29 @@
#define CONFIG_VERSION 1
-#include "data_types.h"
-
#include
#include
+#include
#include
#include
+#include
+#include
#include
#include
-#include
-#include
-#include
-//JSON loading requirements
+// JSON loading requirements
+#include
#include
#include
-#include
-typedef QMap> MusicList;
+#include "include/data_types.h"
+#include "include/typedefs.h"
/**
* @brief The config file handler class.
*/
-class ConfigManager {
+class ConfigManager
+{
public:
/**
@@ -99,7 +99,7 @@ class ConfigManager {
*
* @return See short description.
*/
- static QSettings* areaData();
+ static QSettings *areaData();
/**
* @brief Returns a sanitized QStringList of the areas.
@@ -289,7 +289,7 @@ class ConfigManager {
* @return See short description.
*/
static bool discordBanWebhookEnabled();
-
+
/**
* @brief Returns the Discord Ban Webhook URL.
*
@@ -309,7 +309,7 @@ class ConfigManager {
/**
* @brief Returns the Discord Uptime Webhook URL.
- *
+ *
* @return See short description.
*/
static QString discordUptimeWebhookUrl();
@@ -451,7 +451,8 @@ class ConfigManager {
* @brief A struct that contains the help information for a command.
* It's split in the syntax and the explanation text.
*/
- struct help {
+ struct help
+ {
QString usage;
QString text;
};
@@ -482,8 +483,7 @@ class ConfigManager {
*/
static void reloadSettings();
-
-private:
+ private:
/**
* @brief Checks if a file exists and is valid.
*
@@ -491,7 +491,7 @@ private:
*
* @return True if the file exists and is valid, false otherwise.
*/
- static bool fileExists(const QFileInfo& file);
+ static bool fileExists(const QFileInfo &file);
/**
* @brief Checks if a directory exists and is valid.
@@ -500,63 +500,64 @@ private:
*
* @return True if the directory exists and is valid, false otherwise.
*/
- static bool dirExists(const QFileInfo& dir);
+ static bool dirExists(const QFileInfo &dir);
/**
* @brief A struct for storing QStringLists loaded from command configuration files.
*/
- struct CommandSettings {
+ struct CommandSettings
+ {
QStringList magic_8ball; //!< Contains answers for /8ball, found in config/text/8ball.txt
- QStringList praises; //!< Contains command praises, found in config/text/praises.txt
- QStringList reprimands; //!< Contains command reprimands, found in config/text/reprimands.txt
- QStringList gimps; //!< Contains phrases for /gimp, found in config/text/gimp.txt
- QStringList cdns; // !< Contains domains for custom song validation, found in config/text/cdns.txt
+ QStringList praises; //!< Contains command praises, found in config/text/praises.txt
+ QStringList reprimands; //!< Contains command reprimands, found in config/text/reprimands.txt
+ QStringList gimps; //!< Contains phrases for /gimp, found in config/text/gimp.txt
+ QStringList cdns; // !< Contains domains for custom song validation, found in config/text/cdns.txt
};
/**
* @brief Contains the settings required for various commands.
*/
- static CommandSettings* m_commands;
+ static CommandSettings *m_commands;
/**
* @brief Stores all server configuration values.
*/
- static QSettings* m_settings;
+ static QSettings *m_settings;
/**
* @brief Stores all discord webhook configuration values.
*/
- static QSettings* m_discord;
+ static QSettings *m_discord;
/**
* @brief Stores all of the area valus.
*/
- static QSettings* m_areas;
+ static QSettings *m_areas;
/**
* @brief Stores all adjustable logstrings.
*/
- static QSettings* m_logtext;
+ static QSettings *m_logtext;
/**
* @brief Pointer to QElapsedTimer to track the uptime of the server.
*/
- static QElapsedTimer* m_uptimeTimer;
+ static QElapsedTimer *m_uptimeTimer;
/**
* @brief Contains the musiclist with time durations.
*/
- static MusicList* m_musicList;
+ static MusicList *m_musicList;
/**
* @brief Contains an ordered list for the musiclist.
*/
- static QStringList* m_ordered_list;
+ static QStringList *m_ordered_list;
/**
* @brief QHash containing the help information for all commands registered to the server.
*/
- static QHash* m_commands_help;
+ static QHash *m_commands_help;
/**
* @brief Returns a stringlist with the contents of a .txt file from config/text/.
@@ -566,6 +567,4 @@ private:
static QStringList loadConfigFile(const QString filename);
};
-
-
#endif // CONFIG_MANAGER_H
diff --git a/core/include/data_types.h b/core/include/data_types.h
index f6385e8..e134883 100644
--- a/core/include/data_types.h
+++ b/core/include/data_types.h
@@ -19,6 +19,7 @@
#define DATA_TYPES_H
#include
+
/**
* @brief A class for handling several custom data types.
*/
@@ -26,20 +27,22 @@ class DataTypes
{
Q_GADGET
-public:
+ public:
/**
* @brief Custom type for authorization types.
*/
- enum class AuthType {
- SIMPLE,
- ADVANCED
- };
+ enum class AuthType
+ {
+ SIMPLE,
+ ADVANCED
+ };
Q_ENUM(AuthType);
/**
* @brief Custom type for logging types.
*/
- enum class LogType {
+ enum class LogType
+ {
MODCALL,
FULL,
FULLAREA
@@ -47,13 +50,15 @@ public:
Q_ENUM(LogType)
};
-template
-T toDataType(const QString& f_string){
+template
+T toDataType(const QString &f_string)
+{
return QVariant(f_string).value();
}
-template
-QString fromDataType(const T& f_t){
+template
+QString fromDataType(const T &f_t)
+{
return QVariant::fromValue(f_t).toString();
}
diff --git a/core/include/db_manager.h b/core/include/db_manager.h
index d758066..8042d36 100644
--- a/core/include/db_manager.h
+++ b/core/include/db_manager.h
@@ -21,13 +21,13 @@
#define DB_VERSION 1
#include
+#include
#include
#include
#include
#include
#include
#include
-#include
/**
* @brief A class used to handle database interaction.
@@ -39,9 +39,11 @@
* differently than the average user.
* This comes in two forms, when the user's client is banned, and when the user is a moderator.
*/
-class DBManager : public QObject {
+class DBManager : public QObject
+{
Q_OBJECT
-public:
+
+ public:
/**
* @brief Constructor for the DBManager class.
*
@@ -51,8 +53,8 @@ public:
DBManager();
/**
- * @brief Destructor for the DBManager class. Closes the underlying database.
- */
+ * @brief Destructor for the DBManager class. Closes the underlying database.
+ */
~DBManager();
/**
@@ -95,15 +97,16 @@ public:
/**
* @brief Details about a ban.
*/
- struct BanInfo {
- QString ipid; //!< The banned user's IPID.
- QHostAddress ip; //!< The banned user's IP.
- QString hdid; //!< The banned user's hardware ID.
+ struct BanInfo
+ {
+ QString ipid; //!< The banned user's IPID.
+ QHostAddress ip; //!< The banned user's IP.
+ QString hdid; //!< The banned user's hardware ID.
unsigned long time; //!< The time the ban was registered.
- QString reason; //!< The reason given for the ban by the moderator who registered it.
+ QString reason; //!< The reason given for the ban by the moderator who registered it.
long long duration; //!< The duration of the ban, in seconds.
- int id; //!< The unique ID of the ban.
- QString moderator; //!< The moderator who issued the ban.
+ int id; //!< The unique ID of the ban.
+ QString moderator; //!< The moderator who issued the ban.
};
/**
@@ -250,7 +253,7 @@ public:
*/
bool updatePassword(QString username, QString password);
-private:
+ private:
/**
* @brief The name of the database connection driver.
*/
diff --git a/core/include/discord.h b/core/include/discord.h
index 1f28009..56dc3c0 100644
--- a/core/include/discord.h
+++ b/core/include/discord.h
@@ -18,17 +18,19 @@
#ifndef DISCORD_H
#define DISCORD_H
-#include
#include
-#include "config_manager.h"
+#include
+
+class ConfigManager;
/**
* @brief A class for handling all Discord webhook requests.
*/
-class Discord : public QObject {
+class Discord : public QObject
+{
Q_OBJECT
-public:
+ public:
/**
* @brief Constructor for the Discord object
*
@@ -37,13 +39,13 @@ public:
* @param f_webhook_sendfile Whether or not to send a file containing area logs with the webhook POST request.
* @param parent Qt-based parent, passed along to inherited constructor from QObject.
*/
- Discord(QObject* parent = nullptr);
+ Discord(QObject *parent = nullptr);
/**
- * @brief Deconstructor for the Discord class.
- *
- * @details Marks the nam to be deleted later.
- */
+ * @brief Deconstructor for the Discord class.
+ *
+ * @details Marks the nam to be deleted later.
+ */
~Discord();
/**
@@ -56,8 +58,7 @@ public:
*/
void stopUptimeTimer();
-
-public slots:
+ public slots:
/**
* @brief Handles a modcall webhook request.
*
@@ -66,7 +67,7 @@ public slots:
* @param f_reason The reason for the modcall.
* @param f_buffer The area's log buffer.
*/
- void onModcallWebhookRequested(const QString& f_name, const QString& f_area, const QString& f_reason, const QQueue& f_buffer);
+ void onModcallWebhookRequested(const QString &f_name, const QString &f_area, const QString &f_reason, const QQueue &f_buffer);
/**
* @brief Handles a ban webhook request.
@@ -76,18 +77,18 @@ public slots:
* @param f_duration The date the ban expires.
* @param f_reason The reason of the ban.
*/
- void onBanWebhookRequested(const QString& f_ipid, const QString& f_moderator, const QString& f_duration, const QString& f_reason, const int& f_banID);
+ void onBanWebhookRequested(const QString &f_ipid, const QString &f_moderator, const QString &f_duration, const QString &f_reason, const int &f_banID);
/**
* @brief Handles a uptime webhook request.
*/
void onUptimeWebhookRequested();
-private:
+ private:
/**
* @brief The QNetworkAccessManager for webhooks.
*/
- QNetworkAccessManager* m_nam;
+ QNetworkAccessManager *m_nam;
/**
* @brief The QNetworkRequest for webhooks.
@@ -97,7 +98,7 @@ private:
/**
* @brief Timer to post a message that the server is still alive.
*/
- QTimer* m_uptimePostTimer;
+ QTimer *m_uptimePostTimer;
/**
* @brief Constructs a new JSON document for modcalls.
@@ -108,7 +109,7 @@ private:
*
* @return A JSON document for the modcall.
*/
- QJsonDocument constructModcallJson(const QString& f_name, const QString& f_area, const QString& f_reason) const;
+ QJsonDocument constructModcallJson(const QString &f_name, const QString &f_area, const QString &f_reason) const;
/**
* @brief Constructs a new QHttpMultiPart document for log files.
@@ -117,29 +118,29 @@ private:
*
* @return A QHttpMultiPart containing the log file.
*/
- QHttpMultiPart* constructLogMultipart(const QQueue& f_buffer) const;
+ QHttpMultiPart *constructLogMultipart(const QQueue &f_buffer) const;
-private slots:
+ private slots:
/**
* @brief Handles a network reply from a webhook POST request.
*
* @param f_reply Pointer to the QNetworkReply created by the webhook POST request.
*/
- void onReplyFinished(QNetworkReply* f_reply);
+ void onReplyFinished(QNetworkReply *f_reply);
/**
* @brief Sends a webhook POST request with the given JSON document.
*
* @param f_json The JSON document to send.
*/
- void postJsonWebhook(const QJsonDocument& f_json);
+ void postJsonWebhook(const QJsonDocument &f_json);
/**
* @brief Sends a webhook POST request with the given QHttpMultiPart.
*
* @param f_multipart The QHttpMultiPart to send.
*/
- void postMultipartWebhook(QHttpMultiPart& f_multipart);
+ void postMultipartWebhook(QHttpMultiPart &f_multipart);
/**
* @brief Constructs a new JSON document for bans.
@@ -151,15 +152,14 @@ private slots:
*
* @return A JSON document for the ban.
*/
- QJsonDocument constructBanJson(const QString& f_ipid, const QString& f_moderator, const QString& f_duration, const QString& f_reason, const int& f_banID);
+ QJsonDocument constructBanJson(const QString &f_ipid, const QString &f_moderator, const QString &f_duration, const QString &f_reason, const int &f_banID);
/**
* @brief Constructs a new JSON document for the server alive message.
* @param f_timeExpired formatted uptime as a string.
*
* @return A JSON document for the alive notification.
*/
- QJsonDocument constructUptimeJson(const QString& f_timeExpired);
-
+ QJsonDocument constructUptimeJson(const QString &f_timeExpired);
};
#endif // DISCORD_H
diff --git a/core/include/logger/u_logger.h b/core/include/logger/u_logger.h
index 5d1ec7c..bc3ef38 100644
--- a/core/include/logger/u_logger.h
+++ b/core/include/logger/u_logger.h
@@ -18,13 +18,13 @@
#ifndef U_LOGGER_H
#define U_LOGGER_H
-#include
-#include
-#include
-#include
#include "include/config_manager.h"
#include "include/logger/writer_full.h"
#include "include/logger/writer_modcall.h"
+#include
+#include
+#include
+#include
/**
* @brief The Universal Logger class to provide a common place to handle, store and write logs to file.
@@ -32,12 +32,13 @@
class ULogger : public QObject
{
Q_OBJECT
-public:
+
+ public:
/**
* @brief Constructor for the universal logger. Determines which writer is initially created.
* @param Pointer to the Server.
*/
- ULogger(QObject* parent = nullptr);
+ ULogger(QObject *parent = nullptr);
/**
* @brief Deconstructor of the universal logger. Deletes its writer before deconstruction.
@@ -50,65 +51,64 @@ public:
*/
QQueue buffer(const QString &f_areaName);
-public slots:
+ public slots:
/**
* @brief Adds an IC log entry to the area buffer and writes it to the respective log format.
*/
- void logIC(const QString& f_char_name, const QString& f_ooc_name, const QString& f_ipid,
- const QString& f_area_name, const QString &f_message);
+ void logIC(const QString &f_char_name, const QString &f_ooc_name, const QString &f_ipid,
+ const QString &f_area_name, const QString &f_message);
/**
* @brief Adds an OOC log entry to the area buffer and writes it to the respective log format.
*/
- void logOOC(const QString& f_char_Name, const QString& f_ooc_name, const QString& f_ipid,
- const QString& f_area_name, const QString& f_message);
+ void logOOC(const QString &f_char_Name, const QString &f_ooc_name, const QString &f_ipid,
+ const QString &f_area_name, const QString &f_message);
/**
* @brief Adds an login attempt to the area buffer and writes it to the respective log format.
*/
- void logLogin(const QString& f_char_name, const QString& f_ooc_name, const QString& f_moderator_name,
- const QString& f_ipid, const QString &f_area_name, const bool& f_success);
+ void logLogin(const QString &f_char_name, const QString &f_ooc_name, const QString &f_moderator_name,
+ const QString &f_ipid, const QString &f_area_name, const bool &f_success);
/**
* @brief Adds a command usage to the area buffer and writes it to the respective log format.
*/
- void logCMD(const QString& f_char_name, const QString &f_ipid, const QString& f_ooc_name, const QString& f_command,
- const QStringList& f_args, const QString& f_area_name);
+ void logCMD(const QString &f_char_name, const QString &f_ipid, const QString &f_ooc_name, const QString &f_command,
+ const QStringList &f_args, const QString &f_area_name);
/**
* @brief Adds a player kick to the area buffer and writes it to the respective log format.
*/
- void logKick(const QString& f_moderator, const QString& f_target_ipid);
+ void logKick(const QString &f_moderator, const QString &f_target_ipid);
/**
* @brief Adds a player ban to the area buffer and writes it to the respective log format.
*/
- void logBan(const QString& f_moderator, const QString& f_target_ipid, const QString &f_duration);
+ void logBan(const QString &f_moderator, const QString &f_target_ipid, const QString &f_duration);
/**
* @brief Adds a modcall event to the area buffer, also triggers modcall writing.
*/
- void logModcall(const QString& f_char_name, const QString &f_ipid, const QString& f_ooc_name, const QString& f_area_name);
+ void logModcall(const QString &f_char_name, const QString &f_ipid, const QString &f_ooc_name, const QString &f_area_name);
/**
* @brief Logs any connection attempt to the server, wether sucessful or not.
*/
- void logConnectionAttempt(const QString& f_ip_address, const QString& f_ipid, const QString& f_hwid);
+ void logConnectionAttempt(const QString &f_ip_address, const QString &f_ipid, const QString &f_hwid);
/**
* @brief Loads template strings for the logger.
*/
void loadLogtext();
-private:
-
+ private:
/**
* @brief Updates the area buffer with a new entry, moving old ones if the buffer exceesed the maximum size.
* @param Name of the area which buffer is modified.
* @param Formatted QString to be added into the buffer.
*/
- void updateAreaBuffer(const QString& f_areaName, const QString& f_log_entry);
+ void updateAreaBuffer(const QString &f_areaName, const QString &f_log_entry);
/**
* @brief QMap of all available area buffers.
@@ -120,12 +120,12 @@ private:
/**
* @brief Pointer to modcall writer. Handles QQueue delogging into area specific file.
*/
- WriterModcall* writerModcall;
+ WriterModcall *writerModcall;
/**
* @brief Pointer to full writer. Handles single messages in one file.
*/
- WriterFull* writerFull;
+ WriterFull *writerFull;
/**
* @brief Table that contains template strings for text-based logger format.
@@ -133,19 +133,18 @@ private:
* This has the problem of lacking defaults that work for all when the file is missing.
* This QMap contains all default values and overwrites them on logger construction.
*/
- QHashm_logtext {
- {"ic", "[%1][%5][IC][%2(%3)][%4]%6"},
- {"ooc", "[%1][%5][OOC][%2(%3)][%4]%6"},
- {"login", "[%1][LOGIN][%2][%3][%4(%5)]"},
- {"cmdlogin", "[%1][%2][LOGIN][%5][%3(%4)]"},
+ QHash m_logtext{
+ {"ic", "[%1][%5][IC][%2(%3)][%4]%6"},
+ {"ooc", "[%1][%5][OOC][%2(%3)][%4]%6"},
+ {"login", "[%1][LOGIN][%2][%3][%4(%5)]"},
+ {"cmdlogin", "[%1][%2][LOGIN][%5][%3(%4)]"},
{"cmdrootpass", "[%1][%2][ROOTPASS][%5][%3(%4)]"},
- {"cmdadduser", "[%1][%2][USERADD][%6][%3(%4)]%5"},
- {"cmd", "[%1][%2][CMD][%7][%3(%4)]/%5 %6"},
- {"kick", "[%1][%2][KICK][%3]"},
- {"ban", "[%1][%2][BAN][%3][%4]"},
- {"modcall", "[%1][%2][MODCALL][%5][%3(%4)]"},
- {"connect", "[%1][CONNECT][%2][%3][%4]"}
- };
+ {"cmdadduser", "[%1][%2][USERADD][%6][%3(%4)]%5"},
+ {"cmd", "[%1][%2][CMD][%7][%3(%4)]/%5 %6"},
+ {"kick", "[%1][%2][KICK][%3]"},
+ {"ban", "[%1][%2][BAN][%3][%4]"},
+ {"modcall", "[%1][%2][MODCALL][%5][%3(%4)]"},
+ {"connect", "[%1][CONNECT][%2][%3][%4]"}};
};
-#endif //U_LOGGER_H
+#endif // U_LOGGER_H
diff --git a/core/include/logger/writer_full.h b/core/include/logger/writer_full.h
index 69a17f3..77087e8 100644
--- a/core/include/logger/writer_full.h
+++ b/core/include/logger/writer_full.h
@@ -17,10 +17,10 @@
//////////////////////////////////////////////////////////////////////////////////////
#ifndef WRITER_FULL_H
#define WRITER_FULL_H
-#include
-#include
-#include
#include
+#include
+#include
+#include
#include
/**
@@ -29,13 +29,15 @@
class WriterFull : public QObject
{
Q_OBJECT
-public:
+
+ public:
/**
* @brief Constructor for full logwriter
*
* @param QObject pointer to the parent object.
*/
- WriterFull(QObject* parent = nullptr);;
+ WriterFull(QObject *parent = nullptr);
+ ;
/**
* @brief Deconstructor for full logwriter.
@@ -57,7 +59,7 @@ public:
*/
void flush(const QString f_entry, const QString f_area_name);
-private:
+ private:
/**
* @brief Filename of the logfile used. This will always be the time the server starts up.
*/
@@ -69,4 +71,4 @@ private:
QDir l_dir;
};
-#endif //WRITER_FULL_H
+#endif // WRITER_FULL_H
diff --git a/core/include/logger/writer_modcall.h b/core/include/logger/writer_modcall.h
index 3670250..c8517e5 100644
--- a/core/include/logger/writer_modcall.h
+++ b/core/include/logger/writer_modcall.h
@@ -17,13 +17,12 @@
//////////////////////////////////////////////////////////////////////////////////////
#ifndef WRITER_MODCALL_H
#define WRITER_MODCALL_H
-#include
-#include
-#include
#include
-#include
+#include
+#include
+#include
#include
-
+#include
/**
* @brief A class to handle file interaction when writing the modcall buffer.
@@ -31,13 +30,15 @@
class WriterModcall : public QObject
{
Q_OBJECT
-public:
+
+ public:
/**
* @brief Constructor for modcall logwriter
*
* @param QObject pointer to the parent object.
*/
- WriterModcall(QObject* parent = nullptr);;
+ WriterModcall(QObject *parent = nullptr);
+ ;
/**
* @brief Deconstructor for modcall logwriter.
@@ -53,7 +54,7 @@ public:
*/
void flush(const QString f_area_name, QQueue f_buffer);
-private:
+ private:
/**
* @brief Filename of the logfile used.
*/
@@ -65,4 +66,4 @@ private:
QDir l_dir;
};
-#endif //WRITER_MODCALL_H
+#endif // WRITER_MODCALL_H
diff --git a/core/include/music_manager.h b/core/include/music_manager.h
index 2c7fd40..aaa3e44 100644
--- a/core/include/music_manager.h
+++ b/core/include/music_manager.h
@@ -18,26 +18,27 @@
#ifndef MUSIC_MANAGER_H
#define MUSIC_MANAGER_H
-#include
-#include
#include
+#include
+#include
#include
-#include
-#include
+#include "include/aopacket.h"
+#include "include/typedefs.h"
+
+class ConfigManager;
class MusicManager : public QObject
{
Q_OBJECT
-public:
+ public:
/**
* @brief Constructor for the server-wide musiclist manager.
*
* @param Copy of the server musiclist generated by ConfigManager::musiclist();
*/
- MusicManager(QObject* parent = nullptr, QStringList f_root_ordered = {}, QStringList f_cdns = {"cdn.discord.com"},
- QMap > f_root_list = ConfigManager::musiclist());
+ MusicManager(QStringList f_root_ordered, QStringList f_cdns, QMap> f_root_list, QObject *parent = nullptr);
/**
* @brief Destructor for the server-wide musiclist manager.
@@ -146,7 +147,7 @@ public:
*/
bool isCustom(int f_area_id, QString f_song_name);
-public slots:
+ public slots:
/**
* @brief Updates the root musiclist and CDN list.
@@ -158,7 +159,7 @@ public slots:
*/
void userJoinedArea(int f_area_index, int f_user_id);
-signals:
+ signals:
/**
* @brief Sends the FM packet with the musiclist of the area when a client enters.
@@ -178,12 +179,11 @@ signals:
*/
void sendAreaFMPacket(AOPacket f_packet, int f_area_index);
-private:
-
+ private:
/**
* @brief Contains all custom lists of all areas in the server.
*/
- QHash* m_custom_lists;
+ QHash *m_custom_lists;
/**
* @brief Server musiclist shared among all areas.
@@ -198,12 +198,12 @@ private:
/**
* @brief Contains all custom songs ordered in a per-area buffer.
*/
- QMap m_customs_ordered;
+ QMap m_customs_ordered;
/**
* @brief Wether the global musiclist is prepend and validation when adding custom music.
*/
- QHash m_global_enabled;
+ QHash m_global_enabled;
/**
* @brief Contains all server approved content sources.
diff --git a/core/include/server.h b/core/include/server.h
index 36c2f7e..88bb3f3 100644
--- a/core/include/server.h
+++ b/core/include/server.h
@@ -18,35 +18,34 @@
#ifndef SERVER_H
#define SERVER_H
-#include "include/aoclient.h"
-#include "include/aopacket.h"
-#include "include/area_data.h"
-#include "include/ws_proxy.h"
-#include "include/db_manager.h"
-#include "include/discord.h"
-#include "include/config_manager.h"
-#include "include/advertiser.h"
-#include "include/logger/u_logger.h"
-#include "include/music_manager.h"
-
#include
#include
#include
#include
#include
+#include
#include
#include
#include
#include
+#include "include/aopacket.h"
+
+class Advertiser;
class AOClient;
-class DBManager;
class AreaData;
+class ConfigManager;
+class DBManager;
+class Discord;
+class MusicManager;
+class ULogger;
+class WSProxy;
/**
* @brief The class that represents the actual server as it is.
*/
-class Server : public QObject {
+class Server : public QObject
+{
Q_OBJECT
public:
@@ -57,13 +56,13 @@ class Server : public QObject {
* @param p_ws_port The WebSocket port to listen for connections on.
* @param parent Qt-based parent, passed along to inherited constructor from QObject.
*/
- Server(int p_port, int p_ws_port, QObject* parent = nullptr);
+ Server(int p_port, int p_ws_port, QObject *parent = nullptr);
/**
- * @brief Destructor for the Server class.
- *
- * @details Marks every Client, the WSProxy, the underlying #server, and the database manager to be deleted later.
- */
+ * @brief Destructor for the Server class.
+ *
+ * @details Marks every Client, the WSProxy, the underlying #server, and the database manager to be deleted later.
+ */
~Server();
/**
@@ -79,13 +78,21 @@ class Server : public QObject {
/**
* @brief Enum to specifc different targets to send altered packets to a specific usergroup.
*/
- enum class TARGET_TYPE {
+ enum class TARGET_TYPE
+ {
AUTHENTICATED,
MODCHAT,
ADVERT
};
Q_ENUM(TARGET_TYPE)
+ /**
+ * @brief Returns a list of all clients currently in the server.
+ *
+ * @return A list of all clients currently in the server.
+ */
+ QVector getClients();
+
/**
* @brief Gets a pointer to a client by IPID.
*
@@ -95,7 +102,7 @@ class Server : public QObject {
*
* @see Server::getClientsByIpid() to get all clients ran by the same user.
*/
- AOClient* getClient(QString ipid);
+ AOClient *getClient(QString ipid);
/**
* @brief Gets a list of pointers to all clients with the given IPID.
@@ -104,8 +111,8 @@ class Server : public QObject {
*
* @return A list of clients whose IPID match. List may be empty.
*/
- QList getClientsByIpid(QString ipid);
-
+ QList getClientsByIpid(QString ipid);
+
/**
* @brief Gets a pointer to a client by user ID.
*
@@ -113,7 +120,37 @@ class Server : public QObject {
*
* @return A pointer to the client if found, a nullpointer if not.
*/
- AOClient* getClientByID(int id);
+ AOClient *getClientByID(int id);
+
+ /**
+ * @brief Returns the overall player count in the server.
+ *
+ * @return The overall player count in the server.
+ */
+ int getPlayerCount();
+
+ /**
+ * @brief Returns a list of the available characters on the server to use.
+ *
+ * @return A list of the available characters on the server to use.
+ */
+ QStringList getCharacters();
+
+ /**
+ * @brief Returns the count of available characters on the server to use.
+ *
+ * @return The count of available characters on the server to use.
+ */
+ int getCharacterCount();
+
+ /**
+ * @brief Get the available character by index.
+ *
+ * @param f_chr_id The index of the character.
+ *
+ * @return The character if it exist, otherwise an empty stirng.
+ */
+ QString getCharacterById(int f_chr_id);
/**
* @brief Updates which characters are taken in the given area, and sends out an update packet to
@@ -121,7 +158,7 @@ class Server : public QObject {
*
* @param area The area in which to update the list of characters.
*/
- void updateCharsTaken(AreaData* area);
+ void updateCharsTaken(AreaData *area);
/**
* @brief Sends a packet to all clients in a given area.
@@ -185,20 +222,229 @@ class Server : public QObject {
**/
bool isIPBanned(QHostAddress f_remote_IP);
+ /**
+ * @brief Returns the list of areas in the server.
+ *
+ * @return A list of areas.
+ */
+ QVector getAreas();
+
+ /**
+ * @brief Returns the number of areas in the server.
+ */
+ int getAreaCount();
+
+ /**
+ * @brief Returns a pointer to the area associated with the index.
+ *
+ * @param f_area_id The index of the area.
+ *
+ * @return A pointer to the area or null.
+ */
+ AreaData *getAreaById(int f_area_id);
+
/**
* @brief Getter for an area specific buffer from the logger.
*/
- QQueue getAreaBuffer(const QString& f_areaName);
+ QQueue getAreaBuffer(const QString &f_areaName);
+
+ /**
+ * @brief The names of the areas on the server.
+ *
+ * @return A list of names.
+ */
+ QStringList getAreaNames();
+
+ /**
+ * @brief Returns the name of the area associated with the index.
+ *
+ * @param f_area_id The index of the area.
+ *
+ * @return The name of the area or empty.
+ */
+ QString getAreaName(int f_area_id);
+
+ /**
+ * @brief Returns the available songs on the server.
+ *
+ * @return A list of songs.
+ */
+ QStringList getMusicList();
+
+ /**
+ * @brief Returns the available backgrounds on the server.
+ *
+ * @return A list of backgrounds.
+ */
+ QStringList getBackgrounds();
+
+ /**
+ * @brief Returns a pointer to a database manager.
+ *
+ * @return A pointer to database manager.
+ */
+ DBManager *getDatabaseManager();
+
+ /**
+ * @brief The server-wide global timer.
+ */
+ QTimer *timer;
+
+ QStringList getCursedCharsTaken(AOClient *client, QStringList chars_taken);
+
+ /**
+ * @brief Returns whatever a game message may be broadcasted or not.
+ *
+ * @return True if expired; false otherwise.
+ */
+ bool isMessageAllowed();
+
+ /**
+ * @brief Starts a global timer that determines whatever a game message may be broadcasted or not.
+ *
+ * @param f_duration The duration of the message floodguard timer.
+ */
+ void startMessageFloodguard(int f_duration);
+
+ /**
+ * @brief Attempts to parse a IPv6 mapped IPv4 to an IPv4.
+ */
+ QHostAddress parseToIPv4(QHostAddress f_remote_ip);
+
+ public slots:
+ /**
+ * @brief Convenience class to call a reload of available configuraiton elements.
+ */
+ void reloadSettings();
+
+ /**
+ * @brief Handles a new connection.
+ *
+ * @details The function creates an AOClient to represent the user, assigns a user ID to them, and
+ * checks if the client is banned.
+ */
+ void clientConnected();
+
+ /**
+ * @brief Method to construct and reconstruct Discord Webhook Integration.
+ *
+ * @details Constructs or rebuilds Discord Object during server startup and configuration reload.
+ */
+ void handleDiscordIntegration();
+
+ /**
+ * @brief Marks a userID as free and ads it back to the available client id queue.
+ */
+ void markIDFree(const int &f_user_id);
+
+ signals:
+
+ /**
+ * @brief Sends the server name and description, emitted by /reload.
+ *
+ * @param p_name The server name.
+ * @param p_desc The server description.
+ */
+ void reloadRequest(QString p_name, QString p_desc);
+
+ /**
+ * @brief This signal is emitted whenever the current player count has changed.
+ *
+ * @param f_current_player The player count at the time the signal was emitted.
+ */
+ void playerCountUpdated(int f_current_players);
+
+ /**
+ * @brief Triggers a partial update of the modern advertiser as some information, such as ports
+ * can't be updated while the server is running.
+ */
+ void updateHTTPConfiguration();
+
+ /**
+ * @brief Sends a modcall webhook request, emitted by AOClient::pktModcall.
+ *
+ * @param f_name The character or OOC name of the client who sent the modcall.
+ * @param f_area The name of the area the modcall was sent from.
+ * @param f_reason The reason the client specified for the modcall.
+ * @param f_buffer The area's log buffer.
+ */
+ void modcallWebhookRequest(const QString &f_name, const QString &f_area, const QString &f_reason, const QQueue &f_buffer);
+
+ /**
+ * @brief Sends a ban webhook request, emitted by AOClient::cmdBan
+ * @param f_ipid The IPID of the banned client.
+ * @param f_moderator The moderator who issued the ban.
+ * @param f_duration The duration of the ban in a human readable format.
+ * @param f_reason The reason for the ban.
+ * @param f_banID The ID of the issued ban.
+ */
+ void banWebhookRequest(const QString &f_ipid, const QString &f_moderator, const QString &f_duration, const QString &f_reason, const int &f_banID);
+
+ /**
+ * @brief Signal connected to universal logger. Logs a client connection attempt.
+ * @param f_ip_address The IP Address of the incoming connection.
+ * @param f_ipid The IPID of the incoming connection.
+ * @param f_hdid The HDID of the incoming connection.
+ */
+ void logConnectionAttempt(const QString &f_ip_address, const QString &f_ipid, const QString &f_hwid);
+
+ private:
+ /**
+ * @brief The proxy used for WebSocket connections.
+ *
+ * @see WSProxy and WSClient for an explanation as to why this is a thing.
+ */
+ WSProxy *proxy;
+
+ /**
+ * @brief Listens for incoming TCP connections.
+ */
+ QTcpServer *server;
+
+ /**
+ * @brief Handles Discord webhooks.
+ */
+ Discord *discord;
+
+ /**
+ * @brief Handles HTTP server advertising.
+ */
+ Advertiser *ms3_Advertiser;
+
+ /**
+ * @brief Advertises the server in a regular intervall.
+ */
+ QTimer *AdvertiserTimer;
+
+ /**
+ * @brief Handles the universal log framework.
+ */
+ ULogger *logger;
+
+ /**
+ * @brief Handles all musiclists.
+ */
+ MusicManager *music_manager;
+
+ /**
+ * @brief The port through which the server will accept TCP connections.
+ */
+ int port;
+
+ /**
+ * @brief The port through which the server will accept WebSocket connections.
+ */
+ int ws_port;
/**
* @brief The collection of all currently connected clients.
*/
- QVector m_clients;
+ QVector m_clients;
/**
* @brief Collection of all clients with their userID as key.
*/
- QHash m_clients_ids;
+ QHash m_clients_ids;
/**
* @brief Stack of all available IDs for clients. When this is empty the server
@@ -219,7 +465,7 @@ class Server : public QObject {
/**
* @brief The areas on the server.
*/
- QVector m_areas;
+ QVector m_areas;
/**
* @brief The names of the areas on the server.
@@ -247,169 +493,43 @@ class Server : public QObject {
*/
QStringList m_ipban_list;
- /**
- * @brief The database manager on the server, used to store users' bans and authorisation details.
- */
- DBManager* db_manager;
-
- /**
- * @brief The server-wide global timer.
- */
- QTimer* timer;
-
-
- QStringList getCursedCharsTaken(AOClient* client, QStringList chars_taken);
-
/**
* @brief Timer until the next IC message can be sent.
*/
- QTimer next_message_timer;
-
- /**
- * @brief Attempts to parse a IPv6 mapped IPv4 to an IPv4.
- */
- QHostAddress parseToIPv4(QHostAddress f_remote_ip);
+ QTimer *m_message_floodguard_timer;
/**
* @brief If false, IC messages will be rejected.
*/
- bool can_send_ic_messages = true;
-
- public slots:
+ bool m_can_send_ic_messages = true;
/**
- * @brief Convenience class to call a reload of available configuraiton elements.
+ * @brief The database manager on the server, used to store users' bans and authorisation details.
*/
- void reloadSettings();
+ DBManager *db_manager;
- /**
- * @brief Handles a new connection.
- *
- * @details The function creates an AOClient to represent the user, assigns a user ID to them, and
- * checks if the client is banned.
- */
- void clientConnected();
-
- /**
- * @brief Sets #can_send_messages to true.
- *
- * @details Called whenever #next_message_timer reaches 0.
- */
- void allowMessage();
-
- /**
- * @brief Method to construct and reconstruct Discord Webhook Integration.
- *
- * @details Constructs or rebuilds Discord Object during server startup and configuration reload.
- */
- void handleDiscordIntegration();
-
- /**
- * @brief Marks a userID as free and ads it back to the available client id queue.
- */
- void markIDFree(const int& f_user_id);
-
- signals:
-
- /**
- * @brief Sends the server name and description, emitted by /reload.
- *
- * @param p_name The server name.
- * @param p_desc The server description.
- */
- void reloadRequest(QString p_name, QString p_desc);
-
- /**
- * @brief Updates the playercount in the modern advertiser.
- */
- void updatePlayerCount(int f_current_players);
-
- /**
- * @brief Triggers a partial update of the modern advertiser as some information, such as ports
- * can't be updated while the server is running.
- */
- void updateHTTPConfiguration();
-
- /**
- * @brief Sends a modcall webhook request, emitted by AOClient::pktModcall.
- *
- * @param f_name The character or OOC name of the client who sent the modcall.
- * @param f_area The name of the area the modcall was sent from.
- * @param f_reason The reason the client specified for the modcall.
- * @param f_buffer The area's log buffer.
- */
- void modcallWebhookRequest(const QString& f_name, const QString& f_area, const QString& f_reason, const QQueue& f_buffer);
-
- /**
- * @brief Sends a ban webhook request, emitted by AOClient::cmdBan
- * @param f_ipid The IPID of the banned client.
- * @param f_moderator The moderator who issued the ban.
- * @param f_duration The duration of the ban in a human readable format.
- * @param f_reason The reason for the ban.
- * @param f_banID The ID of the issued ban.
- */
- void banWebhookRequest(const QString& f_ipid, const QString& f_moderator, const QString& f_duration, const QString& f_reason, const int& f_banID);
-
- /**
- * @brief Signal connected to universal logger. Logs a client connection attempt.
- * @param f_ip_address The IP Address of the incoming connection.
- * @param f_ipid The IPID of the incoming connection.
- * @param f_hdid The HDID of the incoming connection.
- */
- void logConnectionAttempt(const QString& f_ip_address, const QString& f_ipid, const QString& f_hwid);
-
- private:
/**
* @brief Connects new AOClient to logger and disconnect handling.
**/
- void hookupAOClient(AOClient* client);
+ void hookupAOClient(AOClient *client);
+
+ private slots:
+ /**
+ * @brief Increase the current player count by one.
+ */
+ void increasePlayerCount();
/**
- * @brief The proxy used for WebSocket connections.
+ * @brief Decrease the current player count based on the client id provided.
*
- * @see WSProxy and WSClient for an explanation as to why this is a thing.
+ * @param f_client_id The client id of the client to check.
*/
- WSProxy* proxy;
+ void decreasePlayerCount();
/**
- * @brief Listens for incoming TCP connections.
+ * @brief Allow game messages to be broadcasted.
*/
- QTcpServer* server;
-
- /**
- * @brief Handles Discord webhooks.
- */
- Discord* discord;
-
- /**
- * @brief Handles HTTP server advertising.
- */
- Advertiser* ms3_Advertiser;
-
- /**
- * @brief Advertises the server in a regular intervall.
- */
- QTimer* AdvertiserTimer;
-
- /**
- * @brief Handles the universal log framework.
- */
- ULogger* logger;
-
- /**
- * @brief Handles all musiclists.
- */
- MusicManager* music_manager;
-
- /**
- * @brief The port through which the server will accept TCP connections.
- */
- int port;
-
- /**
- * @brief The port through which the server will accept WebSocket connections.
- */
- int ws_port;
+ void allowMessage();
};
#endif // SERVER_H
diff --git a/core/include/typedefs.h b/core/include/typedefs.h
new file mode 100644
index 0000000..c7fa73a
--- /dev/null
+++ b/core/include/typedefs.h
@@ -0,0 +1,7 @@
+#pragma once
+
+#include
+#include
+#include
+
+typedef QMap> MusicList;
diff --git a/core/include/ws_client.h b/core/include/ws_client.h
index 6f0e68e..d947f0e 100644
--- a/core/include/ws_client.h
+++ b/core/include/ws_client.h
@@ -19,9 +19,9 @@
#define WS_CLIENT_H
#include
-#include
-#include
#include
+#include
+#include
/**
* @brief Represents a WebSocket client (generally WebAO) connected to the server.
@@ -31,9 +31,11 @@
*
* This class is a very thin layer -- see WSProxy for the actual mechanics of this WebSocket-to-TCP proxy solution.
*/
-class WSClient : public QObject {
+class WSClient : public QObject
+{
Q_OBJECT
-public:
+
+ public:
/**
* @brief Creates an instance of the WSClient class.
*
@@ -44,15 +46,15 @@ public:
* @pre This class will not connect up the ports to each other in any way. Unless some setup is done, this class
* by default will never be prompted to read and/or write from/to either of the sockets.
*/
- WSClient(QTcpSocket* p_tcp_socket, QWebSocket* p_web_socket, QObject* parent = nullptr);
+ WSClient(QTcpSocket *p_tcp_socket, QWebSocket *p_web_socket, QObject *parent = nullptr);
/**
- * @brief Destructor for the WSClient class.
- *
- * @details Marks the TCP and WebSocket for later deletion.
- */
+ * @brief Destructor for the WSClient class.
+ *
+ * @details Marks the TCP and WebSocket for later deletion.
+ */
~WSClient();
-public slots:
+ public slots:
/**
* @brief A slot that can be signalled when #tcp_socket has data ready for reading.
* Will read all data in the socket.
@@ -92,17 +94,16 @@ public slots:
*/
void onTcpConnect();
-
-private:
+ private:
/**
* @brief The local TCP socket used as a proxy to connect with the server.
*/
- QTcpSocket* tcp_socket;
+ QTcpSocket *tcp_socket;
/**
* @brief The WebSocket representing an incoming connection.
*/
- QWebSocket* web_socket;
+ QWebSocket *web_socket;
/**
* @brief Stores partial packets in case they don't all come through the TCP socket at once
diff --git a/core/include/ws_proxy.h b/core/include/ws_proxy.h
index d83bed3..e1bd6f3 100644
--- a/core/include/ws_proxy.h
+++ b/core/include/ws_proxy.h
@@ -18,19 +18,21 @@
#ifndef WS_PROXY_H
#define WS_PROXY_H
-#include "include/ws_client.h"
-
+#include
#include
#include
#include
-#include
+
+class WSClient;
/**
* @brief Handles WebSocket connections by redirecting data sent through them through a local TCP connection
* for common handling.
*/
-class WSProxy : public QObject {
+class WSProxy : public QObject
+{
Q_OBJECT
+
public:
/**
* @brief Creates a WSProxy instance.
@@ -40,13 +42,13 @@ class WSProxy : public QObject {
* @param p_ws_port The WebSocket port. Should the same that is opened for WebSockets connections.
* @param parent Qt-based parent, passed along to inherited constructor from QObject.
*/
- WSProxy(int p_local_port, int p_ws_port, QObject* parent);
+ WSProxy(int p_local_port, int p_ws_port, QObject *parent);
/**
- * @brief Destructor for the WSProxy class.
- *
- * @details Marks the WebSocket server that is used to handle the proxy process to be deleted later.
- */
+ * @brief Destructor for the WSProxy class.
+ *
+ * @details Marks the WebSocket server that is used to handle the proxy process to be deleted later.
+ */
~WSProxy();
/**
@@ -54,7 +56,7 @@ class WSProxy : public QObject {
*/
void start();
-public slots:
+ public slots:
/**
* @brief Sets up the proxy process to the newly connected WebSocket.
*
@@ -66,12 +68,12 @@ public slots:
/**
* @brief The WebSocket server listening to incoming WebSocket connections.
*/
- QWebSocketServer* server;
+ QWebSocketServer *server;
/**
* @brief Every client connected through WebSocket.
*/
- QVector clients;
+ QVector clients;
/**
* @brief The TCP port that the WebSocket connections will be redirected through.
diff --git a/core/src/advertiser.cpp b/core/src/advertiser.cpp
index 906f9f7..488202a 100644
--- a/core/src/advertiser.cpp
+++ b/core/src/advertiser.cpp
@@ -17,13 +17,14 @@
//////////////////////////////////////////////////////////////////////////////////////
#include "include/advertiser.h"
+#include "include/config_manager.h"
+
Advertiser::Advertiser()
{
m_manager = new QNetworkAccessManager();
connect(m_manager, &QNetworkAccessManager::finished,
this, &Advertiser::msRequestFinished);
-
m_name = ConfigManager::serverName();
m_hostname = ConfigManager::advertiserHostname();
m_description = ConfigManager::serverDescription();
@@ -61,7 +62,7 @@ void Advertiser::msAdvertiseServer()
l_json["name"] = m_name;
if (!m_description.isEmpty()) {
- l_json["description"] = m_description;
+ l_json["description"] = m_description;
}
m_manager->post(request, QJsonDocument(l_json).toJson());
@@ -73,7 +74,6 @@ void Advertiser::msAdvertiseServer()
if (m_debug)
qWarning().noquote() << "Unable to advertise. Masterserver URL '" + m_masterserver.toString() + "' is not valid.";
return;
-
}
void Advertiser::msRequestFinished(QNetworkReply *f_reply)
@@ -110,5 +110,3 @@ void Advertiser::updateAdvertiserSettings()
m_masterserver = ConfigManager::advertiserIP();
m_debug = ConfigManager::advertiserDebug();
}
-
-
diff --git a/core/src/aoclient.cpp b/core/src/aoclient.cpp
index a57ecf6..2f870f9 100644
--- a/core/src/aoclient.cpp
+++ b/core/src/aoclient.cpp
@@ -17,6 +17,12 @@
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
+#include "include/aopacket.h"
+#include "include/area_data.h"
+#include "include/config_manager.h"
+#include "include/db_manager.h"
+#include "include/server.h"
+
void AOClient::clientData()
{
if (last_read + m_socket->bytesAvailable() > 30720) { // Client can send a max of 30KB to the server over two sequential reads
@@ -53,19 +59,18 @@ void AOClient::clientDisconnected()
qDebug() << remote_ip.toString() << "disconnected";
#endif
if (m_joined) {
- server->m_player_count--;
- emit server->updatePlayerCount(server->m_player_count);
- server->m_areas[m_current_area]->clientLeftArea(server->getCharID(m_current_char), m_id);
+ server->getAreaById(m_current_area)->clientLeftArea(server->getCharID(m_current_char), m_id);
arup(ARUPType::PLAYER_COUNT, true);
}
if (m_current_char != "") {
- server->updateCharsTaken(server->m_areas[m_current_area]);
+ server->updateCharsTaken(server->getAreaById(m_current_area));
}
bool l_updateLocks = false;
- for (AreaData* l_area : qAsConst(server->m_areas)) {
+ const QVector l_areas = server->getAreas();
+ for (AreaData *l_area : l_areas) {
l_updateLocks = l_updateLocks || l_area->removeOwner(m_id);
}
@@ -81,7 +86,7 @@ void AOClient::handlePacket(AOPacket packet)
#ifdef NET_DEBUG
qDebug() << "Received packet:" << packet.header << ":" << packet.contents << "args length:" << packet.contents.length();
#endif
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
PacketInfo l_info = packets.value(packet.header, {false, 0, &AOClient::pktDefault});
if (packet.contents.join("").size() > 16384) {
@@ -112,65 +117,65 @@ void AOClient::handlePacket(AOPacket packet)
void AOClient::changeArea(int new_area)
{
if (m_current_area == new_area) {
- sendServerMessage("You are already in area " + server->m_area_names[m_current_area]);
+ sendServerMessage("You are already in area " + server->getAreaName(m_current_area));
return;
}
- if (server->m_areas[new_area]->lockStatus() == AreaData::LockStatus::LOCKED && !server->m_areas[new_area]->invited().contains(m_id) && !checkAuth(ACLFlags.value("BYPASS_LOCKS"))) {
- sendServerMessage("Area " + server->m_area_names[new_area] + " is locked.");
+ if (server->getAreaById(new_area)->lockStatus() == AreaData::LockStatus::LOCKED && !server->getAreaById(new_area)->invited().contains(m_id) && !checkAuth(ACLFlags.value("BYPASS_LOCKS"))) {
+ sendServerMessage("Area " + server->getAreaName(new_area) + " is locked.");
return;
}
if (m_current_char != "") {
- server->m_areas[m_current_area]->changeCharacter(server->getCharID(m_current_char), -1);
- server->updateCharsTaken(server->m_areas[m_current_area]);
+ server->getAreaById(m_current_area)->changeCharacter(server->getCharID(m_current_char), -1);
+ server->updateCharsTaken(server->getAreaById(m_current_area));
}
- server->m_areas[m_current_area]->clientLeftArea(m_char_id, m_id);
+ server->getAreaById(m_current_area)->clientLeftArea(m_char_id, m_id);
bool l_character_taken = false;
- if (server->m_areas[new_area]->charactersTaken().contains(server->getCharID(m_current_char))) {
+ if (server->getAreaById(new_area)->charactersTaken().contains(server->getCharID(m_current_char))) {
m_current_char = "";
m_char_id = -1;
l_character_taken = true;
}
- server->m_areas[new_area]->clientJoinedArea(m_char_id, m_id);
+ server->getAreaById(new_area)->clientJoinedArea(m_char_id, m_id);
m_current_area = new_area;
arup(ARUPType::PLAYER_COUNT, true);
- sendEvidenceList(server->m_areas[new_area]);
- sendPacket("HP", {"1", QString::number(server->m_areas[new_area]->defHP())});
- sendPacket("HP", {"2", QString::number(server->m_areas[new_area]->proHP())});
- sendPacket("BN", {server->m_areas[new_area]->background()});
+ sendEvidenceList(server->getAreaById(new_area));
+ sendPacket("HP", {"1", QString::number(server->getAreaById(new_area)->defHP())});
+ sendPacket("HP", {"2", QString::number(server->getAreaById(new_area)->proHP())});
+ sendPacket("BN", {server->getAreaById(new_area)->background()});
if (l_character_taken) {
sendPacket("DONE");
}
- const QList l_timers = server->m_areas[m_current_area]->timers();
- for (QTimer* l_timer : l_timers) {
- int l_timer_id = server->m_areas[m_current_area]->timers().indexOf(l_timer) + 1;
+ const QList l_timers = server->getAreaById(m_current_area)->timers();
+ for (QTimer *l_timer : l_timers) {
+ int l_timer_id = server->getAreaById(m_current_area)->timers().indexOf(l_timer) + 1;
if (l_timer->isActive()) {
sendPacket("TI", {QString::number(l_timer_id), "2"});
- sendPacket("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(l_timer->remainingTime())))});
+ sendPacket("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0, 0).msecsTo(QTime(0, 0).addMSecs(l_timer->remainingTime())))});
}
else {
sendPacket("TI", {QString::number(l_timer_id), "3"});
}
}
- sendServerMessage("You moved to area " + server->m_area_names[m_current_area]);
- if (server->m_areas[m_current_area]->sendAreaMessageOnJoin())
- sendServerMessage(server->m_areas[m_current_area]->areaMessage());
+ sendServerMessage("You moved to area " + server->getAreaName(m_current_area));
+ if (server->getAreaById(m_current_area)->sendAreaMessageOnJoin())
+ sendServerMessage(server->getAreaById(m_current_area)->areaMessage());
- if (server->m_areas[m_current_area]->lockStatus() == AreaData::LockStatus::SPECTATABLE)
- sendServerMessage("Area " + server->m_area_names[m_current_area] + " is spectate-only; to chat IC you will need to be invited by the CM.");
+ if (server->getAreaById(m_current_area)->lockStatus() == AreaData::LockStatus::SPECTATABLE)
+ sendServerMessage("Area " + server->getAreaName(m_current_area) + " is spectate-only; to chat IC you will need to be invited by the CM.");
}
bool AOClient::changeCharacter(int char_id)
{
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
- if(char_id >= server->m_characters.length())
+ if (char_id >= server->getCharacterCount())
return false;
if (m_is_charcursed && !m_charcurse_list.contains(char_id)) {
return false;
}
-
+
bool l_successfulChange = l_area->changeCharacter(server->getCharID(m_current_char), char_id);
if (char_id < 0) {
@@ -178,7 +183,7 @@ bool AOClient::changeCharacter(int char_id)
}
if (l_successfulChange == true) {
- QString l_char_selected = server->m_characters[char_id];
+ QString l_char_selected = server->getCharacterById(char_id);
m_current_char = l_char_selected;
m_pos = "";
server->updateCharsTaken(l_area);
@@ -217,39 +222,45 @@ void AOClient::arup(ARUPType type, bool broadcast)
{
QStringList l_arup_data;
l_arup_data.append(QString::number(type));
- for (AreaData* l_area : qAsConst(server->m_areas)) {
- switch(type) {
- case ARUPType::PLAYER_COUNT: {
- l_arup_data.append(QString::number(l_area->playerCount()));
- break;
- }
- case ARUPType::STATUS: {
- QString l_area_status = QVariant::fromValue(l_area->status()).toString().replace("_", "-"); // LOOKING_FOR_PLAYERS to LOOKING-FOR-PLAYERS
- l_arup_data.append(l_area_status);
- break;
- }
- case ARUPType::CM: {
- if (l_area->owners().isEmpty())
- l_arup_data.append("FREE");
- else {
- QStringList l_area_owners;
- const QList l_owner_ids = l_area->owners();
- for (int l_owner_id : l_owner_ids) {
- AOClient* l_owner = server->getClientByID(l_owner_id);
- l_area_owners.append("[" + QString::number(l_owner->m_id) + "] " + l_owner->m_current_char);
- }
- l_arup_data.append(l_area_owners.join(", "));
+ const QVector l_areas = server->getAreas();
+ for (AreaData *l_area : l_areas) {
+ switch (type) {
+ case ARUPType::PLAYER_COUNT:
+ {
+ l_arup_data.append(QString::number(l_area->playerCount()));
+ break;
+ }
+ case ARUPType::STATUS:
+ {
+ QString l_area_status = QVariant::fromValue(l_area->status()).toString().replace("_", "-"); // LOOKING_FOR_PLAYERS to LOOKING-FOR-PLAYERS
+ l_arup_data.append(l_area_status);
+ break;
+ }
+ case ARUPType::CM:
+ {
+ if (l_area->owners().isEmpty())
+ l_arup_data.append("FREE");
+ else {
+ QStringList l_area_owners;
+ const QList l_owner_ids = l_area->owners();
+ for (int l_owner_id : l_owner_ids) {
+ AOClient *l_owner = server->getClientByID(l_owner_id);
+ l_area_owners.append("[" + QString::number(l_owner->m_id) + "] " + l_owner->m_current_char);
}
- break;
- }
- case ARUPType::LOCKED: {
- QString l_lock_status = QVariant::fromValue(l_area->lockStatus()).toString();
- l_arup_data.append(l_lock_status);
- break;
- }
- default: {
- return;
+ l_arup_data.append(l_area_owners.join(", "));
}
+ break;
+ }
+ case ARUPType::LOCKED:
+ {
+ QString l_lock_status = QVariant::fromValue(l_area->lockStatus()).toString();
+ l_arup_data.append(l_lock_status);
+ break;
+ }
+ default:
+ {
+ return;
+ }
}
}
if (broadcast)
@@ -258,7 +269,8 @@ void AOClient::arup(ARUPType type, bool broadcast)
sendPacket("ARUP", l_arup_data);
}
-void AOClient::fullArup() {
+void AOClient::fullArup()
+{
arup(ARUPType::PLAYER_COUNT, false);
arup(ARUPType::STATUS, false);
arup(ARUPType::CM, false);
@@ -271,8 +283,8 @@ void AOClient::sendPacket(AOPacket packet)
qDebug() << "Sent packet:" << packet.header << ":" << packet.contents;
#endif
packet.contents.replaceInStrings("#", "")
- .replaceInStrings("%", "")
- .replaceInStrings("$", "");
+ .replaceInStrings("%", "")
+ .replaceInStrings("$", "");
if (packet.header != "LE")
packet.contents.replaceInStrings("&", "");
m_socket->write(packet.toUtf8());
@@ -326,7 +338,7 @@ bool AOClient::checkAuth(unsigned long long acl_mask)
#endif
if (acl_mask != ACLFlags.value("NONE")) {
if (acl_mask == ACLFlags.value("CM")) {
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
if (l_area->owners().contains(m_id))
return true;
}
@@ -338,7 +350,7 @@ bool AOClient::checkAuth(unsigned long long acl_mask)
return m_authenticated;
break;
case DataTypes::AuthType::ADVANCED:
- unsigned long long l_user_acl = server->db_manager->getACL(m_moderator_name);
+ unsigned long long l_user_acl = server->getDatabaseManager()->getACL(m_moderator_name);
return (l_user_acl & acl_mask) != 0;
break;
}
@@ -346,7 +358,6 @@ bool AOClient::checkAuth(unsigned long long acl_mask)
return true;
}
-
QString AOClient::getIpid() const
{
return m_ipid;
@@ -357,7 +368,12 @@ QString AOClient::getHwid() const
return m_hwid;
}
-Server* AOClient::getServer() { return server; }
+bool AOClient::hasJoined() const
+{
+ return m_joined;
+}
+
+Server *AOClient::getServer() { return server; }
void AOClient::onAfkTimeout()
{
@@ -366,26 +382,26 @@ void AOClient::onAfkTimeout()
m_is_afk = true;
}
-AOClient::AOClient(Server *p_server, QTcpSocket *p_socket, QObject *parent, int user_id, MusicManager *p_manager)
- : QObject(parent),
- m_id(user_id),
- m_remote_ip(p_socket->peerAddress()),
- m_password(""),
- m_joined(false),
- m_current_area(0),
- m_current_char(""),
- m_socket(p_socket),
- server(p_server),
- is_partial(false),
- m_last_wtce_time(0),
- m_music_manager(p_manager)
+AOClient::AOClient(Server *p_server, QTcpSocket *p_socket, QObject *parent, int user_id, MusicManager *p_manager) :
+ QObject(parent),
+ m_id(user_id),
+ m_remote_ip(p_socket->peerAddress()),
+ m_password(""),
+ m_joined(false),
+ m_current_area(0),
+ m_current_char(""),
+ m_socket(p_socket),
+ server(p_server),
+ is_partial(false),
+ m_last_wtce_time(0),
+ m_music_manager(p_manager)
{
m_afk_timer = new QTimer;
m_afk_timer->setSingleShot(true);
- connect(m_afk_timer, &QTimer::timeout,
- this, &AOClient::onAfkTimeout);
+ connect(m_afk_timer, &QTimer::timeout, this, &AOClient::onAfkTimeout);
}
-AOClient::~AOClient() {
+AOClient::~AOClient()
+{
m_socket->deleteLater();
}
diff --git a/core/src/area_data.cpp b/core/src/area_data.cpp
index c95f9d9..2248d38 100644
--- a/core/src/area_data.cpp
+++ b/core/src/area_data.cpp
@@ -18,9 +18,12 @@
#include
+#include "include/aopacket.h"
#include "include/area_data.h"
+#include "include/config_manager.h"
+#include "include/music_manager.h"
-AreaData::AreaData(QString p_name, int p_index, MusicManager* p_music_manager = nullptr) :
+AreaData::AreaData(QString p_name, int p_index, MusicManager *p_music_manager = nullptr) :
m_index(p_index),
m_music_manager(p_music_manager),
m_playerCount(0),
@@ -38,7 +41,7 @@ AreaData::AreaData(QString p_name, int p_index, MusicManager* p_music_manager =
QStringList name_split = p_name.split(":");
name_split.removeFirst();
m_name = name_split.join(":");
- QSettings* areas_ini = ConfigManager::areaData();
+ QSettings *areas_ini = ConfigManager::areaData();
areas_ini->setIniCodec("UTF-8");
areas_ini->beginGroup(p_name);
m_background = areas_ini->value("background", "gs4").toString();
@@ -46,20 +49,22 @@ AreaData::AreaData(QString p_name, int p_index, MusicManager* p_music_manager =
m_iniswapAllowed = areas_ini->value("iniswap_allowed", "true").toBool();
m_bgLocked = areas_ini->value("bg_locked", "false").toBool();
m_eviMod = QVariant(areas_ini->value("evidence_mod", "FFA").toString().toUpper()).value();
- m_blankpostingAllowed = areas_ini->value("blankposting_allowed","true").toBool();
+ m_blankpostingAllowed = areas_ini->value("blankposting_allowed", "true").toBool();
+ m_area_message = areas_ini->value("area_message").toString();
+ m_send_area_message = areas_ini->value("send_area_message_on_join", false).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();
m_ignoreBgList = areas_ini->value("ignore_bglist", "false").toBool();
m_jukebox = areas_ini->value("jukebox_enabled", "false").toBool();
areas_ini->endGroup();
- QTimer* timer1 = new QTimer();
+ QTimer *timer1 = new QTimer();
m_timers.append(timer1);
- QTimer* timer2 = new QTimer();
+ QTimer *timer2 = new QTimer();
m_timers.append(timer2);
- QTimer* timer3 = new QTimer();
+ QTimer *timer3 = new QTimer();
m_timers.append(timer3);
- QTimer* timer4 = new QTimer();
+ QTimer *timer4 = new QTimer();
m_timers.append(timer4);
m_jukebox_timer = new QTimer();
connect(m_jukebox_timer, &QTimer::timeout,
@@ -67,13 +72,13 @@ AreaData::AreaData(QString p_name, int p_index, MusicManager* p_music_manager =
}
const QMap AreaData::map_statuses = {
- {"idle", AreaData::Status::IDLE },
- {"rp", AreaData::Status::RP },
- {"casing", AreaData::Status::CASING },
- {"lfp", AreaData::Status::LOOKING_FOR_PLAYERS },
- {"looking-for-players", AreaData::Status::LOOKING_FOR_PLAYERS },
- {"recess", AreaData::Status::RECESS },
- {"gaming", AreaData::Status::GAMING },
+ {"idle", AreaData::Status::IDLE},
+ {"rp", AreaData::Status::RP},
+ {"casing", AreaData::Status::CASING},
+ {"lfp", AreaData::Status::LOOKING_FOR_PLAYERS},
+ {"looking-for-players", AreaData::Status::LOOKING_FOR_PLAYERS},
+ {"recess", AreaData::Status::RECESS},
+ {"gaming", AreaData::Status::GAMING},
};
void AreaData::clientLeftArea(int f_charId, int f_userId)
@@ -95,9 +100,9 @@ void AreaData::clientJoinedArea(int f_charId, int f_userId)
}
m_joined_ids.append(f_userId);
emit userJoinedArea(m_index, f_userId);
- //The name will never be shown as we are using a spectator ID. Still nice for people who network sniff.
- //We auto-loop this so you'll never sit in silence unless wanted.
- emit sendAreaPacketClient(AOPacket("MC",{m_currentMusic, QString::number(-1), ConfigManager::serverName(), QString::number(1)}), f_userId);
+ // The name will never be shown as we are using a spectator ID. Still nice for people who network sniff.
+ // We auto-loop this so you'll never sit in silence unless wanted.
+ emit sendAreaPacketClient(AOPacket("MC", {m_currentMusic, QString::number(-1), ConfigManager::serverName(), QString::number(1)}), f_userId);
}
QList AreaData::owners() const
@@ -238,7 +243,7 @@ QList AreaData::evidence() const
void AreaData::swapEvidence(int f_eviId1, int f_eviId2)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
- //swapItemsAt does not exist in Qt older than 5.13
+ // swapItemsAt does not exist in Qt older than 5.13
m_evidence.swap(f_eviId1, f_eviId2);
#else
m_evidence.swapItemsAt(f_eviId1, f_eviId2);
@@ -323,7 +328,7 @@ void AreaData::toggleImmediate()
m_forceImmediate = !m_forceImmediate;
}
-const QStringList& AreaData::lastICMessage() const
+const QStringList &AreaData::lastICMessage() const
{
return m_lastICMessage;
}
@@ -391,7 +396,7 @@ QPair AreaData::jumpToStatement(int f_
}
}
-const QVector& AreaData::testimony() const
+const QVector &AreaData::testimony() const
{
return m_testimony;
}
@@ -438,7 +443,7 @@ QString AreaData::musicPlayerBy() const
return m_musicPlayedBy;
}
-void AreaData::setMusicPlayedBy(const QString& f_music_player)
+void AreaData::setMusicPlayedBy(const QString &f_music_player)
{
m_musicPlayedBy = f_music_player;
}
@@ -468,7 +473,8 @@ void AreaData::changeHP(AreaData::Side f_side, int f_newHP)
{
if (f_side == Side::DEFENCE) {
m_defHP = std::min(std::max(0, f_newHP), 10);
- } else if(f_side == Side::PROSECUTOR) {
+ }
+ else if (f_side == Side::PROSECUTOR) {
m_proHP = std::min(std::max(0, f_newHP), 10);
}
}
@@ -490,7 +496,7 @@ void AreaData::changeDoc(const QString &f_newDoc_r)
QString AreaData::areaMessage() const
{
- return m_area_message;
+ return m_area_message.isEmpty() ? "No area message set." : m_area_message;
}
bool AreaData::sendAreaMessageOnJoin() const
@@ -498,12 +504,14 @@ bool AreaData::sendAreaMessageOnJoin() const
return m_send_area_message;
}
-void AreaData::changeAreaMessage(const QString& f_newMessage_r)
+void AreaData::changeAreaMessage(const QString &f_newMessage_r)
{
- if(f_newMessage_r.isEmpty())
- m_area_message = "No area message set.";
- else
- m_area_message = f_newMessage_r;
+ m_area_message = f_newMessage_r;
+}
+
+void AreaData::clearAreaMessage()
+{
+ changeAreaMessage(QString{});
}
bool AreaData::bgLocked() const
@@ -567,24 +575,24 @@ void AreaData::toggleJukebox()
QString AreaData::addJukeboxSong(QString f_song)
{
- if(!m_jukebox_queue.contains(f_song)) {
- //Retrieve song information.
- QPair l_song = m_music_manager->songInformation(f_song, index());
+ if (!m_jukebox_queue.contains(f_song)) {
+ // Retrieve song information.
+ QPair l_song = m_music_manager->songInformation(f_song, index());
- if (l_song.second > 0) {
- if (m_jukebox_queue.size() == 0) {
+ if (l_song.second > 0) {
+ if (m_jukebox_queue.size() == 0) {
- emit sendAreaPacket(AOPacket("MC",{l_song.first,QString::number(-1)}), index());
- m_jukebox_timer->start(l_song.second * 1000);
- setCurrentMusic(f_song);
- setMusicPlayedBy("Jukebox");
- }
- m_jukebox_queue.append(f_song);
- return "Song added to Jukebox.";
- }
- else {
- return "Unable to add song. Duration shorter than 1.";
+ emit sendAreaPacket(AOPacket("MC", {l_song.first, QString::number(-1)}), index());
+ m_jukebox_timer->start(l_song.second * 1000);
+ setCurrentMusic(f_song);
+ setMusicPlayedBy("Jukebox");
}
+ m_jukebox_queue.append(f_song);
+ return "Song added to Jukebox.";
+ }
+ else {
+ return "Unable to add song. Duration shorter than 1.";
+ }
}
return "Unable to add song. Song already in Jukebox.";
}
@@ -597,18 +605,18 @@ QVector AreaData::joinedIDs() const
void AreaData::switchJukeboxSong()
{
QString l_song_name;
- if(m_jukebox_queue.size() == 1) {
+ if (m_jukebox_queue.size() == 1) {
l_song_name = m_jukebox_queue[0];
- QPair l_song = m_music_manager->songInformation(l_song_name, index());
- emit sendAreaPacket(AOPacket("MC",{l_song.first,"-1"}), m_index);
+ QPair l_song = m_music_manager->songInformation(l_song_name, index());
+ emit sendAreaPacket(AOPacket("MC", {l_song.first, "-1"}), m_index);
m_jukebox_timer->start(l_song.second * 1000);
}
else {
- int l_random_index = QRandomGenerator::system()->bounded(m_jukebox_queue.size() -1);
+ int l_random_index = QRandomGenerator::system()->bounded(m_jukebox_queue.size() - 1);
l_song_name = m_jukebox_queue[l_random_index];
- QPair l_song = m_music_manager->songInformation(l_song_name, index());
- emit sendAreaPacket(AOPacket("MC",{l_song.first,"-1"}), m_index);
+ QPair l_song = m_music_manager->songInformation(l_song_name, index());
+ emit sendAreaPacket(AOPacket("MC", {l_song.first, "-1"}), m_index);
m_jukebox_timer->start(l_song.second * 1000);
m_jukebox_queue.remove(l_random_index);
diff --git a/core/src/commands/area.cpp b/core/src/commands/area.cpp
index 0d5338a..15c3a1b 100644
--- a/core/src/commands/area.cpp
+++ b/core/src/commands/area.cpp
@@ -17,14 +17,18 @@
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
+#include "include/aopacket.h"
+#include "include/area_data.h"
+#include "include/config_manager.h"
+#include "include/server.h"
+
// This file is for commands under the area category in aoclient.h
// Be sure to register the command in the header before adding it here!
-
void AOClient::cmdCM(int argc, QStringList argv)
{
QString l_sender_name = m_ooc_name;
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
if (l_area->isProtected()) {
sendServerMessage("This area is protected, you may not become CM.");
return;
@@ -39,7 +43,7 @@ void AOClient::cmdCM(int argc, QStringList argv)
}
else if (argc == 1) { // we are CM, and we want to make ID argv[0] also CM
bool ok;
- AOClient* l_owner_candidate = server->getClientByID(argv[0].toInt(&ok));
+ AOClient *l_owner_candidate = server->getClientByID(argv[0].toInt(&ok));
if (!ok) {
sendServerMessage("That doesn't look like a valid ID.");
return;
@@ -63,7 +67,7 @@ void AOClient::cmdCM(int argc, QStringList argv)
void AOClient::cmdUnCM(int argc, QStringList argv)
{
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
int l_uid;
if (l_area->owners().isEmpty()) {
@@ -85,7 +89,7 @@ void AOClient::cmdUnCM(int argc, QStringList argv)
sendServerMessage("That user is not CMed.");
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
return;
@@ -108,7 +112,7 @@ void AOClient::cmdInvite(int argc, QStringList argv)
{
Q_UNUSED(argc);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
bool ok;
int l_invited_id = argv[0].toInt(&ok);
if (!ok) {
@@ -116,7 +120,7 @@ void AOClient::cmdInvite(int argc, QStringList argv)
return;
}
- AOClient* target_client = server->getClientByID(l_invited_id);
+ AOClient *target_client = server->getClientByID(l_invited_id);
if (target_client == nullptr) {
sendServerMessage("No client with that ID found.");
return;
@@ -133,7 +137,7 @@ void AOClient::cmdUnInvite(int argc, QStringList argv)
{
Q_UNUSED(argc);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
bool ok;
int l_uninvited_id = argv[0].toInt(&ok);
if (!ok) {
@@ -141,7 +145,7 @@ void AOClient::cmdUnInvite(int argc, QStringList argv)
return;
}
- AOClient* target_client = server->getClientByID(l_uninvited_id);
+ AOClient *target_client = server->getClientByID(l_uninvited_id);
if (target_client == nullptr) {
sendServerMessage("No client with that ID found.");
return;
@@ -163,16 +167,17 @@ void AOClient::cmdLock(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* area = server->m_areas[m_current_area];
+ AreaData *area = server->getAreaById(m_current_area);
if (area->lockStatus() == AreaData::LockStatus::LOCKED) {
sendServerMessage("This area is already locked.");
return;
}
sendServerMessageArea("This area is now locked.");
area->lock();
- for (AOClient* client : qAsConst(server->m_clients)) { // qAsConst here avoids detaching the container
- if (client->m_current_area == m_current_area && client->m_joined) {
- area->invite(client->m_id);
+ const QVector l_clients = server->getClients();
+ for (AOClient *l_client : l_clients) {
+ if (l_client->m_current_area == m_current_area && l_client->hasJoined()) {
+ area->invite(l_client->m_id);
}
}
arup(ARUPType::LOCKED, true);
@@ -183,16 +188,17 @@ void AOClient::cmdSpectatable(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
if (l_area->lockStatus() == AreaData::LockStatus::SPECTATABLE) {
sendServerMessage("This area is already in spectate mode.");
return;
}
sendServerMessageArea("This area is now spectatable.");
l_area->spectatable();
- for (AOClient* client : qAsConst(server->m_clients)) {
- if (client->m_current_area == m_current_area && client->m_joined) {
- l_area->invite(client->m_id);
+ const QVector l_clients = server->getClients();
+ for (AOClient *l_client : l_clients) {
+ if (l_client->m_current_area == m_current_area && l_client->hasJoined()) {
+ l_area->invite(l_client->m_id);
}
}
arup(ARUPType::LOCKED, true);
@@ -203,7 +209,7 @@ void AOClient::cmdUnLock(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
if (l_area->lockStatus() == AreaData::LockStatus::FREE) {
sendServerMessage("This area is not locked.");
return;
@@ -219,9 +225,9 @@ void AOClient::cmdGetAreas(int argc, QStringList argv)
Q_UNUSED(argv);
QStringList l_entries;
- l_entries.append("\n== Currently Online: " + QString::number(server->m_player_count)+ " ==");
- for (int i = 0; i < server->m_area_names.length(); i++) {
- if (server->m_areas.value(i)->playerCount() > 0) {
+ l_entries.append("\n== Currently Online: " + QString::number(server->getPlayerCount()) + " ==");
+ for (int i = 0; i < server->getAreaCount(); i++) {
+ if (server->getAreaById(i)->playerCount() > 0) {
QStringList l_cur_area_lines = buildAreaList(i);
l_entries.append(l_cur_area_lines);
}
@@ -244,7 +250,7 @@ void AOClient::cmdArea(int argc, QStringList argv)
bool ok;
int l_new_area = argv[0].toInt(&ok);
- if (!ok || l_new_area >= server->m_areas.size() || l_new_area < 0) {
+ if (!ok || l_new_area >= server->getAreaCount() || l_new_area < 0) {
sendServerMessage("That does not look like a valid area ID.");
return;
}
@@ -255,7 +261,7 @@ void AOClient::cmdAreaKick(int argc, QStringList argv)
{
Q_UNUSED(argc);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
bool ok;
int l_idx = argv[0].toInt(&ok);
@@ -263,11 +269,11 @@ void AOClient::cmdAreaKick(int argc, QStringList argv)
sendServerMessage("That does not look like a valid ID.");
return;
}
- if (server->m_areas[m_current_area]->owners().contains(l_idx)) {
+ if (server->getAreaById(m_current_area)->owners().contains(l_idx)) {
sendServerMessage("You cannot kick another CM!");
return;
}
- AOClient* l_client_to_kick = server->getClientByID(l_idx);
+ AOClient *l_client_to_kick = server->getClientByID(l_idx);
if (l_client_to_kick == nullptr) {
sendServerMessage("No client with that ID found.");
return;
@@ -287,9 +293,9 @@ void AOClient::cmdSetBackground(int argc, QStringList argv)
Q_UNUSED(argc);
QString f_background = argv.join(" ");
- AreaData* area = server->m_areas[m_current_area];
+ AreaData *area = server->getAreaById(m_current_area);
if (m_authenticated || !area->bgLocked()) {
- if (server->m_backgrounds.contains(f_background, Qt::CaseInsensitive) || area->ignoreBgList() == true) {
+ if (server->getBackgrounds().contains(f_background, Qt::CaseInsensitive) || area->ignoreBgList() == true) {
area->setBackground(f_background);
server->broadcast(AOPacket("BN", {f_background}), m_current_area);
sendServerMessageArea(m_current_char + " changed the background to " + f_background);
@@ -308,7 +314,7 @@ void AOClient::cmdBgLock(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
if (l_area->bgLocked() == false) {
l_area->toggleBgLock();
@@ -322,7 +328,7 @@ void AOClient::cmdBgUnlock(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
if (l_area->bgLocked() == true) {
l_area->toggleBgLock();
@@ -335,13 +341,14 @@ void AOClient::cmdStatus(int argc, QStringList argv)
{
Q_UNUSED(argc);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
QString l_arg = argv[0].toLower();
if (l_area->changeStatus(l_arg)) {
arup(ARUPType::STATUS, true);
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();
sendServerMessage("That does not look like a valid status. Valid statuses are " + keys.join(", "));
}
@@ -352,18 +359,18 @@ void AOClient::cmdJudgeLog(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
if (l_area->judgelog().isEmpty()) {
sendServerMessage("There have been no judge actions in this area.");
return;
}
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) {
- sendServerMessage(l_message);
+ sendServerMessage(l_message);
}
else {
- QString filteredmessage = l_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);
}
}
@@ -373,7 +380,7 @@ void AOClient::cmdIgnoreBgList(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
l_area->toggleIgnoreBgList();
QString l_state = l_area->ignoreBgList() ? "ignored." : "enforced.";
sendServerMessage("BG list in this area is now " + l_state);
@@ -381,7 +388,7 @@ void AOClient::cmdIgnoreBgList(int argc, QStringList argv)
void AOClient::cmdAreaMessage(int argc, QStringList argv)
{
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
if (argc == 0) {
sendServerMessage(l_area->areaMessage());
return;
@@ -398,10 +405,10 @@ void AOClient::cmdToggleAreaMessageOnJoin(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
l_area->toggleAreaMessageJoin();
QString l_state = l_area->sendAreaMessageOnJoin() ? "enabled." : "disabled.";
- sendServerMessage("Sending message on area join is now " +l_state);
+ sendServerMessage("Sending message on area join is now " + l_state);
}
void AOClient::cmdClearAreaMessage(int argc, QStringList argv)
@@ -409,8 +416,8 @@ void AOClient::cmdClearAreaMessage(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
- l_area->changeAreaMessage(QString{});
- if (l_area->sendAreaMessageOnJoin()) //Turn off the automatic sending.
- cmdToggleAreaMessageOnJoin(0,QStringList{}); //Dummy values.
+ AreaData *l_area = server->getAreaById(m_current_area);
+ l_area->clearAreaMessage();
+ if (l_area->sendAreaMessageOnJoin()) // Turn off the automatic sending.
+ cmdToggleAreaMessageOnJoin(0, QStringList{}); // Dummy values.
}
diff --git a/core/src/commands/authentication.cpp b/core/src/commands/authentication.cpp
index 04c90cc..3a63261 100644
--- a/core/src/commands/authentication.cpp
+++ b/core/src/commands/authentication.cpp
@@ -17,6 +17,10 @@
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
+#include "include/config_manager.h"
+#include "include/db_manager.h"
+#include "include/server.h"
+
// This file is for commands under the authentication category in aoclient.h
// Be sure to register the command in the header before adding it here!
@@ -86,7 +90,7 @@ void AOClient::cmdSetRootPass(int argc, QStringList argv)
#endif
QString l_salt = QStringLiteral("%1").arg(l_salt_number, 16, 16, QLatin1Char('0'));
- server->db_manager->createUser("root", l_salt, argv[0], ACLFlags.value("SUPER"));
+ server->getDatabaseManager()->createUser("root", l_salt, argv[0], ACLFlags.value("SUPER"));
}
void AOClient::cmdAddUser(int argc, QStringList argv)
@@ -107,7 +111,7 @@ void AOClient::cmdAddUser(int argc, QStringList argv)
#endif
QString l_salt = QStringLiteral("%1").arg(l_salt_number, 16, 16, QLatin1Char('0'));
- if (server->db_manager->createUser(argv[0], l_salt, argv[1], ACLFlags.value("NONE")))
+ if (server->getDatabaseManager()->createUser(argv[0], l_salt, argv[1], ACLFlags.value("NONE")))
sendServerMessage("Created user " + argv[0] + ".\nUse /addperm to modify their permissions.");
else
sendServerMessage("Unable to create user " + argv[0] + ".\nDoes a user with that name already exist?");
@@ -117,7 +121,7 @@ void AOClient::cmdRemoveUser(int argc, QStringList argv)
{
Q_UNUSED(argc);
- if (server->db_manager->deleteUser(argv[0]))
+ if (server->getDatabaseManager()->deleteUser(argv[0]))
sendServerMessage("Successfully removed user " + argv[0] + ".");
else
sendServerMessage("Unable to remove user " + argv[0] + ".\nDoes it exist?");
@@ -125,19 +129,21 @@ void AOClient::cmdRemoveUser(int argc, QStringList argv)
void AOClient::cmdListPerms(int argc, QStringList argv)
{
- unsigned long long l_user_acl = server->db_manager->getACL(m_moderator_name);
+ unsigned long long l_user_acl = server->getDatabaseManager()->getACL(m_moderator_name);
QStringList l_message;
const QStringList l_keys = ACLFlags.keys();
if (argc == 0) {
// Just print out all permissions available to the user.
l_message.append("You have been given the following permissions:");
for (const QString &l_perm : l_keys) {
- if (l_perm == "NONE"); // don't need to list this one
+ if (l_perm == "NONE")
+ ; // don't need to list this one
else if (l_perm == "SUPER") {
if (l_user_acl == ACLFlags.value("SUPER")) // This has to be checked separately, because SUPER & anything will always be truthy
l_message.append("SUPER (Be careful! This grants the user all permissions.)");
}
- else if ((ACLFlags.value(l_perm) & l_user_acl) == 0); // user doesn't have this permission, don't print it
+ else if ((ACLFlags.value(l_perm) & l_user_acl) == 0)
+ ; // user doesn't have this permission, don't print it
else
l_message.append(l_perm);
}
@@ -149,7 +155,7 @@ void AOClient::cmdListPerms(int argc, QStringList argv)
}
l_message.append("User " + argv[0] + " has the following permissions:");
- unsigned long long l_acl = server->db_manager->getACL(argv[0]);
+ unsigned long long l_acl = server->getDatabaseManager()->getACL(argv[0]);
if (l_acl == 0) {
sendServerMessage("This user either doesn't exist, or has no permissions set.");
return;
@@ -168,7 +174,7 @@ void AOClient::cmdAddPerms(int argc, QStringList argv)
{
Q_UNUSED(argc);
- unsigned long long l_user_acl = server->db_manager->getACL(m_moderator_name);
+ unsigned long long l_user_acl = server->getDatabaseManager()->getACL(m_moderator_name);
argv[1] = argv[1].toUpper();
const QStringList l_keys = ACLFlags.keys();
@@ -191,7 +197,7 @@ void AOClient::cmdAddPerms(int argc, QStringList argv)
unsigned long long l_newperm = ACLFlags.value(argv[1]);
if ((l_newperm & l_user_acl) != 0) {
- if (server->db_manager->updateACL(argv[0], l_newperm, true))
+ if (server->getDatabaseManager()->updateACL(argv[0], l_newperm, true))
sendServerMessage("Successfully added permission " + argv[1] + " to user " + argv[0]);
else
sendServerMessage(argv[0] + " wasn't found!");
@@ -205,7 +211,7 @@ void AOClient::cmdRemovePerms(int argc, QStringList argv)
{
Q_UNUSED(argc);
- unsigned long long l_user_acl = server->db_manager->getACL(m_moderator_name);
+ unsigned long long l_user_acl = server->getDatabaseManager()->getACL(m_moderator_name);
argv[1] = argv[1].toUpper();
const QStringList l_keys = ACLFlags.keys();
@@ -234,7 +240,7 @@ void AOClient::cmdRemovePerms(int argc, QStringList argv)
unsigned long long l_newperm = ACLFlags.value(argv[1]);
if ((l_newperm & l_user_acl) != 0) {
- if (server->db_manager->updateACL(argv[0], l_newperm, false))
+ if (server->getDatabaseManager()->updateACL(argv[0], l_newperm, false))
sendServerMessage("Successfully removed permission " + argv[1] + " from user " + argv[0]);
else
sendServerMessage(argv[0] + " wasn't found!");
@@ -249,7 +255,7 @@ void AOClient::cmdListUsers(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- QStringList l_users = server->db_manager->getUsers();
+ QStringList l_users = server->getDatabaseManager()->getUsers();
sendServerMessage("All users:\n" + l_users.join("\n"));
}
@@ -291,7 +297,7 @@ void AOClient::cmdChangePassword(int argc, QStringList argv)
return;
}
- if (server->db_manager->updatePassword(l_username, l_password)) {
+ if (server->getDatabaseManager()->updatePassword(l_username, l_password)) {
sendServerMessage("Successfully changed password.");
}
else {
diff --git a/core/src/commands/casing.cpp b/core/src/commands/casing.cpp
index d664bdb..7ee4419 100644
--- a/core/src/commands/casing.cpp
+++ b/core/src/commands/casing.cpp
@@ -17,13 +17,18 @@
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
+#include "include/aopacket.h"
+#include "include/area_data.h"
+#include "include/config_manager.h"
+#include "include/server.h"
+
// This file is for commands under the casing category in aoclient.h
// Be sure to register the command in the header before adding it here!
void AOClient::cmdDoc(int argc, QStringList argv)
{
QString l_sender_name = m_ooc_name;
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
if (argc == 0) {
sendServerMessage("Document: " + l_area->document());
}
@@ -39,7 +44,7 @@ void AOClient::cmdClearDoc(int argc, QStringList argv)
Q_UNUSED(argv);
QString l_sender_name = m_ooc_name;
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
l_area->changeDoc("No document.");
sendServerMessageArea(l_sender_name + " cleared the document.");
}
@@ -48,7 +53,7 @@ void AOClient::cmdEvidenceMod(int argc, QStringList argv)
{
Q_UNUSED(argc);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
argv[0] = argv[0].toLower();
if (argv[0] == "cm")
l_area->setEviMod(AreaData::EvidenceMod::CM);
@@ -72,8 +77,8 @@ void AOClient::cmdEvidence_Swap(int argc, QStringList argv)
{
Q_UNUSED(argc);
- AreaData* l_area = server->m_areas[m_current_area];
- int l_ev_size = l_area->evidence().size() -1;
+ AreaData *l_area = server->getAreaById(m_current_area);
+ int l_ev_size = l_area->evidence().size() - 1;
if (l_ev_size < 0) {
sendServerMessage("No evidence in area.");
@@ -106,7 +111,7 @@ void AOClient::cmdTestify(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
if (l_area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING) {
sendServerMessage("Testimony recording is already in progress. Please stop it before starting a new one.");
}
@@ -122,11 +127,10 @@ void AOClient::cmdExamine(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
- if (l_area->testimony().size() -1 > 0)
- {
+ AreaData *l_area = server->getAreaById(m_current_area);
+ if (l_area->testimony().size() - 1 > 0) {
l_area->restartTestimony();
- server->broadcast(AOPacket("RT",{"testimony2"}), m_current_area);
+ server->broadcast(AOPacket("RT", {"testimony2"}), m_current_area);
server->broadcast(AOPacket("MS", {l_area->testimony()[0]}), m_current_area);
return;
}
@@ -141,20 +145,19 @@ void AOClient::cmdTestimony(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
- if (l_area->testimony().size() -1 < 1) {
- sendServerMessage("Unable to display empty testimony.");
- return;
- }
+ AreaData *l_area = server->getAreaById(m_current_area);
+ if (l_area->testimony().size() - 1 < 1) {
+ sendServerMessage("Unable to display empty testimony.");
+ return;
+ }
- QString l_ooc_message;
- for (int i = 1; i <= l_area->testimony().size() -1; i++)
- {
- QStringList l_packet = l_area->testimony().at(i);
- QString l_ic_message = l_packet[4];
- l_ooc_message.append( "[" + QString::number(i) + "]" + l_ic_message + "\n");
- }
- sendServerMessage(l_ooc_message);
+ QString l_ooc_message;
+ for (int i = 1; i <= l_area->testimony().size() - 1; i++) {
+ QStringList l_packet = l_area->testimony().at(i);
+ QString l_ic_message = l_packet[4];
+ l_ooc_message.append("[" + QString::number(i) + "]" + l_ic_message + "\n");
+ }
+ sendServerMessage(l_ooc_message);
}
void AOClient::cmdDeleteStatement(int argc, QStringList argv)
@@ -162,7 +165,7 @@ void AOClient::cmdDeleteStatement(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
int l_c_statement = l_area->statement();
if (l_area->testimony().size() - 1 == 0) {
sendServerMessage("Unable to delete statement. No statements saved in this area.");
@@ -178,7 +181,7 @@ void AOClient::cmdUpdateStatement(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- server->m_areas[m_current_area]->setTestimonyRecording(AreaData::TestimonyRecording::UPDATE);
+ server->getAreaById(m_current_area)->setTestimonyRecording(AreaData::TestimonyRecording::UPDATE);
sendServerMessage("The next IC-Message will replace the last displayed replay message.");
}
@@ -187,9 +190,9 @@ void AOClient::cmdPauseTestimony(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
l_area->setTestimonyRecording(AreaData::TestimonyRecording::STOPPED);
- server->broadcast(AOPacket("RT",{"testimony1", "1"}), m_current_area);
+ server->broadcast(AOPacket("RT", {"testimony1", "1"}), m_current_area);
sendServerMessage("Testimony has been stopped.");
}
@@ -198,8 +201,8 @@ void AOClient::cmdAddStatement(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- if (server->m_areas[m_current_area]->statement() < ConfigManager::maxStatements()) {
- server->m_areas[m_current_area]->setTestimonyRecording(AreaData::TestimonyRecording::ADD);
+ if (server->getAreaById(m_current_area)->statement() < ConfigManager::maxStatements()) {
+ server->getAreaById(m_current_area)->setTestimonyRecording(AreaData::TestimonyRecording::ADD);
sendServerMessage("The next IC-Message will be inserted into the testimony.");
}
else
@@ -218,18 +221,18 @@ void AOClient::cmdSaveTestimony(int argc, QStringList argv)
l_permission_found = true;
if (l_permission_found) {
- AreaData* l_area = server->m_areas[m_current_area];
- if (l_area->testimony().size() -1 <= 0) {
+ AreaData *l_area = server->getAreaById(m_current_area);
+ if (l_area->testimony().size() - 1 <= 0) {
sendServerMessage("Can't save an empty testimony.");
return;
}
QDir l_dir_testimony("storage/testimony");
- if (!l_dir_testimony.exists()) {
- l_dir_testimony.mkpath(".");
- }
+ if (!l_dir_testimony.exists()) {
+ l_dir_testimony.mkpath(".");
+ }
- QString l_testimony_name = argv[0].trimmed().toLower().replace("..",""); // :)
+ QString l_testimony_name = argv[0].trimmed().toLower().replace("..", ""); // :)
QFile l_file("storage/testimony/" + l_testimony_name + ".txt");
if (l_file.exists()) {
sendServerMessage("Unable to save testimony. Testimony name already exists.");
@@ -238,9 +241,8 @@ void AOClient::cmdSaveTestimony(int argc, QStringList argv)
QTextStream l_out(&l_file);
l_out.setCodec("UTF-8");
- if(l_file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
- for (int i = 0; i <= l_area->testimony().size() -1; i++)
- {
+ if (l_file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
+ for (int i = 0; i <= l_area->testimony().size() - 1; i++) {
l_out << l_area->testimony().at(i).join("#") << "\n";
}
sendServerMessage("Testimony saved. To load it use /loadtestimony " + l_testimony_name);
@@ -257,14 +259,14 @@ void AOClient::cmdLoadTestimony(int argc, QStringList argv)
{
Q_UNUSED(argc);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
QDir l_dir_testimony("storage/testimony");
if (!l_dir_testimony.exists()) {
sendServerMessage("Unable to load testimonies. Testimony storage not found.");
return;
}
- QString l_testimony_name = argv[0].trimmed().toLower().replace("..",""); // :)
+ QString l_testimony_name = argv[0].trimmed().toLower().replace("..", ""); // :)
QFile l_file("storage/testimony/" + l_testimony_name + ".txt");
if (!l_file.exists()) {
sendServerMessage("Unable to load testimony. Testimony name not found.");
diff --git a/core/src/commands/command_helper.cpp b/core/src/commands/command_helper.cpp
index 4a8537e..c6262d8 100644
--- a/core/src/commands/command_helper.cpp
+++ b/core/src/commands/command_helper.cpp
@@ -17,6 +17,11 @@
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
+#include "include/aopacket.h"
+#include "include/area_data.h"
+#include "include/config_manager.h"
+#include "include/server.h"
+
// This file is for functions used by various commands, defined in the command helper function category in aoclient.h
// Be sure to register the command in the header before adding it here!
@@ -32,33 +37,34 @@ void AOClient::cmdDefault(int argc, QStringList argv)
QStringList AOClient::buildAreaList(int area_idx)
{
QStringList entries;
- QString area_name = server->m_area_names[area_idx];
- AreaData* area = server->m_areas[area_idx];
+ QString area_name = server->getAreaName(area_idx);
+ AreaData *area = server->getAreaById(area_idx);
entries.append("=== " + area_name + " ===");
switch (area->lockStatus()) {
- case AreaData::LockStatus::LOCKED:
- entries.append("[LOCKED]");
- break;
- case AreaData::LockStatus::SPECTATABLE:
- entries.append("[SPECTATABLE]");
- break;
- case AreaData::LockStatus::FREE:
- default:
- break;
+ case AreaData::LockStatus::LOCKED:
+ entries.append("[LOCKED]");
+ break;
+ case AreaData::LockStatus::SPECTATABLE:
+ entries.append("[SPECTATABLE]");
+ break;
+ case AreaData::LockStatus::FREE:
+ default:
+ break;
}
entries.append("[" + QString::number(area->playerCount()) + " users][" + QVariant::fromValue(area->status()).toString().replace("_", "-") + "]");
- for (AOClient* client : qAsConst(server->m_clients)) {
- if (client->m_current_area == area_idx && client->m_joined) {
- QString char_entry = "[" + QString::number(client->m_id) + "] " + client->m_current_char;
- if (client->m_current_char == "")
+ const QVector l_clients = server->getClients();
+ for (AOClient *l_client : l_clients) {
+ if (l_client->m_current_area == area_idx && l_client->hasJoined()) {
+ QString char_entry = "[" + QString::number(l_client->m_id) + "] " + l_client->m_current_char;
+ if (l_client->m_current_char == "")
char_entry += "Spectator";
- if (client->m_showname != "")
- char_entry += " (" + client->m_showname + ")";
- if (area->owners().contains(client->m_id))
+ if (l_client->m_showname != "")
+ char_entry += " (" + l_client->m_showname + ")";
+ if (area->owners().contains(l_client->m_id))
char_entry.insert(0, "[CM] ");
if (m_authenticated)
- char_entry += " (" + client->getIpid() + "): " + client->m_ooc_name;
- if (client->m_is_afk)
+ char_entry += " (" + l_client->getIpid() + "): " + l_client->m_ooc_name;
+ if (l_client->m_is_afk)
char_entry += " [AFK]";
entries.append(char_entry);
}
@@ -100,8 +106,8 @@ void AOClient::diceThrower(int argc, QStringList argv, bool p_roll)
QString AOClient::getAreaTimer(int area_idx, int timer_idx)
{
- AreaData* l_area = server->m_areas[area_idx];
- QTimer* l_timer;
+ AreaData *l_area = server->getAreaById(area_idx);
+ QTimer *l_timer;
QString l_timer_name = (timer_idx == 0) ? "Global timer" : "Timer " + QString::number(timer_idx);
if (timer_idx == 0)
@@ -112,7 +118,7 @@ QString AOClient::getAreaTimer(int area_idx, int timer_idx)
return "Invalid timer ID.";
if (l_timer->isActive()) {
- QTime l_current_time = QTime(0,0).addMSecs(l_timer->remainingTime());
+ QTime l_current_time = QTime(0, 0).addMSecs(l_timer->remainingTime());
return l_timer_name + " is at " + l_current_time.toString("hh:mm:ss.zzz");
}
@@ -168,10 +174,10 @@ QString AOClient::getReprimand(bool f_positive)
{
if (f_positive) {
return ConfigManager::praiseList().at(genRand(0, ConfigManager::praiseList().size() - 1));
- }
+ }
else {
return ConfigManager::reprimandsList().at(genRand(0, ConfigManager::reprimandsList().size() - 1));
- }
+ }
}
bool AOClient::checkPasswordRequirements(QString f_username, QString f_password)
diff --git a/core/src/commands/messaging.cpp b/core/src/commands/messaging.cpp
index 3c1b36d..7b43897 100644
--- a/core/src/commands/messaging.cpp
+++ b/core/src/commands/messaging.cpp
@@ -17,6 +17,10 @@
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
+#include "include/aopacket.h"
+#include "include/area_data.h"
+#include "include/server.h"
+
// This file is for commands under the messaging category in aoclient.h
// Be sure to register the command in the header before adding it here!
@@ -25,7 +29,7 @@ void AOClient::cmdPos(int argc, QStringList argv)
Q_UNUSED(argc);
changePosition(argv[0]);
- updateEvidenceList(server->m_areas[m_current_area]);
+ updateEvidenceList(server->getAreaById(m_current_area));
}
void AOClient::cmdForcePos(int argc, QStringList argv)
@@ -33,7 +37,7 @@ void AOClient::cmdForcePos(int argc, QStringList argv)
Q_UNUSED(argc);
bool ok;
- QList l_targets;
+ QList l_targets;
int l_target_id = argv[1].toInt(&ok);
int l_forced_clients = 0;
if (!ok && argv[1] != "*") {
@@ -41,7 +45,7 @@ void AOClient::cmdForcePos(int argc, QStringList argv)
return;
}
else if (ok) {
- AOClient* l_target_client = server->getClientByID(l_target_id);
+ AOClient *l_target_client = server->getClientByID(l_target_id);
if (l_target_client != nullptr)
l_targets.append(l_target_client);
else {
@@ -51,12 +55,13 @@ void AOClient::cmdForcePos(int argc, QStringList argv)
}
else if (argv[1] == "*") { // force all clients in the area
- for (AOClient* client : qAsConst(server->m_clients)) {
- if (client->m_current_area == m_current_area)
- l_targets.append(client);
+ const QVector l_clients = server->getClients();
+ for (AOClient *l_client : l_clients) {
+ if (l_client->m_current_area == m_current_area)
+ l_targets.append(l_client);
}
}
- for (AOClient* l_target : l_targets) {
+ for (AOClient *l_target : l_targets) {
l_target->sendServerMessage("Position forcibly changed by CM.");
l_target->changePosition(argv[0]);
l_forced_clients++;
@@ -69,7 +74,7 @@ void AOClient::cmdG(int argc, QStringList argv)
Q_UNUSED(argc);
QString l_sender_name = m_ooc_name;
- QString l_sender_area = server->m_area_names.value(m_current_area);
+ QString l_sender_area = server->getAreaName(m_current_area);
QString l_sender_message = argv.join(" ");
//Slightly better readability
AOPacket l_mod_packet = AOPacket("CT", {"[G][" + m_ipid + "][" + l_sender_area + "]" + l_sender_name, l_sender_message});
@@ -82,9 +87,9 @@ void AOClient::cmdNeed(int argc, QStringList argv)
{
Q_UNUSED(argc);
- QString l_sender_area = server->m_area_names.value(m_current_area);
+ QString l_sender_area = server->getAreaName(m_current_area);
QString l_sender_message = argv.join(" ");
- server->broadcast(AOPacket("CT",{"=== Advert ===\n[" + l_sender_area + "] needs " + l_sender_message+ "."}),Server::TARGET_TYPE::ADVERT);
+ server->broadcast(AOPacket("CT", {"=== Advert ===\n[" + l_sender_area + "] needs " + l_sender_message + "."}), Server::TARGET_TYPE::ADVERT);
}
void AOClient::cmdSwitch(int argc, QStringList argv)
@@ -109,11 +114,11 @@ void AOClient::cmdRandomChar(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
int l_selected_char_id;
bool l_taken = true;
while (l_taken) {
- l_selected_char_id = genRand(0, server->m_characters.size() - 1);
+ l_selected_char_id = genRand(0, server->getCharacterCount() - 1);
if (!l_area->charactersTaken().contains(l_selected_char_id)) {
l_taken = false;
}
@@ -143,7 +148,7 @@ void AOClient::cmdPM(int argc, QStringList argv)
sendServerMessage("That does not look like a valid ID.");
return;
}
- AOClient* l_target_client = server->getClientByID(l_target_id);
+ AOClient *l_target_client = server->getClientByID(l_target_id);
if (l_target_client == nullptr) {
sendServerMessage("No client with that ID found.");
return;
@@ -154,7 +159,7 @@ void AOClient::cmdPM(int argc, QStringList argv)
}
QString l_message = argv.join(" "); //...which means it will not end up as part of the message
l_target_client->sendServerMessage("Message from " + m_ooc_name + " (" + QString::number(m_id) + "): " + l_message);
- sendServerMessage("PM sent to " + QString::number(l_target_id) +". Message: " + l_message);
+ sendServerMessage("PM sent to " + QString::number(l_target_id) + ". Message: " + l_message);
}
void AOClient::cmdAnnounce(int argc, QStringList argv)
@@ -178,9 +183,9 @@ void AOClient::cmdGM(int argc, QStringList argv)
Q_UNUSED(argc);
QString l_sender_name = m_ooc_name;
- QString l_sender_area = server->m_area_names.value(m_current_area);
+ QString l_sender_area = server->getAreaName(m_current_area);
QString l_sender_message = argv.join(" ");
- server->broadcast(AOPacket("CT", {"[G][" + l_sender_area + "]" + "["+ l_sender_name+"][M]", l_sender_message}),Server::TARGET_TYPE::MODCHAT);
+ server->broadcast(AOPacket("CT", {"[G][" + l_sender_area + "]" + "[" + l_sender_name + "][M]", l_sender_message}), Server::TARGET_TYPE::MODCHAT);
}
void AOClient::cmdLM(int argc, QStringList argv)
@@ -189,7 +194,7 @@ void AOClient::cmdLM(int argc, QStringList argv)
QString l_sender_name = m_ooc_name;
QString l_sender_message = argv.join(" ");
- server->broadcast(AOPacket("CT", {"["+ l_sender_name +"][M]", l_sender_message}), m_current_area);
+ server->broadcast(AOPacket("CT", {"[" + l_sender_name + "][M]", l_sender_message}), m_current_area);
}
void AOClient::cmdGimp(int argc, QStringList argv)
@@ -203,7 +208,7 @@ void AOClient::cmdGimp(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -230,7 +235,7 @@ void AOClient::cmdUnGimp(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -257,7 +262,7 @@ void AOClient::cmdDisemvowel(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -284,7 +289,7 @@ void AOClient::cmdUnDisemvowel(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -311,7 +316,7 @@ void AOClient::cmdShake(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -338,7 +343,7 @@ void AOClient::cmdUnShake(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -392,7 +397,7 @@ void AOClient::cmdCharCurse(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -424,14 +429,14 @@ void AOClient::cmdCharCurse(int argc, QStringList argv)
l_target->m_is_charcursed = true;
- //Kick back to char select screen
+ // Kick back to char select screen
if (!l_target->m_charcurse_list.contains(server->getCharID(l_target->m_current_char))) {
l_target->changeCharacter(-1);
- server->updateCharsTaken(server->m_areas.value(m_current_area));
+ server->updateCharsTaken(server->getAreaById(m_current_area));
l_target->sendPacket("DONE");
}
else {
- server->updateCharsTaken(server->m_areas.value(m_current_area));
+ server->updateCharsTaken(server->getAreaById(m_current_area));
}
l_target->sendServerMessage("You have been charcursed!");
@@ -449,7 +454,7 @@ void AOClient::cmdUnCharCurse(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -462,7 +467,7 @@ void AOClient::cmdUnCharCurse(int argc, QStringList argv)
}
l_target->m_is_charcursed = false;
l_target->m_charcurse_list.clear();
- server->updateCharsTaken(server->m_areas.value(m_current_area));
+ server->updateCharsTaken(server->getAreaById(m_current_area));
sendServerMessage("Uncharcursed player.");
l_target->sendServerMessage("You were uncharcursed.");
}
@@ -486,7 +491,7 @@ void AOClient::cmdCharSelect(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_target_id);
+ AOClient *l_target = server->getClientByID(l_target_id);
if (l_target == nullptr) {
sendServerMessage("Unable to locate client with ID " + QString::number(l_target_id) + ".");
@@ -496,7 +501,6 @@ void AOClient::cmdCharSelect(int argc, QStringList argv)
l_target->changeCharacter(-1);
l_target->sendPacket("DONE");
sendServerMessage("Client has been forced into character select!");
-
}
}
@@ -511,7 +515,7 @@ void AOClient::cmdA(int argc, QStringList argv)
return;
}
- AreaData* l_area = server->m_areas[l_area_id];
+ AreaData *l_area = server->getAreaById(l_area_id);
if (!l_area->owners().contains(m_id)) {
sendServerMessage("You are not CM in that area.");
return;
@@ -527,12 +531,12 @@ void AOClient::cmdS(int argc, QStringList argv)
{
Q_UNUSED(argc);
- int l_all_areas = server->m_areas.size() - 1;
+ int l_all_areas = server->getAreaCount() - 1;
QString l_sender_name = m_ooc_name;
QString l_ooc_message = argv.join(" ");
for (int i = 0; i <= l_all_areas; i++) {
- if (server->m_areas[i]->owners().contains(m_id))
+ if (server->getAreaById(i)->owners().contains(m_id))
server->broadcast(AOPacket("CT", {"[CM]" + l_sender_name, l_ooc_message}), i);
}
}
diff --git a/core/src/commands/moderation.cpp b/core/src/commands/moderation.cpp
index ad85eae..1a55653 100644
--- a/core/src/commands/moderation.cpp
+++ b/core/src/commands/moderation.cpp
@@ -17,6 +17,11 @@
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
+#include "include/area_data.h"
+#include "include/config_manager.h"
+#include "include/db_manager.h"
+#include "include/server.h"
+
// This file is for commands under the moderation category in aoclient.h
// Be sure to register the command in the header before adding it here!
@@ -57,12 +62,12 @@ void AOClient::cmdBan(int argc, QStringList argv)
break;
}
- const QList l_targets = server->getClientsByIpid(l_ban.ipid);
- for (AOClient* client : l_targets) {
+ const QList l_targets = server->getClientsByIpid(l_ban.ipid);
+ for (AOClient *l_client : l_targets) {
if (!l_ban_logged) {
- l_ban.ip = client->m_remote_ip;
- l_ban.hdid = client->m_hwid;
- server->db_manager->addBan(l_ban);
+ l_ban.ip = l_client->m_remote_ip;
+ l_ban.hdid = l_client->m_hwid;
+ server->getDatabaseManager()->addBan(l_ban);
sendServerMessage("Banned user with ipid " + l_ban.ipid + " for reason: " + l_ban.reason);
l_ban_logged = true;
}
@@ -73,12 +78,12 @@ void AOClient::cmdBan(int argc, QStringList argv)
else {
l_ban_duration = "The heat death of the universe.";
}
- int l_ban_id = server->db_manager->getBanID(l_ban.ip);
- client->sendPacket("KB", {l_ban.reason + "\nID: " + QString::number(l_ban_id) + "\nUntil: " + l_ban_duration});
- client->m_socket->close();
+ int l_ban_id = server->getDatabaseManager()->getBanID(l_ban.ip);
+ l_client->sendPacket("KB", {l_ban.reason + "\nID: " + QString::number(l_ban_id) + "\nUntil: " + l_ban_duration});
+ l_client->m_socket->close();
l_kick_counter++;
- emit logBan(l_ban.moderator,l_ban.ipid,l_ban_duration,l_ban.reason);
+ emit logBan(l_ban.moderator, l_ban.ipid, l_ban_duration, l_ban.reason);
if (ConfigManager::discordBanWebhookEnabled())
emit server->banWebhookRequest(l_ban.ipid, l_ban.moderator, l_ban_duration, l_ban.reason, l_ban_id);
}
@@ -88,7 +93,7 @@ void AOClient::cmdBan(int argc, QStringList argv)
// We're banning someone not connected.
if (!l_ban_logged) {
- server->db_manager->addBan(l_ban);
+ server->getDatabaseManager()->addBan(l_ban);
sendServerMessage("Banned " + l_ban.ipid + " for reason: " + l_ban.reason);
}
}
@@ -105,15 +110,15 @@ void AOClient::cmdKick(int argc, QStringList argv)
}
}
- const QList l_targets = server->getClientsByIpid(l_target_ipid);
- for (AOClient* client : l_targets) {
- client->sendPacket("KK", {l_reason});
- client->m_socket->close();
+ const QList l_targets = server->getClientsByIpid(l_target_ipid);
+ for (AOClient *l_client : l_targets) {
+ l_client->sendPacket("KK", {l_reason});
+ l_client->m_socket->close();
l_kick_counter++;
}
if (l_kick_counter > 0) {
- if (ConfigManager::authType() == DataTypes::AuthType::ADVANCED){
+ if (ConfigManager::authType() == DataTypes::AuthType::ADVANCED) {
emit logKick(m_moderator_name, l_target_ipid, l_reason);
}
else {
@@ -132,7 +137,8 @@ void AOClient::cmdMods(int argc, QStringList argv)
QStringList l_entries;
int l_online_count = 0;
- for (AOClient* l_client : qAsConst(server->m_clients)) {
+ const QVector l_clients = server->getClients();
+ for (AOClient *l_client : l_clients) {
if (l_client->m_authenticated) {
l_entries << "---";
if (ConfigManager::authType() != DataTypes::AuthType::SIMPLE)
@@ -157,7 +163,7 @@ void AOClient::cmdCommands(int argc, QStringList argv)
QStringList l_entries;
l_entries << "Allowed commands:";
QMap::const_iterator i;
- for (i = commands.constBegin(); i!= commands.constEnd(); ++i) {
+ for (i = commands.constBegin(); i != commands.constEnd(); ++i) {
CommandInfo info = i.value();
if (checkAuth(info.acl_mask)) { // if we are allowed to use this command
l_entries << "/" + i.key();
@@ -168,7 +174,7 @@ void AOClient::cmdCommands(int argc, QStringList argv)
void AOClient::cmdHelp(int argc, QStringList argv)
{
- if(argc > 1) {
+ if (argc > 1) {
sendServerMessage("Too many arguments. Please only use the command name.");
return;
}
@@ -178,7 +184,7 @@ void AOClient::cmdHelp(int argc, QStringList argv)
if (l_command_info.usage.isEmpty() || l_command_info.text.isEmpty()) // my picoseconds :(
sendServerMessage("Unable to find the command " + l_command_name + ".");
else
- sendServerMessage("==Help==\n" +l_command_info.usage + "\n" + l_command_info.text);
+ sendServerMessage("==Help==\n" + l_command_info.usage + "\n" + l_command_info.text);
}
void AOClient::cmdMOTD(int argc, QStringList argv)
@@ -206,7 +212,7 @@ void AOClient::cmdBans(int argc, QStringList argv)
QStringList l_recent_bans;
l_recent_bans << "Last 5 bans:";
l_recent_bans << "-----";
- const QList l_bans_list = server->db_manager->getRecentBans();
+ const QList l_bans_list = server->getDatabaseManager()->getRecentBans();
for (const DBManager::BanInfo &l_ban : l_bans_list) {
QString l_banned_until;
if (l_ban.duration == -2)
@@ -235,7 +241,7 @@ void AOClient::cmdUnBan(int argc, QStringList argv)
sendServerMessage("Invalid ban ID.");
return;
}
- else if (server->db_manager->invalidateBan(l_target_ban))
+ else if (server->getDatabaseManager()->invalidateBan(l_target_ban))
sendServerMessage("Successfully invalidated ban " + argv[0] + ".");
else
sendServerMessage("Couldn't invalidate ban " + argv[0] + ", are you sure it exists?");
@@ -260,7 +266,7 @@ void AOClient::cmdMute(int argc, QStringList argv)
return;
}
- AOClient* target = server->getClientByID(l_uid);
+ AOClient *target = server->getClientByID(l_uid);
if (target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -287,7 +293,7 @@ void AOClient::cmdUnMute(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -314,7 +320,7 @@ void AOClient::cmdOocMute(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -341,7 +347,7 @@ void AOClient::cmdOocUnMute(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -368,7 +374,7 @@ void AOClient::cmdBlockWtce(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -395,7 +401,7 @@ void AOClient::cmdUnBlockWtce(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -417,7 +423,7 @@ void AOClient::cmdAllowBlankposting(int argc, QStringList argv)
Q_UNUSED(argv);
QString l_sender_name = m_ooc_name;
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
l_area->toggleBlankposting();
if (l_area->blankpostingAllowed() == false) {
sendServerMessageArea(l_sender_name + " has set blankposting in the area to forbidden.");
@@ -435,7 +441,7 @@ void AOClient::cmdBanInfo(int argc, QStringList argv)
QString l_lookup_type;
if (argc == 1) {
- l_lookup_type = "banid";
+ l_lookup_type = "banid";
}
else if (argc == 2) {
l_lookup_type = argv[1];
@@ -449,7 +455,7 @@ void AOClient::cmdBanInfo(int argc, QStringList argv)
return;
}
QString l_id = argv[0];
- const QList l_bans = server->db_manager->getBanInfo(l_lookup_type, l_id);
+ const QList l_bans = server->getDatabaseManager()->getBanInfo(l_lookup_type, l_id);
for (const DBManager::BanInfo &l_ban : l_bans) {
QString l_banned_until;
if (l_ban.duration == -2)
@@ -473,7 +479,7 @@ void AOClient::cmdReload(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- //Todo: Make this a signal when splitting AOClient and Server.
+ // Todo: Make this a signal when splitting AOClient and Server.
server->reloadSettings();
sendServerMessage("Reloaded configurations");
}
@@ -483,7 +489,7 @@ void AOClient::cmdForceImmediate(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
l_area->toggleImmediate();
QString l_state = l_area->forceImmediate() ? "on." : "off.";
sendServerMessage("Forced immediate text processing in this area is now " + l_state);
@@ -494,7 +500,7 @@ void AOClient::cmdAllowIniswap(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
l_area->toggleIniswap();
QString state = l_area->iniswapAllowed() ? "allowed." : "disallowed.";
sendServerMessage("Iniswapping in this area is now " + state);
@@ -504,7 +510,7 @@ void AOClient::cmdPermitSaving(int argc, QStringList argv)
{
Q_UNUSED(argc);
- AOClient* l_client = server->getClientByID(argv[0].toInt());
+ AOClient *l_client = server->getClientByID(argv[0].toInt());
if (l_client == nullptr) {
sendServerMessage("Invalid ID.");
return;
@@ -530,7 +536,7 @@ void AOClient::cmdKickUid(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
return;
@@ -560,7 +566,6 @@ void AOClient::cmdUpdateBan(int argc, QStringList argv)
return;
}
l_updated_info = QVariant(l_duration_seconds);
-
}
else if (argv[1] == "reason") {
QString l_args_str = argv[2];
@@ -574,7 +579,7 @@ void AOClient::cmdUpdateBan(int argc, QStringList argv)
sendServerMessage("Invalid update type.");
return;
}
- if (!server->db_manager->updateBan(l_ban_id, argv[1], l_updated_info)) {
+ if (!server->getDatabaseManager()->updateBan(l_ban_id, argv[1], l_updated_info)) {
sendServerMessage("There was an error updating the ban. Please confirm the ban ID is valid.");
return;
}
@@ -599,8 +604,8 @@ void AOClient::cmdClearCM(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas.value(m_current_area);
- foreach (int l_client_id,l_area->owners()) {
+ AreaData *l_area = server->getAreaById(m_current_area);
+ foreach (int l_client_id, l_area->owners()) {
l_area->removeOwner(l_client_id);
}
arup(ARUPType::CM, true);
diff --git a/core/src/commands/music.cpp b/core/src/commands/music.cpp
index 629bb63..00a60d1 100644
--- a/core/src/commands/music.cpp
+++ b/core/src/commands/music.cpp
@@ -16,6 +16,12 @@
// along with this program. If not, see . //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
+
+#include "include/aopacket.h"
+#include "include/area_data.h"
+#include "include/music_manager.h"
+#include "include/server.h"
+
// This file is for commands under the music category in aoclient.h
// Be sure to register the command in the header before adding it here!
@@ -27,7 +33,7 @@ void AOClient::cmdPlay(int argc, QStringList argv)
sendServerMessage("You are blocked from changing the music.");
return;
}
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
QString l_song = argv.join(" ");
if (m_showname.isEmpty()) {
l_area->changeMusic(m_current_char, l_song);
@@ -44,7 +50,7 @@ void AOClient::cmdCurrentMusic(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
if (!l_area->currentMusic().isEmpty() && !l_area->currentMusic().contains("~stop.mp3")) // dummy track for stopping music
sendServerMessage("The current song is " + l_area->currentMusic() + " played by " + l_area->musicPlayerBy());
else
@@ -62,7 +68,7 @@ void AOClient::cmdBlockDj(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -89,7 +95,7 @@ void AOClient::cmdUnBlockDj(int argc, QStringList argv)
return;
}
- AOClient* l_target = server->getClientByID(l_uid);
+ AOClient *l_target = server->getClientByID(l_uid);
if (l_target == nullptr) {
sendServerMessage("No client with that ID found.");
@@ -110,7 +116,7 @@ void AOClient::cmdToggleMusic(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
l_area->toggleMusic();
QString l_state = l_area->isMusicAllowed() ? "allowed." : "disallowed.";
sendServerMessage("Music in this area is now " + l_state);
@@ -122,7 +128,7 @@ void AOClient::cmdToggleJukebox(int argc, QStringList argv)
Q_UNUSED(argv);
if (checkAuth(ACLFlags.value("CM")) | checkAuth(ACLFlags.value("Jukebox"))) {
- AreaData* l_area = server->m_areas.value(m_current_area);
+ AreaData *l_area = server->getAreaById(m_current_area);
l_area->toggleJukebox();
QString l_state = l_area->isjukeboxEnabled() ? "enabled." : "disabled.";
sendServerMessageArea("The jukebox in this area has been " + l_state);
@@ -136,11 +142,11 @@ void AOClient::cmdAddSong(int argc, QStringList argv)
{
Q_UNUSED(argc);
- //This needs some explanation.
- //Akashi has no concept of argument count,so any space is interpreted as a new element
- //in the QStringList. This works fine until someone enters something with a space.
- //Since we can't preencode those elements, we join all as a string and use a delimiter
- //that does not exist in file and URL paths. I decided on the ol' reliable ','.
+ // This needs some explanation.
+ // Akashi has no concept of argument count,so any space is interpreted as a new element
+ // in the QStringList. This works fine until someone enters something with a space.
+ // Since we can't preencode those elements, we join all as a string and use a delimiter
+ // that does not exist in file and URL paths. I decided on the ol' reliable ','.
QString l_argv_string = argv.join(" ");
QStringList l_argv = l_argv_string.split(",");
diff --git a/core/src/commands/roleplay.cpp b/core/src/commands/roleplay.cpp
index 5d8881f..22dd5bc 100644
--- a/core/src/commands/roleplay.cpp
+++ b/core/src/commands/roleplay.cpp
@@ -17,6 +17,11 @@
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
+#include "include/aopacket.h"
+#include "include/area_data.h"
+#include "include/config_manager.h"
+#include "include/server.h"
+
// This file is for commands under the roleplay category in aoclient.h
// Be sure to register the command in the header before adding it here!
@@ -26,8 +31,8 @@ void AOClient::cmdFlip(int argc, QStringList argv)
Q_UNUSED(argv);
QString l_sender_name = m_ooc_name;
- QStringList l_faces = {"heads","tails"};
- QString l_face = l_faces[AOClient::genRand(0,1)];
+ QStringList l_faces = {"heads", "tails"};
+ QString l_face = l_faces[AOClient::genRand(0, 1)];
sendServerMessageArea(l_sender_name + " flipped a coin and got " + l_face + ".");
}
@@ -43,7 +48,7 @@ void AOClient::cmdRollP(int argc, QStringList argv)
void AOClient::cmdTimer(int argc, QStringList argv)
{
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
// Called without arguments
// Shows a brief of all timers
@@ -77,7 +82,7 @@ void AOClient::cmdTimer(int argc, QStringList argv)
// Select the proper timer
// Check against permissions if global timer is selected
- QTimer* l_requested_timer;
+ QTimer *l_requested_timer;
if (l_timer_id == 0) {
if (!checkAuth(ACLFlags.value("GLOBAL_TIMER"))) {
sendServerMessage("You are not authorized to alter the global timer.");
@@ -96,10 +101,10 @@ void AOClient::cmdTimer(int argc, QStringList argv)
// argument is a valid time
QTime l_requested_time = QTime::fromString(argv[1], "hh:mm:ss");
if (l_requested_time.isValid()) {
- l_requested_timer->setInterval(QTime(0,0).msecsTo(l_requested_time));
+ l_requested_timer->setInterval(QTime(0, 0).msecsTo(l_requested_time));
l_requested_timer->start();
sendServerMessage("Set timer " + QString::number(l_timer_id) + " to " + argv[1] + ".");
- AOPacket l_update_timer("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0,0).msecsTo(l_requested_time))});
+ AOPacket l_update_timer("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0, 0).msecsTo(l_requested_time))});
l_is_global ? server->broadcast(l_show_timer) : server->broadcast(l_show_timer, m_current_area); // Show the timer
l_is_global ? server->broadcast(l_update_timer) : server->broadcast(l_update_timer, m_current_area);
return;
@@ -109,7 +114,7 @@ void AOClient::cmdTimer(int argc, QStringList argv)
if (argv[1] == "start") {
l_requested_timer->start();
sendServerMessage("Started timer " + QString::number(l_timer_id) + ".");
- AOPacket l_update_timer("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(l_requested_timer->remainingTime())))});
+ AOPacket l_update_timer("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0, 0).msecsTo(QTime(0, 0).addMSecs(l_requested_timer->remainingTime())))});
l_is_global ? server->broadcast(l_show_timer) : server->broadcast(l_show_timer, m_current_area);
l_is_global ? server->broadcast(l_update_timer) : server->broadcast(l_update_timer, m_current_area);
}
@@ -117,7 +122,7 @@ void AOClient::cmdTimer(int argc, QStringList argv)
l_requested_timer->setInterval(l_requested_timer->remainingTime());
l_requested_timer->stop();
sendServerMessage("Stopped timer " + QString::number(l_timer_id) + ".");
- AOPacket l_update_timer("TI", {QString::number(l_timer_id), "1", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(l_requested_timer->interval())))});
+ AOPacket l_update_timer("TI", {QString::number(l_timer_id), "1", QString::number(QTime(0, 0).msecsTo(QTime(0, 0).addMSecs(l_requested_timer->interval())))});
l_is_global ? server->broadcast(l_update_timer) : server->broadcast(l_update_timer, m_current_area);
}
else if (argv[1] == "hide" || argv[1] == "unset") {
@@ -134,7 +139,7 @@ void AOClient::cmdNoteCard(int argc, QStringList argv)
{
Q_UNUSED(argc);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
QString l_notecard = argv.join(" ");
l_area->addNotecard(m_current_char, l_notecard);
sendServerMessageArea(m_current_char + " wrote a note card.");
@@ -145,7 +150,7 @@ void AOClient::cmdNoteCardClear(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
if (!l_area->addNotecard(m_current_char, QString())) {
sendServerMessageArea(m_current_char + " erased their note card.");
}
@@ -156,7 +161,7 @@ void AOClient::cmdNoteCardReveal(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
- AreaData* l_area = server->m_areas[m_current_area];
+ AreaData *l_area = server->getAreaById(m_current_area);
const QStringList l_notecards = l_area->getNotecards();
if (l_notecards.isEmpty()) {
@@ -177,14 +182,14 @@ void AOClient::cmd8Ball(int argc, QStringList argv)
if (ConfigManager::magic8BallAnswers().isEmpty()) {
qWarning() << "8ball.txt is empty!";
sendServerMessage("8ball.txt is empty.");
- }
+ }
else {
QString l_response = ConfigManager::magic8BallAnswers().at((genRand(1, ConfigManager::magic8BallAnswers().size() - 1)));
QString l_sender_name = m_ooc_name;
QString l_sender_message = argv.join(" ");
sendServerMessageArea(l_sender_name + " asked the magic 8-ball, \"" + l_sender_message + "\" and the answer is: " + l_response);
- }
+ }
}
void AOClient::cmdSubTheme(int argc, QStringList argv)
@@ -192,7 +197,8 @@ void AOClient::cmdSubTheme(int argc, QStringList argv)
Q_UNUSED(argc);
QString l_subtheme = argv.join(" ");
- for (AOClient* l_client : qAsConst(server->m_clients)) {
+ const QVector l_clients = server->getClients();
+ for (AOClient *l_client : l_clients) {
if (l_client->m_current_area == m_current_area)
l_client->sendPacket("ST", {l_subtheme, "1"});
}
diff --git a/core/src/config_manager.cpp b/core/src/config_manager.cpp
index f465366..e74c769 100644
--- a/core/src/config_manager.cpp
+++ b/core/src/config_manager.cpp
@@ -19,15 +19,15 @@
#include
-QSettings* ConfigManager::m_settings = new QSettings("config/config.ini", QSettings::IniFormat);
-QSettings* ConfigManager::m_discord = new QSettings("config/discord.ini", QSettings::IniFormat);
-QSettings* ConfigManager::m_areas = new QSettings("config/areas.ini", QSettings::IniFormat);
-QSettings* ConfigManager::m_logtext = new QSettings("config/text/logtext.ini", QSettings::IniFormat);
-ConfigManager::CommandSettings* ConfigManager::m_commands = new CommandSettings();
-QElapsedTimer* ConfigManager::m_uptimeTimer = new QElapsedTimer;
-MusicList* ConfigManager::m_musicList = new MusicList;
-QHash* ConfigManager::m_commands_help = new QHash;
-QStringList* ConfigManager::m_ordered_list = new QStringList;
+QSettings *ConfigManager::m_settings = new QSettings("config/config.ini", QSettings::IniFormat);
+QSettings *ConfigManager::m_discord = new QSettings("config/discord.ini", QSettings::IniFormat);
+QSettings *ConfigManager::m_areas = new QSettings("config/areas.ini", QSettings::IniFormat);
+QSettings *ConfigManager::m_logtext = new QSettings("config/text/logtext.ini", QSettings::IniFormat);
+ConfigManager::CommandSettings *ConfigManager::m_commands = new CommandSettings();
+QElapsedTimer *ConfigManager::m_uptimeTimer = new QElapsedTimer;
+MusicList *ConfigManager::m_musicList = new MusicList;
+QHash *ConfigManager::m_commands_help = new QHash;
+QStringList *ConfigManager::m_ordered_list = new QStringList;
bool ConfigManager::verifyServerConfig()
{
@@ -35,15 +35,15 @@ bool ConfigManager::verifyServerConfig()
QStringList l_directories{"config/", "config/text/"};
for (const QString &l_directory : l_directories) {
if (!dirExists(QFileInfo(l_directory))) {
- qCritical() << l_directory + " does not exist!";
- return false;
+ qCritical() << l_directory + " does not exist!";
+ return false;
}
}
// Verify config files
QStringList l_config_files{"config/config.ini", "config/areas.ini", "config/backgrounds.txt", "config/characters.txt", "config/music.json",
"config/discord.ini", "config/text/8ball.txt", "config/text/gimp.txt", "config/text/praise.txt",
- "config/text/reprimands.txt","config/text/commandhelp.json","config/text/cdns.txt"};
+ "config/text/reprimands.txt", "config/text/commandhelp.json", "config/text/cdns.txt"};
for (const QString &l_file : l_config_files) {
if (!fileExists(QFileInfo(l_file))) {
qCritical() << l_file + " does not exist!";
@@ -94,6 +94,8 @@ bool ConfigManager::verifyServerConfig()
m_commands->reprimands = (loadConfigFile("reprimands"));
m_commands->gimps = (loadConfigFile("gimp"));
m_commands->cdns = (loadConfigFile("cdns"));
+ if (m_commands->cdns.isEmpty())
+ m_commands->cdns = QStringList{"cdn.discord.com"};
m_uptimeTimer->start();
@@ -102,7 +104,7 @@ bool ConfigManager::verifyServerConfig()
QString ConfigManager::bindIP()
{
- return m_settings->value("Options/bind_ip","all").toString();
+ return m_settings->value("Options/bind_ip", "all").toString();
}
QStringList ConfigManager::charlist()
@@ -138,22 +140,22 @@ MusicList ConfigManager::musiclist()
QJsonParseError l_error;
QJsonDocument l_music_list_json = QJsonDocument::fromJson(l_music_json.readAll(), &l_error);
- if (!(l_error.error == QJsonParseError::NoError)) { //Non-Terminating error.
+ if (!(l_error.error == QJsonParseError::NoError)) { // Non-Terminating error.
qWarning() << "Unable to load musiclist. The following error was encounted : " + l_error.errorString();
- return QMap>{}; //Server can still run without music.
+ return QMap>{}; // Server can still run without music.
}
// Akashi expects the musiclist to be contained in a JSON array, even if its only a single category.
QJsonArray l_Json_root_array = l_music_list_json.array();
QJsonObject l_child_obj;
QJsonArray l_child_array;
- for (int i = 0; i <= l_Json_root_array.size() -1; i++){ //Iterate trough entire JSON file to assemble musiclist
+ for (int i = 0; i <= l_Json_root_array.size() - 1; i++) { // Iterate trough entire JSON file to assemble musiclist
l_child_obj = l_Json_root_array.at(i).toObject();
- //Technically not a requirement, but neat for organisation.
+ // Technically not a requirement, but neat for organisation.
QString l_category_name = l_child_obj["category"].toString();
if (!l_category_name.isEmpty()) {
- m_musicList->insert(l_category_name,{l_category_name,0});
+ m_musicList->insert(l_category_name, {l_category_name, 0});
m_ordered_list->append(l_category_name);
}
else {
@@ -161,7 +163,7 @@ MusicList ConfigManager::musiclist()
}
l_child_array = l_child_obj["songs"].toArray();
- for (int i = 0; i <= l_child_array.size() -1; i++){ // Inner for loop because a category can contain multiple songs.
+ for (int i = 0; i <= l_child_array.size() - 1; i++) { // Inner for loop because a category can contain multiple songs.
QJsonObject l_song_obj = l_child_array.at(i).toObject();
QString l_song_name = l_song_obj["name"].toString();
QString l_real_name = l_song_obj["realname"].toString();
@@ -169,8 +171,8 @@ MusicList ConfigManager::musiclist()
l_real_name = l_song_name;
}
int l_song_duration = l_song_obj["length"].toVariant().toInt();
- m_musicList->insert(l_song_name,{l_real_name,l_song_duration});
- m_ordered_list->append(l_song_name);
+ m_musicList->insert(l_song_name, {l_real_name, l_song_duration});
+ m_ordered_list->append(l_song_name);
}
}
l_music_json.close();
@@ -190,7 +192,7 @@ void ConfigManager::loadCommandHelp()
QJsonParseError l_error;
QJsonDocument l_help_list_json = QJsonDocument::fromJson(l_help_json.readAll(), &l_error);
- if (!(l_error.error == QJsonParseError::NoError)) { //Non-Terminating error.
+ if (!(l_error.error == QJsonParseError::NoError)) { // Non-Terminating error.
qWarning() << "Unable to load help information. The following error occurred: " + l_error.errorString();
}
@@ -198,7 +200,7 @@ void ConfigManager::loadCommandHelp()
QJsonArray l_Json_root_array = l_help_list_json.array();
QJsonObject l_child_obj;
- for (int i = 0; i <= l_Json_root_array.size() -1; i++){
+ for (int i = 0; i <= l_Json_root_array.size() - 1; i++) {
l_child_obj = l_Json_root_array.at(i).toObject();
QString l_name = l_child_obj["name"].toString();
QString l_usage = l_child_obj["usage"].toString();
@@ -209,12 +211,12 @@ void ConfigManager::loadCommandHelp()
l_help_information.usage = l_usage;
l_help_information.text = l_text;
- m_commands_help->insert(l_name,l_help_information);
+ m_commands_help->insert(l_name, l_help_information);
}
}
}
-QSettings* ConfigManager::areaData()
+QSettings *ConfigManager::areaData()
{
return m_areas;
}
@@ -222,7 +224,7 @@ QSettings* ConfigManager::areaData()
QStringList ConfigManager::sanitizedAreaNames()
{
QStringList l_area_names = m_areas->childGroups(); // invisibly does a lexicographical sort, because Qt is great like that
- std::sort(l_area_names.begin(), l_area_names.end(), [] (const QString &a, const QString &b) {return a.split(":")[0].toInt() < b.split(":")[0].toInt();});
+ std::sort(l_area_names.begin(), l_area_names.end(), [](const QString &a, const QString &b) { return a.split(":")[0].toInt() < b.split(":")[0].toInt(); });
QStringList l_sanitized_area_names;
for (const QString &areaName : qAsConst(l_area_names)) {
QStringList l_nameSplit = areaName.split(":");
@@ -452,13 +454,13 @@ QString ConfigManager::discordBanWebhookUrl()
bool ConfigManager::discordUptimeEnabled()
{
- return m_discord->value("Discord/webhook_uptime_enabled","false").toBool();
+ return m_discord->value("Discord/webhook_uptime_enabled", "false").toBool();
}
int ConfigManager::discordUptimeTime()
{
bool ok;
- int l_aliveTime = m_discord->value("Discord/webhook_uptime_time","60").toInt(&ok);
+ int l_aliveTime = m_discord->value("Discord/webhook_uptime_time", "60").toInt(&ok);
if (!ok) {
qWarning("alive_time is not an int");
l_aliveTime = 60;
@@ -532,7 +534,7 @@ bool ConfigManager::passwordCanContainUsername()
QString ConfigManager::LogText(QString f_logtype)
{
- return m_logtext->value("LogConfiguration/" + f_logtype,"").toString();
+ return m_logtext->value("LogConfiguration/" + f_logtype, "").toString();
}
int ConfigManager::afkTimeout()
@@ -578,23 +580,23 @@ QStringList ConfigManager::cdnList()
bool ConfigManager::advertiseServer()
{
- return m_settings->value("Advertiser/advertise","true").toBool();
+ return m_settings->value("Advertiser/advertise", "true").toBool();
}
bool ConfigManager::advertiserDebug()
{
- return m_settings->value("Advertiser/debug","true").toBool();
+ return m_settings->value("Advertiser/debug", "true").toBool();
}
QUrl ConfigManager::advertiserIP()
{
- qDebug() << m_settings->value("Advertiser/ms_ip","").toUrl();
- return m_settings->value("Advertiser/ms_ip","").toUrl();
+ qDebug() << m_settings->value("Advertiser/ms_ip", "").toUrl();
+ return m_settings->value("Advertiser/ms_ip", "").toUrl();
}
QString ConfigManager::advertiserHostname()
{
- return m_settings->value("Advertiser/hostname","").toString();
+ return m_settings->value("Advertiser/hostname", "").toString();
}
qint64 ConfigManager::uptime()
diff --git a/core/src/db_manager.cpp b/core/src/db_manager.cpp
index e80e0b8..595f011 100644
--- a/core/src/db_manager.cpp
+++ b/core/src/db_manager.cpp
@@ -26,8 +26,8 @@ DBManager::DBManager() :
qWarning().noquote() << tr("Database Info: Database not found. Attempting to create new database.");
}
else {
- //We should only check if a file is readable/writeable when it actually exists.
- if(!db_info.isReadable() || !db_info.isWritable())
+ // We should only check if a file is readable/writeable when it actually exists.
+ if (!db_info.isReadable() || !db_info.isWritable())
qCritical() << tr("Database Error: Missing permissions. Check if \"%1\" is writable.").arg(db_filename);
}
@@ -59,9 +59,11 @@ QPair DBManager::isIPBanned(QString ipid)
long long current_time = QDateTime::currentDateTime().toSecsSinceEpoch();
if (ban_time + duration > current_time)
return {true, reason};
- else return {false, nullptr};
+ else
+ return {false, nullptr};
}
- else return {false, nullptr};
+ else
+ return {false, nullptr};
}
QPair DBManager::isHDIDBanned(QString hdid)
@@ -79,9 +81,11 @@ QPair DBManager::isHDIDBanned(QString hdid)
long long current_time = QDateTime::currentDateTime().toSecsSinceEpoch();
if (ban_time + duration > current_time)
return {true, reason};
- else return {false, nullptr};
+ else
+ return {false, nullptr};
}
- else return {false, nullptr};
+ else
+ return {false, nullptr};
}
int DBManager::getBanID(QString hdid)
@@ -98,7 +102,6 @@ int DBManager::getBanID(QString hdid)
}
}
-
int DBManager::getBanID(QHostAddress ip)
{
QSqlQuery query;
@@ -199,7 +202,7 @@ bool DBManager::createUser(QString username, QString salt, QString password, uns
bool DBManager::deleteUser(QString username)
{
if (username == "root") {
- //To prevent lockout scenarios where an admin may accidentally delete root.
+ // To prevent lockout scenarios where an admin may accidentally delete root.
return false;
}
@@ -209,9 +212,9 @@ bool DBManager::deleteUser(QString username)
username_exists.addBindValue(username);
username_exists.exec();
username_exists.first();
- //If EXISTS can't find a record, it returns 0.
+ // If EXISTS can't find a record, it returns 0.
if (username_exists.value(0).toInt() == 0)
- //We were unable to locate an entry with this name.
+ // We were unable to locate an entry with this name.
return false;
}
{
@@ -405,7 +408,7 @@ void DBManager::updateDB(int current_version)
QSqlQuery("ALTER TABLE bans ADD COLUMN MODERATOR TEXT");
Q_FALLTHROUGH();
case 1:
- QSqlQuery ("PRAGMA user_version = " + QString::number(DB_VERSION));
+ QSqlQuery("PRAGMA user_version = " + QString::number(DB_VERSION));
break;
}
}
diff --git a/core/src/discord.cpp b/core/src/discord.cpp
index 9683ff7..bd79182 100644
--- a/core/src/discord.cpp
+++ b/core/src/discord.cpp
@@ -17,7 +17,9 @@
//////////////////////////////////////////////////////////////////////////////////////
#include "include/discord.h"
-Discord::Discord(QObject* parent) :
+#include "include/config_manager.h"
+
+Discord::Discord(QObject *parent) :
QObject(parent)
{
m_nam = new QNetworkAccessManager();
@@ -26,7 +28,7 @@ Discord::Discord(QObject* parent) :
m_uptimePostTimer = new QTimer;
connect(m_uptimePostTimer, &QTimer::timeout,
- this, &Discord::onUptimeWebhookRequested);
+ this, &Discord::onUptimeWebhookRequested);
}
void Discord::onModcallWebhookRequested(const QString &f_name, const QString &f_area, const QString &f_reason, const QQueue &f_buffer)
@@ -44,7 +46,7 @@ void Discord::onModcallWebhookRequested(const QString &f_name, const QString &f_
void Discord::onBanWebhookRequested(const QString &f_ipid, const QString &f_moderator, const QString &f_duration, const QString &f_reason, const int &f_banID)
{
m_request.setUrl(QUrl(ConfigManager::discordBanWebhookUrl()));
- QJsonDocument l_json = constructBanJson(f_ipid,f_moderator, f_duration, f_reason, f_banID);
+ QJsonDocument l_json = constructBanJson(f_ipid, f_moderator, f_duration, f_reason, f_banID);
postJsonWebhook(l_json);
}
@@ -65,18 +67,16 @@ QJsonDocument Discord::constructModcallJson(const QString &f_name, const QString
{
QJsonObject l_json;
QJsonArray l_array;
- QJsonObject l_object {
+ QJsonObject l_object{
{"color", ConfigManager::discordWebhookColor()},
{"title", f_name + " filed a modcall in " + f_area},
- {"description", f_reason}
- };
+ {"description", f_reason}};
l_array.append(l_object);
if (!ConfigManager::discordModcallWebhookContent().isEmpty())
- l_json["content"] = ConfigManager::discordModcallWebhookContent();
+ l_json["content"] = ConfigManager::discordModcallWebhookContent();
l_json["embeds"] = l_array;
-
return QJsonDocument(l_json);
}
@@ -84,35 +84,33 @@ QJsonDocument Discord::constructBanJson(const QString &f_ipid, const QString &f_
{
QJsonObject l_json;
QJsonArray l_array;
- QJsonObject l_object {
+ QJsonObject l_object{
{"color", ConfigManager::discordWebhookColor()},
{"title", "Ban issued by " + f_moderator},
- {"description", "Client IPID : " + f_ipid + "\nBan ID: " + QString::number(f_banID) + "\nBan reason : " + f_reason +"\nBanned until : " +f_duration}
- };
+ {"description", "Client IPID : " + f_ipid + "\nBan ID: " + QString::number(f_banID) + "\nBan reason : " + f_reason + "\nBanned until : " + f_duration}};
l_array.append(l_object);
l_json["embeds"] = l_array;
return QJsonDocument(l_json);
}
-QJsonDocument Discord::constructUptimeJson(const QString& f_timeExpired)
+QJsonDocument Discord::constructUptimeJson(const QString &f_timeExpired)
{
QJsonObject l_json;
QJsonArray l_array;
- QJsonObject l_object {
+ QJsonObject l_object{
{"color", ConfigManager::discordWebhookColor()},
{"title", "Your server is online!"},
- {"description", "Your server has been online for " + f_timeExpired}
- };
+ {"description", "Your server has been online for " + f_timeExpired}};
l_array.append(l_object);
l_json["embeds"] = l_array;
return QJsonDocument(l_json);
}
-QHttpMultiPart* Discord::constructLogMultipart(const QQueue &f_buffer) const
+QHttpMultiPart *Discord::constructLogMultipart(const QQueue &f_buffer) const
{
- QHttpMultiPart* l_multipart = new QHttpMultiPart();
+ QHttpMultiPart *l_multipart = new QHttpMultiPart();
QHttpPart l_file;
l_file.setRawHeader(QByteArray("Content-Disposition"), QByteArray("form-data; name=\"file\"; filename=\"log.txt\""));
l_file.setRawHeader(QByteArray("Content-Type"), QByteArray("plain/text"));
@@ -143,7 +141,7 @@ void Discord::postMultipartWebhook(QHttpMultiPart &f_multipart)
return;
}
m_request.setHeader(QNetworkRequest::ContentTypeHeader, "multipart/form-data; boundary=" + f_multipart.boundary());
- QNetworkReply* l_reply = m_nam->post(m_request, &f_multipart);
+ QNetworkReply *l_reply = m_nam->post(m_request, &f_multipart);
f_multipart.setParent(l_reply);
}
diff --git a/core/src/logger/u_logger.cpp b/core/src/logger/u_logger.cpp
index 358f515..eeb99d9 100644
--- a/core/src/logger/u_logger.cpp
+++ b/core/src/logger/u_logger.cpp
@@ -17,17 +17,17 @@
//////////////////////////////////////////////////////////////////////////////////////
#include "include/logger/u_logger.h"
-ULogger::ULogger(QObject* parent) :
+ULogger::ULogger(QObject *parent) :
QObject(parent)
{
switch (ConfigManager::loggingType()) {
- case DataTypes::LogType::MODCALL :
- writerModcall = new WriterModcall;
- break;
- case DataTypes::LogType::FULL :
- case DataTypes::LogType::FULLAREA :
- writerFull = new WriterFull;
- break;
+ case DataTypes::LogType::MODCALL:
+ writerModcall = new WriterModcall;
+ break;
+ case DataTypes::LogType::FULL:
+ case DataTypes::LogType::FULLAREA:
+ writerFull = new WriterFull;
+ break;
}
loadLogtext();
}
@@ -35,45 +35,45 @@ ULogger::ULogger(QObject* parent) :
ULogger::~ULogger()
{
switch (ConfigManager::loggingType()) {
- case DataTypes::LogType::MODCALL :
- writerModcall->deleteLater();
- break;
- case DataTypes::LogType::FULL :
- case DataTypes::LogType::FULLAREA :
- writerFull->deleteLater();
- break;
+ case DataTypes::LogType::MODCALL:
+ writerModcall->deleteLater();
+ break;
+ case DataTypes::LogType::FULL:
+ case DataTypes::LogType::FULLAREA:
+ writerFull->deleteLater();
+ break;
}
}
-void ULogger::logIC(const QString& f_char_name, const QString& f_ooc_name, const QString& f_ipid,
- const QString& f_area_name, const QString& f_message)
+void ULogger::logIC(const QString &f_char_name, const QString &f_ooc_name, const QString &f_ipid,
+ const QString &f_area_name, const QString &f_message)
{
QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss");
QString l_logEntry = QString(m_logtext.value("ic") + "\n").arg(l_time, f_char_name, f_ooc_name, f_ipid, f_area_name, f_message);
- updateAreaBuffer(f_area_name,l_logEntry);
+ updateAreaBuffer(f_area_name, l_logEntry);
}
-void ULogger::logOOC(const QString& f_char_name, const QString& f_ooc_name, const QString& f_ipid,
- const QString& f_area_name, const QString& f_message)
+void ULogger::logOOC(const QString &f_char_name, const QString &f_ooc_name, const QString &f_ipid,
+ const QString &f_area_name, const QString &f_message)
{
QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss");
QString l_logEntry = QString(m_logtext.value("ooc") + "\n")
- .arg(l_time, f_char_name, f_ooc_name, f_ipid, f_area_name, f_message);
- updateAreaBuffer(f_area_name,l_logEntry);
+ .arg(l_time, f_char_name, f_ooc_name, f_ipid, f_area_name, f_message);
+ updateAreaBuffer(f_area_name, l_logEntry);
}
-void ULogger::logLogin(const QString& f_char_name, const QString& f_ooc_name, const QString& f_moderator_name,
- const QString& f_ipid, const QString& f_area_name, const bool &f_success)
+void ULogger::logLogin(const QString &f_char_name, const QString &f_ooc_name, const QString &f_moderator_name,
+ const QString &f_ipid, const QString &f_area_name, const bool &f_success)
{
QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss");
QString l_success = f_success ? "SUCCESS][" + f_moderator_name : "FAILED][" + f_moderator_name;
QString l_logEntry = QString(m_logtext.value("login") + "\n")
- .arg(l_time, l_success, f_ipid, f_char_name, f_ooc_name);
+ .arg(l_time, l_success, f_ipid, f_char_name, f_ooc_name);
updateAreaBuffer(f_area_name, l_logEntry);
}
-void ULogger::logCMD(const QString& f_char_name,const QString& f_ipid, const QString& f_ooc_name, const QString& f_command,
- const QStringList& f_args, const QString& f_area_name)
+void ULogger::logCMD(const QString &f_char_name, const QString &f_ipid, const QString &f_ooc_name, const QString &f_command,
+ const QStringList &f_args, const QString &f_area_name)
{
QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss");
QString l_logEntry;
@@ -81,44 +81,44 @@ void ULogger::logCMD(const QString& f_char_name,const QString& f_ipid, const QSt
// These must be filtered out
if (f_command == "login") {
l_logEntry = QString(m_logtext.value("cmdlogin") + "\n")
- .arg(l_time, f_area_name, f_char_name, f_ooc_name, f_ipid);
+ .arg(l_time, f_area_name, f_char_name, f_ooc_name, f_ipid);
}
else if (f_command == "rootpass") {
l_logEntry = QString(m_logtext.value("cmdrootpass") + "\n")
- .arg(l_time, f_area_name, f_char_name, f_ooc_name, f_ipid);
+ .arg(l_time, f_area_name, f_char_name, f_ooc_name, f_ipid);
}
else if (f_command == "adduser" && !f_args.isEmpty()) {
- l_logEntry = QString(m_logtext.value("adduser") + "\n")
- .arg(l_time, f_area_name, f_char_name, f_ooc_name, f_args.at(0), f_ipid);
+ l_logEntry = QString(m_logtext.value("adduser") + "\n")
+ .arg(l_time, f_area_name, f_char_name, f_ooc_name, f_args.at(0), f_ipid);
}
else {
l_logEntry = QString(m_logtext.value("cmd") + "\n")
- .arg(l_time, f_area_name, f_char_name, f_ooc_name, f_command, f_args.join(" "), f_ipid);
+ .arg(l_time, f_area_name, f_char_name, f_ooc_name, f_command, f_args.join(" "), f_ipid);
}
- updateAreaBuffer(f_area_name,l_logEntry);
+ updateAreaBuffer(f_area_name, l_logEntry);
}
-void ULogger::logKick(const QString& f_moderator, const QString& f_target_ipid)
+void ULogger::logKick(const QString &f_moderator, const QString &f_target_ipid)
{
QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss");
QString l_logEntry = QString(m_logtext.value("kick") + "\n")
- .arg(l_time, f_moderator, f_target_ipid);
- updateAreaBuffer("SERVER",l_logEntry);
+ .arg(l_time, f_moderator, f_target_ipid);
+ updateAreaBuffer("SERVER", l_logEntry);
}
void ULogger::logBan(const QString &f_moderator, const QString &f_target_ipid, const QString &f_duration)
{
QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss");
QString l_logEntry = QString(m_logtext.value("ban") + "\n")
- .arg(l_time, f_moderator, f_target_ipid, f_duration);
- updateAreaBuffer("SERVER",l_logEntry);
+ .arg(l_time, f_moderator, f_target_ipid, f_duration);
+ updateAreaBuffer("SERVER", l_logEntry);
}
void ULogger::logModcall(const QString &f_char_name, const QString &f_ipid, const QString &f_ooc_name, const QString &f_area_name)
{
QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss");
QString l_logEvent = QString(m_logtext.value("modcall") + "\n")
- .arg(l_time, f_area_name, f_char_name, f_ooc_name, f_ipid);
+ .arg(l_time, f_area_name, f_char_name, f_ooc_name, f_ipid);
updateAreaBuffer(f_area_name, l_logEvent);
if (ConfigManager::loggingType() == DataTypes::LogType::MODCALL) {
@@ -126,18 +126,18 @@ void ULogger::logModcall(const QString &f_char_name, const QString &f_ipid, cons
}
}
-void ULogger::logConnectionAttempt(const QString& f_ip_address, const QString& f_ipid, const QString& f_hwid)
+void ULogger::logConnectionAttempt(const QString &f_ip_address, const QString &f_ipid, const QString &f_hwid)
{
QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss");
QString l_logEntry = QString(m_logtext.value("connect") + "\n")
- .arg(l_time, f_ip_address, f_ipid, f_hwid);
- updateAreaBuffer("SERVER",l_logEntry);
+ .arg(l_time, f_ip_address, f_ipid, f_hwid);
+ updateAreaBuffer("SERVER", l_logEntry);
}
void ULogger::loadLogtext()
{
- //All of this to prevent one single clazy warning from appearing.
- for (auto iterator = m_logtext.keyBegin(), end = m_logtext.keyEnd(); iterator != end; ++iterator){
+ // All of this to prevent one single clazy warning from appearing.
+ for (auto iterator = m_logtext.keyBegin(), end = m_logtext.keyEnd(); iterator != end; ++iterator) {
QString l_tempstring = ConfigManager::LogText(iterator.operator*());
if (!l_tempstring.isEmpty()) {
m_logtext[iterator.operator*()] = l_tempstring;
@@ -145,9 +145,9 @@ void ULogger::loadLogtext()
}
}
-void ULogger::updateAreaBuffer(const QString& f_area_name, const QString& f_log_entry)
+void ULogger::updateAreaBuffer(const QString &f_area_name, const QString &f_log_entry)
{
- QQueuel_buffer = m_bufferMap.value(f_area_name);
+ QQueue l_buffer = m_bufferMap.value(f_area_name);
if (l_buffer.length() <= ConfigManager::logBuffer()) {
l_buffer.enqueue(f_log_entry);
@@ -158,7 +158,7 @@ void ULogger::updateAreaBuffer(const QString& f_area_name, const QString& f_log_
}
m_bufferMap.insert(f_area_name, l_buffer);
- if (ConfigManager::loggingType() == DataTypes::LogType::FULL){
+ if (ConfigManager::loggingType() == DataTypes::LogType::FULL) {
writerFull->flush(f_log_entry);
}
if (ConfigManager::loggingType() == DataTypes::LogType::FULLAREA) {
@@ -166,7 +166,7 @@ void ULogger::updateAreaBuffer(const QString& f_area_name, const QString& f_log_
}
}
-QQueue ULogger::buffer(const QString& f_area_name)
+QQueue ULogger::buffer(const QString &f_area_name)
{
return m_bufferMap.value(f_area_name);
}
diff --git a/core/src/logger/writer_full.cpp b/core/src/logger/writer_full.cpp
index 199c8fc..914c1a8 100644
--- a/core/src/logger/writer_full.cpp
+++ b/core/src/logger/writer_full.cpp
@@ -17,7 +17,7 @@
//////////////////////////////////////////////////////////////////////////////////////
#include "include/logger/writer_full.h"
-WriterFull::WriterFull(QObject* parent) :
+WriterFull::WriterFull(QObject *parent) :
QObject(parent)
{
l_dir.setPath("logs/");
@@ -47,4 +47,3 @@ void WriterFull::flush(const QString f_entry, const QString f_area_name)
}
l_logfile.close();
};
-
diff --git a/core/src/logger/writer_modcall.cpp b/core/src/logger/writer_modcall.cpp
index cea8e4a..ddaaca4 100644
--- a/core/src/logger/writer_modcall.cpp
+++ b/core/src/logger/writer_modcall.cpp
@@ -17,7 +17,7 @@
//////////////////////////////////////////////////////////////////////////////////////
#include "include/logger/writer_modcall.h"
-WriterModcall::WriterModcall(QObject* parent) :
+WriterModcall::WriterModcall(QObject *parent) :
QObject(parent)
{
l_dir.setPath("logs/");
@@ -43,5 +43,4 @@ void WriterModcall::flush(const QString f_area_name, QQueue f_buffer)
}
l_logfile.close();
-
};
diff --git a/core/src/music_manager.cpp b/core/src/music_manager.cpp
index 6bb649f..34171ee 100644
--- a/core/src/music_manager.cpp
+++ b/core/src/music_manager.cpp
@@ -1,11 +1,14 @@
#include "include/music_manager.h"
-MusicManager::MusicManager(QObject *parent, QStringList f_root_ordered, QStringList f_cdns, QMap> f_root_list) :
+#include "include/aopacket.h"
+#include "include/config_manager.h"
+
+MusicManager::MusicManager(QStringList f_root_ordered, QStringList f_cdns, QMap> f_root_list, QObject *parent) :
QObject(parent),
m_root_list(f_root_list),
m_root_ordered(f_root_ordered)
{
- m_custom_lists = new QHash>>;
+ m_custom_lists = new QHash>>;
if (!f_cdns.isEmpty()) {
m_cdns = f_cdns;
}
@@ -13,7 +16,6 @@ MusicManager::MusicManager(QObject *parent, QStringList f_root_ordered, QStringL
MusicManager::~MusicManager()
{
-
}
QStringList MusicManager::musiclist(int f_area_id)
@@ -33,28 +35,27 @@ QStringList MusicManager::rootMusiclist()
bool MusicManager::registerArea(int f_area_id)
{
- if(m_custom_lists->contains(f_area_id)) {
- //This area is already registered. We can't add it.
+ if (m_custom_lists->contains(f_area_id)) {
+ // This area is already registered. We can't add it.
return false;
}
- m_custom_lists->insert(f_area_id,{});
- m_global_enabled.insert(f_area_id,true);
+ m_custom_lists->insert(f_area_id, {});
+ m_global_enabled.insert(f_area_id, true);
return true;
}
bool MusicManager::validateSong(QString f_song_name, QStringList f_approved_cdns)
{
- QStringList l_extensions = {".opus", ".ogg", ".mp3", ".wav" };
+ QStringList l_extensions = {".opus", ".ogg", ".mp3", ".wav"};
bool l_cdn_approved = false;
- //Check if URL formatted.
+ // Check if URL formatted.
if (f_song_name.contains("/")) {
- //Only allow HTTPS/HTTP sources.
+ // Only allow HTTPS/HTTP sources.
if (f_song_name.startsWith("https://") || f_song_name.startsWith("http://")) {
for (const QString &l_cdn : qAsConst(f_approved_cdns)) {
- //Iterate trough all available CDNs to find an approved match
- if (f_song_name.startsWith("https://" + l_cdn + "/", Qt::CaseInsensitive)
- || f_song_name.startsWith("http://" + l_cdn + "/", Qt::CaseInsensitive)) {
+ // Iterate trough all available CDNs to find an approved match
+ if (f_song_name.startsWith("https://" + l_cdn + "/", Qt::CaseInsensitive) || f_song_name.startsWith("http://" + l_cdn + "/", Qt::CaseInsensitive)) {
l_cdn_approved = true;
break;
}
@@ -68,9 +69,10 @@ bool MusicManager::validateSong(QString f_song_name, QStringList f_approved_cdns
}
}
- bool l_suffix_found = false;;
+ bool l_suffix_found = false;
+ ;
for (const QString &suffix : qAsConst(l_extensions)) {
- if (f_song_name.endsWith(suffix)){
+ if (f_song_name.endsWith(suffix)) {
l_suffix_found = true;
break;
}
@@ -85,7 +87,7 @@ bool MusicManager::validateSong(QString f_song_name, QStringList f_approved_cdns
bool MusicManager::addCustomSong(QString f_song_name, QString f_real_name, int f_duration, int f_area_id)
{
- //Validate if simple name.
+ // Validate if simple name.
QString l_song_name = f_song_name;
if (f_song_name.split(".").size() == 1) {
l_song_name = l_song_name + ".opus";
@@ -109,16 +111,16 @@ bool MusicManager::addCustomSong(QString f_song_name, QString f_real_name, int f
return false;
}
- if (m_customs_ordered.value(f_area_id).contains(l_song_name)){
+ if (m_customs_ordered.value(f_area_id).contains(l_song_name)) {
return false;
}
// There should be a way to directly insert into the QMap. Too bad!
MusicList l_custom_list = m_custom_lists->value(f_area_id);
- l_custom_list.insert(l_song_name,{l_real_name,f_duration});
- m_custom_lists->insert(f_area_id,l_custom_list);
- m_customs_ordered.insert(f_area_id,(QStringList {m_customs_ordered.value(f_area_id)} << l_song_name));
- emit sendAreaFMPacket(AOPacket("FM",musiclist(f_area_id)), f_area_id);
+ l_custom_list.insert(l_song_name, {l_real_name, f_duration});
+ m_custom_lists->insert(f_area_id, l_custom_list);
+ m_customs_ordered.insert(f_area_id, (QStringList{m_customs_ordered.value(f_area_id)} << l_song_name));
+ emit sendAreaFMPacket(AOPacket("FM", musiclist(f_area_id)), f_area_id);
return true;
}
@@ -142,28 +144,28 @@ bool MusicManager::addCustomCategory(QString f_category_name, int f_area_id)
return false;
}
- QMap> l_custom_list = m_custom_lists->value(f_area_id);
- l_custom_list.insert(l_category_name,{l_category_name,0});
- m_custom_lists->insert(f_area_id,l_custom_list);
- m_customs_ordered.insert(f_area_id,(QStringList {m_customs_ordered.value(f_area_id)} << l_category_name));
- emit sendAreaFMPacket(AOPacket("FM",musiclist(f_area_id)), f_area_id);
+ QMap> l_custom_list = m_custom_lists->value(f_area_id);
+ l_custom_list.insert(l_category_name, {l_category_name, 0});
+ m_custom_lists->insert(f_area_id, l_custom_list);
+ m_customs_ordered.insert(f_area_id, (QStringList{m_customs_ordered.value(f_area_id)} << l_category_name));
+ emit sendAreaFMPacket(AOPacket("FM", musiclist(f_area_id)), f_area_id);
return true;
}
bool MusicManager::removeCategorySong(QString f_songcategory_name, int f_area_id)
{
- if (!m_root_list.contains(f_songcategory_name)){
+ if (!m_root_list.contains(f_songcategory_name)) {
MusicList l_custom_list = m_custom_lists->value(f_area_id);
if (l_custom_list.contains(f_songcategory_name)) {
l_custom_list.remove(f_songcategory_name);
- m_custom_lists->insert(f_area_id,l_custom_list);
+ m_custom_lists->insert(f_area_id, l_custom_list);
- //Updating the list alias too.
+ // Updating the list alias too.
QStringList l_customs_ordered = m_customs_ordered.value(f_area_id);
l_customs_ordered.removeAll(f_songcategory_name);
m_customs_ordered.insert(f_area_id, l_customs_ordered);
- emit sendAreaFMPacket(AOPacket("FM",musiclist(f_area_id)), f_area_id);
+ emit sendAreaFMPacket(AOPacket("FM", musiclist(f_area_id)), f_area_id);
return true;
} // Fallthrough
}
@@ -176,7 +178,7 @@ bool MusicManager::toggleRootEnabled(int f_area_id)
if (m_global_enabled.value(f_area_id)) {
sanitiseCustomList(f_area_id);
}
- emit sendAreaFMPacket(AOPacket("FM",musiclist(f_area_id)), f_area_id);
+ emit sendAreaFMPacket(AOPacket("FM", musiclist(f_area_id)), f_area_id);
return m_global_enabled.value(f_area_id);
}
@@ -185,8 +187,8 @@ void MusicManager::sanitiseCustomList(int f_area_id)
MusicList l_sanitised_list;
QStringList l_sanitised_ordered = m_customs_ordered.value(f_area_id);
for (auto iterator = m_custom_lists->value(f_area_id).keyBegin(),
- end = m_custom_lists->value(f_area_id).keyEnd(); iterator != end; ++iterator)
- {
+ end = m_custom_lists->value(f_area_id).keyEnd();
+ iterator != end; ++iterator) {
QString l_key = iterator.operator*();
if (!m_root_list.contains(l_key)) {
l_sanitised_list.insert(l_key, m_custom_lists->value(f_area_id).value(l_key));
@@ -194,7 +196,6 @@ void MusicManager::sanitiseCustomList(int f_area_id)
else {
l_sanitised_ordered.removeAll(l_key);
}
-
}
m_custom_lists->insert(f_area_id, l_sanitised_list);
m_customs_ordered.insert(f_area_id, l_sanitised_ordered);
@@ -203,7 +204,7 @@ void MusicManager::sanitiseCustomList(int f_area_id)
void MusicManager::clearCustomList(int f_area_id)
{
m_custom_lists->remove(f_area_id);
- m_custom_lists->insert(f_area_id,{});
+ m_custom_lists->insert(f_area_id, {});
m_customs_ordered.remove(f_area_id);
m_customs_ordered.insert(f_area_id, {});
}
diff --git a/core/src/packets.cpp b/core/src/packets.cpp
index fc1b228..328c09f 100644
--- a/core/src/packets.cpp
+++ b/core/src/packets.cpp
@@ -17,7 +17,16 @@
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
-void AOClient::pktDefault(AreaData* area, int argc, QStringList argv, AOPacket packet)
+#include
+
+#include "include/aopacket.h"
+#include "include/area_data.h"
+#include "include/config_manager.h"
+#include "include/db_manager.h"
+#include "include/music_manager.h"
+#include "include/server.h"
+
+void AOClient::pktDefault(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(area);
Q_UNUSED(argc);
@@ -29,7 +38,7 @@ void AOClient::pktDefault(AreaData* area, int argc, QStringList argv, AOPacket p
#endif
}
-void AOClient::pktHardwareId(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktHardwareId(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(area);
Q_UNUSED(argc);
@@ -37,16 +46,16 @@ void AOClient::pktHardwareId(AreaData* area, int argc, QStringList argv, AOPacke
m_hwid = argv[0];
emit server->logConnectionAttempt(m_remote_ip.toString(), m_ipid, m_hwid);
- auto l_ban = server->db_manager->isHDIDBanned(m_hwid);
+ auto l_ban = server->getDatabaseManager()->isHDIDBanned(m_hwid);
if (l_ban.first) {
- sendPacket("BD", {l_ban.second + "\nBan ID: " + QString::number(server->db_manager->getBanID(m_hwid))});
+ sendPacket("BD", {l_ban.second + "\nBan ID: " + QString::number(server->getDatabaseManager()->getBanID(m_hwid))});
m_socket->close();
return;
}
sendPacket("ID", {QString::number(m_id), "akashi", QCoreApplication::applicationVersion()});
}
-void AOClient::pktSoftwareId(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktSoftwareId(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(area);
Q_UNUSED(argc);
@@ -56,14 +65,12 @@ void AOClient::pktSoftwareId(AreaData* area, int argc, QStringList argv, AOPacke
// The only ones that are critical to ensuring the server works are
// "noencryption" and "fastloading"
QStringList l_feature_list = {
- "noencryption", "yellowtext", "prezoom",
- "flipping", "customobjections", "fastloading",
- "deskmod", "evidence", "cccc_ic_support",
- "arup", "casing_alerts", "modcall_reason",
- "looping_sfx", "additive", "effects",
- "y_offset", "expanded_desk_mods", "auth_packet"
- };
-
+ "noencryption", "yellowtext", "prezoom",
+ "flipping", "customobjections", "fastloading",
+ "deskmod", "evidence", "cccc_ic_support",
+ "arup", "casing_alerts", "modcall_reason",
+ "looping_sfx", "additive", "effects",
+ "y_offset", "expanded_desk_mods", "auth_packet"};
m_version.string = argv[1];
QRegularExpression rx("\\b(\\d+)\\.(\\d+)\\.(\\d+)\\b"); // matches X.X.X (e.g. 2.9.0, 2.4.10, etc.)
@@ -74,16 +81,16 @@ void AOClient::pktSoftwareId(AreaData* area, int argc, QStringList argv, AOPacke
m_version.minor = l_match.captured(3).toInt();
}
- sendPacket("PN", {QString::number(server->m_player_count), QString::number(ConfigManager::maxPlayers()), ConfigManager::serverDescription()});
+ sendPacket("PN", {QString::number(server->getPlayerCount()), QString::number(ConfigManager::maxPlayers()), ConfigManager::serverDescription()});
sendPacket("FL", l_feature_list);
if (ConfigManager::assetUrl().isValid()) {
- QByteArray l_asset_url = ConfigManager::assetUrl().toEncoded(QUrl::EncodeSpaces);
- sendPacket("ASS", {l_asset_url});
+ QByteArray l_asset_url = ConfigManager::assetUrl().toEncoded(QUrl::EncodeSpaces);
+ sendPacket("ASS", {l_asset_url});
}
}
-void AOClient::pktBeginLoad(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktBeginLoad(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(area);
Q_UNUSED(argc);
@@ -93,30 +100,30 @@ void AOClient::pktBeginLoad(AreaData* area, int argc, QStringList argv, AOPacket
// Evidence isn't loaded during this part anymore
// As a result, we can always send "0" for evidence length
// Client only cares about what it gets from LE
- sendPacket("SI", {QString::number(server->m_characters.length()), "0", QString::number(server->m_area_names.length() + server->m_music_list.length())});
+ sendPacket("SI", {QString::number(server->getCharacterCount()), "0", QString::number(server->getAreaCount() + server->getMusicList().length())});
}
-void AOClient::pktRequestChars(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktRequestChars(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(area);
Q_UNUSED(argc);
Q_UNUSED(argv);
Q_UNUSED(packet);
- sendPacket("SC", server->m_characters);
+ sendPacket("SC", server->getCharacters());
}
-void AOClient::pktRequestMusic(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktRequestMusic(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(area);
Q_UNUSED(argc);
Q_UNUSED(argv);
Q_UNUSED(packet);
- sendPacket("SM", server->m_area_names + server->m_music_list);
+ sendPacket("SM", server->getAreaNames() + server->getMusicList());
}
-void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktLoadingDone(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(argc);
Q_UNUSED(argv);
@@ -132,44 +139,43 @@ void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPack
return;
}
- server->m_player_count++;
m_joined = true;
server->updateCharsTaken(area);
sendEvidenceList(area);
sendPacket("HP", {"1", QString::number(area->defHP())});
sendPacket("HP", {"2", QString::number(area->proHP())});
- sendPacket("FA", server->m_area_names);
- //Here lies OPPASS, the genius of FanatSors who send the modpass to everyone in plain text.
+ sendPacket("FA", server->getAreaNames());
+ // Here lies OPPASS, the genius of FanatSors who send the modpass to everyone in plain text.
sendPacket("DONE");
sendPacket("BN", {area->background()});
-
+
sendServerMessage("=== MOTD ===\r\n" + ConfigManager::motd() + "\r\n=============");
fullArup(); // Give client all the area data
if (server->timer->isActive()) {
sendPacket("TI", {"0", "2"});
- sendPacket("TI", {"0", "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(server->timer->remainingTime())))});
+ sendPacket("TI", {"0", "0", QString::number(QTime(0, 0).msecsTo(QTime(0, 0).addMSecs(server->timer->remainingTime())))});
}
else {
sendPacket("TI", {"0", "3"});
}
- const QList l_timers = area->timers();
- for (QTimer* l_timer : l_timers) {
+ const QList l_timers = area->timers();
+ for (QTimer *l_timer : l_timers) {
int l_timer_id = area->timers().indexOf(l_timer) + 1;
if (l_timer->isActive()) {
sendPacket("TI", {QString::number(l_timer_id), "2"});
- sendPacket("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(l_timer->remainingTime())))});
+ sendPacket("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0, 0).msecsTo(QTime(0, 0).addMSecs(l_timer->remainingTime())))});
}
else {
sendPacket("TI", {QString::number(l_timer_id), "3"});
}
}
- emit server->updatePlayerCount(server->m_player_count);
+ emit joined();
area->clientJoinedArea(-1, m_id);
arup(ARUPType::PLAYER_COUNT, true); // Tell everyone there is a new player
}
-void AOClient::pktCharPassword(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktCharPassword(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(area);
Q_UNUSED(argc);
@@ -178,7 +184,7 @@ void AOClient::pktCharPassword(AreaData* area, int argc, QStringList argv, AOPac
m_password = argv[0];
}
-void AOClient::pktSelectChar(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktSelectChar(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(area);
Q_UNUSED(argc);
@@ -194,7 +200,7 @@ void AOClient::pktSelectChar(AreaData* area, int argc, QStringList argv, AOPacke
m_char_id = l_selected_char_id;
}
-void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktIcChat(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(argc);
Q_UNUSED(argv);
@@ -204,7 +210,7 @@ void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket pa
return;
}
- if (!server->can_send_ic_messages) {
+ if (!server->isMessageAllowed()) {
return;
}
@@ -216,14 +222,13 @@ void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket pa
validated_packet.contents[5] = m_pos;
server->broadcast(validated_packet, m_current_area);
- emit logIC((m_current_char + " " + m_showname), m_ooc_name, m_ipid,server->m_areas[m_current_area]->name(), m_last_message);
+ emit logIC((m_current_char + " " + m_showname), m_ooc_name, m_ipid, server->getAreaById(m_current_area)->name(), m_last_message);
area->updateLastICMessage(validated_packet.contents);
- server->can_send_ic_messages = false;
- server->next_message_timer.start(ConfigManager::messageFloodguard());
+ server->startMessageFloodguard(ConfigManager::messageFloodguard());
}
-void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktOocChat(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(argc);
Q_UNUSED(packet);
@@ -234,7 +239,7 @@ void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket p
}
m_ooc_name = dezalgo(argv[0]).replace(QRegExp("\\[|\\]|\\{|\\}|\\#|\\$|\\%|\\&"), ""); // no fucky wucky shit here
- if (m_ooc_name.isEmpty() || m_ooc_name == ConfigManager::serverName()) // impersonation & empty name protection
+ if (m_ooc_name.isEmpty() || m_ooc_name == ConfigManager::serverName()) // impersonation & empty name protection
return;
if (m_ooc_name.length() > 30) {
@@ -246,12 +251,12 @@ void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket p
loginAttempt(argv[1]);
return;
}
-
+
QString l_message = dezalgo(argv[1]);
if (l_message.length() == 0 || l_message.length() > ConfigManager::maxCharacters())
return;
AOPacket final_packet("CT", {m_ooc_name, l_message, "0"});
- if(l_message.at(0) == '/') {
+ if (l_message.at(0) == '/') {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QStringList l_cmd_argv = l_message.split(" ", QString::SplitBehavior::SkipEmptyParts);
#else
@@ -263,7 +268,7 @@ void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket p
int l_cmd_argc = l_cmd_argv.length();
handleCommand(l_command, l_cmd_argc, l_cmd_argv);
- emit logCMD((m_current_char + " " + m_showname), m_ipid, m_ooc_name, l_command, l_cmd_argv,server->m_areas[m_current_area]->name());
+ emit logCMD((m_current_char + " " + m_showname), m_ipid, m_ooc_name, l_command, l_cmd_argv, server->getAreaById(m_current_area)->name());
return;
}
else {
@@ -272,7 +277,7 @@ void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket p
emit logOOC((m_current_char + " " + m_showname), m_ooc_name, m_ipid, area->name(), l_message);
}
-void AOClient::pktPing(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktPing(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(area);
Q_UNUSED(argc);
@@ -285,7 +290,7 @@ void AOClient::pktPing(AreaData* area, int argc, QStringList argv, AOPacket pack
sendPacket("CHECK");
}
-void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktChangeMusic(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(packet);
@@ -297,7 +302,7 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack
// argument is a valid song
QString l_argument = argv[0];
- if (server->m_music_list.contains(l_argument) || m_music_manager->isCustom(m_current_area, l_argument) || l_argument == "~stop.mp3") { // ~stop.mp3 is a dummy track used by 2.9+
+ if (server->getMusicList().contains(l_argument) || m_music_manager->isCustom(m_current_area, l_argument) || l_argument == "~stop.mp3") { // ~stop.mp3 is a dummy track used by 2.9+
// We have a song here
if (m_is_dj_blocked) {
sendServerMessage("You are blocked from changing the music.");
@@ -314,13 +319,13 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack
l_effects = "0";
QString l_final_song;
- //As categories can be used to stop music we need to check if it has a dot for the extension. If not, we assume its a category.
+ // As categories can be used to stop music we need to check if it has a dot for the extension. If not, we assume its a category.
if (!l_argument.contains("."))
l_final_song = "~stop.mp3";
else
l_final_song = l_argument;
- //Jukebox intercepts the direct playing of messages.
+ // Jukebox intercepts the direct playing of messages.
if (area->isjukeboxEnabled()) {
QString l_jukebox_reply = area->addJukeboxSong(l_final_song);
sendServerMessage(l_jukebox_reply);
@@ -328,33 +333,33 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack
}
if (l_final_song != "~stop.mp3") {
- //We might have an aliased song. We check for its real songname and send it to the clients.
- QPair l_song = m_music_manager->songInformation(l_final_song, m_current_area);
+ // We might have an aliased song. We check for its real songname and send it to the clients.
+ QPair l_song = m_music_manager->songInformation(l_final_song, m_current_area);
l_final_song = l_song.first;
}
AOPacket l_music_change("MC", {l_final_song, argv[1], m_showname, "1", "0", l_effects});
server->broadcast(l_music_change, m_current_area);
- //Since we can't ensure a user has their showname set, we check if its empty to prevent
+ // Since we can't ensure a user has their showname set, we check if its empty to prevent
//"played by ." in /currentmusic.
if (m_showname.isEmpty()) {
- area->changeMusic(m_current_char,l_final_song);
+ area->changeMusic(m_current_char, l_final_song);
return;
}
- area->changeMusic(m_showname,l_final_song);
+ area->changeMusic(m_showname, l_final_song);
return;
}
- for (int i = 0; i < server->m_area_names.length(); i++) {
- QString l_area = server->m_area_names[i];
- if(l_area == l_argument) {
+ for (int i = 0; i < server->getAreaCount(); i++) {
+ QString l_area = server->getAreaName(i);
+ if (l_area == l_argument) {
changeArea(i);
break;
}
}
}
-void AOClient::pktWtCe(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktWtCe(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(argc);
Q_UNUSED(argv);
@@ -370,7 +375,7 @@ void AOClient::pktWtCe(AreaData* area, int argc, QStringList argv, AOPacket pack
updateJudgeLog(area, this, "WT/CE");
}
-void AOClient::pktHpBar(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktHpBar(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(argc);
Q_UNUSED(packet);
@@ -394,7 +399,7 @@ void AOClient::pktHpBar(AreaData* area, int argc, QStringList argv, AOPacket pac
updateJudgeLog(area, this, "updated the penalties");
}
-void AOClient::pktWebSocketIp(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktWebSocketIp(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(area);
Q_UNUSED(argc);
@@ -413,7 +418,7 @@ void AOClient::pktWebSocketIp(AreaData* area, int argc, QStringList argv, AOPack
l_remote_ip = server->parseToIPv4(l_remote_ip);
}
- if (server->isIPBanned(l_remote_ip)){
+ if (server->isIPBanned(l_remote_ip)) {
QString l_reason = "Your IP has been banned by a moderator.";
AOPacket l_ban_reason("BD", {l_reason});
m_socket->write(l_ban_reason.toUtf8());
@@ -422,7 +427,7 @@ void AOClient::pktWebSocketIp(AreaData* area, int argc, QStringList argv, AOPack
}
calculateIpid();
- auto l_ban = server->db_manager->isIPBanned(m_ipid);
+ auto l_ban = server->getDatabaseManager()->isIPBanned(m_ipid);
if (l_ban.first) {
sendPacket("BD", {l_ban.second});
m_socket->close();
@@ -430,7 +435,8 @@ void AOClient::pktWebSocketIp(AreaData* area, int argc, QStringList argv, AOPack
}
int l_multiclient_count = 0;
- for (AOClient* l_joined_client : qAsConst(server->m_clients)) {
+ const QVector l_clients = server->getClients();
+ for (AOClient *l_joined_client : l_clients) {
if (m_remote_ip.isEqual(l_joined_client->m_remote_ip))
l_multiclient_count++;
}
@@ -442,7 +448,7 @@ void AOClient::pktWebSocketIp(AreaData* area, int argc, QStringList argv, AOPack
}
}
-void AOClient::pktModCall(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktModCall(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(argc);
Q_UNUSED(argv);
@@ -460,18 +466,24 @@ void AOClient::pktModCall(AreaData* area, int argc, QStringList argv, AOPacket p
else
l_modcallNotice.append("No reason given.");
- for (AOClient* client : qAsConst(server->m_clients)) {
- if (client->m_authenticated) {
- client->sendPacket(AOPacket("ZZ", {l_modcallNotice}));
- }
+ const QVector l_clients = server->getClients();
+ for (AOClient *l_client : l_clients) {
+ if (l_client->m_authenticated)
+ l_client->sendPacket(AOPacket("ZZ", {l_modcallNotice}));
}
- emit logModcall((m_current_char + " " + m_showname), m_ipid, m_ooc_name, server->m_areas[m_current_area]->name());
+ emit logModcall((m_current_char + " " + m_showname), m_ipid, m_ooc_name, server->getAreaById(m_current_area)->name());
- if (ConfigManager::discordModcallWebhookEnabled())
- emit server->modcallWebhookRequest(l_name, l_areaName, packet.contents[0],server->getAreaBuffer(l_areaName));
+ if (ConfigManager::discordModcallWebhookEnabled()) {
+ QString l_name = m_ooc_name;
+ if (m_ooc_name.isEmpty())
+ l_name = m_current_char;
+
+ QString l_areaName = area->name();
+ emit server->modcallWebhookRequest(l_name, l_areaName, packet.contents[0], server->getAreaBuffer(l_areaName));
+ }
}
-void AOClient::pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktAddEvidence(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(argc);
Q_UNUSED(packet);
@@ -483,7 +495,7 @@ void AOClient::pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPack
sendEvidenceList(area);
}
-void AOClient::pktRemoveEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktRemoveEvidence(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(argc);
Q_UNUSED(packet);
@@ -498,7 +510,7 @@ void AOClient::pktRemoveEvidence(AreaData* area, int argc, QStringList argv, AOP
sendEvidenceList(area);
}
-void AOClient::pktEditEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktEditEvidence(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(argc);
Q_UNUSED(packet);
@@ -514,14 +526,14 @@ void AOClient::pktEditEvidence(AreaData* area, int argc, QStringList argv, AOPac
sendEvidenceList(area);
}
-void AOClient::pktSetCase(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktSetCase(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(area);
Q_UNUSED(argc);
Q_UNUSED(packet);
QList l_prefs_list;
- for (int i = 2; i <=6; i++) {
+ for (int i = 2; i <= 6; i++) {
bool is_int = false;
bool pref = argv[i].toInt(&is_int);
if (!is_int)
@@ -531,7 +543,7 @@ void AOClient::pktSetCase(AreaData* area, int argc, QStringList argv, AOPacket p
m_casing_preferences = l_prefs_list;
}
-void AOClient::pktAnnounceCase(AreaData* area, int argc, QStringList argv, AOPacket packet)
+void AOClient::pktAnnounceCase(AreaData *area, int argc, QStringList argv, AOPacket packet)
{
Q_UNUSED(area);
Q_UNUSED(argc);
@@ -540,7 +552,7 @@ void AOClient::pktAnnounceCase(AreaData* area, int argc, QStringList argv, AOPac
QString l_case_title = argv[0];
QStringList l_needed_roles;
QList l_needs_list;
- for (int i = 1; i <=5; i++) {
+ for (int i = 1; i <= 5; i++) {
bool is_int = false;
bool need = argv[i].toInt(&is_int);
if (!is_int)
@@ -549,22 +561,23 @@ void AOClient::pktAnnounceCase(AreaData* area, int argc, QStringList argv, AOPac
}
QStringList l_roles = {"defense attorney", "prosecutor", "judge", "jurors", "stenographer"};
for (int i = 0; i < 5; i++) {
- if (l_needs_list[i])
- l_needed_roles.append(l_roles[i]);
+ if (l_needs_list[i])
+ l_needed_roles.append(l_roles[i]);
}
if (l_needed_roles.isEmpty())
return;
QString l_message = "=== Case Announcement ===\r\n" + (m_ooc_name == "" ? m_current_char : m_ooc_name) + " needs " + l_needed_roles.join(", ") + " for " + (l_case_title == "" ? "a case" : l_case_title) + "!";
- QList l_clients_to_alert;
+ QList l_clients_to_alert;
// here lies morton, RIP
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QSet l_needs_set(l_needs_list.begin(), l_needs_list.end());
#else
QSet l_needs_set = l_needs_list.toSet();
#endif
- for (AOClient* l_client : qAsConst(server->m_clients)) {
+ const QVector l_clients = server->getClients();
+ for (AOClient *l_client : l_clients) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QSet l_matches(l_client->m_casing_preferences.begin(), l_client->m_casing_preferences.end());
l_matches.intersect(l_needs_set);
@@ -575,7 +588,7 @@ void AOClient::pktAnnounceCase(AreaData* area, int argc, QStringList argv, AOPac
l_clients_to_alert.append(l_client);
}
- for (AOClient* l_client : l_clients_to_alert) {
+ for (AOClient *l_client : l_clients_to_alert) {
l_client->sendPacket(AOPacket("CASEA", {l_message, argv[1], argv[2], argv[3], argv[4], argv[5], "1"}));
// you may be thinking, "hey wait a minute the network protocol documentation doesn't mention that last argument!"
// if you are in fact thinking that, you are correct! it is not in the documentation!
@@ -584,15 +597,16 @@ void AOClient::pktAnnounceCase(AreaData* area, int argc, QStringList argv, AOPac
}
}
-void AOClient::sendEvidenceList(AreaData* area)
+void AOClient::sendEvidenceList(AreaData *area)
{
- for (AOClient* l_client : qAsConst(server->m_clients)) {
+ const QVector l_clients = server->getClients();
+ for (AOClient *l_client : l_clients) {
if (l_client->m_current_area == m_current_area)
l_client->updateEvidenceList(area);
}
}
-void AOClient::updateEvidenceList(AreaData* area)
+void AOClient::updateEvidenceList(AreaData *area)
{
QStringList l_evidence_list;
QString l_evidence_format("%1&%2&%3");
@@ -633,7 +647,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
if (m_current_char == "" || !m_joined)
// Spectators cannot use IC
return l_invalid;
- AreaData* area = server->m_areas[m_current_area];
+ AreaData *area = server->getAreaById(m_current_area);
if (area->lockStatus() == AreaData::LockStatus::SPECTATABLE && !area->invited().contains(m_id) && !checkAuth(ACLFlags.value("BYPASS_LOCKS")))
// Non-invited players cannot speak in spectatable areas
return l_invalid;
@@ -645,7 +659,13 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
// desk modifier
QStringList allowed_desk_mods;
- allowed_desk_mods << "chat" << "0" << "1" << "2" << "3" << "4" << "5";
+ allowed_desk_mods << "chat"
+ << "0"
+ << "1"
+ << "2"
+ << "3"
+ << "4"
+ << "5";
if (allowed_desk_mods.contains(l_incoming_args[0].toString())) {
l_args.append(l_incoming_args[0].toString());
}
@@ -660,7 +680,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
// Selected char is different from supplied folder name
// This means the user is INI-swapped
if (!area->iniswapAllowed()) {
- if (!server->m_characters.contains(l_incoming_args[2].toString(), Qt::CaseInsensitive))
+ if (!server->getCharacters().contains(l_incoming_args[2].toString(), Qt::CaseInsensitive))
return l_invalid;
}
qDebug() << "INI swap detected from " << getIpid();
@@ -679,9 +699,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
return l_invalid;
QString l_incoming_msg = dezalgo(l_incoming_args[4].toString().trimmed());
- if (!area->lastICMessage().isEmpty()
- && l_incoming_msg == area->lastICMessage()[4]
- && l_incoming_msg != "")
+ if (!area->lastICMessage().isEmpty() && l_incoming_msg == area->lastICMessage()[4] && l_incoming_msg != "")
return l_invalid;
if (l_incoming_msg == "" && area->blankpostingAllowed() == false) {
@@ -713,7 +731,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
l_args.append(l_incoming_args[5].toString());
if (m_pos != l_incoming_args[5].toString()) {
m_pos = l_incoming_args[5].toString();
- updateEvidenceList(server->m_areas[m_current_area]);
+ updateEvidenceList(server->getAreaById(m_current_area));
}
// sfx name
@@ -815,10 +833,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
QString l_other_flip = "0";
for (int l_client_id : area->joinedIDs()) {
AOClient* l_client = server->getClientByID(l_client_id);
- if (l_client->m_pairing_with == m_char_id
- && l_other_charid != m_char_id
- && l_client->m_char_id == m_pairing_with
- && l_client->m_pos == m_pos) {
+ if (l_client->m_pairing_with == m_char_id && l_other_charid != m_char_id && l_client->m_char_id == m_pairing_with && l_client->m_pos == m_pos) {
l_other_name = l_client->m_current_iniswap;
l_other_emote = l_client->m_emote;
l_other_offset = l_client->m_offset;
@@ -893,7 +908,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
int l_additive = l_incoming_args[24].toInt();
if (l_additive != 0 && l_additive != 1)
return l_invalid;
- else if (area->lastICMessage().isEmpty()){
+ else if (area->lastICMessage().isEmpty()) {
l_additive = 0;
}
else if (!(m_char_id == area->lastICMessage()[8].toInt())) {
@@ -908,7 +923,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
l_args.append(l_incoming_args[25].toString());
}
- //Testimony playback
+ // Testimony playback
if (area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING || area->testimonyRecording() == AreaData::TestimonyRecording::ADD) {
if (l_args[5] != "wit")
return AOPacket("MS", l_args);
@@ -916,7 +931,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
if (area->statement() == -1) {
l_args[4] = "~~\\n-- " + l_args[4] + " --";
l_args[14] = "3";
- server->broadcast(AOPacket("RT",{"testimony1"}), m_current_area);
+ server->broadcast(AOPacket("RT", {"testimony1"}), m_current_area);
}
addStatement(l_args);
}
@@ -928,7 +943,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
if (l_args[4] == ">") {
m_pos = "wit";
- auto l_statement = area->jumpToStatement(area->statement() +1);
+ auto l_statement = area->jumpToStatement(area->statement() + 1);
l_args = l_statement.first;
l_progress = l_statement.second;
@@ -947,7 +962,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
}
}
- QString l_decoded_message = decodeMessage(l_args[4]); //Get rid of that pesky encoding first.
+ QString l_decoded_message = decodeMessage(l_args[4]); // Get rid of that pesky encoding first.
QRegularExpression jump("(?