make MSG_ReadDeltaUsercmd use a param rather than global to read the

message.
This commit is contained in:
Bill Currie 2005-04-27 12:16:15 +00:00
parent 9dcd2333d9
commit 2697671a9b
5 changed files with 22 additions and 25 deletions

View file

@ -28,11 +28,11 @@
#ifndef __msg_ucmd_h #ifndef __msg_ucmd_h
#define __msg_ucmd_h #define __msg_ucmd_h
#include "QF/sizebuf.h"
extern struct usercmd_s nullcmd; extern struct usercmd_s nullcmd;
struct msg_s;
struct sizebuf_s;
void MSG_WriteDeltaUsercmd (sizebuf_t *sb, struct usercmd_s *from, struct usercmd_s *cmd); void MSG_WriteDeltaUsercmd (struct sizebuf_s *sb, struct usercmd_s *from, struct usercmd_s *cmd);
void MSG_ReadDeltaUsercmd (struct usercmd_s *from, struct usercmd_s *cmd); void MSG_ReadDeltaUsercmd (struct msg_s *msg, struct usercmd_s *from, struct usercmd_s *cmd);
#endif // __msg_ucmd_h #endif // __msg_ucmd_h

View file

@ -45,11 +45,8 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "qw/msg_ucmd.h" #include "qw/msg_ucmd.h"
#include "qw/protocol.h" #include "qw/protocol.h"
#include "netchan.h"
struct usercmd_s nullcmd; struct usercmd_s nullcmd;
void void
MSG_WriteDeltaUsercmd (sizebuf_t *buf, usercmd_t *from, usercmd_t *cmd) MSG_WriteDeltaUsercmd (sizebuf_t *buf, usercmd_t *from, usercmd_t *cmd)
{ {
@ -97,37 +94,37 @@ MSG_WriteDeltaUsercmd (sizebuf_t *buf, usercmd_t *from, usercmd_t *cmd)
} }
void void
MSG_ReadDeltaUsercmd (usercmd_t *from, usercmd_t *move) MSG_ReadDeltaUsercmd (qmsg_t *msg, usercmd_t *from, usercmd_t *move)
{ {
int bits; int bits;
memcpy (move, from, sizeof (*move)); memcpy (move, from, sizeof (*move));
bits = MSG_ReadByte (net_message); bits = MSG_ReadByte (msg);
// read current angles // read current angles
if (bits & CM_ANGLE1) if (bits & CM_ANGLE1)
move->angles[0] = MSG_ReadAngle16 (net_message); move->angles[0] = MSG_ReadAngle16 (msg);
if (bits & CM_ANGLE2) if (bits & CM_ANGLE2)
move->angles[1] = MSG_ReadAngle16 (net_message); move->angles[1] = MSG_ReadAngle16 (msg);
if (bits & CM_ANGLE3) if (bits & CM_ANGLE3)
move->angles[2] = MSG_ReadAngle16 (net_message); move->angles[2] = MSG_ReadAngle16 (msg);
// read movement // read movement
if (bits & CM_FORWARD) if (bits & CM_FORWARD)
move->forwardmove = MSG_ReadShort (net_message); move->forwardmove = MSG_ReadShort (msg);
if (bits & CM_SIDE) if (bits & CM_SIDE)
move->sidemove = MSG_ReadShort (net_message); move->sidemove = MSG_ReadShort (msg);
if (bits & CM_UP) if (bits & CM_UP)
move->upmove = MSG_ReadShort (net_message); move->upmove = MSG_ReadShort (msg);
// read buttons // read buttons
if (bits & CM_BUTTONS) if (bits & CM_BUTTONS)
move->buttons = MSG_ReadByte (net_message); move->buttons = MSG_ReadByte (msg);
if (bits & CM_IMPULSE) if (bits & CM_IMPULSE)
move->impulse = MSG_ReadByte (net_message); move->impulse = MSG_ReadByte (msg);
// read time to run command // read time to run command
move->msec = MSG_ReadByte (net_message); move->msec = MSG_ReadByte (msg);
} }

View file

@ -254,9 +254,9 @@ client_parse_message (client_t *cl)
/*checksum = (byte) */MSG_ReadByte (net_message); /*checksum = (byte) */MSG_ReadByte (net_message);
// read loss percentage // read loss percentage
/*cl->lossage = */MSG_ReadByte (net_message); /*cl->lossage = */MSG_ReadByte (net_message);
MSG_ReadDeltaUsercmd (&nullcmd, &oldest); MSG_ReadDeltaUsercmd (net_message, &nullcmd, &oldest);
MSG_ReadDeltaUsercmd (&oldest, &oldcmd); MSG_ReadDeltaUsercmd (net_message, &oldest, &oldcmd);
MSG_ReadDeltaUsercmd (&oldcmd, &newcmd); MSG_ReadDeltaUsercmd (net_message, &oldcmd, &newcmd);
#if 0 #if 0
if (cl->state != cs_spawned) if (cl->state != cs_spawned)
break; break;

View file

@ -739,7 +739,7 @@ CL_ParsePlayerinfo (void)
state->state_time = parsecounttime; state->state_time = parsecounttime;
if (flags & PF_COMMAND) if (flags & PF_COMMAND)
MSG_ReadDeltaUsercmd (&nullcmd, &state->command); MSG_ReadDeltaUsercmd (net_message, &nullcmd, &state->command);
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
if (flags & (PF_VELOCITY1 << i)) if (flags & (PF_VELOCITY1 << i))

View file

@ -1842,9 +1842,9 @@ SV_ExecuteClientMessage (client_t *cl)
// read loss percentage // read loss percentage
cl->lossage = MSG_ReadByte (net_message); cl->lossage = MSG_ReadByte (net_message);
MSG_ReadDeltaUsercmd (&nullcmd, &oldest); MSG_ReadDeltaUsercmd (net_message, &nullcmd, &oldest);
MSG_ReadDeltaUsercmd (&oldest, &oldcmd); MSG_ReadDeltaUsercmd (net_message, &oldest, &oldcmd);
MSG_ReadDeltaUsercmd (&oldcmd, &newcmd); MSG_ReadDeltaUsercmd (net_message, &oldcmd, &newcmd);
if (cl->state != cs_spawned) if (cl->state != cs_spawned)
break; break;