- merge the svc_strings arrays for cl_parse.c and net_packetlog.c into

net_svc.c, and add add a NET_SVC_GetString function to access it.
  As an added bonus, it actually boundschecks it!
- preexpand that annoying SHOWNET macro, which was only used twice,
  and was quite small and pointless
- whitespace cleanup and a comment typo fix
This commit is contained in:
Adam Olsen 2001-11-05 07:53:03 +00:00
parent 008b59b777
commit d693bc27ff
5 changed files with 85 additions and 164 deletions

View file

@ -199,6 +199,7 @@ typedef struct net_svc_deltapacketentities_s
entity_state_t deltas[MAX_PACKET_ENTITIES];
} net_svc_deltapacketentities_t;
const char *NET_SVC_GetString (int type);
net_status_t NET_SVC_Print_Emit (net_svc_print_t *block, sizebuf_t *buf);
net_status_t NET_SVC_Print_Parse (net_svc_print_t *block, msg_t *msg);
net_status_t NET_SVC_Damage_Emit (net_svc_damage_t *block, sizebuf_t *buf);

View file

@ -224,7 +224,7 @@
U_GLOWSIZE | U_GLOWCOLOR | U_COLORMOD | \
U_EXTEND2)
#define U_GROUP_EXTEND2 (U_GLOWTRAIL | U_VIEWMODEL | U_FRAME2)
// I skip the UNISED and EXTEND3 bits because although they exist in
// I skip the UNUSED and EXTEND3 bits because although they exist in
// QSG2, they're not usable
#define U_VERSION_ID ((U_GROUP_ORIG | U_GROUP_MOREBITS) & ~U_EXTEND1)

View file

