Skip to content

Commit

Permalink
fix off-by-one error in movekeys demo
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewearl committed Dec 20, 2024
1 parent 2ba965a commit 6005c20
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
15 changes: 15 additions & 0 deletions trunk/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,10 @@ SV_SendClientDatagram
*/
qboolean SV_SendClientDatagram (client_t *client)
{
extern cvar_t net_messagetimeout;
extern kbutton_t in_moveleft, in_moveright, in_forward, in_back, in_jump;
char cmd[1024];

byte buf[MAX_DATAGRAM];
sizebuf_t msg;

Expand All @@ -1018,6 +1022,17 @@ qboolean SV_SendClientDatagram (client_t *client)
MSG_WriteByte (&msg, svc_time);
MSG_WriteFloat (&msg, sv.time);

//joe: send movement keys
if (!COM_CheckParm("-nomovekeys"))
{
snprintf(cmd, sizeof(cmd), "net_messagetimeout %smk%i%i%i%i%i\n",
net_messagetimeout.defaultvalue, in_forward.state, in_back.state,
in_moveleft.state, in_moveright.state, in_jump.state);

MSG_WriteByte (&msg, svc_stufftext);
MSG_WriteString (&msg, cmd);
}

// add the client specific data to the datagram
SV_WriteClientdataToMessage (client->edict, &msg);

Expand Down
7 changes: 0 additions & 7 deletions trunk/sv_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,6 @@ void SV_ReadClientMove (usercmd_t *move)
host_client->edict->v.impulse = i;
}

extern cvar_t net_messagetimeout;
extern kbutton_t in_moveleft, in_moveright, in_forward, in_back, in_jump;

/*
===================
SV_ReadClientMessage
Expand All @@ -484,10 +481,6 @@ qboolean SV_ReadClientMessage (void)

MSG_BeginReading ();

//joe: send movement keys
if (!COM_CheckParm("-nomovekeys"))
Host_ClientCommands("net_messagetimeout %smk%i%i%i%i%i\n", net_messagetimeout.defaultvalue, in_forward.state, in_back.state, in_moveleft.state, in_moveright.state, in_jump.state);

while (1)
{
if (!host_client->active)
Expand Down

0 comments on commit 6005c20

Please sign in to comment.