* can insert data at the beginning of the text buffer
*/
current = List_Entry(cbuf->start.next, cmd_input_t, list);
-
- // Recycle memory so using WASD doesn't cause a malloc and free
- List_Move_Tail(¤t->list, &cbuf->free);
-
+
/*
* Assume we're rolling with the current command-line and
* always set this false because alias expansion or cbuf insertion
Cmd_ExecuteString (current->source, current->text, src_local, false);
}
+ // Recycle memory so using WASD doesn't cause a malloc and free
+ List_Move_Tail(¤t->list, &cbuf->free);
+
current = NULL;
if (cbuf->wait)
if (++i == 1000000 && prvm_runawaycheck)
{
Con_Printf(CON_WARN "Cbuf_Execute: runaway loop counter hit limit of %d commands, clearing command buffers!\n", i);
- while (!List_Is_Empty(&cbuf->start))
- List_Move_Tail(cbuf->start.next, &cbuf->free);
- while (!List_Is_Empty(&cbuf->deferred))
- List_Move_Tail(cbuf->deferred.next, &cbuf->free);
- cbuf->size = 0;
+ Cbuf_Clear(cbuf);
}
}
}
// R_TimeReport("console");
}
+void Cbuf_Clear(cmd_buf_t *cbuf)
+{
+ while (!List_Is_Empty(&cbuf->start))
+ List_Move_Tail(cbuf->start.next, &cbuf->free);
+ while (!List_Is_Empty(&cbuf->deferred))
+ List_Move_Tail(cbuf->deferred.next, &cbuf->free);
+ cbuf->size = 0;
+}
+
/*
==============================================================================
void Cbuf_Execute (cmd_buf_t *cbuf);
/*! Performs deferred commands and runs Cbuf_Execute, called by Host_Frame */
void Cbuf_Frame (cmd_buf_t *cbuf);
+/// Clears all command buffers
+void Cbuf_Clear(cmd_buf_t *cbuf);
//===========================================================================
if (cls.state == ca_dedicated)
Sys_Error ("Host_Error: %s",hosterrorstring2); // dedicated servers exit
+ // prevent an endless loop if the error was triggered by a command
+ Cbuf_Clear(cmd_local->cbuf);
+
CL_Disconnect();
cls.demonum = -1;