/* =============== G_IssueMapChange Send commands to the server to actually change the map =============== */ static void G_IssueMapChange( int rotation ) { int i; int map = G_GetCurrentMap( rotation ); char cmd[ MAX_TOKEN_CHARS ]; // allow a manually defined g_layouts setting to override the maprotation if( !g_layouts.string[ 0 ] && mapRotations.rotations[ rotation ].maps[ map ].layouts[ 0 ] ) { trap_Cvar_Set( "g_layouts", mapRotations.rotations[ rotation ].maps[ map ].layouts ); } trap_SendConsoleCommand( EXEC_APPEND, va( "map %s\n", mapRotations.rotations[ rotation ].maps[ map ].name ) ); // load up map defaults if g_mapConfigs is set G_MapConfigs( mapRotations.rotations[ rotation ].maps[ map ].name ); for( i = 0; i < mapRotations.rotations[ rotation ].maps[ map ].numCmds; i++ ) { Q_strncpyz( cmd, mapRotations.rotations[ rotation ].maps[ map ].postCmds[ i ], sizeof( cmd ) ); Q_strcat( cmd, sizeof( cmd ), "\n" ); trap_SendConsoleCommand( EXEC_APPEND, cmd ); } }
/* =============== G_AdvanceMapRotation Increment the current map rotation =============== */ qboolean G_AdvanceMapRotation( void ) { mapRotation_t *mr; mapRotationEntry_t *mre; mapRotationCondition_t *mrc; int currentRotation, currentMap, nextMap; int i, n; mapConditionType_t mct; if( ( currentRotation = g_currentMapRotation.integer ) == NOT_ROTATING ) return qfalse; currentMap = G_GetCurrentMap( currentRotation ); mr = &mapRotations.rotations[ currentRotation ]; mre = &mr->maps[ currentMap ]; nextMap = ( currentMap + 1 ) % mr->numMaps; for( i = 0; i < mre->numConditions; i++ ) { mrc = &mre->conditions[ i ]; if( mrc->unconditional || G_EvaluateMapCondition( mrc ) ) { mct = G_ResolveConditionDestination( &n, mrc->dest ); switch( mct ) { case MCT_MAP: nextMap = n; break; case MCT_ROTATION: //need to increment the current map before changing the rotation //or you get infinite loops with some conditionals G_SetCurrentMap( nextMap, currentRotation ); G_StartMapRotation( mrc->dest, qtrue ); return qtrue; break; default: case MCT_ERR: G_Printf( S_COLOR_YELLOW "WARNING: map switch destination could not be resolved: %s\n", mrc->dest ); break; } } } G_SetCurrentMap( nextMap, currentRotation ); G_IssueMapChange( currentRotation ); return qtrue; }
/* =============== G_CheckMapRotationVote =============== */ qboolean G_CheckMapRotationVote( void ) { mapRotation_t *mr; mapRotationEntry_t *mre; mapRotationCondition_t *mrc; int currentRotation, currentMap, nextMap; int i; rotationVoteLen = 0; if( g_mapRotationVote.integer < 1 ) return qfalse; if( ( currentRotation = g_currentMapRotation.integer ) == NOT_ROTATING ) return qfalse; currentMap = G_GetCurrentMap( currentRotation ); mr = &mapRotations.rotations[ currentRotation ]; nextMap = ( currentMap + 1 ) % mr->numMaps; mre = &mr->maps[ nextMap ]; for( i = 0; i < mre->numConditions; i++ ) { mrc = &mre->conditions[ i ]; if( mrc->lhs == MCV_VOTE ) { Q_strncpyz( rotationVoteList[ rotationVoteLen ], mrc->dest, sizeof( rotationVoteList[ rotationVoteLen ] ) ); rotationVoteLen++; if( rotationVoteLen >= MAX_MAP_ROTATION_CONDS ) break; } } if( !rotationVoteLen ) return qfalse; for( i = 0; i < MAX_CLIENTS; i++ ) { rotationVoteClientPosition[ i ] = 0; rotationVoteClientSelection[ i ] = -1; } return qtrue; }
/* =============== G_IssueMapChange Send commands to the server to actually change the map =============== */ static void G_IssueMapChange( int rotation ) { int i; int map = G_GetCurrentMap( rotation ); char cmd[ MAX_TOKEN_CHARS ]; trap_SendConsoleCommand( EXEC_APPEND, va( "map %s\n", mapRotations.rotations[ rotation ].maps[ map ].name ) ); for( i = 0; i < mapRotations.rotations[ rotation ].maps[ map ].numCmds; i++ ) { Q_strncpyz( cmd, mapRotations.rotations[ rotation ].maps[ map ].postCmds[ i ], sizeof( cmd ) ); Q_strcat( cmd, sizeof( cmd ), "\n" ); trap_SendConsoleCommand( EXEC_APPEND, cmd ); } }
/* =============== G_IssueMapChange Send commands to the server to actually change the map =============== */ static void G_IssueMapChange( int rotation ) { int i; int map = G_GetCurrentMap( rotation ); char cmd[ MAX_TOKEN_CHARS ]; char newmap[ MAX_CVAR_VALUE_STRING ]; Q_strncpyz( newmap, mapRotations.rotations[rotation].maps[map].name, sizeof( newmap )); if (!Q_stricmp( newmap, "*VOTE*") ) { fileHandle_t f; G_GetVotedMap( newmap, sizeof( newmap ), rotation, map ); if( trap_FS_FOpenFile( va("maps/%s.bsp", newmap), &f, FS_READ ) > 0 ) { trap_FS_FCloseFile( f ); } else { G_AdvanceMapRotation(); return; } } // allow a manually defined g_layouts setting to override the maprotation if( !g_layouts.string[ 0 ] && mapRotations.rotations[ rotation ].maps[ map ].layouts[ 0 ] ) { trap_Cvar_Set( "g_layouts", mapRotations.rotations[ rotation ].maps[ map ].layouts ); } trap_SendConsoleCommand( EXEC_APPEND, va( "map %s\n", newmap ) ); // load up map defaults if g_mapConfigs is set G_MapConfigs( newmap ); for( i = 0; i < mapRotations.rotations[ rotation ].maps[ map ].numCmds; i++ ) { Q_strncpyz( cmd, mapRotations.rotations[ rotation ].maps[ map ].postCmds[ i ], sizeof( cmd ) ); Q_strcat( cmd, sizeof( cmd ), "\n" ); trap_SendConsoleCommand( EXEC_APPEND, cmd ); } }
qboolean G_CurrentMapIsRotation( void ) { char mapname[ 64 ]; int map, rotation; int i; // Check for an active map rotation, // only return false if rotation is running and current map is not from it if ( !G_MapRotationActive() || g_currentMapRotation.integer == NOT_ROTATING ) return qtrue; rotation = g_currentMapRotation.integer; if( !( rotation >= 0 && rotation < mapRotations.numRotations ) ) return qtrue; map = G_GetCurrentMap( rotation ); if( !(map >= 0 && map < mapRotations.rotations[ rotation ].numMaps ) ) return qtrue; trap_Cvar_VariableStringBuffer( "mapname", mapname, sizeof( mapname ) ); if( !Q_stricmp( mapRotations.rotations[ rotation ].maps[ map ].name, mapname ) ) return qtrue; if( !Q_stricmp( mapRotations.rotations[ rotation ].maps[ map ].name, "*VOTE*" ) ) { for( i = 0; i < mapRotations.rotations[ rotation ].maps[ map ].numConditions; i++ ) { if( mapRotations.rotations[ rotation ].maps[ map ].conditions[ i ].lhs == MCV_VOTE && !Q_stricmp( mapRotations.rotations[ rotation ].maps[ map ].conditions[ i ].dest, mapname ) ) return qtrue; } } return qfalse; }