More cl_parse tidyup.

svcs are now in order: makes it even easier to see what's different between
nq and qw.
This commit is contained in:
Bill Currie 2012-05-26 10:39:42 +09:00
parent 476ad75724
commit 7299ca7bec
2 changed files with 203 additions and 156 deletions

View file

@ -868,8 +868,8 @@ void
CL_ParseServerMessage (void)
{
int cmd = 0, i, j;
signon_t so;
const char *str;
signon_t so;
// if recording demos, copy the message out
if (cl_shownet->int_val == 1)
@ -908,19 +908,19 @@ CL_ParseServerMessage (void)
switch (cmd) {
default:
Host_Error ("CL_ParseServerMessage: Illegible server "
"message %d\n", cmd);
"message: %d\n", cmd);
break;
case svc_nop:
break;
case svc_time:
cl.mtime[1] = cl.mtime[0];
cl.mtime[0] = MSG_ReadFloat (net_message);
break;
case svc_disconnect:
Host_EndGame ("Server disconnected\n");
case svc_clientdata:
CL_ParseClientdata ();
case svc_updatestat:
i = MSG_ReadByte (net_message);
j = MSG_ReadLong (net_message);
CL_SetStat (i, j);
break;
case svc_version:
@ -932,36 +932,28 @@ CL_ParseServerMessage (void)
cl.protocol = i;
break;
case svc_disconnect:
Host_EndGame ("Server disconnected\n");
case svc_setview:
cl.viewentity = MSG_ReadShort (net_message);
viewentity = cl.viewentity; // FIXME: evil hack
break;
case svc_sound:
CL_ParseStartSoundPacket ();
break;
case svc_time:
cl.mtime[1] = cl.mtime[0];
cl.mtime[0] = MSG_ReadFloat (net_message);
break;
case svc_print:
Sys_Printf ("%s", MSG_ReadString (net_message));
break;
case svc_centerprint:
str = MSG_ReadString (net_message);
if (strcmp (str, centerprint->str)) {
dstring_copystr (centerprint, str);
//FIXME logging
}
Sbar_CenterPrint (str);
break;
case svc_stufftext:
Cbuf_AddText (host_cbuf, MSG_ReadString (net_message));
break;
case svc_damage:
V_ParseDamage ();
break;
case svc_serverinfo:
CL_ParseServerInfo ();
// leave intermission full screen
r_data->vid->recalc_refdef = true;
break;
case svc_setangle:
{
vec_t *dest = cl.viewangles;
@ -969,9 +961,11 @@ CL_ParseServerMessage (void)
MSG_ReadAngleV (net_message, dest);
break;
}
case svc_setview:
cl.viewentity = MSG_ReadShort (net_message);
viewentity = cl.viewentity; // FIXME: evil hack
case svc_serverinfo:
CL_ParseServerInfo ();
// leave intermission full screen
r_data->vid->recalc_refdef = true;
break;
case svc_lightstyle:
@ -980,16 +974,15 @@ CL_ParseServerMessage (void)
Host_Error ("svc_lightstyle > MAX_LIGHTSTYLES");
strcpy (cl.lightstyle[i].map, MSG_ReadString (net_message));
cl.lightstyle[i].length = strlen (cl.lightstyle[i].map);
// FIXME extra info
break;
case svc_sound:
CL_ParseStartSoundPacket ();
break;
case svc_stopsound:
i = MSG_ReadShort (net_message);
S_StopSound (i >> 3, i & 7);
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:
@ -1001,13 +994,13 @@ 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));
case svc_clientdata:
CL_ParseClientdata ();
break;
case svc_stopsound:
i = MSG_ReadShort (net_message);
S_StopSound (i >> 3, i & 7);
break;
case svc_updatecolors:
@ -1031,17 +1024,22 @@ CL_ParseServerMessage (void)
CL_ParseParticleEffect ();
break;
case svc_damage:
V_ParseDamage ();
break;
case svc_spawnstatic:
CL_ParseStatic (1);
break;
// svc_spawnbinary
case svc_spawnbaseline:
i = MSG_ReadShort (net_message);
// must use CL_EntityNum () to force cl.num_entities up
CL_ParseBaseline (CL_EntityNum (i), 1);
break;
case svc_spawnstatic:
CL_ParseStatic (1);
break;
case svc_spawnstaticsound:
CL_ParseStaticSound (1);
break;
case svc_temp_entity:
CL_ParseTEnt ();
break;
@ -1063,6 +1061,15 @@ CL_ParseServerMessage (void)
CL_SignonReply ();
break;
case svc_centerprint:
str = MSG_ReadString (net_message);
if (strcmp (str, centerprint->str)) {
dstring_copystr (centerprint, str);
//FIXME logging
}
Sbar_CenterPrint (str);
break;
case svc_killedmonster:
cl.stats[STAT_MONSTERS]++;
break;
@ -1071,10 +1078,28 @@ CL_ParseServerMessage (void)
cl.stats[STAT_SECRETS]++;
break;
case svc_updatestat:
i = MSG_ReadByte (net_message);
j = MSG_ReadLong (net_message);
CL_SetStat (i, j);
case svc_spawnstaticsound:
CL_ParseStaticSound (1);
break;
case svc_intermission:
cl.intermission = 1;
r_data->force_fullscreen = 1;
cl.completed_time = cl.time;
r_data->vid->recalc_refdef = true; // go to full screen
break;
case svc_finale:
cl.intermission = 2;
r_data->force_fullscreen = 1;
cl.completed_time = cl.time;
r_data->vid->recalc_refdef = true; // go to full screen
str = MSG_ReadString (net_message);
if (strcmp (str, centerprint->str)) {
dstring_copystr (centerprint, str);
//FIXME logging
}
Sbar_CenterPrint (str);
break;
case svc_cdtrack:
@ -1087,24 +1112,8 @@ CL_ParseServerMessage (void)
CDAudio_Play ((byte) cl.cdtrack, true);
break;
case svc_intermission:
cl.intermission = 1;
r_data->force_fullscreen = 1;
cl.completed_time = cl.time;
r_data->vid->recalc_refdef = true; // go to full screen
break;
case svc_finale:
cl.intermission = 2;
r_data->force_fullscreen = 1;
cl.completed_time = cl.time;
r_data->vid->recalc_refdef = true; // go to full screen
str = MSG_ReadString (net_message);
if (strcmp (str, centerprint->str)) {
dstring_copystr (centerprint, str);
//FIXME logging
}
Sbar_CenterPrint (str);
case svc_sellscreen:
Cmd_ExecuteString ("help", src_command);
break;
case svc_cutscene:
@ -1120,11 +1129,28 @@ CL_ParseServerMessage (void)
Sbar_CenterPrint (str);
break;
case svc_sellscreen:
Cmd_ExecuteString ("help", src_command);
break;
// svc_smallkick (same value as svc_cutscene)
// svc_bigkick
// svc_updateping
// svc_updateentertime
// svc_updatestatlong
// svc_muzzleflash
// svc_updateuserinfo
// svc_download
// svc_playerinfo
// svc_nails
// svc_chokecount
// svc_modellist
// svc_soundlist
// svc_packetentities
// svc_deltapacketentities
// svc_maxspeed
// svc_entgravity
// svc_setinfo
// svc_serverinfo
// svc_updatepl
// PROTOCOL_FITZQUAKE
// PROTOCOL_FITZQUAKE (these overlap with the above listed qw svcs)
case svc_skybox:
r_funcs->R_LoadSkys (MSG_ReadString(net_message));
break;

