From 514d15b659bb4284fdb2a17e200480048ae56fbc Mon Sep 17 00:00:00 2001 From: IronClawTrem Date: Tue, 27 Aug 2019 00:42:24 +0100 Subject: restart the current map if the next map is the same as the current map --- src/game/g_main.c | 8 +++++++- src/game/g_maprotation.c | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/game/g_main.c b/src/game/g_main.c index 5386f9f..4ae31bb 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -1868,6 +1868,10 @@ void ExitLevel( void ) gclient_t *cl; buildHistory_t *tmp, *mark; + char currentmap[ MAX_CVAR_VALUE_STRING ]; + + trap_Cvar_VariableStringBuffer( "mapname", currentmap, sizeof( currentmap )); + if( level.mapRotationVoteTime ) { if( level.time < level.mapRotationVoteTime && @@ -1892,7 +1896,9 @@ void ExitLevel( void ) } } - if ( G_MapExists( g_nextMap.string ) ) + if( !Q_stricmp( currentmap, g_nextMap.string ) ) + trap_SendConsoleCommand( EXEC_APPEND, "map_restart\n" ); + else if ( G_MapExists( g_nextMap.string ) ) trap_SendConsoleCommand( EXEC_APPEND, va("!map %s\n", g_nextMap.string ) ); else if( G_MapRotationActive( ) ) G_AdvanceMapRotation( ); diff --git a/src/game/g_maprotation.c b/src/game/g_maprotation.c index a9d0261..a846c79 100644 --- a/src/game/g_maprotation.c +++ b/src/game/g_maprotation.c @@ -680,8 +680,10 @@ static void G_IssueMapChange( int rotation ) int map = G_GetCurrentMap( rotation ); char cmd[ MAX_TOKEN_CHARS ]; char newmap[ MAX_CVAR_VALUE_STRING ]; + char currentmap[ MAX_CVAR_VALUE_STRING ]; Q_strncpyz( newmap, mapRotations.rotations[rotation].maps[map].name, sizeof( newmap )); + trap_Cvar_VariableStringBuffer( "mapname", currentmap, sizeof( currentmap )); if (!Q_stricmp( newmap, "*VOTE*") ) { @@ -722,8 +724,14 @@ static void G_IssueMapChange( int rotation ) mapRotations.rotations[ rotation ].maps[ map ].layouts ); } - trap_SendConsoleCommand( EXEC_APPEND, va( "map %s\n", - newmap ) ); + if( !Q_stricmp( currentmap, newmap ) ) + { + trap_SendConsoleCommand( EXEC_APPEND, "map_restart\n" ); + } + else + { + trap_SendConsoleCommand( EXEC_APPEND, va( "map %s\n", newmap ) ); + } // load up map defaults if g_mapConfigs is set G_MapConfigs( newmap ); -- cgit