From 7389310e98d7050d4e796aff641972effaad0f36 Mon Sep 17 00:00:00 2001 From: /dev/humancontroller Date: Mon, 8 Jun 2015 14:45:40 +0200 Subject: implement setnextmap: an admin command to set the next map and layout --- src/game/g_admin.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/game/g_admin.h | 1 + 2 files changed, 51 insertions(+) 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 ); -- cgit