/* =============== G_GotoLabel Resolve the label of some condition =============== */ static qboolean G_GotoLabel( int rotation, int nodeIndex, char *name, qboolean reset_index, int depth ) { node_t *node; int i; // Search the rotation names... if ( G_StartMapRotation( name, qtrue, qtrue, reset_index, depth ) ) { return qtrue; } // ...then try labels in the rotation for ( i = 0; i < mapRotations.rotations[ rotation ].numNodes; i++ ) { node = mapRotations.rotations[ rotation ].nodes[ i ]; if ( node->type == NT_LABEL && !Q_stricmp( node->u.label.name, name ) ) { G_SetCurrentNodeByIndex( G_NodeIndexAfter( i, rotation ), rotation ); G_AdvanceMapRotation( depth ); return qtrue; } } // finally check for a map by name for ( i = 0; i < mapRotations.rotations[ rotation ].numNodes; i++ ) { nodeIndex = G_NodeIndexAfter( nodeIndex, rotation ); node = mapRotations.rotations[ rotation ].nodes[ nodeIndex ]; if ( node->type == NT_MAP && !Q_stricmp( node->u.map.name, name ) ) { G_SetCurrentNodeByIndex( nodeIndex, rotation ); G_AdvanceMapRotation( depth ); return qtrue; } } return qfalse; }
/* =============== 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 ); } }
/* =============== G_StartMapRotation Switch to a new map rotation =============== */ qboolean G_StartMapRotation( char *name, qboolean advance, qboolean putOnStack, qboolean reset_index, int depth ) { int i; int currentRotation = g_currentMapRotation.integer; for ( i = 0; i < mapRotations.numRotations; i++ ) { if ( !Q_stricmp( mapRotations.rotations[ i ].name, name ) ) { if ( putOnStack && currentRotation >= 0 ) { G_PushRotationStack( currentRotation ); } trap_Cvar_Set( "g_currentMapRotation", va( "%d", i ) ); trap_Cvar_Update( &g_currentMapRotation ); if ( advance ) { if ( reset_index ) { G_SetCurrentNodeByIndex( 0, i ); } G_AdvanceMapRotation( depth ); } break; } } if ( i == mapRotations.numRotations ) { return qfalse; } else { return qtrue; } }
static void Svcmd_G_AdvanceMapRotation_f( void ) { G_AdvanceMapRotation( 0 ); }