summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author/dev/humancontroller <devhc@example.com>2017-03-09 08:43:39 +0100
committer/dev/humancontroller <devhc@example.com>2017-03-09 13:51:15 +0100
commit7b0078d927d4685d41fdff91a54c91dafad38644 (patch)
treeb374f2a861f419bbf36fcc11ab87b6a00f2892f4
parent4e42f2df0f599e0beb5e2a935049fb0670ba3e2b (diff)
execute map configuration scripts before loading the map
emit exec commands for the map configuration scripts before emitting any map or map_restart commands. during loading, if it is detected, that the scripts were not executed in advance (ie., on the first map load, or when subsequent map or map_restart commands are sent from the console), then emit exec commands for the scripts and restart the map
-rw-r--r--src/game/g_main.c11
-rw-r--r--src/game/g_maprotation.c7
2 files changed, 12 insertions, 6 deletions
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 15a4cb69..4858c75c 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -581,15 +581,20 @@ void G_InitGame( int levelTime, int randomSeed, int restart )
else
G_Printf( "Not logging to disk\n" );
+ if( g_mapConfigs.string[ 0 ] && !trap_Cvar_VariableIntegerValue( "g_mapConfigsLoaded" ) )
{
char map[ MAX_CVAR_VALUE_STRING ] = {""};
+ G_Printf( "InitGame: executing map configuration scripts and restarting\n" );
trap_Cvar_VariableStringBuffer( "mapname", map, sizeof( map ) );
G_MapConfigs( map );
+ trap_SendConsoleCommand( EXEC_APPEND, "wait\nmap_restart 0\n" );
+ }
+ else
+ {
+ // we're done with g_mapConfigs, so reset this for the next map
+ trap_Cvar_Set( "g_mapConfigsLoaded", "0" );
}
-
- // we're done with g_mapConfigs, so reset this for the next map
- trap_Cvar_Set( "g_mapConfigsLoaded", "0" );
// set this cvar to 0 if it exists, but otherwise avoid its creation
if( trap_Cvar_VariableIntegerValue( "g_rangeMarkerWarningGiven" ) )
diff --git a/src/game/g_maprotation.c b/src/game/g_maprotation.c
index fde6f8fc..0487079c 100644
--- a/src/game/g_maprotation.c
+++ b/src/game/g_maprotation.c
@@ -130,6 +130,9 @@ G_PerformMapRestart
*/
void G_PerformMapRestart( void )
{
+ char map[ MAX_CVAR_VALUE_STRING ];
+ trap_Cvar_VariableStringBuffer( "mapname", map, sizeof( map ) );
+ G_MapConfigs( map );
level.restarted = qtrue;
trap_SendConsoleCommand( EXEC_APPEND, "map_restart\n" );
}
@@ -142,6 +145,7 @@ G_PerformMapChange
void G_PerformMapChange( const char *map )
{
char buf[ MAX_STRING_CHARS ];
+ G_MapConfigs( map );
level.restarted = qtrue;
Q_snprintf( buf, sizeof( buf ), "map \"%s\"\n", map );
trap_SendConsoleCommand( EXEC_APPEND, buf );
@@ -895,9 +899,6 @@ static void G_IssueMapChange( int index, int rotation )
G_PerformMapChange( map->name );
- // Load up map defaults if g_mapConfigs is set
- G_MapConfigs( map->name );
-
if( strlen( map->postCommand ) > 0 )
trap_SendConsoleCommand( EXEC_APPEND, map->postCommand );
}