+typedef struct cmddeferred_s
+{
+ struct cmddeferred_s *next;
+ char *value;
+ double time;
+} cmddeferred_t;
+
+static cmddeferred_t *cmd_deferred_list = NULL;
+
+/*
+============
+Cmd_Defer_f
+
+Cause a command to be executed after a delay.
+============
+*/
+static void Cmd_Defer_f (void)
+{
+ if(Cmd_Argc() == 1)
+ {
+ double time = Sys_DoubleTime();
+ cmddeferred_t *next = cmd_deferred_list;
+ if(!next)
+ Con_Printf("No commands are pending.\n");
+ while(next)
+ {
+ Con_Printf("-> In %9.2f: %s\n", next->time-time, next->value);
+ next = next->next;
+ }
+ } else if(Cmd_Argc() == 2 && !strcasecmp("clear", Cmd_Argv(1)))
+ {
+ while(cmd_deferred_list)
+ {
+ cmddeferred_t *cmd = cmd_deferred_list;
+ cmd_deferred_list = cmd->next;
+ Mem_Free(cmd->value);
+ Mem_Free(cmd);
+ }
+ } else if(Cmd_Argc() == 3)
+ {
+ const char *value = Cmd_Argv(2);
+ cmddeferred_t *defcmd = (cmddeferred_t*)Mem_Alloc(tempmempool, sizeof(*defcmd));
+ size_t len = strlen(value);
+
+ defcmd->time = Sys_DoubleTime() + atof(Cmd_Argv(1));
+ defcmd->value = (char*)Mem_Alloc(tempmempool, len+1);
+ memcpy(defcmd->value, value, len+1);
+ defcmd->next = NULL;
+
+ if(cmd_deferred_list)
+ {
+ cmddeferred_t *next = cmd_deferred_list;
+ while(next->next)
+ next = next->next;
+ next->next = defcmd;
+ } else
+ cmd_deferred_list = defcmd;
+ /* Stupid me... this changes the order... so commands with the same delay go blub :S
+ defcmd->next = cmd_deferred_list;
+ cmd_deferred_list = defcmd;*/
+ } else {
+ Con_Printf("usage: defer <seconds> <command>\n"
+ " defer clear\n");
+ return;
+ }
+}
+
+/*
+============
+Cmd_Centerprint_f
+
+Print something to the center of the screen using SCR_Centerprint
+============
+*/
+static void Cmd_Centerprint_f (void)
+{
+ char msg[MAX_INPUTLINE];
+ unsigned int i, c, p;
+ c = Cmd_Argc();
+ if(c >= 2)
+ {
+ strlcpy(msg, Cmd_Argv(1), sizeof(msg));
+ for(i = 2; i < c; ++i)
+ {
+ strlcat(msg, " ", sizeof(msg));
+ strlcat(msg, Cmd_Argv(i), sizeof(msg));
+ }
+ c = strlen(msg);
+ for(p = 0, i = 0; i < c; ++i)
+ {
+ if(msg[i] == '\\')
+ {
+ if(msg[i+1] == 'n')
+ msg[p++] = '\n';
+ else if(msg[i+1] == '\\')
+ msg[p++] = '\\';
+ else {
+ msg[p++] = '\\';
+ msg[p++] = msg[i+1];
+ }
+ ++i;
+ } else {
+ msg[p++] = msg[i];
+ }
+ }
+ msg[p] = '\0';
+ SCR_CenterPrint(msg);
+ }
+}
+