@ -72,85 +72,6 @@ static const char rcsid[] =
#include "sbar.h"
#include "view.h"
char *svc_strings[] = {
"svc_bad",
"svc_nop",
"svc_disconnect",
"svc_updatestat",
"svc_version", // [long] server version
"svc_setview", // [short] entity number
"svc_sound", // <see code>
"svc_time", // [float] server time
"svc_print", // [string] null terminated string
"svc_stufftext", // [string] stuffed into client's console
// buffer the string should be \n terminated
"svc_setangle", // [vec3] set view angle to this absolute value
"svc_serverdata", // [long] version ...
"svc_lightstyle", // [byte] [string]
"svc_updatename", // [byte] [string]
"svc_updatefrags", // [byte] [short]
"svc_clientdata", // <shortbits + data>
"svc_stopsound", // <see code>
"svc_updatecolors", // [byte] [byte]
"svc_particle", // [vec3] <variable>
"svc_damage", // [byte] impact [byte] blood [vec3] from
"svc_spawnstatic",
"OBSOLETE svc_spawnbinary",
"svc_spawnbaseline",
"svc_temp_entity", // <variable>
"svc_setpause",
"svc_signonnum",
"svc_centerprint",
"svc_killedmonster",
"svc_foundsecret",
"svc_spawnstaticsound",
"svc_intermission",
"svc_finale",
"svc_cdtrack",
"svc_sellscreen",
"svc_smallkick",
"svc_bigkick",
"svc_updateping",
"svc_updateentertime",
"svc_updatestatlong",
"svc_muzzleflash",
"svc_updateuserinfo",
"svc_download",
"svc_playerinfo",
"svc_nails",
"svc_choke",
"svc_modellist",
"svc_soundlist",
"svc_packetentities",
"svc_deltapacketentities",
"svc_maxspeed",
"svc_entgravity",
"svc_setinfo",
"svc_serverinfo",
"svc_updatepl",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL"
};
int oldparsecountmod;
int parsecountmod;
double parsecounttime;
@ -1207,13 +1128,15 @@ CL_ParseServerMessage (void)
cmd = MSG_ReadByte (net_message);
if (cmd == -1) {
net_message->readcount++; // so the EOM showner has the right
// value
SHOWNET ("END OF MESSAGE");
if (cl_shownet->int_val == 2)
Con_Printf ("%3i:%s\n", net_message->readcount,
"END OF MESSAGE");
break;
}
SHOWNET (svc_strings[cmd]);
if (cl_shownet->int_val == 2)
Con_Printf ("%3i:%s\n", net_message->readcount - 1,
NET_SVC_GetString (cmd));
// other commands
switch (cmd) {

View file

@ -56,6 +56,7 @@ static const char rcsid[] =
#include "compat.h"
#include "net.h"
#include "net_svc.h"
#include "protocol.h"
#include "server.h"
@ -70,81 +71,6 @@ void Parse_Server_Packet (void);
void Parse_Client_Packet (void);
void Net_LogStop (void);
// note: this is SUPPOSED to be duplicate, like many others
const char *svc_string[] = {
"svc_bad",
"svc_nop",
"svc_disconnect",
"svc_updatestat",
"svc_version", // [long] server version
"svc_setview", // [short] entity number
"svc_sound", // <see code>
"svc_time", // [float] server time
"svc_print", // [string] null terminated string
"svc_stufftext", // [string] stuffed into client's
// console buffer the string
// should be \n terminated
"svc_setangle", // [vec3] set the view angle to this
// absolute value
"svc_serverdata", // [long] version ...
"svc_lightstyle", // [byte] [string]
"svc_updatename", // [byte] [string]
"svc_updatefrags", // [byte] [short]
"svc_clientdata", // <shortbits + data>
"svc_stopsound", // <see code>
"svc_updatecolors", // [byte] [byte]
"svc_particle", // [vec3] <variable>
"svc_damage", // [byte] impact [byte] blood [vec3]
// from
"svc_spawnstatic",
"svc_spawnbinary",
"svc_spawnbaseline",
"svc_temp_entity", // <variable>
"svc_setpause",
"svc_signonnum",
"svc_centerprint",
"svc_killedmonster",
"svc_foundsecret",
"svc_spawnstaticsound",
"svc_intermission",
"svc_finale", // [string] music [string] text
"svc_cdtrack", // [byte] track [byte] looptrack
"svc_sellscreen",
"svc_smallkick", // Quake 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",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL"
};
const char *clc_string[] = {
"clc_bad",
"clc_nop",
@ -451,7 +377,7 @@ Parse_Server_Packet ()
MSG_GetReadCount (&packet) - 1, c);
if (c < 53)
Net_LogPrintf ("%s: ", svc_string[c]);
Net_LogPrintf ("%s: ", NET_SVC_GetString (c));
// else Net_LogPrintf("(UNK: %d): ",c);
if (MSG_GetReadCount (&packet) > packet.message->cursize)

View file

@ -51,6 +51,77 @@ static const char rcsid[] =
#include "msg_ucmd.h" // FIXME
#include "net_svc.h"
static const char *net_svc_strings[] = {
"svc_bad",
"svc_nop",
"svc_disconnect",
"svc_updatestat",
"svc_version", // [long] server version
"svc_setview", // [short] entity number
"svc_sound", // <see code>
"svc_time", // [float] server time
"svc_print", // [string] null terminated string
"svc_stufftext", // [string] stuffed into client's
// console buffer the string
// should be \n terminated
"svc_setangle", // [vec3] set the view angle to this
// absolute value
"svc_serverdata", // [long] version ...
"svc_lightstyle", // [byte] [string]
"svc_updatename", // [byte] [string]
"svc_updatefrags", // [byte] [short]
"svc_clientdata", // <shortbits + data>
"svc_stopsound", // <see code>
"svc_updatecolors", // [byte] [byte]
"svc_particle", // [vec3] <variable>
"svc_damage", // [byte] impact [byte] blood [vec3]
// from
"svc_spawnstatic",
"svc_spawnbinary",
"svc_spawnbaseline",
"svc_temp_entity", // <variable>
"svc_setpause",
"svc_signonnum",
"svc_centerprint",
"svc_killedmonster",
"svc_foundsecret",
"svc_spawnstaticsound",
"svc_intermission",
"svc_finale", // [string] music [string] text
"svc_cdtrack", // [byte] track [byte] looptrack
"svc_sellscreen",
"svc_smallkick", // Quake 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",
};
const char *
NET_SVC_GetString (int type)
{
if (type >= 0 && type < (sizeof (net_svc_strings) / sizeof (const char *)))
return net_svc_strings[type];
else
return "Invalid Block Type";
}
net_status_t
NET_SVC_Print_Emit (net_svc_print_t *block, sizebuf_t *buf)
{