View file

@ -129,7 +129,7 @@ const char *svc_strings[] = {
"svc_download",
"svc_playerinfo",
"svc_nails",
"svc_choke",
"svc_chokecount",
"svc_modellist",
"svc_soundlist",
"svc_packetentities",
@ -1296,7 +1296,7 @@ int received_framecount;
void
CL_ParseServerMessage (void)
{
int cmd = 0, i, j;
int cmd = 0, i, j;
const char *str;
static dstring_t *stuffbuf;
@ -1348,6 +1348,21 @@ CL_ParseServerMessage (void)
Host_EndGame ("Server disconnected");
break;
case svc_updatestat:
i = MSG_ReadByte (net_message);
j = MSG_ReadByte (net_message);
CL_SetStat (i, j);
break;
// svc_version
// svc_setview
case svc_sound:
CL_ParseStartSoundPacket ();
break;
// svc_time
case svc_print:
{
dstring_t *p = 0;
@ -1381,15 +1396,6 @@ CL_ParseServerMessage (void)
Con_SetOrMask (0);
break;
}
case svc_centerprint:
str = MSG_ReadString (net_message);
if (strcmp (str, centerprint->str)) {
dstring_copystr (centerprint, str);
//FIXME logging
}
Sbar_CenterPrint (str);
break;
case svc_stufftext:
str = MSG_ReadString (net_message);
if (str[strlen (str) - 1] == '\n') {
@ -1410,14 +1416,6 @@ CL_ParseServerMessage (void)
}
break;
case svc_damage:
V_ParseDamage ();
break;
case svc_serverinfo:
CL_ServerInfo ();
break;
case svc_setangle:
{
vec_t *dest = cl.viewangles;
@ -1448,14 +1446,7 @@ CL_ParseServerMessage (void)
cl.lightstyle[i].length = strlen (cl.lightstyle[i].map);
break;
case svc_sound:
CL_ParseStartSoundPacket ();
break;
case svc_stopsound:
i = MSG_ReadShort (net_message);
S_StopSound (i >> 3, i & 7);
break;
// svc_updatename
case svc_updatefrags:
Sbar_Changed ();
@ -1466,42 +1457,31 @@ CL_ParseServerMessage (void)
cl.players[i].frags = (short) MSG_ReadShort (net_message);
break;
case svc_updateping:
i = MSG_ReadByte (net_message);
if (i >= MAX_CLIENTS)
Host_Error ("CL_ParseServerMessage: svc_updateping > "
"MAX_SCOREBOARD");
cl.players[i].ping = MSG_ReadShort (net_message);
// svc_clientdata
case svc_stopsound:
i = MSG_ReadShort (net_message);
S_StopSound (i >> 3, i & 7);
break;
case svc_updatepl:
i = MSG_ReadByte (net_message);
if (i >= MAX_CLIENTS)
Host_Error ("CL_ParseServerMessage: svc_updatepl > "
"MAX_SCOREBOARD");
cl.players[i].pl = MSG_ReadByte (net_message);
// svc_updatecolors
// svc_particle
case svc_damage:
V_ParseDamage ();
break;
case svc_updateentertime:
// time is sent over as seconds ago
i = MSG_ReadByte (net_message);
if (i >= MAX_CLIENTS)
Host_Error ("CL_ParseServerMessage: svc_updateentertime "
"> MAX_SCOREBOARD");
cl.players[i].entertime = realtime - MSG_ReadFloat
(net_message);
case svc_spawnstatic:
CL_ParseStatic ();
break;
// svc_spawnbinary
case svc_spawnbaseline:
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;
@ -1514,6 +1494,17 @@ CL_ParseServerMessage (void)
CDAudio_Resume ();
break;
// svc_signonnum
case svc_centerprint:
str = MSG_ReadString (net_message);
if (strcmp (str, centerprint->str)) {
dstring_copystr (centerprint, str);
//FIXME logging
}
Sbar_CenterPrint (str);
break;
case svc_killedmonster:
cl.stats[STAT_MONSTERS]++;
break;
@ -1522,21 +1513,8 @@ CL_ParseServerMessage (void)
cl.stats[STAT_SECRETS]++;
break;
case svc_updatestat:
i = MSG_ReadByte (net_message);
j = MSG_ReadByte (net_message);
CL_SetStat (i, j);
break;
case svc_updatestatlong:
i = MSG_ReadByte (net_message);
j = MSG_ReadLong (net_message);
CL_SetStat (i, j);
break;
case svc_cdtrack:
cl.cdtrack = MSG_ReadByte (net_message);
CDAudio_Play ((byte) cl.cdtrack, true);
case svc_spawnstaticsound:
CL_ParseStaticSound ();
break;
case svc_intermission:
@ -1545,7 +1523,7 @@ CL_ParseServerMessage (void)
cl.intermission = 1;
r_data->force_fullscreen = 1;
cl.completed_time = realtime;
r_data->vid->recalc_refdef = true; // go to full screen
r_data->vid->recalc_refdef = true; // go to full screen
Sys_MaskPrintf (SYS_DEV, "intermission simorg: ");
MSG_ReadCoordV (net_message, cl.simorg);
for (i = 0; i < 3; i++)
@ -1576,10 +1554,17 @@ CL_ParseServerMessage (void)
Sbar_CenterPrint (str);
break;
case svc_cdtrack:
cl.cdtrack = MSG_ReadByte (net_message);
CDAudio_Play ((byte) cl.cdtrack, true);
break;
case svc_sellscreen:
Cmd_ExecuteString ("help", src_command);
break;
// svc_cutscene (same value as svc_smallkick)
case svc_smallkick:
cl.punchangle = -2;
break;
@ -1588,6 +1573,30 @@ CL_ParseServerMessage (void)
cl.punchangle = -4;
break;
case svc_updateping:
i = MSG_ReadByte (net_message);
if (i >= MAX_CLIENTS)
Host_Error ("CL_ParseServerMessage: svc_updateping > "
"MAX_SCOREBOARD");
cl.players[i].ping = MSG_ReadShort (net_message);
break;
case svc_updateentertime:
// time is sent over as seconds ago
i = MSG_ReadByte (net_message);
if (i >= MAX_CLIENTS)
Host_Error ("CL_ParseServerMessage: svc_updateentertime "
"> MAX_SCOREBOARD");
cl.players[i].entertime = realtime - MSG_ReadFloat
(net_message);
break;
case svc_updatestatlong:
i = MSG_ReadByte (net_message);
j = MSG_ReadLong (net_message);
CL_SetStat (i, j);
break;
case svc_muzzleflash:
CL_MuzzleFlash ();
break;
@ -1596,10 +1605,6 @@ CL_ParseServerMessage (void)
CL_UpdateUserinfo ();
break;
case svc_setinfo:
CL_SetInfo ();
break;
case svc_download:
CL_ParseDownload ();
break;
@ -1612,10 +1617,6 @@ CL_ParseServerMessage (void)
CL_ParseProjectiles (false);
break;
case svc_nails2: // FIXME from qwex
CL_ParseProjectiles (true);
break;
case svc_chokecount: // some preceding packets were choked
i = MSG_ReadByte (net_message);
for (j = 0; j < i; j++)
@ -1646,6 +1647,26 @@ CL_ParseServerMessage (void)
case svc_entgravity:
movevars.entgravity = MSG_ReadFloat (net_message);
break;
case svc_setinfo:
CL_SetInfo ();
break;
case svc_serverinfo:
CL_ServerInfo ();
break;
case svc_updatepl:
i = MSG_ReadByte (net_message);
if (i >= MAX_CLIENTS)
Host_Error ("CL_ParseServerMessage: svc_updatepl > "
"MAX_SCOREBOARD");
cl.players[i].pl = MSG_ReadByte (net_message);
break;
case svc_nails2: // FIXME from qwex
CL_ParseProjectiles (true);
break;
}
}