================ idMultiplayerGame::ServerCallVote ================ */
| 2708 | ================ |
| 2709 | */ |
| 2710 | void idMultiplayerGame::ServerCallVote( int clientNum, const idBitMsg &msg ) { |
| 2711 | vote_flags_t voteIndex; |
| 2712 | int vote_timeLimit, vote_fragLimit, vote_clientNum, vote_gameTypeIndex; //, vote_kickIndex; |
| 2713 | char value[ MAX_STRING_CHARS ]; |
| 2714 | |
| 2715 | assert( clientNum != -1 ); |
| 2716 | assert( !gameLocal.isClient ); |
| 2717 | |
| 2718 | voteIndex = (vote_flags_t)msg.ReadByte( ); |
| 2719 | msg.ReadString( value, sizeof( value ) ); |
| 2720 | |
| 2721 | // sanity checks - setup the vote |
| 2722 | if ( vote != VOTE_NONE ) { |
| 2723 | gameLocal.ServerSendChatMessage( clientNum, "server", common->GetLanguageDict()->GetString( "#str_04273" ) ); |
| 2724 | common->DPrintf( "client %d: called vote while voting already in progress - ignored\n", clientNum ); |
| 2725 | return; |
| 2726 | } |
| 2727 | switch ( voteIndex ) { |
| 2728 | case VOTE_RESTART: |
| 2729 | ServerStartVote( clientNum, voteIndex, "" ); |
| 2730 | ClientStartVote( clientNum, common->GetLanguageDict()->GetString( "#str_04271" ) ); |
| 2731 | break; |
| 2732 | case VOTE_NEXTMAP: |
| 2733 | ServerStartVote( clientNum, voteIndex, "" ); |
| 2734 | ClientStartVote( clientNum, common->GetLanguageDict()->GetString( "#str_04272" ) ); |
| 2735 | break; |
| 2736 | case VOTE_TIMELIMIT: |
| 2737 | vote_timeLimit = strtol( value, NULL, 10 ); |
| 2738 | if ( vote_timeLimit == gameLocal.serverInfo.GetInt( "si_timeLimit" ) ) { |
| 2739 | gameLocal.ServerSendChatMessage( clientNum, "server", common->GetLanguageDict()->GetString( "#str_04270" ) ); |
| 2740 | common->DPrintf( "client %d: already at the voted Time Limit\n", clientNum ); |
| 2741 | return; |
| 2742 | } |
| 2743 | if ( vote_timeLimit < si_timeLimit.GetMinValue() || vote_timeLimit > si_timeLimit.GetMaxValue() ) { |
| 2744 | gameLocal.ServerSendChatMessage( clientNum, "server", common->GetLanguageDict()->GetString( "#str_04269" ) ); |
| 2745 | common->DPrintf( "client %d: timelimit value out of range for vote: %s\n", clientNum, value ); |
| 2746 | return; |
| 2747 | } |
| 2748 | ServerStartVote( clientNum, voteIndex, value ); |
| 2749 | ClientStartVote( clientNum, va( common->GetLanguageDict()->GetString( "#str_04268" ), vote_timeLimit ) ); |
| 2750 | break; |
| 2751 | case VOTE_FRAGLIMIT: |
| 2752 | vote_fragLimit = strtol( value, NULL, 10 ); |
| 2753 | if ( vote_fragLimit == gameLocal.serverInfo.GetInt( "si_fragLimit" ) ) { |
| 2754 | gameLocal.ServerSendChatMessage( clientNum, "server", common->GetLanguageDict()->GetString( "#str_04267" ) ); |
| 2755 | common->DPrintf( "client %d: already at the voted Frag Limit\n", clientNum ); |
| 2756 | return; |
| 2757 | } |
| 2758 | if ( vote_fragLimit < si_fragLimit.GetMinValue() || vote_fragLimit > si_fragLimit.GetMaxValue() ) { |
| 2759 | gameLocal.ServerSendChatMessage( clientNum, "server", common->GetLanguageDict()->GetString( "#str_04266" ) ); |
| 2760 | common->DPrintf( "client %d: fraglimit value out of range for vote: %s\n", clientNum, value ); |
| 2761 | return; |
| 2762 | } |
| 2763 | ServerStartVote( clientNum, voteIndex, value ); |
| 2764 | ClientStartVote( clientNum, va( common->GetLanguageDict()->GetString( "#str_04303" ), gameLocal.gameType == GAME_LASTMAN ? common->GetLanguageDict()->GetString( "#str_04264" ) : common->GetLanguageDict()->GetString( "#str_04265" ), vote_fragLimit ) ); |
| 2765 | break; |
| 2766 | case VOTE_GAMETYPE: |
| 2767 | vote_gameTypeIndex = strtol( value, NULL, 10 ); |
no test coverage detected