Remove Q2 hacks from the usercmd_t type. Just translate them without trying to be clever.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6194 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2022-02-19 20:49:42 +00:00
parent 4b48a8b191
commit 01c498d136
4 changed files with 35 additions and 23 deletions

View file

@ -231,14 +231,24 @@ CL_PredictMovement
Sets cl.predicted_origin and cl.predicted_angles Sets cl.predicted_origin and cl.predicted_angles
================= =================
*/ */
static void CLQ2_UserCmdToQ2(q2usercmd_t *out, const usercmd_t *cmd)
{
out->msec = cmd->msec;
out->buttons = cmd->buttons;
VectorCopy(cmd->angles, out->angles);
out->forwardmove = cmd->forwardmove;
out->sidemove = cmd->sidemove;
out->upmove = cmd->upmove;
out->impulse = cmd->impulse;
out->lightlevel = cmd->lightlevel;
}
static void CLQ2_PredictMovement (int seat) //q2 doesn't support split clients. static void CLQ2_PredictMovement (int seat) //q2 doesn't support split clients.
{ {
#ifdef Q2BSPS #ifdef Q2BSPS
int ack, current; int ack, current;
int frame; int frame;
int oldframe; int oldframe;
q2usercmd_t *cmd; q2pmove_t pm;
q2pmove_t pm;
int step; int step;
int oldz; int oldz;
#endif #endif
@ -293,10 +303,7 @@ static void CLQ2_PredictMovement (int seat) //q2 doesn't support split clients.
while (++ack < current) while (++ack < current)
{ {
frame = ack & (UPDATE_MASK); frame = ack & (UPDATE_MASK);
cmd = (q2usercmd_t*)&cl.outframes[frame].cmd[seat]; CLQ2_UserCmdToQ2(&pm.cmd, &cl.outframes[frame].cmd[seat]);
cmd->msec = cl.outframes[frame].cmd[seat].msec;
pm.cmd = *cmd;
Q2_Pmove (&pm); Q2_Pmove (&pm);
// save for debug checking // save for debug checking
@ -305,10 +312,7 @@ static void CLQ2_PredictMovement (int seat) //q2 doesn't support split clients.
if (cl_pendingcmd[seat].msec) if (cl_pendingcmd[seat].msec)
{ {
cmd = (q2usercmd_t*)&cl_pendingcmd[seat]; CLQ2_UserCmdToQ2(&pm.cmd, &cl_pendingcmd[seat]);
cmd->msec = cl_pendingcmd[seat].msec;
pm.cmd = *cmd;
Q2_Pmove (&pm); Q2_Pmove (&pm);
} }

View file

@ -2412,13 +2412,12 @@ void MSGQ2_ReadDeltaUsercmd (const usercmd_t *from, usercmd_t *move)
else else
move->buttons = MSG_ReadByte (); move->buttons = MSG_ReadByte ();
} }
move->buttons_compat = move->buttons & 0xff;
if (bits & Q2CM_IMPULSE) if (bits & Q2CM_IMPULSE)
move->impulse = MSG_ReadByte (); move->impulse = MSG_ReadByte ();
// read time to run command // read time to run command
move->msec_compat = move->msec = MSG_ReadByte (); move->msec = MSG_ReadByte ();
move->lightlevel = MSG_ReadByte (); move->lightlevel = MSG_ReadByte ();
} }

View file

@ -1270,14 +1270,10 @@ struct vrdevinfo_s
}; };
typedef struct usercmd_s typedef struct usercmd_s
{ {
//the first members of this structure MUST match the q2 version
qbyte msec_compat;
qbyte buttons_compat;
short angles[3]; short angles[3];
short forwardmove, sidemove, upmove; signed int forwardmove,sidemove,upmove;
qbyte impulse; unsigned int impulse;
qbyte lightlevel; unsigned int lightlevel;
//end q2 compat
unsigned int sequence; // just for debugging prints unsigned int sequence; // just for debugging prints
float msec; //replace msec, but with more precision float msec; //replace msec, but with more precision

View file

@ -8447,6 +8447,19 @@ void SV_ExecuteClientMessage (client_t *cl)
sv_player = NULL; sv_player = NULL;
} }
#ifdef Q2SERVER #ifdef Q2SERVER
static void SVQ2_ClientThink(q2edict_t *ed, usercmd_t *cmd)
{
q2usercmd_t q2;
q2.msec = cmd->msec;
q2.buttons = cmd->buttons;
VectorCopy(cmd->angles, q2.angles);
q2.forwardmove = cmd->forwardmove;
q2.sidemove = cmd->sidemove;
q2.upmove = cmd->upmove;
q2.impulse = cmd->impulse;
q2.lightlevel = cmd->lightlevel;
ge->ClientThink (ed, &q2);
}
void SVQ2_ExecuteClientMessage (client_t *cl) void SVQ2_ExecuteClientMessage (client_t *cl)
{ {
int c; int c;
@ -8603,15 +8616,15 @@ void SVQ2_ExecuteClientMessage (client_t *cl)
{ {
while (net_drop > 2) while (net_drop > 2)
{ {
ge->ClientThink (split->q2edict, (q2usercmd_t*)&split->lastcmd); SVQ2_ClientThink (split->q2edict, &split->lastcmd);
net_drop--; net_drop--;
} }
if (net_drop > 1) if (net_drop > 1)
ge->ClientThink (split->q2edict, (q2usercmd_t*)&oldest); SVQ2_ClientThink (split->q2edict, &oldest);
if (net_drop > 0) if (net_drop > 0)
ge->ClientThink (split->q2edict, (q2usercmd_t*)&oldcmd); SVQ2_ClientThink (split->q2edict, &oldcmd);
} }
ge->ClientThink (split->q2edict, (q2usercmd_t*)&newcmd); SVQ2_ClientThink (split->q2edict, &newcmd);
} }
split->lastcmd = newcmd; split->lastcmd = newcmd;