1 | #include "protocol7.h" |
2 | #include <base/system.h> |
3 | #include <engine/shared/packer.h> |
4 | #include <engine/shared/protocol.h> |
5 | namespace protocol7 { |
6 | CNetObjHandler::CNetObjHandler() |
7 | { |
8 | m_pMsgFailedOn = "" ; |
9 | m_pObjFailedOn = "" ; |
10 | m_NumObjFailures = 0; |
11 | } |
12 | |
13 | const char *CNetObjHandler::FailedObjOn() const { return m_pObjFailedOn; } |
14 | int CNetObjHandler::NumObjFailures() const { return m_NumObjFailures; } |
15 | const char *CNetObjHandler::FailedMsgOn() const { return m_pMsgFailedOn; } |
16 | |
17 | |
18 | |
19 | |
20 | static const int max_int = 0x7fffffff; |
21 | |
22 | bool CNetObjHandler::CheckInt(const char *pErrorMsg, int Value, int Min, int Max) |
23 | { |
24 | if(Value < Min || Value > Max) { m_pObjFailedOn = pErrorMsg; m_NumObjFailures++; return false; } |
25 | return true; |
26 | } |
27 | |
28 | bool CNetObjHandler::CheckFlag(const char *pErrorMsg, int Value, int Mask) |
29 | { |
30 | if((Value&Mask) != Value) { m_pObjFailedOn = pErrorMsg; m_NumObjFailures++; return false; } |
31 | return true; |
32 | } |
33 | |
34 | const char *CNetObjHandler::ms_apObjNames[] = { |
35 | "invalid" , |
36 | "PlayerInput" , |
37 | "Projectile" , |
38 | "Laser" , |
39 | "Pickup" , |
40 | "Flag" , |
41 | "GameData" , |
42 | "GameDataTeam" , |
43 | "GameDataFlag" , |
44 | "CharacterCore" , |
45 | "Character" , |
46 | "PlayerInfo" , |
47 | "SpectatorInfo" , |
48 | "De_ClientInfo" , |
49 | "De_GameInfo" , |
50 | "De_TuneParams" , |
51 | "Common" , |
52 | "Explosion" , |
53 | "Spawn" , |
54 | "HammerHit" , |
55 | "Death" , |
56 | "SoundWorld" , |
57 | "Damage" , |
58 | "PlayerInfoRace" , |
59 | "GameDataRace" , |
60 | "" |
61 | }; |
62 | |
63 | int CNetObjHandler::ms_aObjSizes[] = { |
64 | 0, |
65 | sizeof(CNetObj_PlayerInput), |
66 | sizeof(CNetObj_Projectile), |
67 | sizeof(CNetObj_Laser), |
68 | sizeof(CNetObj_Pickup), |
69 | sizeof(CNetObj_Flag), |
70 | sizeof(CNetObj_GameData), |
71 | sizeof(CNetObj_GameDataTeam), |
72 | sizeof(CNetObj_GameDataFlag), |
73 | sizeof(CNetObj_CharacterCore), |
74 | sizeof(CNetObj_Character), |
75 | sizeof(CNetObj_PlayerInfo), |
76 | sizeof(CNetObj_SpectatorInfo), |
77 | sizeof(CNetObj_De_ClientInfo), |
78 | sizeof(CNetObj_De_GameInfo), |
79 | sizeof(CNetObj_De_TuneParams), |
80 | sizeof(CNetEvent_Common), |
81 | sizeof(CNetEvent_Explosion), |
82 | sizeof(CNetEvent_Spawn), |
83 | sizeof(CNetEvent_HammerHit), |
84 | sizeof(CNetEvent_Death), |
85 | sizeof(CNetEvent_SoundWorld), |
86 | sizeof(CNetEvent_Damage), |
87 | sizeof(CNetObj_PlayerInfoRace), |
88 | sizeof(CNetObj_GameDataRace), |
89 | 0 |
90 | }; |
91 | |
92 | const char *CNetObjHandler::ms_apMsgNames[] = { |
93 | "invalid" , |
94 | "Sv_Motd" , |
95 | "Sv_Broadcast" , |
96 | "Sv_Chat" , |
97 | "Sv_Team" , |
98 | "Sv_KillMsg" , |
99 | "Sv_TuneParams" , |
100 | "Unused" , |
101 | "Sv_ReadyToEnter" , |
102 | "Sv_WeaponPickup" , |
103 | "Sv_Emoticon" , |
104 | "Sv_VoteClearOptions" , |
105 | "Sv_VoteOptionListAdd" , |
106 | "Sv_VoteOptionAdd" , |
107 | "Sv_VoteOptionRemove" , |
108 | "Sv_VoteSet" , |
109 | "Sv_VoteStatus" , |
110 | "Sv_ServerSettings" , |
111 | "Sv_ClientInfo" , |
112 | "Sv_GameInfo" , |
113 | "Sv_ClientDrop" , |
114 | "Sv_GameMsg" , |
115 | "De_ClientEnter" , |
116 | "De_ClientLeave" , |
117 | "Cl_Say" , |
118 | "Cl_SetTeam" , |
119 | "Cl_SetSpectatorMode" , |
120 | "Cl_StartInfo" , |
121 | "Cl_Kill" , |
122 | "Cl_ReadyChange" , |
123 | "Cl_Emoticon" , |
124 | "Cl_Vote" , |
125 | "Cl_CallVote" , |
126 | "Sv_SkinChange" , |
127 | "Cl_SkinChange" , |
128 | "Sv_RaceFinish" , |
129 | "Sv_Checkpoint" , |
130 | "Sv_CommandInfo" , |
131 | "Sv_CommandInfoRemove" , |
132 | "Cl_Command" , |
133 | "" |
134 | }; |
135 | |
136 | const char *CNetObjHandler::GetObjName(int Type) const |
137 | { |
138 | if(Type < 0 || Type >= NUM_NETOBJTYPES) return "(out of range)" ; |
139 | return ms_apObjNames[Type]; |
140 | }; |
141 | |
142 | int CNetObjHandler::GetObjSize(int Type) const |
143 | { |
144 | if(Type < 0 || Type >= NUM_NETOBJTYPES) return 0; |
145 | return ms_aObjSizes[Type]; |
146 | }; |
147 | |
148 | const char *CNetObjHandler::GetMsgName(int Type) const |
149 | { |
150 | if(Type < 0 || Type >= NUM_NETMSGTYPES) return "(out of range)" ; |
151 | return ms_apMsgNames[Type]; |
152 | }; |
153 | |
154 | int CNetObjHandler::ValidateObj(int Type, const void *pData, int Size) |
155 | { |
156 | switch(Type) |
157 | { |
158 | case NETOBJTYPE_PLAYERINPUT: |
159 | { |
160 | CNetObj_PlayerInput *pObj = (CNetObj_PlayerInput *)pData; |
161 | if(sizeof(*pObj) != Size) return -1; |
162 | if(!CheckInt(pErrorMsg: "m_Direction" , Value: pObj->m_Direction, Min: -1, Max: 1)) return -1; |
163 | if(!CheckInt(pErrorMsg: "m_Jump" , Value: pObj->m_Jump, Min: 0, Max: 1)) return -1; |
164 | if(!CheckInt(pErrorMsg: "m_Hook" , Value: pObj->m_Hook, Min: 0, Max: 1)) return -1; |
165 | if(!CheckFlag(pErrorMsg: "m_PlayerFlags" , Value: pObj->m_PlayerFlags, Mask: PLAYERFLAG_ADMIN|PLAYERFLAG_CHATTING|PLAYERFLAG_SCOREBOARD|PLAYERFLAG_READY|PLAYERFLAG_DEAD|PLAYERFLAG_WATCHING|PLAYERFLAG_BOT|PLAYERFLAG_AIM)) return -1; |
166 | if(!CheckInt(pErrorMsg: "m_WantedWeapon" , Value: pObj->m_WantedWeapon, Min: 0, Max: NUM_WEAPONS-1)) return -1; |
167 | return 0; |
168 | } |
169 | |
170 | case NETOBJTYPE_PROJECTILE: |
171 | { |
172 | CNetObj_Projectile *pObj = (CNetObj_Projectile *)pData; |
173 | if(sizeof(*pObj) != Size) return -1; |
174 | if(!CheckInt(pErrorMsg: "m_Type" , Value: pObj->m_Type, Min: 0, Max: NUM_WEAPONS-1)) return -1; |
175 | if(!CheckInt(pErrorMsg: "m_StartTick" , Value: pObj->m_StartTick, Min: 0, Max: max_int)) return -1; |
176 | return 0; |
177 | } |
178 | |
179 | case NETOBJTYPE_LASER: |
180 | { |
181 | CNetObj_Laser *pObj = (CNetObj_Laser *)pData; |
182 | if(sizeof(*pObj) != Size) return -1; |
183 | if(!CheckInt(pErrorMsg: "m_StartTick" , Value: pObj->m_StartTick, Min: 0, Max: max_int)) return -1; |
184 | return 0; |
185 | } |
186 | |
187 | case NETOBJTYPE_PICKUP: |
188 | { |
189 | CNetObj_Pickup *pObj = (CNetObj_Pickup *)pData; |
190 | if(sizeof(*pObj) != Size) return -1; |
191 | if(!CheckInt(pErrorMsg: "m_Type" , Value: pObj->m_Type, Min: 0, Max: 7)) return -1; |
192 | return 0; |
193 | } |
194 | |
195 | case NETOBJTYPE_FLAG: |
196 | { |
197 | CNetObj_Flag *pObj = (CNetObj_Flag *)pData; |
198 | if(sizeof(*pObj) != Size) return -1; |
199 | if(!CheckInt(pErrorMsg: "m_Team" , Value: pObj->m_Team, Min: TEAM_RED, Max: TEAM_BLUE)) return -1; |
200 | return 0; |
201 | } |
202 | |
203 | case NETOBJTYPE_GAMEDATA: |
204 | { |
205 | CNetObj_GameData *pObj = (CNetObj_GameData *)pData; |
206 | if(sizeof(*pObj) != Size) return -1; |
207 | if(!CheckInt(pErrorMsg: "m_GameStartTick" , Value: pObj->m_GameStartTick, Min: 0, Max: max_int)) return -1; |
208 | if(!CheckFlag(pErrorMsg: "m_GameStateFlags" , Value: pObj->m_GameStateFlags, Mask: GAMESTATEFLAG_WARMUP|GAMESTATEFLAG_SUDDENDEATH|GAMESTATEFLAG_ROUNDOVER|GAMESTATEFLAG_GAMEOVER|GAMESTATEFLAG_PAUSED|GAMESTATEFLAG_STARTCOUNTDOWN)) return -1; |
209 | if(!CheckInt(pErrorMsg: "m_GameStateEndTick" , Value: pObj->m_GameStateEndTick, Min: 0, Max: max_int)) return -1; |
210 | return 0; |
211 | } |
212 | |
213 | case NETOBJTYPE_GAMEDATATEAM: |
214 | { |
215 | CNetObj_GameDataTeam *pObj = (CNetObj_GameDataTeam *)pData; |
216 | if(sizeof(*pObj) != Size) return -1; |
217 | return 0; |
218 | } |
219 | |
220 | case NETOBJTYPE_GAMEDATAFLAG: |
221 | { |
222 | CNetObj_GameDataFlag *pObj = (CNetObj_GameDataFlag *)pData; |
223 | if(sizeof(*pObj) != Size) return -1; |
224 | if(!CheckInt(pErrorMsg: "m_FlagCarrierRed" , Value: pObj->m_FlagCarrierRed, Min: FLAG_MISSING, Max: MAX_CLIENTS-1)) return -1; |
225 | if(!CheckInt(pErrorMsg: "m_FlagCarrierBlue" , Value: pObj->m_FlagCarrierBlue, Min: FLAG_MISSING, Max: MAX_CLIENTS-1)) return -1; |
226 | if(!CheckInt(pErrorMsg: "m_FlagDropTickRed" , Value: pObj->m_FlagDropTickRed, Min: 0, Max: max_int)) return -1; |
227 | if(!CheckInt(pErrorMsg: "m_FlagDropTickBlue" , Value: pObj->m_FlagDropTickBlue, Min: 0, Max: max_int)) return -1; |
228 | return 0; |
229 | } |
230 | |
231 | case NETOBJTYPE_CHARACTERCORE: |
232 | { |
233 | CNetObj_CharacterCore *pObj = (CNetObj_CharacterCore *)pData; |
234 | if(sizeof(*pObj) != Size) return -1; |
235 | if(!CheckInt(pErrorMsg: "m_Tick" , Value: pObj->m_Tick, Min: 0, Max: max_int)) return -1; |
236 | if(!CheckInt(pErrorMsg: "m_Direction" , Value: pObj->m_Direction, Min: -1, Max: 1)) return -1; |
237 | if(!CheckInt(pErrorMsg: "m_Jumped" , Value: pObj->m_Jumped, Min: 0, Max: 3)) return -1; |
238 | if(!CheckInt(pErrorMsg: "m_HookedPlayer" , Value: pObj->m_HookedPlayer, Min: -1, Max: MAX_CLIENTS-1)) return -1; |
239 | if(!CheckInt(pErrorMsg: "m_HookState" , Value: pObj->m_HookState, Min: -1, Max: 5)) return -1; |
240 | if(!CheckInt(pErrorMsg: "m_HookTick" , Value: pObj->m_HookTick, Min: 0, Max: max_int)) return -1; |
241 | return 0; |
242 | } |
243 | |
244 | case NETOBJTYPE_CHARACTER: |
245 | { |
246 | CNetObj_Character *pObj = (CNetObj_Character *)pData; |
247 | if(sizeof(*pObj) != Size) return -1; |
248 | if(!CheckInt(pErrorMsg: "m_Tick" , Value: pObj->m_Tick, Min: 0, Max: max_int)) return -1; |
249 | if(!CheckInt(pErrorMsg: "m_Direction" , Value: pObj->m_Direction, Min: -1, Max: 1)) return -1; |
250 | if(!CheckInt(pErrorMsg: "m_Jumped" , Value: pObj->m_Jumped, Min: 0, Max: 3)) return -1; |
251 | if(!CheckInt(pErrorMsg: "m_HookedPlayer" , Value: pObj->m_HookedPlayer, Min: -1, Max: MAX_CLIENTS-1)) return -1; |
252 | if(!CheckInt(pErrorMsg: "m_HookState" , Value: pObj->m_HookState, Min: -1, Max: 5)) return -1; |
253 | if(!CheckInt(pErrorMsg: "m_HookTick" , Value: pObj->m_HookTick, Min: 0, Max: max_int)) return -1; |
254 | if(!CheckInt(pErrorMsg: "m_Health" , Value: pObj->m_Health, Min: 0, Max: 10)) return -1; |
255 | if(!CheckInt(pErrorMsg: "m_Armor" , Value: pObj->m_Armor, Min: 0, Max: 10)) return -1; |
256 | if(!CheckInt(pErrorMsg: "m_Weapon" , Value: pObj->m_Weapon, Min: 0, Max: NUM_WEAPONS-1)) return -1; |
257 | if(!CheckInt(pErrorMsg: "m_Emote" , Value: pObj->m_Emote, Min: 0, Max: 5)) return -1; |
258 | if(!CheckInt(pErrorMsg: "m_AttackTick" , Value: pObj->m_AttackTick, Min: 0, Max: max_int)) return -1; |
259 | if(!CheckFlag(pErrorMsg: "m_TriggeredEvents" , Value: pObj->m_TriggeredEvents, Mask: COREEVENTFLAG_GROUND_JUMP|COREEVENTFLAG_AIR_JUMP|COREEVENTFLAG_HOOK_ATTACH_PLAYER|COREEVENTFLAG_HOOK_ATTACH_GROUND|COREEVENTFLAG_HOOK_HIT_NOHOOK)) return -1; |
260 | return 0; |
261 | } |
262 | |
263 | case NETOBJTYPE_PLAYERINFO: |
264 | { |
265 | CNetObj_PlayerInfo *pObj = (CNetObj_PlayerInfo *)pData; |
266 | if(sizeof(*pObj) != Size) return -1; |
267 | if(!CheckFlag(pErrorMsg: "m_PlayerFlags" , Value: pObj->m_PlayerFlags, Mask: PLAYERFLAG_ADMIN|PLAYERFLAG_CHATTING|PLAYERFLAG_SCOREBOARD|PLAYERFLAG_READY|PLAYERFLAG_DEAD|PLAYERFLAG_WATCHING|PLAYERFLAG_BOT|PLAYERFLAG_AIM)) return -1; |
268 | return 0; |
269 | } |
270 | |
271 | case NETOBJTYPE_SPECTATORINFO: |
272 | { |
273 | CNetObj_SpectatorInfo *pObj = (CNetObj_SpectatorInfo *)pData; |
274 | if(sizeof(*pObj) != Size) return -1; |
275 | if(!CheckInt(pErrorMsg: "m_SpecMode" , Value: pObj->m_SpecMode, Min: 0, Max: NUM_SPECMODES-1)) return -1; |
276 | if(!CheckInt(pErrorMsg: "m_SpectatorId" , Value: pObj->m_SpectatorId, Min: -1, Max: MAX_CLIENTS-1)) return -1; |
277 | return 0; |
278 | } |
279 | |
280 | case NETOBJTYPE_DE_CLIENTINFO: |
281 | { |
282 | CNetObj_De_ClientInfo *pObj = (CNetObj_De_ClientInfo *)pData; |
283 | if(sizeof(*pObj) != Size) return -1; |
284 | if(!CheckInt(pErrorMsg: "m_Local" , Value: pObj->m_Local, Min: 0, Max: 1)) return -1; |
285 | if(!CheckInt(pErrorMsg: "m_Team" , Value: pObj->m_Team, Min: TEAM_SPECTATORS, Max: TEAM_BLUE)) return -1; |
286 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[0]" , Value: pObj->m_aUseCustomColors[0], Min: 0, Max: 1)) return -1; |
287 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[1]" , Value: pObj->m_aUseCustomColors[1], Min: 0, Max: 1)) return -1; |
288 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[2]" , Value: pObj->m_aUseCustomColors[2], Min: 0, Max: 1)) return -1; |
289 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[3]" , Value: pObj->m_aUseCustomColors[3], Min: 0, Max: 1)) return -1; |
290 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[4]" , Value: pObj->m_aUseCustomColors[4], Min: 0, Max: 1)) return -1; |
291 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[5]" , Value: pObj->m_aUseCustomColors[5], Min: 0, Max: 1)) return -1; |
292 | return 0; |
293 | } |
294 | |
295 | case NETOBJTYPE_DE_GAMEINFO: |
296 | { |
297 | CNetObj_De_GameInfo *pObj = (CNetObj_De_GameInfo *)pData; |
298 | if(sizeof(*pObj) != Size) return -1; |
299 | if(!CheckFlag(pErrorMsg: "m_GameFlags" , Value: pObj->m_GameFlags, Mask: GAMEFLAG_TEAMS|GAMEFLAG_FLAGS|GAMEFLAG_SURVIVAL|GAMEFLAG_RACE)) return -1; |
300 | if(!CheckInt(pErrorMsg: "m_ScoreLimit" , Value: pObj->m_ScoreLimit, Min: 0, Max: max_int)) return -1; |
301 | if(!CheckInt(pErrorMsg: "m_TimeLimit" , Value: pObj->m_TimeLimit, Min: 0, Max: max_int)) return -1; |
302 | if(!CheckInt(pErrorMsg: "m_MatchNum" , Value: pObj->m_MatchNum, Min: 0, Max: max_int)) return -1; |
303 | if(!CheckInt(pErrorMsg: "m_MatchCurrent" , Value: pObj->m_MatchCurrent, Min: 0, Max: max_int)) return -1; |
304 | return 0; |
305 | } |
306 | |
307 | case NETOBJTYPE_DE_TUNEPARAMS: |
308 | { |
309 | CNetObj_De_TuneParams *pObj = (CNetObj_De_TuneParams *)pData; |
310 | if(sizeof(*pObj) != Size) return -1; |
311 | return 0; |
312 | } |
313 | |
314 | case NETEVENTTYPE_COMMON: |
315 | { |
316 | CNetEvent_Common *pObj = (CNetEvent_Common *)pData; |
317 | if(sizeof(*pObj) != Size) return -1; |
318 | return 0; |
319 | } |
320 | |
321 | case NETEVENTTYPE_EXPLOSION: |
322 | { |
323 | CNetEvent_Explosion *pObj = (CNetEvent_Explosion *)pData; |
324 | if(sizeof(*pObj) != Size) return -1; |
325 | return 0; |
326 | } |
327 | |
328 | case NETEVENTTYPE_SPAWN: |
329 | { |
330 | CNetEvent_Spawn *pObj = (CNetEvent_Spawn *)pData; |
331 | if(sizeof(*pObj) != Size) return -1; |
332 | return 0; |
333 | } |
334 | |
335 | case NETEVENTTYPE_HAMMERHIT: |
336 | { |
337 | CNetEvent_HammerHit *pObj = (CNetEvent_HammerHit *)pData; |
338 | if(sizeof(*pObj) != Size) return -1; |
339 | return 0; |
340 | } |
341 | |
342 | case NETEVENTTYPE_DEATH: |
343 | { |
344 | CNetEvent_Death *pObj = (CNetEvent_Death *)pData; |
345 | if(sizeof(*pObj) != Size) return -1; |
346 | if(!CheckInt(pErrorMsg: "m_ClientId" , Value: pObj->m_ClientId, Min: 0, Max: MAX_CLIENTS-1)) return -1; |
347 | return 0; |
348 | } |
349 | |
350 | case NETEVENTTYPE_SOUNDWORLD: |
351 | { |
352 | CNetEvent_SoundWorld *pObj = (CNetEvent_SoundWorld *)pData; |
353 | if(sizeof(*pObj) != Size) return -1; |
354 | if(!CheckInt(pErrorMsg: "m_SoundId" , Value: pObj->m_SoundId, Min: 0, Max: NUM_SOUNDS-1)) return -1; |
355 | return 0; |
356 | } |
357 | |
358 | case NETEVENTTYPE_DAMAGE: |
359 | { |
360 | CNetEvent_Damage *pObj = (CNetEvent_Damage *)pData; |
361 | if(sizeof(*pObj) != Size) return -1; |
362 | if(!CheckInt(pErrorMsg: "m_ClientId" , Value: pObj->m_ClientId, Min: 0, Max: MAX_CLIENTS-1)) return -1; |
363 | if(!CheckInt(pErrorMsg: "m_HealthAmount" , Value: pObj->m_HealthAmount, Min: 0, Max: 9)) return -1; |
364 | if(!CheckInt(pErrorMsg: "m_ArmorAmount" , Value: pObj->m_ArmorAmount, Min: 0, Max: 9)) return -1; |
365 | if(!CheckInt(pErrorMsg: "m_Self" , Value: pObj->m_Self, Min: 0, Max: 1)) return -1; |
366 | return 0; |
367 | } |
368 | |
369 | case NETOBJTYPE_PLAYERINFORACE: |
370 | { |
371 | CNetObj_PlayerInfoRace *pObj = (CNetObj_PlayerInfoRace *)pData; |
372 | if(sizeof(*pObj) != Size) return -1; |
373 | if(!CheckInt(pErrorMsg: "m_RaceStartTick" , Value: pObj->m_RaceStartTick, Min: 0, Max: max_int)) return -1; |
374 | return 0; |
375 | } |
376 | |
377 | case NETOBJTYPE_GAMEDATARACE: |
378 | { |
379 | CNetObj_GameDataRace *pObj = (CNetObj_GameDataRace *)pData; |
380 | if(sizeof(*pObj) != Size) return -1; |
381 | if(!CheckInt(pErrorMsg: "m_BestTime" , Value: pObj->m_BestTime, Min: -1, Max: max_int)) return -1; |
382 | if(!CheckInt(pErrorMsg: "m_Precision" , Value: pObj->m_Precision, Min: 0, Max: 3)) return -1; |
383 | if(!CheckFlag(pErrorMsg: "m_RaceFlags" , Value: pObj->m_RaceFlags, Mask: RACEFLAG_HIDE_KILLMSG|RACEFLAG_FINISHMSG_AS_CHAT|RACEFLAG_KEEP_WANTED_WEAPON)) return -1; |
384 | return 0; |
385 | } |
386 | |
387 | } |
388 | return -1; |
389 | }; |
390 | |
391 | void *CNetObjHandler::SecureUnpackMsg(int Type, CUnpacker *pUnpacker) |
392 | { |
393 | m_pMsgFailedOn = 0; |
394 | m_pObjFailedOn = 0; |
395 | switch(Type) |
396 | { |
397 | case NETMSGTYPE_SV_MOTD: |
398 | { |
399 | CNetMsg_Sv_Motd *pMsg = (CNetMsg_Sv_Motd *)m_aMsgData; |
400 | (void)pMsg; |
401 | pMsg->m_pMessage = pUnpacker->GetString(); |
402 | } break; |
403 | |
404 | case NETMSGTYPE_SV_BROADCAST: |
405 | { |
406 | CNetMsg_Sv_Broadcast *pMsg = (CNetMsg_Sv_Broadcast *)m_aMsgData; |
407 | (void)pMsg; |
408 | pMsg->m_pMessage = pUnpacker->GetString(); |
409 | } break; |
410 | |
411 | case NETMSGTYPE_SV_CHAT: |
412 | { |
413 | CNetMsg_Sv_Chat *pMsg = (CNetMsg_Sv_Chat *)m_aMsgData; |
414 | (void)pMsg; |
415 | pMsg->m_Mode = pUnpacker->GetInt(); |
416 | pMsg->m_ClientId = pUnpacker->GetInt(); |
417 | pMsg->m_TargetId = pUnpacker->GetInt(); |
418 | pMsg->m_pMessage = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
419 | if(!CheckInt(pErrorMsg: "m_Mode" , Value: pMsg->m_Mode, Min: 0, Max: NUM_CHATS-1)) break; |
420 | if(!CheckInt(pErrorMsg: "m_ClientId" , Value: pMsg->m_ClientId, Min: -1, Max: MAX_CLIENTS-1)) break; |
421 | if(!CheckInt(pErrorMsg: "m_TargetId" , Value: pMsg->m_TargetId, Min: -1, Max: MAX_CLIENTS-1)) break; |
422 | } break; |
423 | |
424 | case NETMSGTYPE_SV_TEAM: |
425 | { |
426 | CNetMsg_Sv_Team *pMsg = (CNetMsg_Sv_Team *)m_aMsgData; |
427 | (void)pMsg; |
428 | pMsg->m_ClientId = pUnpacker->GetInt(); |
429 | pMsg->m_Team = pUnpacker->GetInt(); |
430 | pMsg->m_Silent = pUnpacker->GetInt(); |
431 | pMsg->m_CooldownTick = pUnpacker->GetInt(); |
432 | if(!CheckInt(pErrorMsg: "m_ClientId" , Value: pMsg->m_ClientId, Min: -1, Max: MAX_CLIENTS-1)) break; |
433 | if(!CheckInt(pErrorMsg: "m_Team" , Value: pMsg->m_Team, Min: TEAM_SPECTATORS, Max: TEAM_BLUE)) break; |
434 | if(!CheckInt(pErrorMsg: "m_Silent" , Value: pMsg->m_Silent, Min: 0, Max: 1)) break; |
435 | if(!CheckInt(pErrorMsg: "m_CooldownTick" , Value: pMsg->m_CooldownTick, Min: 0, Max: max_int)) break; |
436 | } break; |
437 | |
438 | case NETMSGTYPE_SV_KILLMSG: |
439 | { |
440 | CNetMsg_Sv_KillMsg *pMsg = (CNetMsg_Sv_KillMsg *)m_aMsgData; |
441 | (void)pMsg; |
442 | pMsg->m_Killer = pUnpacker->GetInt(); |
443 | pMsg->m_Victim = pUnpacker->GetInt(); |
444 | pMsg->m_Weapon = pUnpacker->GetInt(); |
445 | pMsg->m_ModeSpecial = pUnpacker->GetInt(); |
446 | if(!CheckInt(pErrorMsg: "m_Killer" , Value: pMsg->m_Killer, Min: -2, Max: MAX_CLIENTS-1)) break; |
447 | if(!CheckInt(pErrorMsg: "m_Victim" , Value: pMsg->m_Victim, Min: 0, Max: MAX_CLIENTS-1)) break; |
448 | if(!CheckInt(pErrorMsg: "m_Weapon" , Value: pMsg->m_Weapon, Min: -3, Max: NUM_WEAPONS-1)) break; |
449 | } break; |
450 | |
451 | case NETMSGTYPE_SV_TUNEPARAMS: |
452 | { |
453 | CNetMsg_Sv_TuneParams *pMsg = (CNetMsg_Sv_TuneParams *)m_aMsgData; |
454 | (void)pMsg; |
455 | } break; |
456 | |
457 | case NETMSGTYPE_UNUSED: |
458 | { |
459 | CNetMsg_Unused *pMsg = (CNetMsg_Unused *)m_aMsgData; |
460 | (void)pMsg; |
461 | } break; |
462 | |
463 | case NETMSGTYPE_SV_READYTOENTER: |
464 | { |
465 | CNetMsg_Sv_ReadyToEnter *pMsg = (CNetMsg_Sv_ReadyToEnter *)m_aMsgData; |
466 | (void)pMsg; |
467 | } break; |
468 | |
469 | case NETMSGTYPE_SV_WEAPONPICKUP: |
470 | { |
471 | CNetMsg_Sv_WeaponPickup *pMsg = (CNetMsg_Sv_WeaponPickup *)m_aMsgData; |
472 | (void)pMsg; |
473 | pMsg->m_Weapon = pUnpacker->GetInt(); |
474 | if(!CheckInt(pErrorMsg: "m_Weapon" , Value: pMsg->m_Weapon, Min: 0, Max: NUM_WEAPONS-1)) break; |
475 | } break; |
476 | |
477 | case NETMSGTYPE_SV_EMOTICON: |
478 | { |
479 | CNetMsg_Sv_Emoticon *pMsg = (CNetMsg_Sv_Emoticon *)m_aMsgData; |
480 | (void)pMsg; |
481 | pMsg->m_ClientId = pUnpacker->GetInt(); |
482 | pMsg->m_Emoticon = pUnpacker->GetInt(); |
483 | if(!CheckInt(pErrorMsg: "m_ClientId" , Value: pMsg->m_ClientId, Min: 0, Max: MAX_CLIENTS-1)) break; |
484 | if(!CheckInt(pErrorMsg: "m_Emoticon" , Value: pMsg->m_Emoticon, Min: 0, Max: 15)) break; |
485 | } break; |
486 | |
487 | case NETMSGTYPE_SV_VOTECLEAROPTIONS: |
488 | { |
489 | CNetMsg_Sv_VoteClearOptions *pMsg = (CNetMsg_Sv_VoteClearOptions *)m_aMsgData; |
490 | (void)pMsg; |
491 | } break; |
492 | |
493 | case NETMSGTYPE_SV_VOTEOPTIONLISTADD: |
494 | { |
495 | CNetMsg_Sv_VoteOptionListAdd *pMsg = (CNetMsg_Sv_VoteOptionListAdd *)m_aMsgData; |
496 | (void)pMsg; |
497 | } break; |
498 | |
499 | case NETMSGTYPE_SV_VOTEOPTIONADD: |
500 | { |
501 | CNetMsg_Sv_VoteOptionAdd *pMsg = (CNetMsg_Sv_VoteOptionAdd *)m_aMsgData; |
502 | (void)pMsg; |
503 | pMsg->m_pDescription = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
504 | } break; |
505 | |
506 | case NETMSGTYPE_SV_VOTEOPTIONREMOVE: |
507 | { |
508 | CNetMsg_Sv_VoteOptionRemove *pMsg = (CNetMsg_Sv_VoteOptionRemove *)m_aMsgData; |
509 | (void)pMsg; |
510 | pMsg->m_pDescription = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
511 | } break; |
512 | |
513 | case NETMSGTYPE_SV_VOTESET: |
514 | { |
515 | CNetMsg_Sv_VoteSet *pMsg = (CNetMsg_Sv_VoteSet *)m_aMsgData; |
516 | (void)pMsg; |
517 | pMsg->m_ClientId = pUnpacker->GetInt(); |
518 | pMsg->m_Type = pUnpacker->GetInt(); |
519 | pMsg->m_Timeout = pUnpacker->GetInt(); |
520 | pMsg->m_pDescription = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
521 | pMsg->m_pReason = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
522 | if(!CheckInt(pErrorMsg: "m_ClientId" , Value: pMsg->m_ClientId, Min: -1, Max: MAX_CLIENTS-1)) break; |
523 | if(!CheckInt(pErrorMsg: "m_Type" , Value: pMsg->m_Type, Min: 0, Max: 6)) break; |
524 | if(!CheckInt(pErrorMsg: "m_Timeout" , Value: pMsg->m_Timeout, Min: 0, Max: 60)) break; |
525 | } break; |
526 | |
527 | case NETMSGTYPE_SV_VOTESTATUS: |
528 | { |
529 | CNetMsg_Sv_VoteStatus *pMsg = (CNetMsg_Sv_VoteStatus *)m_aMsgData; |
530 | (void)pMsg; |
531 | pMsg->m_Yes = pUnpacker->GetInt(); |
532 | pMsg->m_No = pUnpacker->GetInt(); |
533 | pMsg->m_Pass = pUnpacker->GetInt(); |
534 | pMsg->m_Total = pUnpacker->GetInt(); |
535 | if(!CheckInt(pErrorMsg: "m_Yes" , Value: pMsg->m_Yes, Min: 0, Max: MAX_CLIENTS)) break; |
536 | if(!CheckInt(pErrorMsg: "m_No" , Value: pMsg->m_No, Min: 0, Max: MAX_CLIENTS)) break; |
537 | if(!CheckInt(pErrorMsg: "m_Pass" , Value: pMsg->m_Pass, Min: 0, Max: MAX_CLIENTS)) break; |
538 | if(!CheckInt(pErrorMsg: "m_Total" , Value: pMsg->m_Total, Min: 0, Max: MAX_CLIENTS)) break; |
539 | } break; |
540 | |
541 | case NETMSGTYPE_SV_SERVERSETTINGS: |
542 | { |
543 | CNetMsg_Sv_ServerSettings *pMsg = (CNetMsg_Sv_ServerSettings *)m_aMsgData; |
544 | (void)pMsg; |
545 | pMsg->m_KickVote = pUnpacker->GetInt(); |
546 | pMsg->m_KickMin = pUnpacker->GetInt(); |
547 | pMsg->m_SpecVote = pUnpacker->GetInt(); |
548 | pMsg->m_TeamLock = pUnpacker->GetInt(); |
549 | pMsg->m_TeamBalance = pUnpacker->GetInt(); |
550 | pMsg->m_PlayerSlots = pUnpacker->GetInt(); |
551 | if(!CheckInt(pErrorMsg: "m_KickVote" , Value: pMsg->m_KickVote, Min: 0, Max: 1)) break; |
552 | if(!CheckInt(pErrorMsg: "m_KickMin" , Value: pMsg->m_KickMin, Min: 0, Max: MAX_CLIENTS)) break; |
553 | if(!CheckInt(pErrorMsg: "m_SpecVote" , Value: pMsg->m_SpecVote, Min: 0, Max: 1)) break; |
554 | if(!CheckInt(pErrorMsg: "m_TeamLock" , Value: pMsg->m_TeamLock, Min: 0, Max: 1)) break; |
555 | if(!CheckInt(pErrorMsg: "m_TeamBalance" , Value: pMsg->m_TeamBalance, Min: 0, Max: 1)) break; |
556 | if(!CheckInt(pErrorMsg: "m_PlayerSlots" , Value: pMsg->m_PlayerSlots, Min: 0, Max: MAX_CLIENTS)) break; |
557 | } break; |
558 | |
559 | case NETMSGTYPE_SV_CLIENTINFO: |
560 | { |
561 | CNetMsg_Sv_ClientInfo *pMsg = (CNetMsg_Sv_ClientInfo *)m_aMsgData; |
562 | (void)pMsg; |
563 | pMsg->m_ClientId = pUnpacker->GetInt(); |
564 | pMsg->m_Local = pUnpacker->GetInt(); |
565 | pMsg->m_Team = pUnpacker->GetInt(); |
566 | pMsg->m_pName = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
567 | pMsg->m_pClan = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
568 | pMsg->m_Country = pUnpacker->GetInt(); |
569 | pMsg->m_apSkinPartNames[0] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
570 | pMsg->m_apSkinPartNames[1] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
571 | pMsg->m_apSkinPartNames[2] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
572 | pMsg->m_apSkinPartNames[3] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
573 | pMsg->m_apSkinPartNames[4] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
574 | pMsg->m_apSkinPartNames[5] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
575 | pMsg->m_aUseCustomColors[0] = pUnpacker->GetInt(); |
576 | pMsg->m_aUseCustomColors[1] = pUnpacker->GetInt(); |
577 | pMsg->m_aUseCustomColors[2] = pUnpacker->GetInt(); |
578 | pMsg->m_aUseCustomColors[3] = pUnpacker->GetInt(); |
579 | pMsg->m_aUseCustomColors[4] = pUnpacker->GetInt(); |
580 | pMsg->m_aUseCustomColors[5] = pUnpacker->GetInt(); |
581 | pMsg->m_aSkinPartColors[0] = pUnpacker->GetInt(); |
582 | pMsg->m_aSkinPartColors[1] = pUnpacker->GetInt(); |
583 | pMsg->m_aSkinPartColors[2] = pUnpacker->GetInt(); |
584 | pMsg->m_aSkinPartColors[3] = pUnpacker->GetInt(); |
585 | pMsg->m_aSkinPartColors[4] = pUnpacker->GetInt(); |
586 | pMsg->m_aSkinPartColors[5] = pUnpacker->GetInt(); |
587 | pMsg->m_Silent = pUnpacker->GetInt(); |
588 | if(!CheckInt(pErrorMsg: "m_ClientId" , Value: pMsg->m_ClientId, Min: 0, Max: MAX_CLIENTS-1)) break; |
589 | if(!CheckInt(pErrorMsg: "m_Local" , Value: pMsg->m_Local, Min: 0, Max: 1)) break; |
590 | if(!CheckInt(pErrorMsg: "m_Team" , Value: pMsg->m_Team, Min: TEAM_SPECTATORS, Max: TEAM_BLUE)) break; |
591 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[0]" , Value: pMsg->m_aUseCustomColors[0], Min: 0, Max: 1)) break; |
592 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[1]" , Value: pMsg->m_aUseCustomColors[1], Min: 0, Max: 1)) break; |
593 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[2]" , Value: pMsg->m_aUseCustomColors[2], Min: 0, Max: 1)) break; |
594 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[3]" , Value: pMsg->m_aUseCustomColors[3], Min: 0, Max: 1)) break; |
595 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[4]" , Value: pMsg->m_aUseCustomColors[4], Min: 0, Max: 1)) break; |
596 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[5]" , Value: pMsg->m_aUseCustomColors[5], Min: 0, Max: 1)) break; |
597 | if(!CheckInt(pErrorMsg: "m_Silent" , Value: pMsg->m_Silent, Min: 0, Max: 1)) break; |
598 | } break; |
599 | |
600 | case NETMSGTYPE_SV_GAMEINFO: |
601 | { |
602 | CNetMsg_Sv_GameInfo *pMsg = (CNetMsg_Sv_GameInfo *)m_aMsgData; |
603 | (void)pMsg; |
604 | pMsg->m_GameFlags = pUnpacker->GetInt(); |
605 | pMsg->m_ScoreLimit = pUnpacker->GetInt(); |
606 | pMsg->m_TimeLimit = pUnpacker->GetInt(); |
607 | pMsg->m_MatchNum = pUnpacker->GetInt(); |
608 | pMsg->m_MatchCurrent = pUnpacker->GetInt(); |
609 | if(!CheckFlag(pErrorMsg: "m_GameFlags" , Value: pMsg->m_GameFlags, Mask: GAMEFLAG_TEAMS|GAMEFLAG_FLAGS|GAMEFLAG_SURVIVAL|GAMEFLAG_RACE)) break; |
610 | if(!CheckInt(pErrorMsg: "m_ScoreLimit" , Value: pMsg->m_ScoreLimit, Min: 0, Max: max_int)) break; |
611 | if(!CheckInt(pErrorMsg: "m_TimeLimit" , Value: pMsg->m_TimeLimit, Min: 0, Max: max_int)) break; |
612 | if(!CheckInt(pErrorMsg: "m_MatchNum" , Value: pMsg->m_MatchNum, Min: 0, Max: max_int)) break; |
613 | if(!CheckInt(pErrorMsg: "m_MatchCurrent" , Value: pMsg->m_MatchCurrent, Min: 0, Max: max_int)) break; |
614 | } break; |
615 | |
616 | case NETMSGTYPE_SV_CLIENTDROP: |
617 | { |
618 | CNetMsg_Sv_ClientDrop *pMsg = (CNetMsg_Sv_ClientDrop *)m_aMsgData; |
619 | (void)pMsg; |
620 | pMsg->m_ClientId = pUnpacker->GetInt(); |
621 | pMsg->m_pReason = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
622 | pMsg->m_Silent = pUnpacker->GetInt(); |
623 | if(!CheckInt(pErrorMsg: "m_ClientId" , Value: pMsg->m_ClientId, Min: 0, Max: MAX_CLIENTS-1)) break; |
624 | if(!CheckInt(pErrorMsg: "m_Silent" , Value: pMsg->m_Silent, Min: 0, Max: 1)) break; |
625 | } break; |
626 | |
627 | case NETMSGTYPE_SV_GAMEMSG: |
628 | { |
629 | CNetMsg_Sv_GameMsg *pMsg = (CNetMsg_Sv_GameMsg *)m_aMsgData; |
630 | (void)pMsg; |
631 | } break; |
632 | |
633 | case NETMSGTYPE_DE_CLIENTENTER: |
634 | { |
635 | CNetMsg_De_ClientEnter *pMsg = (CNetMsg_De_ClientEnter *)m_aMsgData; |
636 | (void)pMsg; |
637 | pMsg->m_pName = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
638 | pMsg->m_ClientId = pUnpacker->GetInt(); |
639 | pMsg->m_Team = pUnpacker->GetInt(); |
640 | if(!CheckInt(pErrorMsg: "m_ClientId" , Value: pMsg->m_ClientId, Min: -1, Max: MAX_CLIENTS-1)) break; |
641 | if(!CheckInt(pErrorMsg: "m_Team" , Value: pMsg->m_Team, Min: TEAM_SPECTATORS, Max: TEAM_BLUE)) break; |
642 | } break; |
643 | |
644 | case NETMSGTYPE_DE_CLIENTLEAVE: |
645 | { |
646 | CNetMsg_De_ClientLeave *pMsg = (CNetMsg_De_ClientLeave *)m_aMsgData; |
647 | (void)pMsg; |
648 | pMsg->m_pName = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
649 | pMsg->m_ClientId = pUnpacker->GetInt(); |
650 | pMsg->m_pReason = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
651 | if(!CheckInt(pErrorMsg: "m_ClientId" , Value: pMsg->m_ClientId, Min: -1, Max: MAX_CLIENTS-1)) break; |
652 | } break; |
653 | |
654 | case NETMSGTYPE_CL_SAY: |
655 | { |
656 | CNetMsg_Cl_Say *pMsg = (CNetMsg_Cl_Say *)m_aMsgData; |
657 | (void)pMsg; |
658 | pMsg->m_Mode = pUnpacker->GetInt(); |
659 | pMsg->m_Target = pUnpacker->GetInt(); |
660 | pMsg->m_pMessage = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
661 | if(!CheckInt(pErrorMsg: "m_Mode" , Value: pMsg->m_Mode, Min: 0, Max: NUM_CHATS-1)) break; |
662 | if(!CheckInt(pErrorMsg: "m_Target" , Value: pMsg->m_Target, Min: -1, Max: MAX_CLIENTS-1)) break; |
663 | } break; |
664 | |
665 | case NETMSGTYPE_CL_SETTEAM: |
666 | { |
667 | CNetMsg_Cl_SetTeam *pMsg = (CNetMsg_Cl_SetTeam *)m_aMsgData; |
668 | (void)pMsg; |
669 | pMsg->m_Team = pUnpacker->GetInt(); |
670 | if(!CheckInt(pErrorMsg: "m_Team" , Value: pMsg->m_Team, Min: TEAM_SPECTATORS, Max: TEAM_BLUE)) break; |
671 | } break; |
672 | |
673 | case NETMSGTYPE_CL_SETSPECTATORMODE: |
674 | { |
675 | CNetMsg_Cl_SetSpectatorMode *pMsg = (CNetMsg_Cl_SetSpectatorMode *)m_aMsgData; |
676 | (void)pMsg; |
677 | pMsg->m_SpecMode = pUnpacker->GetInt(); |
678 | pMsg->m_SpectatorId = pUnpacker->GetInt(); |
679 | if(!CheckInt(pErrorMsg: "m_SpecMode" , Value: pMsg->m_SpecMode, Min: 0, Max: NUM_SPECMODES-1)) break; |
680 | if(!CheckInt(pErrorMsg: "m_SpectatorId" , Value: pMsg->m_SpectatorId, Min: -1, Max: MAX_CLIENTS-1)) break; |
681 | } break; |
682 | |
683 | case NETMSGTYPE_CL_STARTINFO: |
684 | { |
685 | CNetMsg_Cl_StartInfo *pMsg = (CNetMsg_Cl_StartInfo *)m_aMsgData; |
686 | (void)pMsg; |
687 | pMsg->m_pName = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
688 | pMsg->m_pClan = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
689 | pMsg->m_Country = pUnpacker->GetInt(); |
690 | pMsg->m_apSkinPartNames[0] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
691 | pMsg->m_apSkinPartNames[1] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
692 | pMsg->m_apSkinPartNames[2] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
693 | pMsg->m_apSkinPartNames[3] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
694 | pMsg->m_apSkinPartNames[4] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
695 | pMsg->m_apSkinPartNames[5] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
696 | pMsg->m_aUseCustomColors[0] = pUnpacker->GetInt(); |
697 | pMsg->m_aUseCustomColors[1] = pUnpacker->GetInt(); |
698 | pMsg->m_aUseCustomColors[2] = pUnpacker->GetInt(); |
699 | pMsg->m_aUseCustomColors[3] = pUnpacker->GetInt(); |
700 | pMsg->m_aUseCustomColors[4] = pUnpacker->GetInt(); |
701 | pMsg->m_aUseCustomColors[5] = pUnpacker->GetInt(); |
702 | pMsg->m_aSkinPartColors[0] = pUnpacker->GetInt(); |
703 | pMsg->m_aSkinPartColors[1] = pUnpacker->GetInt(); |
704 | pMsg->m_aSkinPartColors[2] = pUnpacker->GetInt(); |
705 | pMsg->m_aSkinPartColors[3] = pUnpacker->GetInt(); |
706 | pMsg->m_aSkinPartColors[4] = pUnpacker->GetInt(); |
707 | pMsg->m_aSkinPartColors[5] = pUnpacker->GetInt(); |
708 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[0]" , Value: pMsg->m_aUseCustomColors[0], Min: 0, Max: 1)) break; |
709 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[1]" , Value: pMsg->m_aUseCustomColors[1], Min: 0, Max: 1)) break; |
710 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[2]" , Value: pMsg->m_aUseCustomColors[2], Min: 0, Max: 1)) break; |
711 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[3]" , Value: pMsg->m_aUseCustomColors[3], Min: 0, Max: 1)) break; |
712 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[4]" , Value: pMsg->m_aUseCustomColors[4], Min: 0, Max: 1)) break; |
713 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[5]" , Value: pMsg->m_aUseCustomColors[5], Min: 0, Max: 1)) break; |
714 | } break; |
715 | |
716 | case NETMSGTYPE_CL_KILL: |
717 | { |
718 | CNetMsg_Cl_Kill *pMsg = (CNetMsg_Cl_Kill *)m_aMsgData; |
719 | (void)pMsg; |
720 | } break; |
721 | |
722 | case NETMSGTYPE_CL_READYCHANGE: |
723 | { |
724 | CNetMsg_Cl_ReadyChange *pMsg = (CNetMsg_Cl_ReadyChange *)m_aMsgData; |
725 | (void)pMsg; |
726 | } break; |
727 | |
728 | case NETMSGTYPE_CL_EMOTICON: |
729 | { |
730 | CNetMsg_Cl_Emoticon *pMsg = (CNetMsg_Cl_Emoticon *)m_aMsgData; |
731 | (void)pMsg; |
732 | pMsg->m_Emoticon = pUnpacker->GetInt(); |
733 | if(!CheckInt(pErrorMsg: "m_Emoticon" , Value: pMsg->m_Emoticon, Min: 0, Max: 15)) break; |
734 | } break; |
735 | |
736 | case NETMSGTYPE_CL_VOTE: |
737 | { |
738 | CNetMsg_Cl_Vote *pMsg = (CNetMsg_Cl_Vote *)m_aMsgData; |
739 | (void)pMsg; |
740 | pMsg->m_Vote = pUnpacker->GetInt(); |
741 | if(!CheckInt(pErrorMsg: "m_Vote" , Value: pMsg->m_Vote, Min: -1, Max: 1)) break; |
742 | } break; |
743 | |
744 | case NETMSGTYPE_CL_CALLVOTE: |
745 | { |
746 | CNetMsg_Cl_CallVote *pMsg = (CNetMsg_Cl_CallVote *)m_aMsgData; |
747 | (void)pMsg; |
748 | pMsg->m_pType = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
749 | pMsg->m_pValue = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
750 | pMsg->m_pReason = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
751 | pMsg->m_Force = pUnpacker->GetInt(); |
752 | if(!CheckInt(pErrorMsg: "m_Force" , Value: pMsg->m_Force, Min: 0, Max: 1)) break; |
753 | } break; |
754 | |
755 | case NETMSGTYPE_SV_SKINCHANGE: |
756 | { |
757 | CNetMsg_Sv_SkinChange *pMsg = (CNetMsg_Sv_SkinChange *)m_aMsgData; |
758 | (void)pMsg; |
759 | pMsg->m_ClientId = pUnpacker->GetInt(); |
760 | pMsg->m_apSkinPartNames[0] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
761 | pMsg->m_apSkinPartNames[1] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
762 | pMsg->m_apSkinPartNames[2] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
763 | pMsg->m_apSkinPartNames[3] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
764 | pMsg->m_apSkinPartNames[4] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
765 | pMsg->m_apSkinPartNames[5] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
766 | pMsg->m_aUseCustomColors[0] = pUnpacker->GetInt(); |
767 | pMsg->m_aUseCustomColors[1] = pUnpacker->GetInt(); |
768 | pMsg->m_aUseCustomColors[2] = pUnpacker->GetInt(); |
769 | pMsg->m_aUseCustomColors[3] = pUnpacker->GetInt(); |
770 | pMsg->m_aUseCustomColors[4] = pUnpacker->GetInt(); |
771 | pMsg->m_aUseCustomColors[5] = pUnpacker->GetInt(); |
772 | pMsg->m_aSkinPartColors[0] = pUnpacker->GetInt(); |
773 | pMsg->m_aSkinPartColors[1] = pUnpacker->GetInt(); |
774 | pMsg->m_aSkinPartColors[2] = pUnpacker->GetInt(); |
775 | pMsg->m_aSkinPartColors[3] = pUnpacker->GetInt(); |
776 | pMsg->m_aSkinPartColors[4] = pUnpacker->GetInt(); |
777 | pMsg->m_aSkinPartColors[5] = pUnpacker->GetInt(); |
778 | if(!CheckInt(pErrorMsg: "m_ClientId" , Value: pMsg->m_ClientId, Min: 0, Max: MAX_CLIENTS-1)) break; |
779 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[0]" , Value: pMsg->m_aUseCustomColors[0], Min: 0, Max: 1)) break; |
780 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[1]" , Value: pMsg->m_aUseCustomColors[1], Min: 0, Max: 1)) break; |
781 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[2]" , Value: pMsg->m_aUseCustomColors[2], Min: 0, Max: 1)) break; |
782 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[3]" , Value: pMsg->m_aUseCustomColors[3], Min: 0, Max: 1)) break; |
783 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[4]" , Value: pMsg->m_aUseCustomColors[4], Min: 0, Max: 1)) break; |
784 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[5]" , Value: pMsg->m_aUseCustomColors[5], Min: 0, Max: 1)) break; |
785 | } break; |
786 | |
787 | case NETMSGTYPE_CL_SKINCHANGE: |
788 | { |
789 | CNetMsg_Cl_SkinChange *pMsg = (CNetMsg_Cl_SkinChange *)m_aMsgData; |
790 | (void)pMsg; |
791 | pMsg->m_apSkinPartNames[0] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
792 | pMsg->m_apSkinPartNames[1] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
793 | pMsg->m_apSkinPartNames[2] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
794 | pMsg->m_apSkinPartNames[3] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
795 | pMsg->m_apSkinPartNames[4] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
796 | pMsg->m_apSkinPartNames[5] = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
797 | pMsg->m_aUseCustomColors[0] = pUnpacker->GetInt(); |
798 | pMsg->m_aUseCustomColors[1] = pUnpacker->GetInt(); |
799 | pMsg->m_aUseCustomColors[2] = pUnpacker->GetInt(); |
800 | pMsg->m_aUseCustomColors[3] = pUnpacker->GetInt(); |
801 | pMsg->m_aUseCustomColors[4] = pUnpacker->GetInt(); |
802 | pMsg->m_aUseCustomColors[5] = pUnpacker->GetInt(); |
803 | pMsg->m_aSkinPartColors[0] = pUnpacker->GetInt(); |
804 | pMsg->m_aSkinPartColors[1] = pUnpacker->GetInt(); |
805 | pMsg->m_aSkinPartColors[2] = pUnpacker->GetInt(); |
806 | pMsg->m_aSkinPartColors[3] = pUnpacker->GetInt(); |
807 | pMsg->m_aSkinPartColors[4] = pUnpacker->GetInt(); |
808 | pMsg->m_aSkinPartColors[5] = pUnpacker->GetInt(); |
809 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[0]" , Value: pMsg->m_aUseCustomColors[0], Min: 0, Max: 1)) break; |
810 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[1]" , Value: pMsg->m_aUseCustomColors[1], Min: 0, Max: 1)) break; |
811 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[2]" , Value: pMsg->m_aUseCustomColors[2], Min: 0, Max: 1)) break; |
812 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[3]" , Value: pMsg->m_aUseCustomColors[3], Min: 0, Max: 1)) break; |
813 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[4]" , Value: pMsg->m_aUseCustomColors[4], Min: 0, Max: 1)) break; |
814 | if(!CheckInt(pErrorMsg: "m_aUseCustomColors[5]" , Value: pMsg->m_aUseCustomColors[5], Min: 0, Max: 1)) break; |
815 | } break; |
816 | |
817 | case NETMSGTYPE_SV_RACEFINISH: |
818 | { |
819 | CNetMsg_Sv_RaceFinish *pMsg = (CNetMsg_Sv_RaceFinish *)m_aMsgData; |
820 | (void)pMsg; |
821 | pMsg->m_ClientId = pUnpacker->GetInt(); |
822 | pMsg->m_Time = pUnpacker->GetInt(); |
823 | pMsg->m_Diff = pUnpacker->GetInt(); |
824 | pMsg->m_RecordPersonal = pUnpacker->GetInt(); |
825 | pMsg->m_RecordServer = pUnpacker->GetIntOrDefault(Default: 0); |
826 | if(!CheckInt(pErrorMsg: "m_ClientId" , Value: pMsg->m_ClientId, Min: 0, Max: MAX_CLIENTS-1)) break; |
827 | if(!CheckInt(pErrorMsg: "m_Time" , Value: pMsg->m_Time, Min: -1, Max: max_int)) break; |
828 | if(!CheckInt(pErrorMsg: "m_RecordPersonal" , Value: pMsg->m_RecordPersonal, Min: 0, Max: 1)) break; |
829 | if(!CheckInt(pErrorMsg: "m_RecordServer" , Value: pMsg->m_RecordServer, Min: 0, Max: 1)) break; |
830 | } break; |
831 | |
832 | case NETMSGTYPE_SV_CHECKPOINT: |
833 | { |
834 | CNetMsg_Sv_Checkpoint *pMsg = (CNetMsg_Sv_Checkpoint *)m_aMsgData; |
835 | (void)pMsg; |
836 | pMsg->m_Diff = pUnpacker->GetInt(); |
837 | } break; |
838 | |
839 | case NETMSGTYPE_SV_COMMANDINFO: |
840 | { |
841 | CNetMsg_Sv_CommandInfo *pMsg = (CNetMsg_Sv_CommandInfo *)m_aMsgData; |
842 | (void)pMsg; |
843 | pMsg->m_pName = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
844 | pMsg->m_pArgsFormat = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
845 | pMsg->m_pHelpText = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
846 | } break; |
847 | |
848 | case NETMSGTYPE_SV_COMMANDINFOREMOVE: |
849 | { |
850 | CNetMsg_Sv_CommandInfoRemove *pMsg = (CNetMsg_Sv_CommandInfoRemove *)m_aMsgData; |
851 | (void)pMsg; |
852 | pMsg->m_pName = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
853 | } break; |
854 | |
855 | case NETMSGTYPE_CL_COMMAND: |
856 | { |
857 | CNetMsg_Cl_Command *pMsg = (CNetMsg_Cl_Command *)m_aMsgData; |
858 | (void)pMsg; |
859 | pMsg->m_pName = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
860 | pMsg->m_pArguments = pUnpacker->GetString(SanitizeType: CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES); |
861 | } break; |
862 | |
863 | default: |
864 | m_pMsgFailedOn = "(type out of range)" ; |
865 | break; |
866 | } |
867 | |
868 | if(pUnpacker->Error()) |
869 | m_pMsgFailedOn = "(unpack error)" ; |
870 | |
871 | if(m_pMsgFailedOn || m_pObjFailedOn) { |
872 | if(!m_pMsgFailedOn) |
873 | m_pMsgFailedOn = "" ; |
874 | if(!m_pObjFailedOn) |
875 | m_pObjFailedOn = "" ; |
876 | return 0; |
877 | } |
878 | m_pMsgFailedOn = "" ; |
879 | m_pObjFailedOn = "" ; |
880 | return m_aMsgData; |
881 | }; |
882 | } |
883 | |
884 | |