================ idMultiplayerGame::ServerCallVote ================ */
| 3399 | ================ |
| 3400 | */ |
| 3401 | void idMultiplayerGame::ServerCallVote( int clientNum, const idBitMsg &msg ) { |
| 3402 | vote_flags_t voteIndex; |
| 3403 | int vote_timeLimit, vote_fragLimit, vote_clientNum, vote_gameTypeIndex; //, vote_kickIndex; |
| 3404 | char value[ MAX_STRING_CHARS ]; |
| 3405 | |
| 3406 | assert( clientNum != -1 ); |
| 3407 | assert( !gameLocal.isClient ); |
| 3408 | |
| 3409 | voteIndex = (vote_flags_t)msg.ReadByte( ); |
| 3410 | msg.ReadString( value, sizeof( value ) ); |
| 3411 | |
| 3412 | // sanity checks - setup the vote |
| 3413 | if ( vote != VOTE_NONE ) { |
| 3414 | gameLocal.ServerSendChatMessage( clientNum, "server", common->GetLanguageDict()->GetString( "#str_04273" ) ); |
| 3415 | common->DPrintf( "client %d: called vote while voting already in progress - ignored\n", clientNum ); |
| 3416 | return; |
| 3417 | } |
| 3418 | switch ( voteIndex ) { |
| 3419 | case VOTE_RESTART: |
| 3420 | ServerStartVote( clientNum, voteIndex, "" ); |
| 3421 | ClientStartVote( clientNum, common->GetLanguageDict()->GetString( "#str_04271" ) ); |
| 3422 | break; |
| 3423 | case VOTE_NEXTMAP: |
| 3424 | ServerStartVote( clientNum, voteIndex, "" ); |
| 3425 | ClientStartVote( clientNum, common->GetLanguageDict()->GetString( "#str_04272" ) ); |
| 3426 | break; |
| 3427 | case VOTE_TIMELIMIT: |
| 3428 | vote_timeLimit = strtol( value, NULL, 10 ); |
| 3429 | if ( vote_timeLimit == gameLocal.serverInfo.GetInt( "si_timeLimit" ) ) { |
| 3430 | gameLocal.ServerSendChatMessage( clientNum, "server", common->GetLanguageDict()->GetString( "#str_04270" ) ); |
| 3431 | common->DPrintf( "client %d: already at the voted Time Limit\n", clientNum ); |
| 3432 | return; |
| 3433 | } |
| 3434 | if ( vote_timeLimit < si_timeLimit.GetMinValue() || vote_timeLimit > si_timeLimit.GetMaxValue() ) { |
| 3435 | gameLocal.ServerSendChatMessage( clientNum, "server", common->GetLanguageDict()->GetString( "#str_04269" ) ); |
| 3436 | common->DPrintf( "client %d: timelimit value out of range for vote: %s\n", clientNum, value ); |
| 3437 | return; |
| 3438 | } |
| 3439 | ServerStartVote( clientNum, voteIndex, value ); |
| 3440 | ClientStartVote( clientNum, va( common->GetLanguageDict()->GetString( "#str_04268" ), vote_timeLimit ) ); |
| 3441 | break; |
| 3442 | case VOTE_FRAGLIMIT: |
| 3443 | vote_fragLimit = strtol( value, NULL, 10 ); |
| 3444 | if ( vote_fragLimit == gameLocal.serverInfo.GetInt( "si_fragLimit" ) ) { |
| 3445 | gameLocal.ServerSendChatMessage( clientNum, "server", common->GetLanguageDict()->GetString( "#str_04267" ) ); |
| 3446 | common->DPrintf( "client %d: already at the voted Frag Limit\n", clientNum ); |
| 3447 | return; |
| 3448 | } |
| 3449 | if ( vote_fragLimit < si_fragLimit.GetMinValue() || vote_fragLimit > si_fragLimit.GetMaxValue() ) { |
| 3450 | gameLocal.ServerSendChatMessage( clientNum, "server", common->GetLanguageDict()->GetString( "#str_04266" ) ); |
| 3451 | common->DPrintf( "client %d: fraglimit value out of range for vote: %s\n", clientNum, value ); |
| 3452 | return; |
| 3453 | } |
| 3454 | ServerStartVote( clientNum, voteIndex, value ); |
| 3455 | ClientStartVote( clientNum, va( common->GetLanguageDict()->GetString( "#str_04303" ), gameLocal.gameType == GAME_LASTMAN ? common->GetLanguageDict()->GetString( "#str_04264" ) : common->GetLanguageDict()->GetString( "#str_04265" ), vote_fragLimit ) ); |
| 3456 | break; |
| 3457 | case VOTE_GAMETYPE: |
| 3458 | vote_gameTypeIndex = strtol( value, NULL, 10 ); |
no test coverage detected