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);
|
R_NewMap (cl.worldmodel, cl.model_precache, MAX_MODELS);
|
||||||
Con_NewMap ();
|
Con_NewMap ();
|
||||||
|
Hunk_Check (); // make sure nothing is hurt
|
||||||
Sbar_CenterPrint (0);
|
Sbar_CenterPrint (0);
|
||||||
|
|
||||||
if (cl.model_precache[1] && cl.model_precache[1]->entities) {
|
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);
|
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) \
|
#define SHOWNET(x) \
|
||||||
if (cl_shownet->int_val == 2) \
|
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);
|
||||||
|
@ -874,7 +883,7 @@ int viewentity;
|
||||||
void
|
void
|
||||||
CL_ParseServerMessage (void)
|
CL_ParseServerMessage (void)
|
||||||
{
|
{
|
||||||
int cmd, i;
|
int cmd = 0, i, j;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
// if recording demos, copy the message out
|
// if recording demos, copy the message out
|
||||||
|
@ -890,13 +899,16 @@ CL_ParseServerMessage (void)
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (net_message->badread)
|
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);
|
cmd = MSG_ReadByte (net_message);
|
||||||
|
|
||||||
if (cmd == -1) {
|
if (cmd == -1) {
|
||||||
|
net_message->readcount++; // so the EOM SHOWNET has the right
|
||||||
|
// value
|
||||||
SHOWNET ("END OF MESSAGE");
|
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 the high bit of the command byte is set, it is a fast update
|
||||||
if (cmd & U_SIGNAL) {
|
if (cmd & U_SIGNAL) {
|
||||||
|
@ -911,7 +923,7 @@ CL_ParseServerMessage (void)
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
default:
|
default:
|
||||||
Host_Error ("CL_ParseServerMessage: Illegible server "
|
Host_Error ("CL_ParseServerMessage: Illegible server "
|
||||||
"message\n");
|
"message %d\n", cmd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case svc_nop:
|
case svc_nop:
|
||||||
|
@ -965,9 +977,12 @@ CL_ParseServerMessage (void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case svc_setangle:
|
case svc_setangle:
|
||||||
MSG_ReadAngleV (net_message, cl.viewangles);
|
{
|
||||||
break;
|
vec_t *dest = cl.viewangles;
|
||||||
|
|
||||||
|
MSG_ReadAngleV (net_message, dest);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case svc_setview:
|
case svc_setview:
|
||||||
cl.viewentity = MSG_ReadShort (net_message);
|
cl.viewentity = MSG_ReadShort (net_message);
|
||||||
viewentity = cl.viewentity; // FIXME: evil hack
|
viewentity = cl.viewentity; // FIXME: evil hack
|
||||||
|
@ -976,7 +991,7 @@ CL_ParseServerMessage (void)
|
||||||
case svc_lightstyle:
|
case svc_lightstyle:
|
||||||
i = MSG_ReadByte (net_message);
|
i = MSG_ReadByte (net_message);
|
||||||
if (i >= MAX_LIGHTSTYLES)
|
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));
|
strcpy (r_lightstyle[i].map, MSG_ReadString (net_message));
|
||||||
r_lightstyle[i].length = strlen (r_lightstyle[i].map);
|
r_lightstyle[i].length = strlen (r_lightstyle[i].map);
|
||||||
// FIXME extra info
|
// FIXME extra info
|
||||||
|
@ -991,15 +1006,6 @@ CL_ParseServerMessage (void)
|
||||||
S_StopSound (i >> 3, i & 7);
|
S_StopSound (i >> 3, i & 7);
|
||||||
break;
|
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:
|
case svc_updatefrags:
|
||||||
Sbar_Changed ();
|
Sbar_Changed ();
|
||||||
i = MSG_ReadByte (net_message);
|
i = MSG_ReadByte (net_message);
|
||||||
|
@ -1009,6 +1015,15 @@ CL_ParseServerMessage (void)
|
||||||
cl.scores[i].frags = (short) MSG_ReadShort (net_message);
|
cl.scores[i].frags = (short) MSG_ReadShort (net_message);
|
||||||
break;
|
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:
|
case svc_updatecolors:
|
||||||
Sbar_Changed ();
|
Sbar_Changed ();
|
||||||
i = MSG_ReadByte (net_message);
|
i = MSG_ReadByte (net_message);
|
||||||
|
@ -1037,21 +1052,20 @@ CL_ParseServerMessage (void)
|
||||||
case svc_spawnstatic:
|
case svc_spawnstatic:
|
||||||
CL_ParseStatic (1);
|
CL_ParseStatic (1);
|
||||||
break;
|
break;
|
||||||
|
case svc_spawnstaticsound:
|
||||||
|
CL_ParseStaticSound (1);
|
||||||
|
break;
|
||||||
case svc_temp_entity:
|
case svc_temp_entity:
|
||||||
CL_ParseTEnt ();
|
CL_ParseTEnt ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case svc_setpause:
|
case svc_setpause:
|
||||||
{
|
|
||||||
r_paused = cl.paused = MSG_ReadByte (net_message);
|
r_paused = cl.paused = MSG_ReadByte (net_message);
|
||||||
|
if (cl.paused)
|
||||||
if (cl.paused) {
|
|
||||||
CDAudio_Pause ();
|
CDAudio_Pause ();
|
||||||
} else {
|
else
|
||||||
CDAudio_Resume ();
|
CDAudio_Resume ();
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case svc_signonnum:
|
case svc_signonnum:
|
||||||
i = MSG_ReadByte (net_message);
|
i = MSG_ReadByte (net_message);
|
||||||
|
@ -1072,13 +1086,8 @@ CL_ParseServerMessage (void)
|
||||||
|
|
||||||
case svc_updatestat:
|
case svc_updatestat:
|
||||||
i = MSG_ReadByte (net_message);
|
i = MSG_ReadByte (net_message);
|
||||||
if (i < 0 || i >= MAX_CL_STATS)
|
j = MSG_ReadLong (net_message);
|
||||||
Sys_Error ("svc_updatestat: %i is invalid", i);
|
CL_SetStat (i, j);
|
||||||
cl.stats[i] = MSG_ReadLong (net_message);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case svc_spawnstaticsound:
|
|
||||||
CL_ParseStaticSound (1);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case svc_cdtrack:
|
case svc_cdtrack:
|
||||||
|
|
|
@ -1239,16 +1239,16 @@ CL_MuzzleFlash (void)
|
||||||
|
|
||||||
#define SHOWNET(x) \
|
#define SHOWNET(x) \
|
||||||
if (cl_shownet->int_val == 2) \
|
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;
|
int received_framecount;
|
||||||
|
|
||||||
void
|
void
|
||||||
CL_ParseServerMessage (void)
|
CL_ParseServerMessage (void)
|
||||||
{
|
{
|
||||||
|
int cmd = 0, i, j;
|
||||||
const char *str;
|
const char *str;
|
||||||
static dstring_t *stuffbuf;
|
static dstring_t *stuffbuf;
|
||||||
int cmd = 0, i, j;
|
|
||||||
|
|
||||||
received_framecount = host_framecount;
|
received_framecount = host_framecount;
|
||||||
cl.last_servermessage = realtime;
|
cl.last_servermessage = realtime;
|
||||||
|
@ -1265,11 +1265,9 @@ CL_ParseServerMessage (void)
|
||||||
|
|
||||||
// parse the message
|
// parse the message
|
||||||
while (1) {
|
while (1) {
|
||||||
if (net_message->badread) {
|
if (net_message->badread)
|
||||||
Host_Error ("CL_ParseServerMessage: Bad server message: %s\n",
|
Host_Error ("CL_ParseServerMessage: Bad server message: %s\n",
|
||||||
svc_strings[cmd]);
|
svc_strings[cmd]);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd = MSG_ReadByte (net_message);
|
cmd = MSG_ReadByte (net_message);
|
||||||
|
|
||||||
|
@ -1277,10 +1275,10 @@ CL_ParseServerMessage (void)
|
||||||
net_message->readcount++; // so the EOM SHOWNET has the right
|
net_message->readcount++; // so the EOM SHOWNET has the right
|
||||||
// value
|
// value
|
||||||
SHOWNET ("END OF MESSAGE");
|
SHOWNET ("END OF MESSAGE");
|
||||||
break;
|
break; // end of message
|
||||||
}
|
}
|
||||||
|
|
||||||
SHOWNET (svc_strings[cmd]);
|
SHOWNET (va ("%s(%d)", svc_strings[cmd], cmd));
|
||||||
|
|
||||||
// other commands
|
// other commands
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
@ -1300,7 +1298,8 @@ CL_ParseServerMessage (void)
|
||||||
Host_EndGame ("Server disconnected");
|
Host_EndGame ("Server disconnected");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case svc_print: {
|
case svc_print:
|
||||||
|
{
|
||||||
dstring_t *p = 0;
|
dstring_t *p = 0;
|
||||||
|
|
||||||
i = MSG_ReadByte (net_message);
|
i = MSG_ReadByte (net_message);
|
||||||
|
@ -1365,6 +1364,24 @@ CL_ParseServerMessage (void)
|
||||||
V_ParseDamage ();
|
V_ParseDamage ();
|
||||||
break;
|
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:
|
case svc_serverdata:
|
||||||
// make sure any stuffed commands are done
|
// make sure any stuffed commands are done
|
||||||
Cbuf_Execute_Stack (cl_stbuf);
|
Cbuf_Execute_Stack (cl_stbuf);
|
||||||
|
@ -1372,23 +1389,6 @@ CL_ParseServerMessage (void)
|
||||||
vid.recalc_refdef = true; // leave full screen intermission
|
vid.recalc_refdef = true; // leave full screen intermission
|
||||||
break;
|
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:
|
case svc_lightstyle:
|
||||||
i = MSG_ReadByte (net_message);
|
i = MSG_ReadByte (net_message);
|
||||||
if (i >= MAX_LIGHTSTYLES)
|
if (i >= MAX_LIGHTSTYLES)
|
||||||
|
@ -1445,19 +1445,24 @@ CL_ParseServerMessage (void)
|
||||||
i = MSG_ReadShort (net_message);
|
i = MSG_ReadShort (net_message);
|
||||||
CL_ParseBaseline (&cl_baselines[i]);
|
CL_ParseBaseline (&cl_baselines[i]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case svc_spawnstatic:
|
case svc_spawnstatic:
|
||||||
CL_ParseStatic ();
|
CL_ParseStatic ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case svc_spawnstaticsound:
|
case svc_spawnstaticsound:
|
||||||
CL_ParseStaticSound ();
|
CL_ParseStaticSound ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case svc_temp_entity:
|
case svc_temp_entity:
|
||||||
CL_ParseTEnt ();
|
CL_ParseTEnt ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case svc_setpause:
|
||||||
|
r_paused = cl.paused = MSG_ReadByte (net_message);
|
||||||
|
if (cl.paused)
|
||||||
|
CDAudio_Pause ();
|
||||||
|
else
|
||||||
|
CDAudio_Resume ();
|
||||||
|
break;
|
||||||
|
|
||||||
case svc_killedmonster:
|
case svc_killedmonster:
|
||||||
cl.stats[STAT_MONSTERS]++;
|
cl.stats[STAT_MONSTERS]++;
|
||||||
break;
|
break;
|
||||||
|
@ -1544,10 +1549,6 @@ CL_ParseServerMessage (void)
|
||||||
CL_SetInfo ();
|
CL_SetInfo ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case svc_serverinfo:
|
|
||||||
CL_ServerInfo ();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case svc_download:
|
case svc_download:
|
||||||
CL_ParseDownload ();
|
CL_ParseDownload ();
|
||||||
break;
|
break;
|
||||||
|
@ -1594,14 +1595,6 @@ CL_ParseServerMessage (void)
|
||||||
case svc_entgravity:
|
case svc_entgravity:
|
||||||
movevars.entgravity = MSG_ReadFloat (net_message);
|
movevars.entgravity = MSG_ReadFloat (net_message);
|
||||||
break;
|
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