atrooney-online-2/include/demoserver.h
Crystalwarrior aa2a29f091
Fix demoserver max_wait skips happening even when they're not supposed to (#680)
* Fix demoserver max_wait logic being absolutely bonkers, causing random skips that make no sense
actually comment this piece of code

* Add /debug command to demos which allows you to see the remaining time for each packet, allowing you to visualize wait packets.

Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-03-19 17:18:27 -05:00

58 lines
1.1 KiB
C++

#ifndef DEMOSERVER_H
#define DEMOSERVER_H
#include "aopacket.h"
#include <QDebug>
#include <QObject>
#include <QQueue>
#include <QTcpServer>
#include <QTcpSocket>
#include <QTimer>
#include <QFileDialog>
#include <QMessageBox>
class DemoServer : public QObject
{
Q_OBJECT
public:
explicit DemoServer(QObject *parent = nullptr);
bool server_started = false;
int port = 27088;
int max_wait = -1;
private:
void handle_packet(AOPacket packet);
void load_demo(QString filename);
void reset_state();
QTcpServer* tcp_server;
QTcpSocket* client_sock = nullptr;
bool client_connected = false;
bool partial_packet = false;
bool debug_mode = 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:
void skip_timers(qint64 msecs);
};
#endif // DEMOSERVER_H