summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author/dev/humancontroller <devhc@example.com>2017-03-09 07:06:30 +0100
committer/dev/humancontroller <devhc@example.com>2017-03-09 13:51:15 +0100
commit5092712ab377f401fa0b874a990ab7d3cabd08db (patch)
tree4855836136cd09c9c22501098c08a795cb4c3712
parentac941c9413cf378985e7506f1c245fbfdf319e60 (diff)
add G_PerformMapChange() and G_PerformMapRestart(), and use them
currently, they abstract the use of trap_SendConsoleCommand() this change happens to add an instance of ``level.restarted = qtrue;''
-rw-r--r--src/game/g_admin.c10
-rw-r--r--src/game/g_local.h2
-rw-r--r--src/game/g_main.c4
-rw-r--r--src/game/g_maprotation.c26
-rw-r--r--src/game/g_svcmds.c3
5 files changed, 36 insertions, 9 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index 4d4c15a7..25e63f46 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -2068,11 +2068,12 @@ qboolean G_admin_changemap( gentity_t *ent )
admin_log( map );
admin_log( layout );
- trap_SendConsoleCommand( EXEC_APPEND, va( "map \"%s\"\n", map ) );
- level.restarted = qtrue;
AP( va( "print \"^3changemap: ^7map '%s' started by %s^7 %s\n\"", map,
( ent ) ? ent->client->pers.netname : "console",
( layout[ 0 ] ) ? va( "(forcing layout '%s')", layout ) : "" ) );
+
+ G_PerformMapChange( map );
+
return qtrue;
}
@@ -2771,12 +2772,13 @@ qboolean G_admin_restart( gentity_t *ent )
!Q_stricmp( teampref, "keepteamslock" ) )
trap_Cvar_Set( "g_lockTeamsAtStart", "1" );
- trap_SendConsoleCommand( EXEC_APPEND, "map_restart\n" );
-
AP( va( "print \"^3restart: ^7map restarted by %s %s %s\n\"",
( ent ) ? ent->client->pers.netname : "console",
( layout[ 0 ] ) ? va( "^7(forcing layout '%s^7')", layout ) : "",
( teampref[ 0 ] ) ? va( "^7(with teams option: '%s^7')", teampref ) : "" ) );
+
+ G_PerformMapRestart();
+
return qtrue;
}
diff --git a/src/game/g_local.h b/src/game/g_local.h
index bc1fef27..4b47c896 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -1048,6 +1048,8 @@ void G_InitMapRotations( void );
void G_ShutdownMapRotations( void );
qboolean G_MapExists( char *name );
void G_ClearRotationStack( void );
+void G_PerformMapRestart( void );
+void G_PerformMapChange( const char *map );
//
// g_namelog.c
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 6bd86887..5ab04d94 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -1641,11 +1641,11 @@ void ExitLevel( void )
gclient_t *cl;
if ( G_MapExists( g_nextMap.string ) )
- trap_SendConsoleCommand( EXEC_APPEND, va("map \"%s\"\n", g_nextMap.string ) );
+ G_PerformMapChange( g_nextMap.string );
else if( G_MapRotationActive( ) )
G_AdvanceMapRotation( 0 );
else
- trap_SendConsoleCommand( EXEC_APPEND, "map_restart\n" );
+ G_PerformMapRestart();
trap_Cvar_Set( "g_nextMap", "" );
diff --git a/src/game/g_maprotation.c b/src/game/g_maprotation.c
index e9f87b37..fde6f8fc 100644
--- a/src/game/g_maprotation.c
+++ b/src/game/g_maprotation.c
@@ -125,6 +125,30 @@ qboolean G_MapExists( char *name )
/*
===============
+G_PerformMapRestart
+===============
+*/
+void G_PerformMapRestart( void )
+{
+ level.restarted = qtrue;
+ trap_SendConsoleCommand( EXEC_APPEND, "map_restart\n" );
+}
+
+/*
+===============
+G_PerformMapChange
+===============
+*/
+void G_PerformMapChange( const char *map )
+{
+ char buf[ MAX_STRING_CHARS ];
+ level.restarted = qtrue;
+ Q_snprintf( buf, sizeof( buf ), "map \"%s\"\n", map );
+ trap_SendConsoleCommand( EXEC_APPEND, buf );
+}
+
+/*
+===============
G_RotationExists
Check if a rotation exists
@@ -869,7 +893,7 @@ static void G_IssueMapChange( int index, int rotation )
trap_Cvar_Set( "g_layouts", map->layouts );
}
- trap_SendConsoleCommand( EXEC_APPEND, va( "map \"%s\"\n", map->name ) );
+ G_PerformMapChange( map->name );
// Load up map defaults if g_mapConfigs is set
G_MapConfigs( map->name );
diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c
index 262f8744..952c6801 100644
--- a/src/game/g_svcmds.c
+++ b/src/game/g_svcmds.c
@@ -267,8 +267,7 @@ static void Svcmd_LayoutLoad_f( void )
s = ConcatArgs( 1 );
Q_strncpyz( layouts, s, sizeof( layouts ) );
trap_Cvar_Set( "g_layouts", layouts );
- trap_SendConsoleCommand( EXEC_APPEND, "map_restart\n" );
- level.restarted = qtrue;
+ G_PerformMapRestart();
}
static void Svcmd_AdmitDefeat_f( void )