From db20a6ce185a215f3c554d702ad76d757e4205e0 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Tue, 6 Oct 2020 23:38:05 +0300 Subject: [PATCH] Add ioquake3 vstr/nextdemo support --- doc/040_cvarlist.md | 5 +++++ doc/050_commands.md | 2 ++ src/common/cmdparser.c | 19 +++++++++++++++++++ src/server/sv_init.c | 5 ++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/doc/040_cvarlist.md b/doc/040_cvarlist.md index 6c41173e..71eb76da 100644 --- a/doc/040_cvarlist.md +++ b/doc/040_cvarlist.md @@ -129,6 +129,11 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable` spawned in maps (in fact, some official Ground Zero maps contain these entities). This cvar is set to 0 by default. +* **nextdemo**: Defines the next command to run after maps from the + `nextserver` list. By default this is set to the empty string. + +* **nextserver**: Used for looping the introduction demos. + ## Audio * **al_device**: OpenAL device to use. In most cases there's no need to diff --git a/doc/050_commands.md b/doc/050_commands.md index 0399064e..85b3117b 100644 --- a/doc/050_commands.md +++ b/doc/050_commands.md @@ -21,3 +21,5 @@ original clients (Vanilla Quake II) commands are still in place. * **listmaps**: Lists available maps for the player to load. Maps from loaded pak files will be listed first followed by maps placed in the current game's maps folder. + +* **vstr**: Inserts the current value of a variable as command text. diff --git a/src/common/cmdparser.c b/src/common/cmdparser.c index 6d0e710c..d772b258 100644 --- a/src/common/cmdparser.c +++ b/src/common/cmdparser.c @@ -366,6 +366,9 @@ Cbuf_AddLateCommands(void) return ret; } +/* + * Execute a script file + */ void Cmd_Exec_f(void) { @@ -401,6 +404,21 @@ Cmd_Exec_f(void) FS_FreeFile(f); } +/* + * Inserts the current value of a variable as command text + */ +void Cmd_Vstr_f( void ) { + const char *v; + + if (Cmd_Argc() != 2) { + Com_Printf("vstr : execute a variable command\n"); + return; + } + + v = Cvar_VariableString(Cmd_Argv(1)); + Cbuf_InsertText(va("%s\n", v)); +} + /* * Just prints the rest of the line to the console */ @@ -1111,6 +1129,7 @@ Cmd_Init(void) /* register our commands */ Cmd_AddCommand("cmdlist", Cmd_List_f); Cmd_AddCommand("exec", Cmd_Exec_f); + Cmd_AddCommand("vstr", Cmd_Vstr_f); Cmd_AddCommand("echo", Cmd_Echo_f); Cmd_AddCommand("alias", Cmd_Alias_f); Cmd_AddCommand("wait", Cmd_Wait_f); diff --git a/src/server/sv_init.c b/src/server/sv_init.c index f40b1ac9..b5e493a0 100644 --- a/src/server/sv_init.c +++ b/src/server/sv_init.c @@ -440,7 +440,10 @@ SV_Map(qboolean attractloop, char *levelstring, qboolean loadgame) } else { - Cvar_Set("nextserver", ""); + // use next demo command if list of map commands as empty + Cvar_Set("nextserver", (char*)Cvar_VariableString("nextdemo")); + // and cleanup nextdemo + Cvar_Set("nextdemo", ""); } /* hack for end game screen in coop mode */