Skip to content

Commit

Permalink
Reset aliasCount once per command buffer frame.
Browse files Browse the repository at this point in the history
Should help avoid infinite config exec loops.
  • Loading branch information
skullernet authored and res2k committed Feb 4, 2024
1 parent 7a27997 commit 039326e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
3 changes: 3 additions & 0 deletions inc/common/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ void Cbuf_Execute(cmdbuf_t *buf);
// Normally called once per frame, but may be explicitly invoked.
// Do not call inside a command function!

void Cbuf_Frame(cmdbuf_t *buf);
// Called once per frame. Decrements waitCount, resets aliasCount.

//===========================================================================

/*
Expand Down
8 changes: 2 additions & 6 deletions src/client/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,12 +739,8 @@ void CL_FinalizeCmd(void)
vec3_t move;

// command buffer ticks in sync with cl_maxfps
if (cmd_buffer.waitCount > 0) {
cmd_buffer.waitCount--;
}
if (cl_cmdbuf.waitCount > 0) {
cl_cmdbuf.waitCount--;
}
Cbuf_Frame(&cmd_buffer);
Cbuf_Frame(&cl_cmdbuf);

if (cls.state != ca_active) {
goto clear; // not talking to a server
Expand Down
11 changes: 11 additions & 0 deletions src/common/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,18 @@ void Cbuf_Execute(cmdbuf_t *buf)
cmd_current = buf;
buf->exec(buf, line);
}
}

/*
============
Cbuf_Frame
============
*/
void Cbuf_Frame(cmdbuf_t *buf)
{
if (buf->waitCount > 0) {
buf->waitCount--;
}
buf->aliasCount = 0; // don't allow infinite alias loops
}

Expand Down
4 changes: 1 addition & 3 deletions src/server/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1956,9 +1956,7 @@ unsigned SV_Frame(unsigned msec)

if (COM_DEDICATED) {
// run cmd buffer in dedicated mode
if (cmd_buffer.waitCount > 0) {
cmd_buffer.waitCount--;
}
Cbuf_Frame(&cmd_buffer);
}

// decide how long to sleep next frame
Expand Down
4 changes: 1 addition & 3 deletions src/server/mvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,7 @@ static void dummy_run(void)
return;

Cbuf_Execute(&dummy_buffer);
if (dummy_buffer.waitCount > 0) {
dummy_buffer.waitCount--;
}
Cbuf_Frame(&dummy_buffer);

// run ClientThink to prevent timeouts, etc
memset(&cmd, 0, sizeof(cmd));
Expand Down

0 comments on commit 039326e

Please sign in to comment.