-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathwidget.h
93 lines (80 loc) · 2.38 KB
/
widget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef WIDGET_H
#define WIDGET_H
#include <QtWidgets/QWidget>
#include <QUdpSocket>
#include <QTcpSocket>
#include <QTcpServer>
#include <QByteArray>
#include <QTimer>
#include <QList>
#include <QFile>
#include <QDir>
#include <QSettings>
#include <QtConcurrent/QtConcurrentMap>
#include <QCryptographicHash>
//#include <windows.h>
#include "character.h"
#include "scene.h"
#include "sync.h"
#define PLAYERSPATH "data/players/"
#define NETDATAPATH "data/netData/"
#define CONFIGFILEPATH "data/server.ini"
#define SERVERSLISTFILEPATH "data/serversList.cfg"
#define TCPPORT 80
#define UDPPORT 80
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
/// Main functions
public slots:
void sendCmdLine();
void checkPingTimeouts();
public:
explicit Widget(QWidget *parent = 0);
~Widget();
void logMessage(QString msg);
void logStatusMessage(QString msg);
void startServer();
void stopServer();
/// UDP/TCP
public slots:
void udpProcessPendingDatagrams();
void tcpConnectClient();
void tcpDisconnectClient();
void tcpProcessPendingDatagrams();
public:
void tcpProcessData(QByteArray data, QTcpSocket *socket);
public:
float startTimestamp;
QUdpSocket *udpSocket;
QList<Player> tcpPlayers; // Used by the TCP login server
QList<Player> udpPlayers; // Used by the UDP game server
QList<Scene> scenes;
int lastNetviewId;
int lastId;
int syncInterval;
private:
Ui::Widget *ui;
QTcpServer *tcpServer;
QList<QTcpSocket *> tcpClientsList;
QByteArray *tcpReceivedDatas;
Player& cmdPeer;
QTimer *pingTimer;
Sync sync;
// Config
int maxConnected; // Max numbre of players connected at the same time, can deny login
int maxRegistered; // Max number of registered players in database, can deny registration
int pingTimeout; // Max time between recdption of pings, can disconnect player
int pingCheckInterval; // Time between ping timeout checks
bool logInfos; // Can disable logMessage, but doesn't affect logStatusMessage
QString saltPassword; // Used to check passwords between login and game servers, must be the same on all the servers involved
bool enableLoginServer; // Starts a login server
bool enableGameServer; // Starts a game server
bool enableMultiplayer; // Sync players' position
};
// Global import from main
extern Widget win;
#endif // WIDGET_H