-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcl_parse_quakeworld.c.h
More file actions
374 lines (315 loc) · 10.4 KB
/
Copy pathcl_parse_quakeworld.c.h
File metadata and controls
374 lines (315 loc) · 10.4 KB
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
// cl_parse_quakeworld.c.h
WARP_X_ (CL_ParseServerMessage)
CL_NetworkTimeReceived(host.realtime); // qw has no clock
// kill all qw nails
cl.qw_num_nails = 0;
// fade weapon view kick
cl.qw_weaponkick = min(cl.qw_weaponkick + 10 * bound(0, cl.time - cl.oldtime, 0.1), 0);
cls.servermovesequence = cls.netcon->qw.incoming_sequence;
qwplayerupdatereceived = false;
while (1) {
if (cl_message.badread)
Host_Error_Line ("CL_ParseServerMessage: Bad QW server message");
cmd = MSG_ReadByte(&cl_message);
if (cmd == -1)
{
SHOWNET("END OF MESSAGE");
break; // end of message
}
cmdindex = cmdcount & 31;
cmdcount++;
cmdlog[cmdindex] = cmd;
SHOWNET(qw_svc_strings[cmd]);
cmdlogname[cmdindex] = qw_svc_strings[cmd];
if (!cmdlogname[cmdindex])
{
// LadyHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
const char *d = "<unknown>";
cmdlogname[cmdindex] = d;
}
// other commands
switch (cmd)
{
default:
{
char description[32*64], logtemp[64];
int count;
strlcpy(description, "packet dump: ", sizeof(description));
j = cmdcount - 32;
if (j < 0)
j = 0;
count = cmdcount - j;
j &= 31;
while(count > 0) {
dpsnprintf(logtemp, sizeof(logtemp), "%3d:%s ", cmdlog[j], cmdlogname[j]);
strlcat(description, logtemp, sizeof(description));
count--;
j++;
j &= 31;
}
description[strlen(description)-1] = '\n'; // replace the last space with a newline
Con_Print(description);
Host_Error_Line ("CL_ParseServerMessage: Illegible server message");
}
break;
case qw_svc_nop:
//Con_Printf ("qw_svc_nop\n");
break;
case qw_svc_disconnect:
if (cls.demonum != -1)
CL_NextDemo();
else
CL_DisconnectEx(q_is_kicked_true, "Server disconnected");
break;
case qw_svc_print:
// CTEXT
j = MSG_ReadByte(&cl_message);
str = MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring));
if (CL_ExaminePrintString(str)) { // look for anything interesting like player IP addresses or ping reports
if (j == 3) {
// chat
va(vabuf, sizeof(vabuf), "\1%s", str);
if (1 /*cl_pext_qw_coloredtext.value*/ && String_Contains (vabuf, "&"))
CSQC_AddPrintTextQWColor (vabuf);
else
CSQC_AddPrintText(vabuf); //[515]: csqc
}
else {
if (1 /*cl_pext_qw_coloredtext.value*/ && String_Contains (str, "&"))
CSQC_AddPrintTextQWColor (str);
else
CSQC_AddPrintText(str);
}
}
break;
case qw_svc_centerprint:
// CTEXT
CL_VM_Parse_CenterPrint(MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring))); //[515]: csqc
break;
case qw_svc_stufftext:
// CTEXT
CL_VM_Parse_StuffCmd(MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring)), q_is_quakeworld_true); //[515]: csqc
break;
case qw_svc_damage:
// svc_damage protocol is identical to nq
V_ParseDamage ();
break;
// Baker: FS_ChangeGameDirs occurs here.
case qw_svc_serverdata:
//Cbuf_Execute(); // make sure any stuffed commands are done
CL_ParseServerInfo(q_is_quakeworld_true);
gamedir_change:
break;
case qw_svc_setangle:
for (j = 0 ; j < 3 ; j ++)
cl.viewangles[j] = MSG_ReadAngle(&cl_message, cls.protocol);
if (!cls.demoplayback)
{
cl.fixangle[0] = true;
VectorCopy(cl.viewangles, cl.mviewangles[0]);
// disable interpolation if this is new
if (!cl.fixangle[1])
VectorCopy(cl.viewangles, cl.mviewangles[1]);
}
break;
case qw_svc_lightstyle:
j = MSG_ReadByte(&cl_message);
if (j >= cl.max_lightstyle)
{
Con_PrintLinef ("svc_lightstyle >= MAX_LIGHTSTYLES_256");
break;
}
strlcpy (cl.lightstyle[j].map, MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring)), sizeof (cl.lightstyle[j].map));
cl.lightstyle[j].map[MAX_STYLESTRING_64 - 1] = 0;
cl.lightstyle[j].length = (int)strlen(cl.lightstyle[j].map);
break;
case qw_svc_sound:
CL_ParseStartSoundPacket (q_is_large_soundindex_false);
break;
case qw_svc_stopsound:
j = (unsigned short) MSG_ReadShort(&cl_message);
S_StopSound(j>>3, j&7);
break;
case qw_svc_updatefrags:
j = MSG_ReadByte(&cl_message);
if (j >= cl.maxclients)
Host_Error_Line ("CL_ParseServerMessage: svc_updatefrags >= cl.maxclients");
cl.scores[j].frags = (signed short) MSG_ReadShort(&cl_message);
break;
case qw_svc_updateping:
j = MSG_ReadByte(&cl_message);
if (j >= cl.maxclients)
Host_Error_Line ("CL_ParseServerMessage: svc_updateping >= cl.maxclients");
cl.scores[j].qw_ping = MSG_ReadShort(&cl_message);
break;
case qw_svc_updatepl:
j = MSG_ReadByte(&cl_message);
if (j >= cl.maxclients)
Host_Error_Line ("CL_ParseServerMessage: svc_updatepl >= cl.maxclients");
cl.scores[j].qw_packetloss = MSG_ReadByte(&cl_message);
break;
case qw_svc_updateentertime:
j = MSG_ReadByte(&cl_message);
if (j >= cl.maxclients)
Host_Error_Line ("CL_ParseServerMessage: svc_updateentertime >= cl.maxclients");
// seconds ago
cl.scores[j].qw_entertime = cl.time - MSG_ReadFloat(&cl_message);
break;
case qw_svc_spawnbaseline:
j = (unsigned short) MSG_ReadShort(&cl_message);
if (j < 0 || j >= MAX_EDICTS_32768)
Host_Error_Line ("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %d", j);
if (j >= cl.max_entities)
CL_ExpandEntities(j);
CL_ParseBaseline(cl.entities + j, q_is_large_modelindex_false, q_fitz_version_none_0, q_is_static_false);
break;
case qw_svc_spawnstatic:
CL_ParseStatic(q_is_large_modelindex_false, q_fitz_version_none_0);
break;
case qw_svc_temp_entity:
if (!CL_VM_Parse_TempEntity())
CL_ParseTempEntity ();
break;
case qw_svc_killedmonster:
cl.stats[STAT_MONSTERS]++;
break;
case qw_svc_foundsecret:
cl.stats[STAT_SECRETS]++;
break;
case qw_svc_updatestat:
j = MSG_ReadByte(&cl_message);
if (j < 0 || j >= MAX_CL_STATS_256)
Host_Error_Line ("svc_updatestat: %d is invalid", j);
cl.stats[j] = MSG_ReadByte(&cl_message);
break;
case qw_svc_updatestatlong:
j = MSG_ReadByte(&cl_message);
if (j < 0 || j >= MAX_CL_STATS_256)
Host_Error_Line ("svc_updatestatlong: %d is invalid", j);
cl.stats[j] = MSG_ReadLong(&cl_message);
break;
case qw_svc_spawnstaticsound:
CL_ParseStaticSound (q_is_large_soundindex_false, q_fitz_version_none_0);
break;
case qw_svc_cdtrack:
cl.cdtrack = cl.looptrack = MSG_ReadByte(&cl_message);
if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
CDAudio_Play ((unsigned char)cls.forcetrack, q_looping_true);
else
CDAudio_Play ((unsigned char)cl.cdtrack, q_looping_true);
break;
case qw_svc_intermission:
if (!cl.intermission)
cl.completed_time = cl.time;
cl.intermission = 1;
MSG_ReadVector(&cl_message, cl.qw_intermission_origin, cls.protocol);
for (j = 0; j < 3; j++)
cl.qw_intermission_angles[j] = MSG_ReadAngle(&cl_message, cls.protocol);
break;
case qw_svc_finale:
if (!cl.intermission)
cl.completed_time = cl.time;
cl.intermission = 2;
SCR_CenterPrint(MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring)));
break;
case qw_svc_sellscreen:
Cmd_ExecuteString(cmd_local, "help", src_local, true);
break;
case qw_svc_smallkick:
cl.qw_weaponkick = -2;
break;
case qw_svc_bigkick:
cl.qw_weaponkick = -4;
break;
case qw_svc_muzzleflash:
j = (unsigned short) MSG_ReadShort(&cl_message);
// NOTE: in QW this only worked on clients
if (j < 0 || j >= MAX_EDICTS_32768)
Host_Error_Line ("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %d", j);
if (j >= cl.max_entities)
CL_ExpandEntities(j);
cl.entities[j].persistent.muzzleflash = 1.0f;
break;
case qw_svc_updateuserinfo:
QW_CL_UpdateUserInfo();
break;
case qw_svc_setinfo:
QW_CL_SetInfo();
break;
case qw_svc_serverinfo:
QW_CL_ServerInfo(); // HEREON
break;
case qw_svc_download:
QW_CL_ParseDownload(q_is_oob_false);
break;
case qw_svc_playerinfo:
// slightly kill qw player entities now that we know there is
// an update of player entities this frame...
if (!qwplayerupdatereceived) {
qwplayerupdatereceived = true;
for (j = 1; j < cl.maxclients; j++)
cl.entities_active[j] = false;
}
EntityStateQW_ReadPlayerUpdate();
break;
case qw_svc_nails:
QW_CL_ParseNails();
break;
case qw_svc_chokecount:
(void) MSG_ReadByte(&cl_message);
// FIXME: apply to netgraph
//for (j = 0;j < j;j++)
// cl.frames[(cls.netcon->qw.incoming_acknowledged-1-j)&QW_UPDATE_MASK_63].receivedtime = -2;
break;
case qw_svc_modellist:
QW_CL_ParseModelList (q_is_doublewidth_false);
break;
case qw_svc_fte_modellistshort:
QW_CL_ParseModelList (q_is_doublewidth_true);
break;
case qw_svc_soundlist:
QW_CL_ParseSoundList();
break;
case qw_svc_packetentities:
EntityFrameQW_CL_ReadFrame (q_is_delta_false);
// first update is the final signon stage
if (cls.signon == SIGNONS_4 - 1) {
cls.signon = SIGNONS_4; // QUAKEWORLD
CL_SignonReply ();
cls.world_frames = 0; cls.world_start_realtime = 0;
}
break;
case qw_svc_deltapacketentities:
EntityFrameQW_CL_ReadFrame (q_is_delta_true);
// first update is the final signon stage
if (cls.signon == SIGNONS_4 - 1) {
cls.signon = SIGNONS_4; // QUAKEWORLD
CL_SignonReply ();
cls.world_frames = 0; cls.world_start_realtime = 0;
}
break;
case qw_svc_maxspeed:
cl.movevars_maxspeed = MSG_ReadFloat(&cl_message);
break;
case qw_svc_entgravity:
cl.movevars_entgravity = MSG_ReadFloat(&cl_message);
if (!cl.movevars_entgravity)
cl.movevars_entgravity = 1.0f;
break;
case qw_svc_setpause:
cl.paused = MSG_ReadByte(&cl_message) != 0;
if (cl.paused && snd_cdautopause.integer)
CDAudio_Pause ();
else if (bgmvolume.value > 0.0f)
CDAudio_Resume ();
S_PauseGameSounds (cl.paused);
break;
}
}
if (qwplayerupdatereceived)
{
// fully kill any player entities that were not updated this frame
for (j = 1; j <= cl.maxclients; j++)
if (!cl.entities_active[j])
cl.entities[j].state_current.active = false;
}