forked from Drifter321/admintool
-
Notifications
You must be signed in to change notification settings - Fork 1
/
query.h
123 lines (106 loc) · 2.34 KB
/
query.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#ifndef INFOQUERY
#define INFOQUERY
#include "serverinfo.h"
#include "customitems.h"
#include <QUdpSocket>
#include <QThread>
#include <QTableWidgetItem>
#define QUERY_TIMEOUT 2000
#define A2S_HEADER 0xFFFFFFFF
#define A2S_INFO 0x54
#define A2S_INFO_CHALLENGE_CHECK 0x41
#define A2S_INFO_CHECK 0x49
#define A2S_INFO_STRING "Source Engine Query"
#define A2S_PLAYER 0x55
#define A2S_PLAYER_CHALLENGE_CHECK 0x41
#define A2S_PLAYER_CHECK 0x44
#define A2S_RULES 0x56
#define A2S_RULES_CHALLENGE_CHECK 0x41
#define A2S_RULES_CHECK 0x45
class MainWindow;
class Worker;
class InfoReply
{
public:
InfoReply(QByteArray, qint64);
QString hostnameRich;
QString map;
QString mod;
QString gamedesc;
qint32 appId;
quint8 players;
quint8 maxplayers;
quint8 bots;
char type;
char os;
bool visibility;
bool vac;
bool success;
QString tags;
QString version;
qint8 protocol;
qint64 ping;
QString serverID;
quint64 rawServerId;
};
class PlayerInfo
{
public:
//~PlayerInfo(){delete [] name;}
QString name;
qint32 score;
float time;
};
class RulesInfo
{
public:
RulesInfo(QString n, QString v){this->name = n; this->value = v;}
//~RulesInfo(){delete [] name; delete[] value;}
QString name;
QString value;
};
class InfoQuery : public QObject
{
Q_OBJECT
QThread workerThread;
public:
InfoQuery(MainWindow *main);
~InfoQuery() {
workerThread.quit();
workerThread.wait();
}
signals:
void query(QHostAddress *, quint16, ServerTableIndexItem *item);
};
class PlayerQuery : public QObject
{
Q_OBJECT
public:
QThread workerThread;
Worker *worker;
PlayerQuery(MainWindow *main);
~PlayerQuery();
private:
MainWindow *pMain;
signals:
void query(QHostAddress *, quint16, ServerTableIndexItem *);
};
class RulesQuery : public QObject
{
Q_OBJECT
public:
QThread workerThread;
Worker *worker;
RulesQuery(MainWindow *main);
~RulesQuery();
private:
MainWindow *pMain;
signals:
void query(QHostAddress *, quint16, ServerTableIndexItem *);
};
QList<PlayerInfo> *GetPlayerReply(QHostAddress, quint16);
InfoReply *GetInfoReply(QHostAddress, quint16);
QList<RulesInfo> *GetRulesReply(QHostAddress, quint16);
QString SecondsToDisplayTime(float time);
QString GetStringFromStream(QDataStream &stream);
#endif // INFOQUERY