-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathClientNetCode.h
120 lines (107 loc) · 3.52 KB
/
ClientNetCode.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
// @Begin License@
// This file is part of Coldest.
//
// Coldest 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.
//
// Coldest 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 Coldest. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright 2008-2012 Ben Nemec
// @End License@
#ifndef CLIENTNETCODE_H
#define CLIENTNETCODE_H
#include "NetCode.h"
#include "ServerInfo.h"
#include "Mesh.h"
#include "Item.h"
#include "tsint.h"
#include <boost/shared_ptr.hpp>
#include <set>
#include <deque>
extern tsint serverfps;
using std::set;
using std::deque;
class ClientNetCode : public NetCode
{
public:
ClientNetCode();
virtual ~ClientNetCode();
bool Connected(){return connected;}
int CurrVersion(){return currversion;}
void AddItem(Item&);
void Connect();
void SpawnRequest();
void SendChat(const string&, const bool);
void ChangeTeam(const int);
void UseItem();
void ChangeView();
void SendKill();
void SendSync();
void SendLoadout();
void SendMasterListRequest();
void SendPowerdown();
void SendCommand(const string&);
void SendFire();
void SendPassword(const string&);
void SendKeepalive();
bool SendVersionRequest();
vector<ServerInfo> servers;
int serverfps;
int serverbps;
Uint32 lasthit;
deque<string> servermessages;
bool messageschanged;
protected:
virtual void Send();
string FillUpdatePacket();
virtual void ReceiveExtended();
virtual void HandlePacket(stringstream&);
virtual void DeleteMesh(Meshlist::iterator&);
// Functions to read from individual packets
void ReadUpdate(stringstream&);
void ReadOccUpdate(stringstream&);
void ReadConnect(stringstream&);
void ReadFailedConnect(stringstream&);
void ReadPing(stringstream&);
void ReadShot(stringstream&);
void ReadHit(stringstream&);
void ReadDamage(stringstream&);
void ReadServerInfo(stringstream&);
void ReadSpawnRequest(stringstream&);
void ReadAck(stringstream&);
void ReadText(stringstream&);
void ReadTeamChange(stringstream&);
void ReadServerMessage(stringstream&);
void ReadDeath(stringstream&);
void ReadItem(stringstream&);
void ReadRemoveItem(stringstream&);
void ReadSync(stringstream&);
void ReadReconnect();
void ReadGameOver(stringstream&);
void ReadRemovePart(stringstream&);
void ReadAnnounce(stringstream&, bool);
void ReadVersion(stringstream&);
bool connected;
int occpacketcounter;
unsigned long recpacketnum;
unsigned long lastsyncpacket;
UDPsocket annsocket;
bool annlisten;
int currversion; // The version we get from the master server
set<ServerInfo> knownservers;
set<unsigned long> partids;
set<unsigned long> itemsreceived;
set<unsigned long> hitsreceived;
set<unsigned long> killsreceived;
set<unsigned long> messagesreceived;
};
typedef boost::shared_ptr<ClientNetCode> ClientNetCodePtr;
#endif // CLIENTNETCODE_H