//***************************************************************************** // static void MAPROTATION_CalcNextMap( void ) { if ( g_MapRotationEntries.empty( )) return; if ( sv_randommaprotation ) { // Mark the current map in the list as being used. g_MapRotationEntries[g_ulCurMapInList].bUsed = true; // If all the maps have been played, make them all available again. { bool bAllMapsPlayed = true; for ( ULONG ulIdx = 0; ulIdx < g_MapRotationEntries.size( ); ulIdx++ ) { if ( !g_MapRotationEntries[ulIdx].bUsed ) { bAllMapsPlayed = false; break; } } if ( bAllMapsPlayed ) { for ( ULONG ulIdx = 0; ulIdx < g_MapRotationEntries.size( ); ulIdx++ ) g_MapRotationEntries[ulIdx].bUsed = false; } } // Select a new map. do { g_ulNextMapInList = M_Random.Random( ) % g_MapRotationEntries.size( ); } while (( g_MapRotationEntries[g_ulNextMapInList].bUsed == true ) || ( g_ulNextMapInList == g_ulCurMapInList )); } else { g_ulNextMapInList = g_ulCurMapInList + 1; g_ulNextMapInList = ( g_ulNextMapInList % MAPROTATION_GetNumEntries( )); } }
//***************************************************************************** // static bool callvote_CheckValidity( FString &Command, FString &Parameters ) { // Get the type of vote this is. ULONG ulVoteCmd = callvote_GetVoteType( Command.GetChars( )); if ( ulVoteCmd == NUM_VOTECMDS ) return ( false ); // Check for any illegal characters. if ( callvote_IsKickVote ( ulVoteCmd ) == false ) { int i = 0; while ( Parameters.GetChars()[i] != '\0' ) { if ( Parameters.GetChars()[i] == ';' || Parameters.GetChars()[i] == ' ' ) { if ( NETWORK_GetState( ) == NETSTATE_SERVER ) SERVER_PrintfPlayer( PRINT_HIGH, SERVER_GetCurrentClient( ), "That vote command contained illegal characters.\n" ); return ( false ); } i++; } } // Then, make sure the parameter for each vote is valid. int parameterInt = atoi( Parameters.GetChars() ); switch ( ulVoteCmd ) { case VOTECMD_KICK: case VOTECMD_KICKFROMGAME: { if ( NETWORK_GetState( ) == NETSTATE_SERVER ) { // Store the player's IP so he can't get away. ULONG ulIdx = SERVER_GetPlayerIndexFromName( Parameters.GetChars( ), true, false ); if ( ulIdx < MAXPLAYERS ) { if ( static_cast<LONG>(ulIdx) == SERVER_GetCurrentClient( )) { SERVER_PrintfPlayer( PRINT_HIGH, SERVER_GetCurrentClient( ), "You cannot call a vote to kick or to force to spectate yourself!\n" ); return ( false ); } // [BB] Don't allow anyone to kick somebody who is on the admin list. [K6] ...or is logged into RCON. if ( SERVER_GetAdminList()->isIPInList( SERVER_GetClient( ulIdx )->Address ) || SERVER_GetClient( ulIdx )->bRCONAccess ) { SERVER_PrintfPlayer( PRINT_HIGH, SERVER_GetCurrentClient( ), "This player is a server admin and thus can't be kicked or forced to spectate!\n" ); return ( false ); } g_KickVoteVictimAddress = SERVER_GetClient( ulIdx )->Address; return ( true ); } else { SERVER_PrintfPlayer( PRINT_HIGH, SERVER_GetCurrentClient( ), "That player doesn't exist.\n" ); return ( false ); } } } break; case VOTECMD_MAP: case VOTECMD_CHANGEMAP: // Don't allow the command if the map doesn't exist. if ( !P_CheckIfMapExists( Parameters.GetChars( ))) { if ( NETWORK_GetState( ) == NETSTATE_SERVER ) SERVER_PrintfPlayer( PRINT_HIGH, SERVER_GetCurrentClient( ), "That map does not exist.\n" ); return ( false ); } // Don't allow us to leave the map rotation. if ( NETWORK_GetState( ) == NETSTATE_SERVER ) { // [BB] Regardless of sv_maprotation, if the server has maps in the rotation, // assume players are restricted to these maps. if ( ( MAPROTATION_GetNumEntries() > 0 ) && ( MAPROTATION_IsMapInRotation( Parameters.GetChars( ) ) == false ) ) { SERVER_PrintfPlayer( PRINT_HIGH, SERVER_GetCurrentClient( ), "That map is not in the map rotation.\n" ); return ( false ); } } break; case VOTECMD_FRAGLIMIT: case VOTECMD_WINLIMIT: case VOTECMD_DUELLIMIT: // Parameteter be between 0 and 255. if (( parameterInt < 0 ) || ( parameterInt >= 256 )) { if ( NETWORK_GetState( ) == NETSTATE_SERVER ) SERVER_PrintfPlayer( PRINT_HIGH, SERVER_GetCurrentClient( ), "%s parameters must be between 0 and 255.\n", Command.GetChars() ); return ( false ); } else if ( parameterInt == 0 ) { if (( Parameters.GetChars()[0] != '0' ) || ( Parameters.Len() != 1 )) return ( false ); } Parameters.Format( "%d", parameterInt ); break; case VOTECMD_TIMELIMIT: case VOTECMD_POINTLIMIT: // Parameteter must be between 0 and 65535. if (( parameterInt < 0 ) || ( parameterInt >= 65536 )) { if ( NETWORK_GetState( ) == NETSTATE_SERVER ) SERVER_PrintfPlayer( PRINT_HIGH, SERVER_GetCurrentClient( ), "%s parameters must be between 0 and 65535.\n", Command.GetChars() ); return ( false ); } else if ( parameterInt == 0 ) { if (( Parameters.GetChars()[0] != '0' ) || ( Parameters.Len() != 1 )) return ( false ); } Parameters.Format( "%d", parameterInt ); break; default: return ( false ); } // Passed all checks! return ( true ); }