From eb9c515c2a3bc141d370adadc1bbeba35b053853 Mon Sep 17 00:00:00 2001 From: Adam Olsen Date: Thu, 18 Oct 2001 08:57:03 +0000 Subject: [PATCH] - yada svc_damage, svc_serverdata - remove a no longer valid commit from NET_SVC_UpdateUserInfo_Parse, and make it always set name/data to 0 if they're unused --- qw/include/net_svc.h | 22 ++++++++++++++++++++++ qw/source/cl_parse.c | 32 ++++++++++++-------------------- qw/source/cl_view.c | 24 +++++++++++------------- qw/source/net_svc.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 88 insertions(+), 34 deletions(-) diff --git a/qw/include/net_svc.h b/qw/include/net_svc.h index b3b38f51e..669a7217e 100644 --- a/qw/include/net_svc.h +++ b/qw/include/net_svc.h @@ -33,6 +33,7 @@ #include "QF/msg.h" #include "bothdefs.h" +#include "pmove.h" typedef struct net_svc_print_s { @@ -40,6 +41,24 @@ typedef struct net_svc_print_s const char *message; } net_svc_print_t; +typedef struct net_svc_damage_s +{ + byte armor; + byte blood; + vec3_t from; +} net_svc_damage_t; + +typedef struct net_svc_serverdata_s +{ + int protocolversion; + int servercount; + const char *gamedir; + byte playernum; + qboolean spectator; + const char *levelname; + movevars_t movevars; +} net_svc_serverdata_t; + typedef struct net_svc_updateuserinfo_s { byte slot; @@ -77,6 +96,9 @@ typedef struct net_svc_modellist_s } net_svc_modellist_t; qboolean NET_SVC_Print_Parse (net_svc_print_t *print, msg_t *message); +qboolean NET_SVC_Damage_Parse (net_svc_damage_t *damage, msg_t *message); +qboolean NET_SVC_ServerData_Parse (net_svc_serverdata_t *serverdata, + msg_t *message); qboolean NET_SVC_UpdateUserInfo_Parse (net_svc_updateuserinfo_t *updateuserinfo, msg_t *message); qboolean NET_SVC_SetInfo_Parse (net_svc_setinfo_t *setinfo, msg_t *message); diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index 435242825..f923a58bd 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -645,17 +645,20 @@ CL_ParseServerData (void) const char *str; int protover; qboolean cflag = false; + net_svc_serverdata_t serverdata; extern char gamedirfile[MAX_OSPATH]; Con_DPrintf ("Serverdata packet received.\n"); + NET_SVC_ServerData_Parse (&serverdata, net_message); + // wipe the client_state_t struct CL_ClearState (); // parse protocol version number // allow 2.2 and 2.29 demos to play - protover = MSG_ReadLong (net_message); + protover = serverdata.protocolversion; if (protover != PROTOCOL_VERSION && !(cls.demoplayback && (protover <= 26 && protover >= 28))) @@ -663,10 +666,10 @@ CL_ParseServerData (void) "need to upgrade.\nCheck http://www.quakeworld.net/", protover, PROTOCOL_VERSION); - cl.servercount = MSG_ReadLong (net_message); + cl.servercount = serverdata.servercount; // game directory - str = MSG_ReadString (net_message); + str = serverdata.gamedir; if (!strequal (gamedirfile, str)) { // save current config @@ -691,32 +694,21 @@ CL_ParseServerData (void) snprintf (fn, sizeof (fn), "cmd_warncmd %d\n", cmd_warncmd_val); Cbuf_AddText (fn); } - // parse player slot, high bit means spectator - cl.playernum = MSG_ReadByte (net_message); - if (cl.playernum & 128) { - cl.spectator = true; - cl.playernum &= ~128; - } + + // parse player slot + cl.playernum = serverdata.playernum; + cl.spectator = serverdata.spectator; // FIXME: evil hack so NQ and QW can share sound code cl.viewentity = cl.playernum + 1; snd_viewentity = cl.playernum + 1; // get the full level name - str = MSG_ReadString (net_message); + str = serverdata.levelname; strncpy (cl.levelname, str, sizeof (cl.levelname) - 1); // get the movevars - movevars.gravity = MSG_ReadFloat (net_message); - movevars.stopspeed = MSG_ReadFloat (net_message); - movevars.maxspeed = MSG_ReadFloat (net_message); - movevars.spectatormaxspeed = MSG_ReadFloat (net_message); - movevars.accelerate = MSG_ReadFloat (net_message); - movevars.airaccelerate = MSG_ReadFloat (net_message); - movevars.wateraccelerate = MSG_ReadFloat (net_message); - movevars.friction = MSG_ReadFloat (net_message); - movevars.waterfriction = MSG_ReadFloat (net_message); - movevars.entgravity = MSG_ReadFloat (net_message); + memcpy (&movevars, &serverdata.movevars, sizeof (movevars)); // seperate the printfs so the server message can have a color Con_Printf ("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36" diff --git a/qw/source/cl_view.c b/qw/source/cl_view.c index e2eb87d6c..40e3af38b 100644 --- a/qw/source/cl_view.c +++ b/qw/source/cl_view.c @@ -44,6 +44,7 @@ static const char rcsid[] = #include "client.h" #include "compat.h" #include "host.h" +#include "net_svc.h" #include "pmove.h" #include "view.h" @@ -248,15 +249,12 @@ void V_ParseDamage (void) { float count, side; - int armor, blood, i; - vec3_t forward, from, right, up; + vec3_t forward, right, up; + net_svc_damage_t damage; - armor = MSG_ReadByte (net_message); - blood = MSG_ReadByte (net_message); - for (i = 0; i < 3; i++) - from[i] = MSG_ReadCoord (net_message); + NET_SVC_Damage_Parse (&damage, net_message); - count = blood * 0.5 + armor * 0.5; + count = damage.blood * 0.5 + damage.armor * 0.5; if (count < 10) count = 10; @@ -270,11 +268,11 @@ V_ParseDamage (void) cl.cshifts[CSHIFT_DAMAGE].percent = bound (0, cl.cshifts[CSHIFT_DAMAGE].percent, 150); - if (armor > blood) { + if (damage.armor > damage.blood) { cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 200; cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 100; cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 100; - } else if (armor) { + } else if (damage.armor) { cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 220; cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 50; cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 50; @@ -286,15 +284,15 @@ V_ParseDamage (void) } // calculate view angle kicks - VectorSubtract (from, cl.simorg, from); - VectorNormalize (from); + VectorSubtract (damage.from, cl.simorg, damage.from); + VectorNormalize (damage.from); AngleVectors (cl.simangles, forward, right, up); - side = DotProduct (from, right); + side = DotProduct (damage.from, right); v_dmg_roll = count * side * v_kickroll->value; - side = DotProduct (from, forward); + side = DotProduct (damage.from, forward); v_dmg_pitch = count * side * v_kickpitch->value; v_dmg_time = v_kicktime->value; diff --git a/qw/source/net_svc.c b/qw/source/net_svc.c index b417c4f81..29210d03f 100644 --- a/qw/source/net_svc.c +++ b/qw/source/net_svc.c @@ -58,6 +58,47 @@ NET_SVC_Print_Parse (net_svc_print_t *print, msg_t *message) return message->badread; } +qboolean +NET_SVC_Damage_Parse (net_svc_damage_t *damage, msg_t *message) +{ + int i; + + damage->armor = MSG_ReadByte (message); + damage->blood = MSG_ReadByte (message); + for (i = 0; i < 3; i++) + damage->from[i] = MSG_ReadCoord (message); + + return message->badread; +} + +qboolean +NET_SVC_ServerData_Parse (net_svc_serverdata_t *serverdata, msg_t *message) +{ + serverdata->protocolversion = MSG_ReadLong (message); + // I could abort now if the version is wrong, but why bother? + serverdata->servercount = MSG_ReadLong (message); + serverdata->gamedir = MSG_ReadString (message); + + // high bit means spectator + serverdata->playernum = MSG_ReadByte (message); + serverdata->spectator = serverdata->playernum >> 7; + serverdata->playernum &= ~(1 << 7); + + serverdata->levelname = MSG_ReadString (message); + serverdata->movevars.gravity = MSG_ReadFloat (message); + serverdata->movevars.stopspeed = MSG_ReadFloat (message); + serverdata->movevars.maxspeed = MSG_ReadFloat (message); + serverdata->movevars.spectatormaxspeed = MSG_ReadFloat (message); + serverdata->movevars.accelerate = MSG_ReadFloat (message); + serverdata->movevars.airaccelerate = MSG_ReadFloat (message); + serverdata->movevars.wateraccelerate = MSG_ReadFloat (message); + serverdata->movevars.friction = MSG_ReadFloat (message); + serverdata->movevars.waterfriction = MSG_ReadFloat (message); + serverdata->movevars.entgravity = MSG_ReadFloat (message); + + return message->badread; +} + qboolean NET_SVC_UpdateUserInfo_Parse (net_svc_updateuserinfo_t *updateuserinfo, msg_t *message) @@ -84,6 +125,7 @@ NET_SVC_Download_Parse (net_svc_download_t *download, msg_t *message) { download->size = MSG_ReadShort (message); download->percent = MSG_ReadByte (message); + download->name = download->data = 0; if (download->size == -2) download->name = MSG_ReadString (message); @@ -96,7 +138,7 @@ NET_SVC_Download_Parse (net_svc_download_t *download, msg_t *message) // size was beyond the end of the packet message->readcount = message->message->cursize; message->badread = true; - download->size = 0; // FIXME: CL_ParseDownload doesn't handle this + download->size = 0; } }