1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
2 
3 #include "BaseNetProtocol.h"
4 
5 #include "Game/Players/PlayerStatistics.h"
6 #include "Sim/Misc/TeamStatistics.h"
7 #include "System/Net/RawPacket.h"
8 #include "System/Net/PackPacket.h"
9 #include "System/Net/ProtocolDef.h"
10 #include <boost/cstdint.hpp>
11 
12 using netcode::PackPacket;
13 typedef boost::shared_ptr<const netcode::RawPacket> PacketType;
14 
Get()15 CBaseNetProtocol& CBaseNetProtocol::Get()
16 {
17 	static CBaseNetProtocol instance;
18 	return instance;
19 }
20 
SendKeyFrame(int frameNum)21 PacketType CBaseNetProtocol::SendKeyFrame(int frameNum)
22 {
23 	PackPacket* packet = new PackPacket(5, NETMSG_KEYFRAME);
24 	*packet << frameNum;
25 	return PacketType(packet);
26 }
27 
SendNewFrame()28 PacketType CBaseNetProtocol::SendNewFrame()
29 {
30 	return PacketType(new PackPacket(1, NETMSG_NEWFRAME));
31 }
32 
33 
SendQuit(const std::string & reason)34 PacketType CBaseNetProtocol::SendQuit(const std::string& reason)
35 {
36 	unsigned size = 3 + reason.size() + 1;
37 	PackPacket* packet = new PackPacket(size, NETMSG_QUIT);
38 	*packet << static_cast<boost::uint16_t>(size) << reason;
39 	return PacketType(packet);
40 }
41 
SendStartPlaying(unsigned countdown)42 PacketType CBaseNetProtocol::SendStartPlaying(unsigned countdown)
43 {
44 	PackPacket* packet = new PackPacket(5, NETMSG_STARTPLAYING);
45 	*packet << countdown;
46 	return PacketType(packet);
47 }
48 
SendSetPlayerNum(uchar myPlayerNum)49 PacketType CBaseNetProtocol::SendSetPlayerNum(uchar myPlayerNum)
50 {
51 	PackPacket* packet = new PackPacket(2, NETMSG_SETPLAYERNUM);
52 	*packet << myPlayerNum;
53 	return PacketType(packet);
54 }
55 
SendPlayerName(uchar myPlayerNum,const std::string & playerName)56 PacketType CBaseNetProtocol::SendPlayerName(uchar myPlayerNum, const std::string& playerName)
57 {
58 	unsigned size = 3 + playerName.size() + 1;
59 	PackPacket* packet = new PackPacket(size, NETMSG_PLAYERNAME);
60 	*packet << static_cast<uchar>(size) << myPlayerNum << playerName;
61 	return PacketType(packet);
62 }
63 
SendRandSeed(unsigned randSeed)64 PacketType CBaseNetProtocol::SendRandSeed(unsigned randSeed)
65 {
66 	PackPacket* packet = new PackPacket(5, NETMSG_RANDSEED);
67 	*packet << randSeed;
68 	return PacketType(packet);
69 }
70 
71 // NETMSG_GAMEID = 9, char gameID[16];
SendGameID(const uchar * buf)72 PacketType CBaseNetProtocol::SendGameID(const uchar* buf)
73 {
74 	PackPacket* packet = new PackPacket(17, NETMSG_GAMEID);
75 	memcpy(packet->GetWritingPos(), buf, 16);
76 	return PacketType(packet);
77 }
78 
SendPathCheckSum(uchar myPlayerNum,boost::uint32_t checksum)79 PacketType CBaseNetProtocol::SendPathCheckSum(uchar myPlayerNum, boost::uint32_t checksum)
80 {
81 	PackPacket* packet = new PackPacket(1 + 1 + sizeof(boost::uint32_t), NETMSG_PATH_CHECKSUM);
82 	*packet << myPlayerNum;
83 	*packet << checksum;
84 	return PacketType(packet);
85 }
86 
87 
SendCommand(uchar myPlayerNum,int id,uchar options,const std::vector<float> & params)88 PacketType CBaseNetProtocol::SendCommand(uchar myPlayerNum, int id, uchar options, const std::vector<float>& params)
89 {
90 	unsigned size = 9 + params.size() * sizeof(float);
91 	PackPacket* packet = new PackPacket(size, NETMSG_COMMAND);
92 	*packet << static_cast<unsigned short>(size) << myPlayerNum << id << options << params;
93 	return PacketType(packet);
94 }
95 
SendSelect(uchar myPlayerNum,const std::vector<short> & selectedUnitIDs)96 PacketType CBaseNetProtocol::SendSelect(uchar myPlayerNum, const std::vector<short>& selectedUnitIDs)
97 {
98 	unsigned size = 4 + selectedUnitIDs.size() * sizeof(short);
99 	PackPacket* packet = new PackPacket(size, NETMSG_SELECT);
100 	*packet << static_cast<unsigned short>(size) << myPlayerNum << selectedUnitIDs;
101 	return PacketType(packet);
102 }
103 
104 
SendPause(uchar myPlayerNum,uchar bPaused)105 PacketType CBaseNetProtocol::SendPause(uchar myPlayerNum, uchar bPaused)
106 {
107 	PackPacket* packet = new PackPacket(3, NETMSG_PAUSE);
108 	*packet << myPlayerNum << bPaused;
109 	return PacketType(packet);
110 }
111 
112 
113 
SendAICommand(uchar myPlayerNum,unsigned char aiID,short unitID,int id,int aiCommandId,uchar options,const std::vector<float> & params)114 PacketType CBaseNetProtocol::SendAICommand(uchar myPlayerNum, unsigned char aiID, short unitID, int id, int aiCommandId, uchar options, const std::vector<float>& params)
115 {
116 	int cmdTypeId = NETMSG_AICOMMAND;
117 	unsigned size = 12 + (params.size() * sizeof(float));
118 	if (aiCommandId != -1) {
119 		cmdTypeId = NETMSG_AICOMMAND_TRACKED;
120 		size += 4;
121 	}
122 	PackPacket* packet = new PackPacket(size, cmdTypeId);
123 	*packet << static_cast<unsigned short>(size) << myPlayerNum << aiID << unitID << id << options;
124 	if (cmdTypeId == NETMSG_AICOMMAND_TRACKED) {
125 		*packet << aiCommandId;
126 	}
127 	*packet << params;
128 	return PacketType(packet);
129 }
130 
SendAIShare(uchar myPlayerNum,unsigned char aiID,uchar sourceTeam,uchar destTeam,float metal,float energy,const std::vector<short> & unitIDs)131 PacketType CBaseNetProtocol::SendAIShare(uchar myPlayerNum, unsigned char aiID, uchar sourceTeam, uchar destTeam, float metal, float energy, const std::vector<short>& unitIDs)
132 {
133 	boost::uint16_t totalNumBytes = 1 + sizeof(boost::uint16_t) + 1 + 1 + 1 + 1 + (2 * sizeof(float)) + (unitIDs.size() * sizeof(short));
134 
135 	PackPacket* packet = new PackPacket(totalNumBytes, NETMSG_AISHARE);
136 	*packet << totalNumBytes << myPlayerNum << aiID << sourceTeam << destTeam << metal << energy << unitIDs;
137 	return PacketType(packet);
138 }
139 
SendUserSpeed(uchar myPlayerNum,float userSpeed)140 PacketType CBaseNetProtocol::SendUserSpeed(uchar myPlayerNum, float userSpeed)
141 {
142 	PackPacket* packet = new PackPacket(6, NETMSG_USER_SPEED);
143 	*packet << myPlayerNum << userSpeed;
144 	return PacketType(packet);
145 }
146 
SendInternalSpeed(float internalSpeed)147 PacketType CBaseNetProtocol::SendInternalSpeed(float internalSpeed)
148 {
149 	PackPacket* packet = new PackPacket(5, NETMSG_INTERNAL_SPEED);
150 	*packet << internalSpeed;
151 	return PacketType(packet);
152 }
153 
SendCPUUsage(float cpuUsage)154 PacketType CBaseNetProtocol::SendCPUUsage(float cpuUsage)
155 {
156 	PackPacket* packet = new PackPacket(5, NETMSG_CPU_USAGE);
157 	*packet << cpuUsage;
158 	return PacketType(packet);
159 }
160 
SendDirectControl(uchar myPlayerNum)161 PacketType CBaseNetProtocol::SendDirectControl(uchar myPlayerNum)
162 {
163 	PackPacket* packet = new PackPacket(2, NETMSG_DIRECT_CONTROL);
164 	*packet << myPlayerNum;
165 	return PacketType(packet);
166 }
167 
SendDirectControlUpdate(uchar myPlayerNum,uchar status,short heading,short pitch)168 PacketType CBaseNetProtocol::SendDirectControlUpdate(uchar myPlayerNum, uchar status, short heading, short pitch)
169 {
170 	PackPacket* packet = new PackPacket(7, NETMSG_DC_UPDATE);
171 	*packet << myPlayerNum << status << heading << pitch;
172 	return PacketType(packet);
173 }
174 
175 
SendAttemptConnect(const std::string & name,const std::string & passwd,const std::string & version,int netloss,bool reconnect)176 PacketType CBaseNetProtocol::SendAttemptConnect(const std::string& name, const std::string& passwd, const std::string& version, int netloss, bool reconnect)
177 {
178 	boost::uint16_t size = 10 + name.size() + passwd.size() + version.size();
179 	PackPacket* packet = new PackPacket(size , NETMSG_ATTEMPTCONNECT);
180 	*packet << size << NETWORK_VERSION << name << passwd << version << uchar(reconnect) << uchar(netloss);
181 	return PacketType(packet);
182 }
183 
184 
SendShare(uchar myPlayerNum,uchar shareTeam,uchar bShareUnits,float shareMetal,float shareEnergy)185 PacketType CBaseNetProtocol::SendShare(uchar myPlayerNum, uchar shareTeam, uchar bShareUnits, float shareMetal, float shareEnergy)
186 {
187 	PackPacket* packet = new PackPacket(12, NETMSG_SHARE);
188 	*packet << myPlayerNum << shareTeam << bShareUnits << shareMetal << shareEnergy;
189 	return PacketType(packet);
190 }
191 
SendSetShare(uchar myPlayerNum,uchar myTeam,float metalShareFraction,float energyShareFraction)192 PacketType CBaseNetProtocol::SendSetShare(uchar myPlayerNum, uchar myTeam, float metalShareFraction, float energyShareFraction)
193 {
194 	PackPacket* packet = new PackPacket(11, NETMSG_SETSHARE);
195 	*packet << myPlayerNum << myTeam << metalShareFraction << energyShareFraction;
196 	return PacketType(packet);
197 }
198 
199 
SendPlayerStat(uchar myPlayerNum,const PlayerStatistics & currentStats)200 PacketType CBaseNetProtocol::SendPlayerStat(uchar myPlayerNum, const PlayerStatistics& currentStats)
201 {
202 	PackPacket* packet = new PackPacket(2 + sizeof(PlayerStatistics), NETMSG_PLAYERSTAT);
203 	*packet << myPlayerNum << currentStats;
204 	return PacketType(packet);
205 }
206 
SendGameOver(uchar myPlayerNum,const std::vector<uchar> & winningAllyTeams)207 PacketType CBaseNetProtocol::SendGameOver(uchar myPlayerNum, const std::vector<uchar>& winningAllyTeams)
208 {
209 	const unsigned size = (3 * sizeof(uchar)) + (winningAllyTeams.size() * sizeof(uchar));
210 	PackPacket* packet = new PackPacket(size, NETMSG_GAMEOVER);
211 	*packet << static_cast<uchar>(size) << myPlayerNum << winningAllyTeams;
212 	return PacketType(packet);
213 }
214 
215 
216 // [NETMSG_MAPDRAW = 31] uchar messageSize = 9, myPlayerNum, command = MAPDRAW_ERASE; short x, z; bool
SendMapErase(uchar myPlayerNum,short x,short z)217 PacketType CBaseNetProtocol::SendMapErase(uchar myPlayerNum, short x, short z)
218 {
219 	PackPacket* packet = new PackPacket(8, NETMSG_MAPDRAW);
220 	*packet << static_cast<uchar>(8) << myPlayerNum << static_cast<uchar>(MAPDRAW_ERASE) << x << z;
221 	return PacketType(packet);
222 }
223 
224 // [NETMSG_MAPDRAW = 31] uchar messageSize, uchar myPlayerNum, command = MAPDRAW_POINT; short x, z; bool; std::string label;
SendMapDrawPoint(uchar myPlayerNum,short x,short z,const std::string & label,bool fromLua)225 PacketType CBaseNetProtocol::SendMapDrawPoint(uchar myPlayerNum, short x, short z, const std::string& label, bool fromLua)
226 {
227 	const unsigned size = 9 + label.size() + 1;
228 	PackPacket* packet = new PackPacket(size, NETMSG_MAPDRAW);
229 	*packet <<
230 		static_cast<uchar>(size) <<
231 		myPlayerNum <<
232 		static_cast<uchar>(MAPDRAW_POINT) <<
233 		x <<
234 		z <<
235 		uchar(fromLua) <<
236 		label;
237 	return PacketType(packet);
238 }
239 
240 // [NETMSG_MAPDRAW = 31] uchar messageSize = 13, myPlayerNum, command = MAPDRAW_LINE; short x1, z1, x2, z2; bool
SendMapDrawLine(uchar myPlayerNum,short x1,short z1,short x2,short z2,bool fromLua)241 PacketType CBaseNetProtocol::SendMapDrawLine(uchar myPlayerNum, short x1, short z1, short x2, short z2, bool fromLua)
242 {
243 	PackPacket* packet = new PackPacket(13, NETMSG_MAPDRAW);
244 	*packet <<
245 		static_cast<uchar>(13) <<
246 		myPlayerNum <<
247 		static_cast<uchar>(MAPDRAW_LINE) <<
248 		x1 << z1 <<
249 		x2 << z2 <<
250 		uchar(fromLua);
251 	return PacketType(packet);
252 }
253 
254 
SendSyncResponse(uchar myPlayerNum,int frameNum,uint checksum)255 PacketType CBaseNetProtocol::SendSyncResponse(uchar myPlayerNum, int frameNum, uint checksum)
256 {
257 	PackPacket* packet = new PackPacket(10, NETMSG_SYNCRESPONSE);
258 	*packet << myPlayerNum << frameNum << checksum;
259 	return PacketType(packet);
260 }
261 
SendSystemMessage(uchar myPlayerNum,std::string message)262 PacketType CBaseNetProtocol::SendSystemMessage(uchar myPlayerNum, std::string message)
263 {
264 	if (message.size() > 65000)
265 	{
266 		message.resize(65000);
267 		message += "...";
268 	}
269 	unsigned size = 1 + 2 + 1 + message.size() + 1;
270 	PackPacket* packet = new PackPacket(size, NETMSG_SYSTEMMSG);
271 	*packet << static_cast<boost::uint16_t>(size) << myPlayerNum << message;
272 	return PacketType(packet);
273 }
274 
SendStartPos(uchar myPlayerNum,uchar teamNum,uchar readyState,float x,float y,float z)275 PacketType CBaseNetProtocol::SendStartPos(uchar myPlayerNum, uchar teamNum, uchar readyState, float x, float y, float z)
276 {
277 	PackPacket* packet = new PackPacket(16, NETMSG_STARTPOS);
278 	*packet << myPlayerNum << teamNum << readyState << x << y << z;
279 	return PacketType(packet);
280 }
281 
SendPlayerInfo(uchar myPlayerNum,float cpuUsage,int ping)282 PacketType CBaseNetProtocol::SendPlayerInfo(uchar myPlayerNum, float cpuUsage, int ping)
283 {
284 	PackPacket* packet = new PackPacket(10, NETMSG_PLAYERINFO);
285 	*packet << myPlayerNum << cpuUsage << static_cast<boost::uint32_t>(ping);
286 	return PacketType(packet);
287 }
288 
SendPlayerLeft(uchar myPlayerNum,uchar bIntended)289 PacketType CBaseNetProtocol::SendPlayerLeft(uchar myPlayerNum, uchar bIntended)
290 {
291 	PackPacket* packet = new PackPacket(3, NETMSG_PLAYERLEFT);
292 	*packet << myPlayerNum << bIntended;
293 	return PacketType(packet);
294 }
295 
296 // NETMSG_LUAMSG = 50, uchar myPlayerNum; std::string modName; (e.g. `custom msg')
SendLuaMsg(uchar myPlayerNum,unsigned short script,uchar mode,const std::vector<boost::uint8_t> & msg)297 PacketType CBaseNetProtocol::SendLuaMsg(uchar myPlayerNum, unsigned short script, uchar mode, const std::vector<boost::uint8_t>& msg)
298 {
299 	if ((7 + msg.size()) >= (1 << (sizeof(boost::uint16_t) * 8)))
300 		throw netcode::PackPacketException("Maximum size exceeded");
301 	boost::uint16_t size = 7 + msg.size();
302 	PackPacket* packet = new PackPacket(size, NETMSG_LUAMSG);
303 	*packet << size << myPlayerNum << script << mode << msg;
304 	return PacketType(packet);
305 }
306 
SendGiveAwayEverything(uchar myPlayerNum,uchar giveToTeam,uchar takeFromTeam)307 PacketType CBaseNetProtocol::SendGiveAwayEverything(uchar myPlayerNum, uchar giveToTeam, uchar takeFromTeam)
308 {
309 	PackPacket* packet = new PackPacket(5, NETMSG_TEAM);
310 	*packet << myPlayerNum << static_cast<uchar>(TEAMMSG_GIVEAWAY) << giveToTeam << takeFromTeam;
311 	return PacketType(packet);
312 }
313 
SendResign(uchar myPlayerNum)314 PacketType CBaseNetProtocol::SendResign(uchar myPlayerNum)
315 {
316 	PackPacket* packet = new PackPacket(5, NETMSG_TEAM);
317 	*packet << myPlayerNum << static_cast<uchar>(TEAMMSG_RESIGN) << static_cast<uchar>(0) << static_cast<uchar>(0);
318 	return PacketType(packet);
319 }
320 
SendJoinTeam(uchar myPlayerNum,uchar wantedTeamNum)321 PacketType CBaseNetProtocol::SendJoinTeam(uchar myPlayerNum, uchar wantedTeamNum)
322 {
323 	PackPacket* packet = new PackPacket(5, NETMSG_TEAM);
324 	*packet << myPlayerNum << static_cast<uchar>(TEAMMSG_JOIN_TEAM) << wantedTeamNum << static_cast<uchar>(0);
325 	return PacketType(packet);
326 }
327 
SendTeamDied(uchar myPlayerNum,uchar whichTeam)328 PacketType CBaseNetProtocol::SendTeamDied(uchar myPlayerNum, uchar whichTeam)
329 {
330 	PackPacket* packet = new PackPacket(5, NETMSG_TEAM);
331 	*packet << myPlayerNum << static_cast<uchar>(TEAMMSG_TEAM_DIED) << whichTeam << static_cast<uchar>(0);
332 	return PacketType(packet);
333 }
334 
SendAICreated(const uchar myPlayerNum,const uchar whichSkirmishAI,const uchar team,const std::string & name)335 PacketType CBaseNetProtocol::SendAICreated(const uchar myPlayerNum,
336                                            const uchar whichSkirmishAI,
337                                            const uchar team,
338                                            const std::string& name)
339 {
340 	// do not hand optimize this math; the compiler will do that
341 	const uint size = 1 + 1 + 1 + 1 + 1 + (name.size() + 1);
342 	PackPacket* packet = new PackPacket(size, NETMSG_AI_CREATED);
343 	*packet
344 		<< static_cast<uchar>(size)
345 		<< myPlayerNum
346 		<< whichSkirmishAI
347 		<< team
348 		<< name;
349 	return PacketType(packet);
350 }
351 
SendAIStateChanged(const uchar myPlayerNum,const uchar whichSkirmishAI,const uchar newState)352 PacketType CBaseNetProtocol::SendAIStateChanged(const uchar myPlayerNum,
353                                                 const uchar whichSkirmishAI,
354                                                 const uchar newState)
355 {
356 	// do not hand optimize this math; the compiler will do that
357 	PackPacket* packet = new PackPacket(1 + 1 + 1 + 1, NETMSG_AI_STATE_CHANGED);
358 	*packet << myPlayerNum << whichSkirmishAI << newState;
359 	return PacketType(packet);
360 }
361 
SendSetAllied(uchar myPlayerNum,uchar whichAllyTeam,uchar state)362 PacketType CBaseNetProtocol::SendSetAllied(uchar myPlayerNum, uchar whichAllyTeam, uchar state)
363 {
364 	PackPacket* packet = new PackPacket(4, NETMSG_ALLIANCE);
365 	*packet << myPlayerNum << whichAllyTeam << state;
366 	return PacketType(packet);
367 }
368 
369 
SendCreateNewPlayer(uchar playerNum,bool spectator,uchar teamNum,std::string playerName)370 PacketType CBaseNetProtocol::SendCreateNewPlayer( uchar playerNum, bool spectator, uchar teamNum, std::string playerName )
371 {
372 	unsigned size = 1 + sizeof(uchar) + sizeof(uchar) + sizeof(uchar) + sizeof (boost::uint16_t) +playerName.size()+1;
373 	PackPacket* packet = new PackPacket( size, NETMSG_CREATE_NEWPLAYER);
374 	*packet << static_cast<boost::uint16_t>(size) << playerNum << (uchar)spectator << teamNum << playerName;
375 	return PacketType(packet);
376 
377 }
378 
SendCurrentFrameProgress(int frameNum)379 PacketType CBaseNetProtocol::SendCurrentFrameProgress(int frameNum)
380 {
381 	PackPacket* packet = new PackPacket(5, NETMSG_GAME_FRAME_PROGRESS);
382 	*packet << frameNum;
383 	return PacketType(packet);
384 }
385 
386 
387 
388 #ifdef SYNCDEBUG
SendSdCheckrequest(int frameNum)389 PacketType CBaseNetProtocol::SendSdCheckrequest(int frameNum)
390 {
391 	PackPacket* packet = new PackPacket(5, NETMSG_SD_CHKREQUEST);
392 	*packet << frameNum;
393 	return PacketType(packet);
394 }
395 
SendSdCheckresponse(uchar myPlayerNum,boost::uint64_t flop,std::vector<unsigned> checksums)396 PacketType CBaseNetProtocol::SendSdCheckresponse(uchar myPlayerNum, boost::uint64_t flop, std::vector<unsigned> checksums)
397 {
398 	unsigned size = 1 + 2 + 1 + 8 + checksums.size() * 4;
399 	PackPacket* packet = new PackPacket(size, NETMSG_SD_CHKRESPONSE);
400 	*packet << static_cast<boost::uint16_t>(size) << myPlayerNum << flop << checksums;
401 	return PacketType(packet);
402 }
403 
SendSdReset()404 PacketType CBaseNetProtocol::SendSdReset()
405 {
406 	return PacketType(new PackPacket(1, NETMSG_SD_RESET));
407 }
408 
SendSdBlockrequest(unsigned short begin,unsigned short length,unsigned short requestSize)409 PacketType CBaseNetProtocol::SendSdBlockrequest(unsigned short begin, unsigned short length, unsigned short requestSize)
410 {
411 	PackPacket* packet = new PackPacket(7, NETMSG_SD_BLKREQUEST);
412 	*packet << begin << length << requestSize;
413 	return PacketType(packet);
414 
415 }
416 
417 
SendSdBlockresponse(uchar myPlayerNum,std::vector<unsigned> checksums)418 PacketType CBaseNetProtocol::SendSdBlockresponse(uchar myPlayerNum, std::vector<unsigned> checksums)
419 {
420 	unsigned size = 1 + 2 + 1 + checksums.size() * 4;
421 	PackPacket* packet = new PackPacket(size, NETMSG_SD_BLKRESPONSE);
422 	*packet << static_cast<boost::uint16_t>(size) << myPlayerNum << checksums;
423 	return PacketType(packet);
424 }
425 #endif // SYNCDEBUG
426 /* FIXME: add these:
427  NETMSG_SD_CHKREQUEST    = 41,
428  NETMSG_SD_CHKRESPONSE   = 42,
429  NETMSG_SD_BLKREQUEST    = 43,
430  NETMSG_SD_BLKRESPONSE   = 44,
431  NETMSG_SD_RESET         = 45,
432 */
433 
CBaseNetProtocol()434 CBaseNetProtocol::CBaseNetProtocol()
435 {
436 	netcode::ProtocolDef* proto = netcode::ProtocolDef::GetInstance();
437 	// proto->AddType() length parameter:
438 	//   > 0:  if its fixed length
439 	//   < 0:  means the next x bytes represent the length
440 
441 	proto->AddType(NETMSG_KEYFRAME, 5);
442 	proto->AddType(NETMSG_NEWFRAME, 1);
443 	proto->AddType(NETMSG_QUIT, -2);
444 	proto->AddType(NETMSG_STARTPLAYING, 5);
445 	proto->AddType(NETMSG_SETPLAYERNUM, 2);
446 	proto->AddType(NETMSG_PLAYERNAME, -1);
447 	proto->AddType(NETMSG_CHAT, -1);
448 	proto->AddType(NETMSG_RANDSEED, 5);
449 	proto->AddType(NETMSG_GAMEID, 17);
450 	proto->AddType(NETMSG_PATH_CHECKSUM, 1 + 1 + sizeof(boost::uint32_t));
451 	proto->AddType(NETMSG_COMMAND, -2);
452 	proto->AddType(NETMSG_SELECT, -2);
453 	proto->AddType(NETMSG_PAUSE, 3);
454 
455 	proto->AddType(NETMSG_AICOMMAND, -2);
456 	proto->AddType(NETMSG_AICOMMAND_TRACKED, -2);
457 	proto->AddType(NETMSG_AICOMMANDS, -2);
458 	proto->AddType(NETMSG_AISHARE, -2);
459 
460 	proto->AddType(NETMSG_USER_SPEED, 6);
461 	proto->AddType(NETMSG_INTERNAL_SPEED, 5);
462 	proto->AddType(NETMSG_CPU_USAGE, 5);
463 	proto->AddType(NETMSG_DIRECT_CONTROL, 2);
464 	proto->AddType(NETMSG_DC_UPDATE, 7);
465 	proto->AddType(NETMSG_ATTEMPTCONNECT, -2);
466 	proto->AddType(NETMSG_SHARE, 12);
467 	proto->AddType(NETMSG_SETSHARE, 11);
468 
469 	proto->AddType(NETMSG_PLAYERSTAT, 2 + sizeof(PlayerStatistics));
470 	proto->AddType(NETMSG_GAMEOVER, -1);
471 	proto->AddType(NETMSG_MAPDRAW, -1);
472 	proto->AddType(NETMSG_SYNCRESPONSE, 10);
473 	proto->AddType(NETMSG_SYSTEMMSG, -2);
474 	proto->AddType(NETMSG_STARTPOS, 16);
475 	proto->AddType(NETMSG_PLAYERINFO, 10);
476 	proto->AddType(NETMSG_PLAYERLEFT, 3);
477 	proto->AddType(NETMSG_LUAMSG, -2);
478 	proto->AddType(NETMSG_TEAM, 5);
479 	proto->AddType(NETMSG_GAMEDATA, -2);
480 	proto->AddType(NETMSG_ALLIANCE, 4);
481 	proto->AddType(NETMSG_CCOMMAND, -2);
482 	proto->AddType(NETMSG_TEAMSTAT, 2 + sizeof(TeamStatistics));
483 	proto->AddType(NETMSG_REQUEST_TEAMSTAT, 4 );
484 
485 	proto->AddType(NETMSG_CREATE_NEWPLAYER, -2);
486 
487 	proto->AddType(NETMSG_AI_CREATED, -1);
488 	proto->AddType(NETMSG_AI_STATE_CHANGED, 4);
489 	proto->AddType(NETMSG_GAME_FRAME_PROGRESS,5);
490 
491 #ifdef SYNCDEBUG
492 	proto->AddType(NETMSG_SD_CHKREQUEST, 5);
493 	proto->AddType(NETMSG_SD_CHKRESPONSE, -2);
494 	proto->AddType(NETMSG_SD_RESET, 1);
495 	proto->AddType(NETMSG_SD_BLKREQUEST, 7);
496 	proto->AddType(NETMSG_SD_BLKRESPONSE, -2);
497 #endif // SYNCDEBUG
498 }
499 
~CBaseNetProtocol()500 CBaseNetProtocol::~CBaseNetProtocol()
501 {
502 	//SendQuit();
503 }
504