mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-19 07:20:50 +00:00
Sanitize some of the differences in cl_parse.c.
Most of the differences in CL_ParseServerMessage are now protocol specific.
This commit is contained in:
parent
deddb5cb6a
commit
be8277c8c4
2 changed files with 72 additions and 70 deletions
|
@ -319,6 +319,7 @@ CL_NewMap (const char *mapname)
|
|||
{
|
||||
R_NewMap (cl.worldmodel, cl.model_precache, MAX_MODELS);
|
||||
Con_NewMap ();
|
||||
Hunk_Check (); // make sure nothing is hurt
|
||||
Sbar_CenterPrint (0);
|
||||
|
||||
if (cl.model_precache[1] && cl.model_precache[1]->entities) {
|
||||
|
@ -865,6 +866,14 @@ CL_ParseStaticSound (int version)
|
|||
S_StaticSound (cl.sound_precache[sound_num], org, vol, atten);
|
||||
}
|
||||
|
||||
static void
|
||||
CL_SetStat (int stat, int value)
|
||||
{
|
||||
if (stat < 0 || stat >= MAX_CL_STATS)
|
||||
Host_Error ("CL_SetStat: %i is invalid", stat);
|
||||
cl.stats[stat] = value;
|
||||
}
|
||||
|
||||
#define SHOWNET(x) \
|
||||
if (cl_shownet->int_val == 2) \
|
||||
Sys_Printf ("%3i:%s\n", net_message->readcount - 1, x);
|
||||
|
@ -874,7 +883,7 @@ int viewentity;
|
|||
void
|
||||
CL_ParseServerMessage (void)
|
||||
{
|
||||
int cmd, i;
|
||||
int cmd = 0, i, j;
|
||||
const char *str;
|
||||
|
||||
// if recording demos, copy the message out
|
||||
|
@ -890,13 +899,16 @@ CL_ParseServerMessage (void)
|
|||
|
||||
while (1) {
|
||||
if (net_message->badread)
|
||||
Host_Error ("CL_ParseServerMessage: Bad server message");
|
||||
Host_Error ("CL_ParseServerMessage: Bad server message: %s\n",
|
||||
svc_strings[cmd]);
|
||||
|
||||
cmd = MSG_ReadByte (net_message);
|
||||
|
||||
if (cmd == -1) {
|
||||
net_message->readcount++; // so the EOM SHOWNET has the right
|
||||
// value
|
||||
SHOWNET ("END OF MESSAGE");
|
||||
return; // end of message
|
||||
break; // end of message
|
||||
}
|
||||
// if the high bit of the command byte is set, it is a fast update
|
||||
if (cmd & U_SIGNAL) {
|
||||
|
@ -911,7 +923,7 @@ CL_ParseServerMessage (void)
|
|||
switch (cmd) {
|
||||
default:
|
||||
Host_Error ("CL_ParseServerMessage: Illegible server "
|
||||
"message\n");
|
||||
"message %d\n", cmd);
|
||||
break;
|
||||
|
||||
case svc_nop:
|
||||
|
@ -965,9 +977,12 @@ CL_ParseServerMessage (void)
|
|||
break;
|
||||
|
||||
case svc_setangle:
|
||||
MSG_ReadAngleV (net_message, cl.viewangles);
|
||||
break;
|
||||
{
|
||||
vec_t *dest = cl.viewangles;
|
||||
|
||||
MSG_ReadAngleV (net_message, dest);
|
||||
break;
|
||||
}
|
||||
case svc_setview:
|
||||
cl.viewentity = MSG_ReadShort (net_message);
|
||||
viewentity = cl.viewentity; // FIXME: evil hack
|
||||
|
@ -976,7 +991,7 @@ CL_ParseServerMessage (void)
|
|||
case svc_lightstyle:
|
||||
i = MSG_ReadByte (net_message);
|
||||
if (i >= MAX_LIGHTSTYLES)
|
||||
Sys_Error ("svc_lightstyle > MAX_LIGHTSTYLES");
|
||||
Host_Error ("svc_lightstyle > MAX_LIGHTSTYLES");
|
||||
strcpy (r_lightstyle[i].map, MSG_ReadString (net_message));
|
||||
r_lightstyle[i].length = strlen (r_lightstyle[i].map);
|
||||
// FIXME extra info
|
||||
|
@ -991,15 +1006,6 @@ CL_ParseServerMessage (void)
|
|||
S_StopSound (i >> 3, i & 7);
|
||||
break;
|
||||
|
||||
case svc_updatename:
|
||||
Sbar_Changed ();
|
||||
i = MSG_ReadByte (net_message);
|
||||
if (i >= cl.maxclients)
|
||||
Host_Error ("CL_ParseServerMessage: svc_updatename > "
|
||||
"MAX_SCOREBOARD");
|
||||
strcpy (cl.scores[i].name, MSG_ReadString (net_message));
|
||||
break;
|
||||
|
||||
case svc_updatefrags:
|
||||
Sbar_Changed ();
|
||||
i = MSG_ReadByte (net_message);
|
||||
|
@ -1009,6 +1015,15 @@ CL_ParseServerMessage (void)
|
|||
cl.scores[i].frags = (short) MSG_ReadShort (net_message);
|
||||
break;
|
||||
|
||||
case svc_updatename:
|
||||
Sbar_Changed ();
|
||||
i = MSG_ReadByte (net_message);
|
||||
if (i >= cl.maxclients)
|
||||
Host_Error ("CL_ParseServerMessage: svc_updatename > "
|
||||
"MAX_SCOREBOARD");
|
||||
strcpy (cl.scores[i].name, MSG_ReadString (net_message));
|
||||
break;
|
||||
|
||||
case svc_updatecolors:
|
||||
Sbar_Changed ();
|
||||
i = MSG_ReadByte (net_message);
|
||||
|
@ -1037,21 +1052,20 @@ CL_ParseServerMessage (void)
|
|||
case svc_spawnstatic:
|
||||
CL_ParseStatic (1);
|
||||
break;
|
||||
case svc_spawnstaticsound:
|
||||
CL_ParseStaticSound (1);
|
||||
break;
|
||||
case svc_temp_entity:
|
||||
CL_ParseTEnt ();
|
||||
break;
|
||||
|
||||
case svc_setpause:
|
||||
{
|
||||
r_paused = cl.paused = MSG_ReadByte (net_message);
|
||||
|
||||
if (cl.paused) {
|
||||
if (cl.paused)
|
||||
CDAudio_Pause ();
|
||||
} else {
|
||||
else
|
||||
CDAudio_Resume ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case svc_signonnum:
|
||||
i = MSG_ReadByte (net_message);
|
||||
|
@ -1072,13 +1086,8 @@ CL_ParseServerMessage (void)
|
|||
|
||||
case svc_updatestat:
|
||||
i = MSG_ReadByte (net_message);
|
||||
if (i < 0 || i >= MAX_CL_STATS)
|
||||
Sys_Error ("svc_updatestat: %i is invalid", i);
|
||||
cl.stats[i] = MSG_ReadLong (net_message);
|
||||
break;
|
||||
|
||||
case svc_spawnstaticsound:
|
||||
CL_ParseStaticSound (1);
|
||||
j = MSG_ReadLong (net_message);
|
||||
CL_SetStat (i, j);
|
||||
break;
|
||||
|
||||
case svc_cdtrack:
|
||||
|
|
|
@ -1239,16 +1239,16 @@ CL_MuzzleFlash (void)
|
|||
|
||||
#define SHOWNET(x) \
|
||||
if (cl_shownet->int_val == 2) \
|
||||
Sys_Printf ("%3i:%s\n", net_message->readcount-1, x);
|
||||
Sys_Printf ("%3i:%s\n", net_message->readcount - 1, x);
|
||||
|
||||
int received_framecount;
|
||||
|
||||
void
|
||||
CL_ParseServerMessage (void)
|
||||
{
|
||||
int cmd = 0, i, j;
|
||||
const char *str;
|
||||
static dstring_t *stuffbuf;
|
||||
int cmd = 0, i, j;
|
||||
|
||||
received_framecount = host_framecount;
|
||||
cl.last_servermessage = realtime;
|
||||
|
@ -1265,11 +1265,9 @@ CL_ParseServerMessage (void)
|
|||
|
||||
// parse the message
|
||||
while (1) {
|
||||
if (net_message->badread) {
|
||||
if (net_message->badread)
|
||||
Host_Error ("CL_ParseServerMessage: Bad server message: %s\n",
|
||||
svc_strings[cmd]);
|
||||
break;
|
||||
}
|
||||
|
||||
cmd = MSG_ReadByte (net_message);
|
||||
|
||||
|
@ -1277,10 +1275,10 @@ CL_ParseServerMessage (void)
|
|||
net_message->readcount++; // so the EOM SHOWNET has the right
|
||||
// value
|
||||
SHOWNET ("END OF MESSAGE");
|
||||
break;
|
||||
break; // end of message
|
||||
}
|
||||
|
||||
SHOWNET (svc_strings[cmd]);
|
||||
SHOWNET (va ("%s(%d)", svc_strings[cmd], cmd));
|
||||
|
||||
// other commands
|
||||
switch (cmd) {
|
||||
|
@ -1300,7 +1298,8 @@ CL_ParseServerMessage (void)
|
|||
Host_EndGame ("Server disconnected");
|
||||
break;
|
||||
|
||||
case svc_print: {
|
||||
case svc_print:
|
||||
{
|
||||
dstring_t *p = 0;
|
||||
|
||||
i = MSG_ReadByte (net_message);
|
||||
|
@ -1365,6 +1364,24 @@ CL_ParseServerMessage (void)
|
|||
V_ParseDamage ();
|
||||
break;
|
||||
|
||||
case svc_serverinfo:
|
||||
CL_ServerInfo ();
|
||||
break;
|
||||
|
||||
case svc_setangle:
|
||||
{
|
||||
vec_t *dest = cl.viewangles;
|
||||
vec3_t dummy;
|
||||
|
||||
if (cls.demoplayback2) {
|
||||
j = MSG_ReadByte (net_message);
|
||||
// fixangle |= 1 << j;
|
||||
if (j != Cam_TrackNum ())
|
||||
dest = dummy;
|
||||
}
|
||||
MSG_ReadAngleV (net_message, dest);
|
||||
break;
|
||||
}
|
||||
case svc_serverdata:
|
||||
// make sure any stuffed commands are done
|
||||
Cbuf_Execute_Stack (cl_stbuf);
|
||||
|
@ -1372,23 +1389,6 @@ CL_ParseServerMessage (void)
|
|||
vid.recalc_refdef = true; // leave full screen intermission
|
||||
break;
|
||||
|
||||
case svc_setangle:
|
||||
if (!cls.demoplayback2) {
|
||||
MSG_ReadAngleV (net_message, cl.viewangles);
|
||||
} else {
|
||||
j = MSG_ReadByte (net_message);
|
||||
// fixangle |= 1 << j;
|
||||
if (j != Cam_TrackNum ()) {
|
||||
MSG_ReadAngle (net_message);
|
||||
MSG_ReadAngle (net_message);
|
||||
MSG_ReadAngle (net_message);
|
||||
} else {
|
||||
MSG_ReadAngleV (net_message, cl.viewangles);
|
||||
}
|
||||
}
|
||||
// FIXME cl.viewangles[PITCH] = cl.viewangles[ROLL] = 0;
|
||||
break;
|
||||
|
||||
case svc_lightstyle:
|
||||
i = MSG_ReadByte (net_message);
|
||||
if (i >= MAX_LIGHTSTYLES)
|
||||
|
@ -1445,19 +1445,24 @@ CL_ParseServerMessage (void)
|
|||
i = MSG_ReadShort (net_message);
|
||||
CL_ParseBaseline (&cl_baselines[i]);
|
||||
break;
|
||||
|
||||
case svc_spawnstatic:
|
||||
CL_ParseStatic ();
|
||||
break;
|
||||
|
||||
case svc_spawnstaticsound:
|
||||
CL_ParseStaticSound ();
|
||||
break;
|
||||
|
||||
case svc_temp_entity:
|
||||
CL_ParseTEnt ();
|
||||
break;
|
||||
|
||||
case svc_setpause:
|
||||
r_paused = cl.paused = MSG_ReadByte (net_message);
|
||||
if (cl.paused)
|
||||
CDAudio_Pause ();
|
||||
else
|
||||
CDAudio_Resume ();
|
||||
break;
|
||||
|
||||
case svc_killedmonster:
|
||||
cl.stats[STAT_MONSTERS]++;
|
||||
break;
|
||||
|
@ -1544,10 +1549,6 @@ CL_ParseServerMessage (void)
|
|||
CL_SetInfo ();
|
||||
break;
|
||||
|
||||
case svc_serverinfo:
|
||||
CL_ServerInfo ();
|
||||
break;
|
||||
|
||||
case svc_download:
|
||||
CL_ParseDownload ();
|
||||
break;
|
||||
|
@ -1594,14 +1595,6 @@ CL_ParseServerMessage (void)
|
|||
case svc_entgravity:
|
||||
movevars.entgravity = MSG_ReadFloat (net_message);
|
||||
break;
|
||||
|
||||
case svc_setpause:
|
||||
r_paused = cl.paused = MSG_ReadByte (net_message);
|
||||
if (cl.paused)
|
||||
CDAudio_Pause ();
|
||||
else
|
||||
CDAudio_Resume ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue