diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/aoapplication.h | 9 | ||||
| -rw-r--r-- | include/aopacket.h | 2 | ||||
| -rw-r--r-- | include/demoserver.h | 55 |
3 files changed, 65 insertions, 1 deletions
diff --git a/include/aoapplication.h b/include/aoapplication.h index 0e003a81..e96fefb5 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -3,6 +3,7 @@ #include "aopacket.h" #include "datatypes.h" +#include "demoserver.h" #include "discord_rich_presence.h" #include "bass.h" @@ -27,6 +28,8 @@ #include <QStringList> #include <QTextStream> +#include <QElapsedTimer> + class NetworkManager; class Lobby; class Courtroom; @@ -261,6 +264,9 @@ public: // directory if it doesn't exist. bool append_to_file(QString p_text, QString p_file, bool make_dir = false); + // Append to the currently open demo file if there is one + void append_to_demofile(QString packet_string); + // Appends the argument string to serverlist.txt void write_to_serverlist_txt(QString p_line); @@ -458,6 +464,9 @@ public: void *user); static void doBASSreset(); + QElapsedTimer demo_timer; + DemoServer* demo_server = nullptr; + private: const int RELEASE = 2; const int MAJOR_VERSION = 8; diff --git a/include/aopacket.h b/include/aopacket.h index 6d1debad..794025c5 100644 --- a/include/aopacket.h +++ b/include/aopacket.h @@ -12,7 +12,7 @@ public: QString get_header() { return m_header; } QStringList &get_contents() { return m_contents; } - QString to_string(); + QString to_string(bool encoded = false); void net_encode(); void net_decode(); diff --git a/include/demoserver.h b/include/demoserver.h new file mode 100644 index 00000000..b21811b7 --- /dev/null +++ b/include/demoserver.h @@ -0,0 +1,55 @@ +#ifndef DEMOSERVER_H +#define DEMOSERVER_H + +#include "aopacket.h" + +#include <QDebug> +#include <QObject> +#include <QQueue> +#include <QTcpServer> +#include <QTcpSocket> +#include <QTimer> +#include <QFileDialog> + +class DemoServer : public QObject +{ + Q_OBJECT +public: + explicit DemoServer(QObject *parent = nullptr); + + bool server_started = false; + int port = 27088; + int max_wait = -1; + int min_wait = -1; + +private: + void handle_packet(AOPacket packet); + void load_demo(QString filename); + + QTcpServer* tcp_server; + QTcpSocket* client_sock = nullptr; + bool client_connected = false; + bool partial_packet = false; + QString temp_packet = ""; + QQueue<QString> demo_data; + QString sc_packet; + int num_chars = 0; + QString p_path; + QTimer *timer; + int elapsed_time = 0; + +private slots: + void accept_connection(); + void destroy_connection(); + void recv_data(); + void client_disconnect(); + void playback(); + +public slots: + void start_server(); + +signals: + +}; + +#endif // DEMOSERVER_H |
