summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
author/dev/humancontroller <devhc@example.com>2015-06-08 14:45:40 +0200
committer/dev/humancontroller <devhc@example.com>2017-03-09 13:51:16 +0100
commit7389310e98d7050d4e796aff641972effaad0f36 (patch)
treee36b16ee7a29c9eba3f6916504407e96c00d6717 /src/game
parent253fda567163917b0305f0df6156f22ca0a9ca70 (diff)
implement setnextmap: an admin command to set the next map and layout
Diffstat (limited to 'src/game')
-rw-r--r--src/game/g_admin.c50
-rw-r--r--src/game/g_admin.h1
2 files changed, 51 insertions, 0 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index c4d3c427..62a45572 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -185,6 +185,11 @@ g_admin_cmd_t g_admin_cmds[ ] =
"[^3name|slot#|admin#^7] [^3level^7]"
},
+ {"setnextmap", G_admin_setnextmap, qfalse, "setnextmap",
+ "set the next map (and, optionally, a forced layout)",
+ "[^3mapname^7] (^5layout^7)"
+ },
+
{"showbans", G_admin_showbans, qtrue, "showbans",
"display a (partial) list of active bans",
"(^5name|IP(/mask)^7) (^5start at ban#^7)"
@@ -2789,6 +2794,51 @@ qboolean G_admin_nextmap( gentity_t *ent )
return qtrue;
}
+qboolean G_admin_setnextmap( gentity_t *ent )
+{
+ int argc = trap_Argc();
+ char map[ MAX_QPATH ];
+ char layout[ MAX_QPATH ];
+
+ if( argc < 2 || argc > 3 )
+ {
+ ADMP( "^3setnextmap: ^7usage: setnextmap [map] (layout)\n" );
+ return qfalse;
+ }
+
+ trap_Argv( 1, map, sizeof( map ) );
+
+ if( !G_MapExists( map ) )
+ {
+ ADMP( va( "^3setnextmap: ^7map '%s' does not exist\n", map ) );
+ return qfalse;
+ }
+
+ if( argc > 2 )
+ {
+ trap_Argv( 2, layout, sizeof( layout ) );
+
+ if( !G_LayoutExists( map, layout ) )
+ {
+ ADMP( va( "^3setnextmap: ^7layout '%s' does not exist for map '%s'\n", layout, map ) );
+ return qfalse;
+ }
+
+ trap_Cvar_Set( "g_nextLayout", layout );
+ }
+ else
+ trap_Cvar_Set( "g_nextLayout", "" );
+ trap_Cvar_Update( &g_nextLayout );
+
+ trap_Cvar_Set( "g_nextMap", map );
+ trap_Cvar_Update( &g_nextMap );
+
+ AP( va( "print \"^3setnextmap: ^7%s^7 has set the next map to '%s'%s\n\"",
+ ( ent ) ? ent->client->pers.netname : "console", map,
+ argc > 2 ? va( " with layout '%s'", layout ) : "" ) );
+ return qtrue;
+}
+
static qboolean namelog_matchip( void *namelog, const void *ip )
{
int i;
diff --git a/src/game/g_admin.h b/src/game/g_admin.h
index da102c65..de51562b 100644
--- a/src/game/g_admin.h
+++ b/src/game/g_admin.h
@@ -176,6 +176,7 @@ qboolean G_admin_spec999( gentity_t *ent );
qboolean G_admin_rename( gentity_t *ent );
qboolean G_admin_restart( gentity_t *ent );
qboolean G_admin_nextmap( gentity_t *ent );
+qboolean G_admin_setnextmap( gentity_t *ent );
qboolean G_admin_namelog( gentity_t *ent );
qboolean G_admin_lock( gentity_t *ent );
qboolean G_admin_pause( gentity_t *ent );