-
Notifications
You must be signed in to change notification settings - Fork 0
/
QWClientPrivate.h
247 lines (213 loc) · 7.76 KB
/
QWClientPrivate.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/*
GNU General Public License version 3 notice
Copyright (C) 2012 Mihawk <[email protected]>. All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see < http://www.gnu.org/licenses/ >.
*/
#ifndef QWCLIENTPRIVATE_H
#define QWCLIENTPRIVATE_H
#include <qglobal.h>
#include <QBuffer>
#include <QDataStream>
#include <QHostAddress>
#include <QList>
#include "QWClient.h"
#include "quakedef.h"
class QWClient;
class QWPack;
class QWClientPrivate
{
public:
QWClientPrivate(QWClient *client);
~QWClientPrivate();
void connect(const char *host, quint16 port);
void run();
void disconnect();
void observe();
void join();
void setBindHost(const QString& host);
void setName(const char *name);
void setTeam(const char *team);
void setColor(quint8 bottom, quint8 top);
void setQuakeFolder(const QString& path);
void setSpectator(bool spectate = true);
void setPassword(const QString& password);
void setPing(quint16 ping);
void setRate(quint16 rate);
void sendCmd(const QString& cmd);
const QString& gameDir() const;
const QString& quakeDir() const;
void reconnect();
const QString host() const { return myHost.toString(); }
quint16 port() const { return myPort; }
QWClient::ClientState state() const { return myState; }
static void stripColor(char* string);
private:
class QWClient* myClient;
class QUdpSocket* mySocket;
class QTime* myTime;
class QTime* myLastServerReplyTime;
class QFile* myDownload; //current active download
QHostAddress myHost;
quint16 myPort;
/* Incoming data buffers */
QByteArray myInData;
QBuffer myInBuffer;
QDataStream myInStream;
/* Outgoing client data buffers */
QDataStream myUnreliableOutStream;
QBuffer myUnreliableOutBuffer;
QByteArray myUnreliableOutData;
QDataStream myReliableOutStream;
QBuffer myReliableOutBuffer;
QByteArray myReliableOutData;
QByteArray myReliableData; //saves reliable messages not acked
/* Everything is assembled here b4 sending */
QDataStream myOutStream;
QBuffer myOutBuffer;
QByteArray myOutData;
bool myBadReadFlag;
static const char*ClientName;
static const char*ClientVersion;
QString myClientName;
QString myClientVersion;
QWClient::ClientState myState;
quint16 myQPort;
quint32 myProtocolVersion;
quint32 myFTEProtocolExtensions;
quint32 myServerCount;
QString myGameDir;
QString myQuakeDir;
QString myMapName;
QString myPassword; // For connecting on servers that require a password
quint32 myIncomingSeq;
quint32 myIncomingAck;
quint32 myOutgoingSeq;
quint32 myLastRealiableSeq;
bool myIncomingSeqReliableFlag;
bool myIncomingAckReliableFlag;
bool myOutgoingSeqReliableFlag;
quint8 myPacketLoss;
quint16 myPing;
/* Download */
QList<QWPack*> myPacks;
/* Client Cvars */
quint16 myRate;
quint8 myTopColor;
quint8 myBottomColor;
QString myName;
bool mySpectatorFlag;
QString myTeam;
/* NameFun Conversion */
static char ourReadableCharsTable[256];
static bool ourReadableCharsTableInitialized;
static void fillReadableCharsTable();
void reloadPackFiles();
void loadPackFile(const QString& filename);
void sendConnectionless(const QByteArray& data);
void sendMovement(); //required on MVDSV
void sendToServer(bool dontWait = false);
void readPackets();
void startDownload(const QString& filename);
bool fileExists(const QString& filename);
bool readFile(const QString& filename, char **data, quint64 *len);
void preSpawn(int mapChecksum);
static unsigned blockCheckSum(void *buffer, int len);
quint32 mapChecksum(const QString& mapName);
quint32 _mapChecksum; // checksum we got from error message
bool myWrongChecksumFlag; // for faster reconection
//========================================================================
// Parsing functions
/* Main parsing functions */
void parseServerMessage();
void parseConnectionless();
/* Helpers */
static float littleFloat(float f);
static quint16 littleShort(quint16 s);
static quint32 littleLong(quint32 l);
/* Reading */
bool checkForBadRead(quint8 typeSize);
float readCoord();
float readAngle();
float readAngle16();
quint8 readByte();
float readFloat();
qint16 readShort();
qint32 readLong();
const QString readString();
void readUserDeltaCmd(userCmd_t *from, userCmd_t *move);
void parseDelta(entityState_t *from, entityState_t *to, int bits);
/* Writing */
static void writeByte(QDataStream* stream, const quint8 b);
static void writeShort(QDataStream* stream, const quint16 s);
static void writeLong(QDataStream* stream, const quint32 l);
static void writeString(QDataStream* stream, const QString& str);
/* Command parsers */
void parseSvcModellist();//s
void parseSvcFTEModellistShort();//s
void parseSvcDisconnect();//
void parseSvcNoop();//
void parseSvcPrint();//
void parseSvcCenterPrint();//
void parseSvcStuffText();//
void parseSvcDamage();//
void parseSvcServerData();//s
void parseSvcSetAngle();//
void parseSvcLightStyle();//
void parseSvcSound();//
void parseSvcStopSound();//
void parseSvcUpdateFrags();//
void parseSvcUpdatePing();//
void parseSvcUpdatePL();//
void parseSvcUpdateEnterTime();//
void parseSvcSpawnBaseLine();//
void parseSvcSpawnStatic();//
void parseSvcTempEntity();//
void parseSvcKilledMonster();//
void parseSvcFoundSecret();//
void parseSvcUpdateStat();//
void parseSvcUpdateStatLong();//
void parseSvcSpawnStaticSound();//
void parseSvcCDTrack();//
void parseSvcIntermission();//
void parseSvcFinale();//
void parseSvcSellScreen();//
void parseSvcSmallKick();//
void parseSvcBigKick();//
void parseSvcMuzzleFlash();//
void parseSvcUpdateUserinfo();//
void parseSvcSetinfo();//
void parseSvcServerinfo();//
void parseSvcDownload();//
void parseChunkedDownload();//NA
void parseSvcPlayerinfo();//
void parseSvcNails();//fixed
void parseSvcChokeCount();//
void parseSvcSoundlist();//
void parseSvcPacketEntities();//look at it
void parseSvcDeltaPacketEntities();//look at it
void parseSvcMaxSpeed();//
void parseSvcEntGravity();//
void parseSvcSetPause();//
void parseSvcNails2();//fixed
void parseSvcFTESpawnBaseline2();//
void parseSvcQizmoVoice();//
void parseSvcFTEVoiceChat();//hmmf
void parseSvcFTESpawnStatic2();//FIXED readbyte supposed to be readShort.
void parseSvcUpdateName();
void parseSvcUpdateColors();
void parseSvcSignonNum();
void parseSvcParticle();
void parseSvcVersion();
void parseSvcClientData();
void parseSvcTime();
};
#endif // QWCLIENTPRIVATE_H