Skip to content

Commit

Permalink
Merge branch 'master' into coolslide
Browse files Browse the repository at this point in the history
  • Loading branch information
in1tiate authored May 15, 2024
2 parents 5128a6a + 4fb61b7 commit b33bd61
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 203 deletions.
65 changes: 16 additions & 49 deletions include/aoapplication.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#ifndef AOAPPLICATION_H
#define AOAPPLICATION_H

#include "widgets/aooptionsdialog.h"
#include "aopacket.h"
#include "datatypes.h"
#include "demoserver.h"
#include "discord_rich_presence.h"
#include "serverdata.h"
#include "widgets/aooptionsdialog.h"

#include "bass.h"

Expand Down Expand Up @@ -87,51 +88,31 @@ class AOApplication : public QApplication {
qint64 latency = 0;
QString window_title;

/////////////////server metadata//////////////////

bool yellow_text_supported = false;
bool prezoom_supported = false;
bool flipping_supported = false;
bool custom_objection_supported = false;
bool desk_mod_supported = false;
bool evidence_supported = false;
bool cccc_ic_supported = false;
bool arup_supported = false;
bool casing_alerts_supported = false;
bool modcall_reason_supported = false;
bool looping_sfx_supported = false;
bool additive_supported = false;
bool effects_supported = false;
bool y_offset_supported = false;
bool expanded_desk_mods_supported = false;
bool auth_packet_supported = false;
bool custom_blips_supported = false;
/// Stores everything related to the server the client is connected to, if
/// any.
server::ServerData m_serverdata;

///////////////loading info///////////////////

// client ID. Not useful, to be removed eventually
int client_id = 0;

QString server_software = "";

int char_list_size = 0;
int loaded_chars = 0;
/// Used for a fancy loading bar upon joining a server.
int generated_chars = 0;
int evidence_list_size = 0;
int loaded_evidence = 0;
int music_list_size = 0;
int loaded_music = 0;

bool courtroom_loaded = false;

//////////////////versioning///////////////

int get_release() const { return RELEASE; }
int get_major_version() const { return MAJOR_VERSION; }
int get_minor_version() const { return MINOR_VERSION; }
QString get_version_string();
/**
* @brief Returns the version string of the software.
*
* @return The string "X.Y.Z", where X is the release of the software (usually
* '2'), Y is the major version, and Z is the minor version.
*/
static QString get_version_string();

///////////////////////////////////////////
static const int RELEASE = 2;
static const int MAJOR_VERSION = 10;
static const int MINOR_VERSION = 1;

// Adds the server to favorite_servers.ini
void add_favorite_server(int p_server);
Expand Down Expand Up @@ -372,16 +353,6 @@ class AOApplication : public QApplication {
// The file name of the log file in base/logs.
QString log_filename;

/**
* @brief A QString of an URL that defines the content repository
* send by the server.
*
* @details Introduced in Version 2.9.2.
* Addresses the issue of contenturl devlivery for WebAO
* without relying on someone adding the link manually.
*/
QString asset_url;

void initBASS();
static void load_bass_plugins();
static void CALLBACK BASSreset(HSTREAM handle, DWORD channel, DWORD data,
Expand All @@ -392,10 +363,6 @@ class AOApplication : public QApplication {
DemoServer* demo_server = nullptr;

private:
const int RELEASE = 2;
const int MAJOR_VERSION = 10;
const int MINOR_VERSION = 1;

QVector<server_type> server_list;
QHash<uint, QString> asset_lookup_cache;
QHash<uint, QString> dir_listing_cache;
Expand Down
153 changes: 153 additions & 0 deletions include/serverdata.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#ifndef SERVERDATA_H
#define SERVERDATA_H

#include <QObject>
#include <QString>
#include <QStringList>

namespace server {
Q_NAMESPACE

/// The base feature set that almost all servers are supposed to support.
enum class BASE_FEATURE_SET {
YELLOWTEXT, ///< Yellow text in in-character messages.
///< @since 2.1.0
FLIPPING, ///< The ability to mirror a character in-game.
///< @since 2.1.0
CUSTOMOBJECTIONS, ///< Enables the use of a single custom objection named
///< `custom`.
///< @since 2.1.0
FASTLOADING, ///< Enables the use of "fast loading" instead of the legacy
///< loading protocol.
///< @since 2.1.0
NOENCRYPTION, ///< Disables "FantaCrypt" for the remainder of the session.
///< @since 2.1.0
DESKMOD, ///< Allows forcing the appearance or disappearance of the desk.
///< @since 2.3 to 2.5
EVIDENCE, ///< Allows creating and presenting evidence.
///< @since 2.3 to 2.5
CCCC_IC_SUPPORT, ///< The ability to pair up with another user's character,
///< the ability to change one's displayed name
///< in-character ("showname"), and the ability to perform
///< "immediate" preanimations (ones that happen alongside
///< text display).
///< @since 2.6.0
ARUP, ///< Areas have more data about them than just their name (including
///< their status, their "lockedness", and who is the Case Master in
///< the area), and sets the client up to receive and send ARUP
///< packets.
///< @since 2.6.0
CASING_ALERTS, ///< The client gains a new window to announce cases with,
///< and the settings to set itself up to receive case alerts
///< based on casing preferences. No longer used.
///< @since 2.6.0
MODCALL_REASON, ///< Enables entering a custom reason for calling
///< moderators.
///< @since 2.6.0
LOOPING_SFX, ///< Enables looping SFX extensions for the in-character
///< command.
///< @since 2.8.0
ADDITIVE, ///< Enables "additive" text that allows in-character messages to
///< concatenate to the previous one sent by the same character.
///< @since 2.8.0
EFFECTS, ///< Enables effect overlays.
///< @since 2.8.0
Y_OFFSET, ///< Enables support for vertical offsets.
///< @since 2.9.0
EXPANDED_DESK_MODS, ///< Enables desk modifiers 2 through 5.
///< @since 2.9.0
AUTH_PACKET, ///< Enables the use of the AUTH packet.
///< @since 2.9.1
PREZOOM, ///< Preanim zoom.
CUSTOM_BLIPS ///< Allows the in-character messages to contain data about
///< what blips to use for the character's current message.
};
Q_ENUM_NS(BASE_FEATURE_SET)

/**
* @brief Arranges data about the server the client is connected to.
*/
class ServerData {
public:
/**
* @brief Returns true if one of the standard features exists on the server.
*
* @details Internally, this calls get_feature(const QString &f_feature)
* with the enum's value converted to string.
*
* @param f_feature The feature to check for.
*
* @return True if the feature exists on the server.
*/
bool get_feature(const BASE_FEATURE_SET &f_feature) const;

/**
* @brief Returns true if the feature exists on the server.
*
* @param f_feature The feature to check for. Case insensitive.
*
* @return True if the feature exists on the server.
*/
bool get_feature(const QString &f_feature) const;

/**
* @brief Sets the feature list, overwriting the existing one.
*
* @param f_feature_list The new feature list of the server.
*/
void set_features(const QStringList &f_feature_list);

/**
* @brief Self-explanatory: gets the software the server is running on.
*
* @return As brief description.
*/
QString get_server_software() const;

/**
* @brief Self-explanatory: setter for server software.
*
* @param f_software The new server software.
*/
void set_server_software(const QString &f_software);

/**
* @brief Getter for the server's asset URL.
*
* @return As brief description.
*
* @see m_asset_url
*/
QString get_asset_url() const;

/**
* @brief Attempts to set the new asset URL for the server.
*
* @details The function converts the sole parameter into UTF-8, then
* attempts to percent decode it. The URL is only set if all these steps
* successfully happen.
*
* @param f_asset_url A QString that contains the URL.
*/
void set_asset_url(const QString &f_asset_url);

private:
/// The features available on the server. Determines what
QStringList m_features;

/// The software the server is running.
QString m_server_software;

/**
* @brief A QString of an URL that defines the content repository
* send by the server.
*
* @details Introduced in Version 2.9.2.
* Addresses the issue of contenturl devlivery for WebAO
* without relying on someone adding the link manually.
*/
QString m_asset_url;
};
} // namespace server

#endif // SERVERDATA_H
Loading

0 comments on commit b33bd61

Please sign in to comment.