예제 #1
0
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;
}
예제 #2
0
/*
===============
G_PrintCurrentRotation

Print the current rotation to an entity
===============
*/
void G_PrintCurrentRotation( gentity_t *ent )
{
	int           mapRotationIndex = g_currentMapRotation.integer;
	mapRotation_t *mapRotation = G_MapRotationActive() ? &mapRotations.rotations[ mapRotationIndex ] : NULL;
	int           i = 0;
	char          currentMapName[ MAX_QPATH ];
	node_t        *node;

	if ( mapRotation == NULL )
	{
		trap_SendServerCommand( ent - g_entities, "print \"^3listrotation^3: ^7there is no active map rotation on this server\n\"" );
		return;
	}

	if ( mapRotation->numNodes == 0 )
	{
		trap_SendServerCommand( ent - g_entities, "print \"^3listrotation^3: ^7there are no maps in the active map rotation\n\"" );
		return;
	}

	trap_Cvar_VariableStringBuffer( "mapname", currentMapName, sizeof( currentMapName ) );

	ADMBP_begin();
	ADMBP( va( "%s:\n", mapRotation->name ) );

	while ( ( node = mapRotation->nodes[ i++ ] ) )
	{
		int  colour = 7;
		char *prefix;
		char *suffix = "";

		switch ( node->type )
		{
			case NT_RETURN:
				prefix = "return";
				break;

			case NT_LABEL:
				prefix = "label: ";
				break;

			case NT_GOTO:
				prefix = "goto: ";
				break;

			case NT_RESUME:
				prefix = "resume: ";
				break;

			default:
				prefix = "";
				break;
		}

		if ( node->type == NT_MAP && !G_MapExists( node->u.map.name ) )
		{
			colour = 1;
		}
		else if ( G_NodeIndexAfter( i - 1, mapRotationIndex ) == G_CurrentNodeIndex( mapRotationIndex ) )
		{
			colour = 3;

			if ( node->type == NT_MAP && Q_stricmp( node->u.map.name, currentMapName ) )
			{
				suffix = va( " (%s)", currentMapName );
			}
		}

		ADMBP(
		  va( " ^%i%3i %s%s%s\n",
		      colour,
		      i,
		      prefix,
		      node->type == NT_MAP ? node->u.map.name : node->u.label.name,
		      suffix ) );
	}

	if ( G_MapExists( g_nextMap.string ) )
	{
		ADMBP( va( "^7The next map has been set to %s\n", g_nextMap.string ) );
	}

	ADMBP_end();
}