Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -r af45c72387f5 src/CMakeLists.txt
- --- a/src/CMakeLists.txt Sat Jul 27 09:47:16 2013 +0200
- +++ b/src/CMakeLists.txt Fri Aug 02 02:25:44 2013 +0300
- @@ -829,6 +829,7 @@
- v_pfx.cpp
- v_text.cpp
- v_video.cpp
- + votedef.cpp
- w_wad.cpp
- wi_stuff.cpp
- zstrformat.cpp
- diff -r af45c72387f5 src/callvote.cpp
- --- a/src/callvote.cpp Sat Jul 27 09:47:16 2013 +0200
- +++ b/src/callvote.cpp Fri Aug 02 02:25:44 2013 +0300
- @@ -65,13 +65,14 @@
- #include "sv_main.h"
- #include "v_video.h"
- #include "maprotation.h"
- +#include "votedef.h"
- #include <list>
- //*****************************************************************************
- // VARIABLES
- static VOTESTATE_e g_VoteState;
- -static FString g_VoteCommand;
- +static FString g_VoteDisplay;
- static FString g_VoteReason;
- static ULONG g_ulVoteCaller;
- static ULONG g_ulVoteCountdownTicks = 0;
- @@ -83,6 +84,8 @@
- static ULONG g_ulPlayersWhoVotedNo[(MAXPLAYERS / 2) + 1];
- static NETADDRESS_s g_KickVoteVictimAddress;
- static std::list<VOTE_s> g_PreviousVotes;
- +static VoteDef::ApplyInput g_VoteData;
- +static FString g_zCurrentSummary;
- //*****************************************************************************
- // PROTOTYPES
- @@ -90,9 +93,8 @@
- static void callvote_EndVote( void );
- static ULONG callvote_CountPlayersWhoVotedYes( void );
- static ULONG callvote_CountPlayersWhoVotedNo( void );
- -static bool callvote_CheckForFlooding( FString &Command, FString &Parameters, ULONG ulPlayer );
- -static bool callvote_CheckValidity( FString &Command, FString &Parameters );
- -static ULONG callvote_GetVoteType( const char *pszCommand );
- +static bool callvote_CheckForFlooding( ULONG& Command, FString& Parameters, ULONG ulPlayer );
- +static bool callvote_CheckValidity( ULONG ulCommand, FString &Parameters );
- //*****************************************************************************
- // FUNCTIONS
- @@ -153,18 +155,31 @@
- ( NETWORK_GetState( ) != NETSTATE_CLIENT ) &&
- ( CLIENTDEMO_IsPlaying( ) == false ))
- {
- - // [BB, RC] If the vote is a kick vote, we have to rewrite g_VoteCommand to both use the stored IP, and temporarily ban it.
- - // [Dusk] Write the kick reason into the ban reason, [BB] but only if it's not empty.
- - if ( strncmp( g_VoteCommand, "kick", 4 ) == 0 )
- + // [Dusk] VOTEDEFized
- + VoteDef* pVoteType = VoteDef::findByIndex( g_VoteData.type );
- + VoteDef::ApplyResult output;
- + g_VoteData.yes = callvote_CountPlayersWhoVotedYes( );
- + g_VoteData.no = callvote_CountPlayersWhoVotedNo( );
- + if ( VoteDef::applyCommand( g_VoteData, output ))
- {
- - g_VoteCommand.Format( "addban %s 10min \"Vote kick, %d to %d", NETWORK_AddressToString( g_KickVoteVictimAddress ), static_cast<int>(callvote_CountPlayersWhoVotedYes( )), static_cast<int>(callvote_CountPlayersWhoVotedNo( )) );
- - if ( g_VoteReason.IsNotEmpty() )
- - g_VoteCommand.AppendFormat ( " (%s)", g_VoteReason.GetChars( ) );
- - g_VoteCommand += ".\"";
- + if ( pVoteType->nativeType() != VoteDef::NumNatives )
- + {
- + Printf( "[VOTE] -> %s\n", output.command.GetChars() );
- + AddCommandString( const_cast<char*>( output.command.GetChars() ));
- + }
- + else
- + {
- + Printf( "[VOTE] -> Script %lu (%ld)\n", pVoteType->scriptNum(), output.arg );
- + int p = g_VoteData.caller;
- + AActor* mo = ( playeringame[p] && players[p].mo != NULL ) ? players[p].mo : NULL;
- + P_StartScript( mo, NULL, pVoteType->scriptNum(), NULL, false,
- + output.arg, 0, 0, 1, false );
- + }
- }
- + else
- + SERVER_Printf( PRINT_HIGH, "\\c[Orange]Vote command error: %s\n", output.error.GetChars() );
- + }
- - AddCommandString( (char *)g_VoteCommand.GetChars( ));
- - }
- // Reset the module.
- CALLVOTE_ClearVote( );
- }
- @@ -175,7 +190,7 @@
- //*****************************************************************************
- //
- -void CALLVOTE_BeginVote( FString Command, FString Parameters, FString Reason, ULONG ulPlayer )
- +void CALLVOTE_BeginVote( ULONG Command, FString Parameters, FString Reason, ULONG ulPlayer )
- {
- // Don't allow a vote in the middle of another vote.
- if ( g_VoteState != VOTESTATE_NOVOTE )
- @@ -185,6 +200,13 @@
- return;
- }
- + g_VoteData.arg = Parameters;
- + g_VoteData.caller = SERVER_GetCurrentClient( );
- + g_VoteData.yes = g_VoteData.no = 0;
- + g_VoteData.type = Command;
- + g_VoteData.reason = Reason;
- + g_zCurrentSummary = VoteDef::makeSummary( g_VoteData );
- +
- // Check and make sure all the parameters are valid.
- if ( callvote_CheckValidity( Command, Parameters ) == false )
- return;
- @@ -196,36 +218,44 @@
- // Play the announcer sound for this.
- ANNOUNCER_PlayEntry( cl_announcer, "VoteNow" );
- + VoteDef* pVoteType = VoteDef::findByIndex( Command );
- +
- // Create the vote console command.
- - g_VoteCommand = Command;
- - g_VoteCommand += " ";
- - g_VoteCommand += Parameters;
- + // [Dusk] Note: this is only used for clients' vote displays.
- + // The real command (or script call) is generated later on.
- + g_VoteDisplay = pVoteType->name();
- + if( Parameters.IsNotEmpty() )
- + {
- + g_VoteDisplay += " ";
- + g_VoteDisplay += Parameters;
- + }
- +
- g_ulVoteCaller = ulPlayer;
- g_VoteReason = Reason.Left(25);
- + // [Dusk] Store IP addresses in VOTEDEF memory so that nobody gets away from kickvotes.
- + VoteDef::storeIPAddresses();
- +
- // Create the record of the vote for flood prevention.
- {
- VOTE_s VoteRecord;
- + time( &VoteRecord.tTimeCalled );
- VoteRecord.fsParameter = Parameters;
- - time_t tNow;
- - time( &tNow );
- - VoteRecord.tTimeCalled = tNow;
- VoteRecord.Address = SERVER_GetClient( g_ulVoteCaller )->Address;
- - VoteRecord.ulVoteType = callvote_GetVoteType( Command );
- -
- - if ( VoteRecord.ulVoteType == VOTECMD_KICK )
- - VoteRecord.KickAddress = g_KickVoteVictimAddress;
- -
- + VoteRecord.ulVoteType = Command;
- + VoteRecord.fsSummary = g_zCurrentSummary;
- g_PreviousVotes.push_back( VoteRecord );
- }
- // Display the message in the console.
- {
- - FString ReasonBlurb = ( g_VoteReason.Len( )) ? ( ", reason: \"" + g_VoteReason + "\"" ) : "";
- + FString ReasonBlurb = ( g_VoteReason.Len( )) ? ( ", reason: \"" + g_VoteReason + "\"" ) : "";
- + FString IPString;
- if ( NETWORK_GetState( ) == NETSTATE_SERVER )
- - Printf( "%s\\c- (%s) has called a vote (\"%s\"%s).\n", players[ulPlayer].userinfo.netname, NETWORK_AddressToString( SERVER_GetClient( ulPlayer )->Address ), g_VoteCommand.GetChars(), ReasonBlurb.GetChars() );
- - else
- - Printf( "%s\\c- has called a vote (\"%s\"%s).\n", players[ulPlayer].userinfo.netname, g_VoteCommand.GetChars(), ReasonBlurb.GetChars() );
- + IPString.Format( " (%s)", NETWORK_AddressToString( SERVER_GetClient( ulPlayer )->Address ));
- +
- + Printf( "%s%s\\c- has called a vote (\"%s\"%s).\n", players[ulPlayer].userinfo.netname,
- + IPString.GetChars(), g_VoteDisplay.GetChars(), ReasonBlurb.GetChars() );
- }
- g_VoteState = VOTESTATE_INVOTE;
- @@ -245,7 +275,7 @@
- ULONG ulIdx;
- g_VoteState = VOTESTATE_NOVOTE;
- - g_VoteCommand = "";
- + g_VoteDisplay = "";
- g_ulVoteCaller = MAXPLAYERS;
- g_ulVoteCountdownTicks = 0;
- g_ulShowVoteScreenTicks = 0;
- @@ -367,7 +397,7 @@
- if ( ulPlayer == g_ulVoteCaller && ( NETWORK_GetState( ) == NETSTATE_SERVER ))
- {
- // [BB] If a player canceled his own vote, don't prevent others from making this type of vote again.
- - g_PreviousVotes.back( ).ulVoteType = NUM_VOTECMDS;
- + g_PreviousVotes.back( ).ulVoteType = VoteDef::numTypes();
- SERVER_Printf( PRINT_HIGH, "Vote caller cancelled the vote.\n" );
- g_bVoteCancelled = true;
- @@ -431,7 +461,7 @@
- {
- return ( true );
- }
- -
- +
- SERVERCOMMANDS_PlayerVote( ulPlayer, false );
- ulNumYes = callvote_CountPlayersWhoVotedYes( );
- @@ -496,11 +526,8 @@
- void CALLVOTE_EndVote( bool bPassed )
- {
- // This is a client-only function.
- - if (( NETWORK_GetState( ) != NETSTATE_CLIENT ) &&
- - ( CLIENTDEMO_IsPlaying( ) == false ))
- - {
- + if ( NETWORK_InClientMode() == false )
- return;
- - }
- g_bVotePassed = bPassed;
- callvote_EndVote( );
- @@ -510,7 +537,7 @@
- //
- const char *CALLVOTE_GetCommand( void )
- {
- - return ( g_VoteCommand.GetChars( ));
- + return ( g_VoteDisplay.GetChars( ));
- }
- //*****************************************************************************
- @@ -645,10 +672,9 @@
- //*****************************************************************************
- //
- -static bool callvote_CheckForFlooding( FString &Command, FString &Parameters, ULONG ulPlayer )
- +static bool callvote_CheckForFlooding( ULONG &Command, FString &Parameters, ULONG ulPlayer )
- {
- NETADDRESS_s Address = SERVER_GetClient( ulPlayer )->Address;
- - ULONG ulVoteType = callvote_GetVoteType( Command );
- time_t tNow;
- time( &tNow );
- @@ -663,11 +689,17 @@
- // Run through the vote cache (backwards, from recent to old) and search for grounds on which to reject the vote.
- for( std::list<VOTE_s>::reverse_iterator i = g_PreviousVotes.rbegin(); i != g_PreviousVotes.rend(); ++i )
- {
- + VoteDef* type = VoteDef::findByIndex( i->ulVoteType );
- + if( !type )
- + continue;
- +
- // One *type* of vote per voter per ## minutes (excluding kick votes if they passed).
- - if ( !( i->ulVoteType == VOTECMD_KICK && i->bPassed ) && NETWORK_CompareAddress( i->Address, Address, true ) && ( ulVoteType == i->ulVoteType ) && (( tNow - i->tTimeCalled ) < VOTER_VOTETYPE_INTERVAL * MINUTE ))
- + if ( !( type->flags() & VoteDef::NoPassedLimit && i->bPassed ) && NETWORK_CompareAddress( i->Address, Address, true ) &&
- + ( g_VoteData.type == i->ulVoteType ) && (( tNow - i->tTimeCalled ) < VOTER_VOTETYPE_INTERVAL * MINUTE ))
- {
- int iMinutesLeft = static_cast<int>( 1 + ( i->tTimeCalled + VOTER_VOTETYPE_INTERVAL * MINUTE - tNow ) / MINUTE );
- - SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "You must wait %d minute%s to call another %s vote.\n", iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ), Command.GetChars() );
- + SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "You must wait %d minute%s to call another %s vote.\n",
- + iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ), type->name().GetChars() );
- return false;
- }
- @@ -675,28 +707,21 @@
- if ( NETWORK_CompareAddress( i->Address, Address, true ) && (( tNow - i->tTimeCalled ) < VOTER_NEWVOTE_INTERVAL * MINUTE ))
- {
- int iMinutesLeft = static_cast<int>( 1 + ( i->tTimeCalled + VOTER_NEWVOTE_INTERVAL * MINUTE - tNow ) / MINUTE );
- - SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "You must wait %d minute%s to call another vote.\n", iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ));
- + SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "You must wait %d minute%s to call another vote.\n",
- + iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ));
- return false;
- }
- // Specific votes ("map map30") that fail can't be re-proposed for ## minutes.
- - if (( ulVoteType == i->ulVoteType ) && ( !i->bPassed ) && (( tNow - i->tTimeCalled ) < VOTE_LITERALREVOTE_INTERVAL * MINUTE ))
- + // [Dusk] Generalized - use VOTEDEF summaries. This takes care of the IP checking for instance.
- + if (( g_zCurrentSummary == i->fsSummary ) && ( !i->bPassed ) && (( tNow - i->tTimeCalled ) < VOTE_LITERALREVOTE_INTERVAL * MINUTE ))
- {
- int iMinutesLeft = static_cast<int>( 1 + ( i->tTimeCalled + VOTE_LITERALREVOTE_INTERVAL * MINUTE - tNow ) / MINUTE );
- - // Kickvotes (can't give the IP to clients!).
- - if (( i->ulVoteType == VOTECMD_KICK ) && ( !i->bPassed ) && NETWORK_CompareAddress( i->KickAddress, g_KickVoteVictimAddress, true ))
- - {
- - SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "That specific player was recently on voted to be kicked, but the vote failed. You must wait %d minute%s to call it again.\n", iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ));
- - return false;
- - }
- -
- - // Other votes.
- - if (( i->ulVoteType != VOTECMD_KICK ) && ( stricmp( i->fsParameter.GetChars(), Parameters.GetChars() ) == 0 ))
- - {
- - SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "That specific vote (\"%s %s\") was recently called, and failed. You must wait %d minute%s to call it again.\n", Command.GetChars(), Parameters.GetChars(), iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ));
- - return false;
- - }
- + SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "That specific vote was recently "
- + "called, and failed. You must wait %d minute%s to call it again.\n",
- + Parameters.GetChars(), iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ));
- + return false;
- }
- }
- @@ -705,15 +730,17 @@
- //*****************************************************************************
- //
- -static bool callvote_CheckValidity( FString &Command, FString &Parameters )
- +static bool callvote_CheckValidity( ULONG Type, 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 ( ulVoteCmd != VOTECMD_KICK )
- + // if ( ulVoteCmd != VOTECMD_KICK )
- {
- int i = 0;
- while ( Parameters.GetChars()[i] != '\0' )
- @@ -729,97 +756,14 @@
- }
- // Then, make sure the parameter for each vote is valid.
- + // [Dusk] Use VoteDef::applyCommand to test this
- int parameterInt = atoi( Parameters.GetChars() );
- - switch ( ulVoteCmd )
- + VoteDef::ApplyResult output;
- +
- + if( !VoteDef::applyCommand( g_VoteData, output ))
- {
- - case VOTECMD_KICK:
- - {
- - 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 votekick yourself!\n" );
- - return ( false );
- - }
- - // [BB] Don't allow anyone to kick somebody who is on the admin list.
- - if ( SERVER_GetAdminList()->isIPInList( SERVER_GetClient( ulIdx )->Address ) )
- - {
- - SERVER_PrintfPlayer( PRINT_HIGH, SERVER_GetCurrentClient( ), "This player is a server admin and thus can't be kicked!\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 )
- - {
- - if ( sv_maprotation && ( 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:
- -
- + SERVER_PrintfPlayer( PRINT_HIGH, SERVER_GetCurrentClient(),
- + "Cannot call that vote: %s\n", output.error.GetChars() );
- return ( false );
- }
- @@ -828,30 +772,6 @@
- }
- //*****************************************************************************
- -//
- -static ULONG callvote_GetVoteType( const char *pszCommand )
- -{
- - if ( stricmp( "kick", pszCommand ) == 0 )
- - return VOTECMD_KICK;
- - else if ( stricmp( "map", pszCommand ) == 0 )
- - return VOTECMD_MAP;
- - else if ( stricmp( "changemap", pszCommand ) == 0 )
- - return VOTECMD_CHANGEMAP;
- - else if ( stricmp( "fraglimit", pszCommand ) == 0 )
- - return VOTECMD_FRAGLIMIT;
- - else if ( stricmp( "timelimit", pszCommand ) == 0 )
- - return VOTECMD_TIMELIMIT;
- - else if ( stricmp( "winlimit", pszCommand ) == 0 )
- - return VOTECMD_WINLIMIT;
- - else if ( stricmp( "duellimit", pszCommand ) == 0 )
- - return VOTECMD_DUELLIMIT;
- - else if ( stricmp( "pointlimit", pszCommand ) == 0 )
- - return VOTECMD_POINTLIMIT;
- -
- - return NUM_VOTECMDS;
- -}
- -
- -//*****************************************************************************
- // CONSOLE COMMANDS/VARIABLES
- CUSTOM_CVAR( Int, sv_minvoters, 1, CVAR_ARCHIVE )
- @@ -874,6 +794,8 @@
- CCMD( callvote )
- {
- ULONG ulVoteCmd;
- + FString arg, reason;
- + VoteDef* pVoteDef;
- // Don't allow a vote unless the player is a client.
- if ( NETWORK_GetState( ) != NETSTATE_CLIENT )
- @@ -885,7 +807,7 @@
- if ( CLIENT_GetConnectionState( ) != CTS_ACTIVE )
- return;
- - if ( argv.argc( ) < 3 )
- + if ( argv.argc( ) < 2 )
- {
- Printf( "callvote <command> <parameters> [reason]: Calls a vote\n" );
- return;
- @@ -898,22 +820,33 @@
- return;
- }
- - ulVoteCmd = callvote_GetVoteType( argv[1] );
- - if ( ulVoteCmd == NUM_VOTECMDS )
- + pVoteDef = VoteDef::findByName( argv[1] );
- + if ( pVoteDef == NULL )
- {
- Printf( "Invalid callvote command.\n" );
- return;
- }
- - if ( argv.argc( ) >= 4 )
- - CLIENTCOMMANDS_CallVote( ulVoteCmd, argv[2], argv[3] );
- + // [Dusk] We may need a second argument
- + if ( pVoteDef->argType( ) != VoteDef::NumArgTypes )
- + {
- + if ( argv.argc( ) < 3 )
- + {
- + Printf( "You need to supply an argument to call a %s vote:\nUsage: %s",
- + pVoteDef->name( ).GetChars( ), pVoteDef->getUsage( ).GetChars( ));
- + return;
- + }
- +
- + arg = ( argv.argc( ) >= 3 ) ? argv[2] : "";
- + reason = ( argv.argc( ) >= 4 ) ? argv[3] : "";
- + }
- else
- - CLIENTCOMMANDS_CallVote( ulVoteCmd, argv[2], "" );
- -/*
- - g_lBytesSent += g_LocalBuffer.cursize;
- - if ( g_lBytesSent > g_lMaxBytesSent )
- - g_lMaxBytesSent = g_lBytesSent;
- -*/
- + {
- + arg = "";
- + reason = ( argv.argc( ) >= 3 ) ? argv[2] : "";
- + }
- +
- + CLIENTCOMMANDS_CallVote( pVoteDef->getIndex(), arg, reason );
- NETWORK_LaunchPacket( CLIENT_GetLocalBuffer( ), CLIENT_GetServerAddress( ));
- NETWORK_ClearBuffer( CLIENT_GetLocalBuffer( ));
- }
- diff -r af45c72387f5 src/callvote.h
- --- a/src/callvote.h Sat Jul 27 09:47:16 2013 +0200
- +++ b/src/callvote.h Fri Aug 02 02:25:44 2013 +0300
- @@ -67,21 +67,6 @@
- #define VOTE_LONGEST_INTERVAL 10 // Sets when old votes are removed from the flood cache. Set to the longest interval of the above.
- //*****************************************************************************
- -enum
- -{
- - VOTECMD_KICK,
- - VOTECMD_MAP,
- - VOTECMD_CHANGEMAP,
- - VOTECMD_FRAGLIMIT,
- - VOTECMD_TIMELIMIT,
- - VOTECMD_WINLIMIT,
- - VOTECMD_DUELLIMIT,
- - VOTECMD_POINTLIMIT,
- -
- - NUM_VOTECMDS
- -};
- -
- -//*****************************************************************************
- typedef enum
- {
- VOTESTATE_NOVOTE,
- @@ -101,18 +86,18 @@
- // Time that this vote was called.
- time_t tTimeCalled;
- - // The type of vote (see NUM_VOTECMDS).
- + // The type of vote.
- ULONG ulVoteType;
- -
- +
- // Parameter of the vote ("map01", "50", etc).
- FString fsParameter;
- - // For kick votes: the address being kicked.
- - NETADDRESS_s KickAddress;
- -
- // Was it passed?
- bool bPassed;
- + // [Dusk] VoteDef summary
- + FString fsSummary;
- +
- } VOTE_s;
- //*****************************************************************************
- @@ -121,7 +106,7 @@
- void CALLVOTE_Construct( void );
- void CALLVOTE_Tick( void );
- //void CALLVOTE_Render( void );
- -void CALLVOTE_BeginVote( FString Command, FString Parameters, FString Reason, ULONG ulPlayer );
- +void CALLVOTE_BeginVote( ULONG Command, FString Parameters, FString Reason, ULONG ulPlayer );
- void CALLVOTE_ClearVote( void );
- bool CALLVOTE_VoteYes( ULONG ulPlayer );
- bool CALLVOTE_VoteNo( ULONG ulPlayer );
- diff -r af45c72387f5 src/cl_main.cpp
- --- a/src/cl_main.cpp Sat Jul 27 09:47:16 2013 +0200
- +++ b/src/cl_main.cpp Fri Aug 02 02:25:44 2013 +0300
- @@ -9859,7 +9859,7 @@
- //
- static void client_CallVote( BYTESTREAM_s *pByteStream )
- {
- - FString command;
- + ULONG ulCommand;
- FString parameters;
- FString reason;
- ULONG ulVoteCaller;
- @@ -9868,7 +9868,7 @@
- ulVoteCaller = NETWORK_ReadByte( pByteStream );
- // Read in the command.
- - command = NETWORK_ReadString( pByteStream );
- + ulCommand = NETWORK_ReadLong( pByteStream );
- // Read in the parameters.
- parameters = NETWORK_ReadString( pByteStream );
- @@ -9877,7 +9877,7 @@
- reason = NETWORK_ReadString( pByteStream );
- // Begin the vote!
- - CALLVOTE_BeginVote( command, parameters, reason, ulVoteCaller );
- + CALLVOTE_BeginVote( ulCommand, parameters, reason, ulVoteCaller );
- }
- //*****************************************************************************
- diff -r af45c72387f5 src/d_main.cpp
- --- a/src/d_main.cpp Sat Jul 27 09:47:16 2013 +0200
- +++ b/src/d_main.cpp Fri Aug 02 02:25:44 2013 +0300
- @@ -140,6 +140,7 @@
- #include "g_shared/pwo.h"
- #include "win32/g15/g15.h"
- +#include "votedef.h"
- EXTERN_CVAR(Bool, hud_althud)
- void DrawHUD();
- @@ -2113,6 +2114,9 @@
- // [BB] Parse the GAMEMODE lump.
- GAMEMODE_ParseGamemodeInfo( );
- + // [Dusk] Initialize vote definitions
- + VoteDef::init();
- +
- // [RH] Initialize localizable strings.
- GStrings.LoadStrings (false);
- diff -r af45c72387f5 src/m_menu.h
- --- a/src/m_menu.h Sat Jul 27 09:47:16 2013 +0200
- +++ b/src/m_menu.h Fri Aug 02 02:25:44 2013 +0300
- @@ -141,6 +141,7 @@
- weaponslot,
- txslider,
- mnnumber,
- + votetype, // [Dusk]
- } itemtype;
- diff -r af45c72387f5 src/m_options.cpp
- --- a/src/m_options.cpp Sat Jul 27 09:47:16 2013 +0200
- +++ b/src/m_options.cpp Fri Aug 02 02:25:44 2013 +0300
- @@ -109,6 +109,7 @@
- // [ZZ] PWO header file
- #include "g_shared/pwo.h"
- +#include "votedef.h"
- // EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
- @@ -191,6 +192,11 @@
- static LONG g_lSavedColor;
- static bool g_bSwitchColorBack;
- +// [Dusk] I want to display an error prompt if the vote type validation fails.
- +// M_StartMessage however relies on the value being a char array - so I'm defining
- +// a buffer here for that.
- +static char g_VoteMenuFailure[256];
- +
- value_t YesNo[2] = {
- { 0.0, "No" },
- { 1.0, "Yes" }
- @@ -1768,8 +1774,10 @@
- if ( !bAllowBots && ( players[lPlayer].bIsBot ))
- return ( false );
- +/*
- if ( lPlayer == consoleplayer )
- return ( false );
- +*/
- return ( true );
- }
- @@ -1887,221 +1895,69 @@
- //====================================================================================
- //
- -// Call Vote-->Kick Player Menu
- -//
- -//====================================================================================
- -
- -CVAR( String, menu_votereason, "", 0 );
- -
- -void kickplayermenu_Kick( void );
- -
- -//*****************************************************************************
- -//
- -static menuitem_t kickplayermenu_Items[] =
- -{
- - { discretes,"Player", {&menu_playerslider_idx}, {1.0}, {0.0}, {0.0}, {NULL} },
- - { redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} },
- - { string, "Reason for kicking:",{&menu_votereason}, {0.0}, {0.0}, {0.0}, {NULL} },
- - { more, "Kick!", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)kickplayermenu_Kick} },
- -};
- -
- -// [BB, RC] Line number of the "Player:" entry from kickplayermenu_Items. If the line number is changed, the value has to be adjusted.
- -#define KICKPLAYER_SLIDER_LOCATION 0
- -
- -//*****************************************************************************
- -//
- -menu_t KickPlayerMenu = {
- - "KICK A PLAYER",
- - 0,
- - countof(kickplayermenu_Items),
- - 0,
- - kickplayermenu_Items,
- - 0,
- - 0,
- -};
- -
- -//*****************************************************************************
- -//
- -void kickplayermenu_Kick( void )
- -{
- - // Clean the name of color codes.
- - FString Name = AvailablePlayers[menu_playerslider_idx].name.GetChars( );
- - V_RemoveColorCodes( Name );
- - V_EscapeBacklashes( Name );
- -
- - FString Reason = menu_votereason.GetGenericRep( CVAR_String ).String;
- - V_EscapeBacklashes( Reason );
- -
- - // Execute the command.
- - char szString[256];
- - sprintf( szString, "callvote kick \"%s\" \"%s\"", Name.Left( 96 ).GetChars(), Reason.Left( 25 ).GetChars());
- - AddCommandString( szString );
- - M_ClearMenus( );
- -}
- -
- -//*****************************************************************************
- -//
- -void kickplayermenu_Show( void )
- -{
- - if ( SERVER_CountPlayers( false ) < 2 )
- - {
- - M_ClearMenus( );
- - M_StartMessage( "There is nobody else here to kick!\n\npress any key.", NULL, false );
- - return;
- - }
- -
- - // Set up the player selection slider.
- - playerslider_BuildList( false );
- - kickplayermenu_Items[KICKPLAYER_SLIDER_LOCATION].b.numvalues = static_cast<float>(AvailablePlayers.Size());
- - kickplayermenu_Items[KICKPLAYER_SLIDER_LOCATION].e.valuestrings = &AvailablePlayers[0];
- -
- - M_SwitchMenu( &KickPlayerMenu );
- -}
- -
- -//====================================================================================
- -//
- -// Call Vote-->Map Menu
- -//
- -//====================================================================================
- -
- -CVAR( String, menu_mapvotemap, "", 0 );
- -CVAR( Bool, menu_mapvoteintermission, false, 0 );
- -
- -//*****************************************************************************
- -//
- -void mapvotemenu_Vote( void )
- -{
- - // Sanitize the inputs.
- - FString Map = menu_mapvotemap.GetGenericRep( CVAR_String ).String;
- - FString Reason = menu_votereason.GetGenericRep( CVAR_String ).String;
- - V_EscapeBacklashes( Map );
- - V_EscapeBacklashes( Reason );
- -
- - if ( !Map.Len( ) )
- - {
- - Printf( "You didn't specify a map!\n" );
- - return;
- - }
- -
- - // Execute the command.
- - char szString[256];
- - sprintf( szString, "callvote %s %s \"%s\"", ( menu_mapvoteintermission.GetGenericRep( CVAR_Bool ).Bool ? "changemap" : "map" ), Map.Left( 128 ).GetChars(), Reason.Left( 25 ).GetChars() );
- - AddCommandString( szString );
- - M_ClearMenus( );
- -}
- -
- -//*****************************************************************************
- -//
- -static menuitem_t mapvotemenu_Items[] =
- -{
- - { string, "Map", {&menu_mapvotemap}, {0.0}, {0.0}, {0.0}, {NULL} },
- - { discrete, "Intermission", {&menu_mapvoteintermission}, {2.0}, {0.0}, {0.0}, {YesNo} },
- - { redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} },
- - { string, "Reason for change:",{&menu_votereason}, {0.0}, {0.0}, {0.0}, {NULL} },
- - { more, "Vote!", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)mapvotemenu_Vote} },
- -};
- -
- -//*****************************************************************************
- -//
- -menu_t MapVoteMenu = {
- - "CHANGE MAP",
- - 0,
- - countof(mapvotemenu_Items),
- - 0,
- - mapvotemenu_Items,
- - 0,
- - 0,
- -};
- -
- -//*****************************************************************************
- -//
- -void mapvotemenu_Show( void )
- -{
- - M_SwitchMenu( &MapVoteMenu );
- -}
- -
- -//====================================================================================
- -//
- -// Call Vote-->Limit Menu
- -//
- -//====================================================================================
- -
- -//*****************************************************************************
- -//
- -value_t limitvote_Types[5] = {
- - { 0.0, "fraglimit" },
- - { 1.0, "timelimit" },
- - { 2.0, "winlimit" },
- - { 3.0, "duellimit" },
- - { 4.0, "pointlimit" }
- -};
- -
- -//*****************************************************************************
- -//
- -CVAR( Int, menu_limitvote_type, 0, 0 );
- -CVAR( String, menu_limitvote_value, "", 0 );
- -
- -//*****************************************************************************
- -//
- -void limitvotemenu_Vote( void )
- -{
- - // Sanitize the inputs.
- - int iVoteType = menu_limitvote_type.GetGenericRep( CVAR_Int ).Int;
- - int iLimit = atoi( menu_limitvote_value.GetGenericRep( CVAR_String ).String );
- - FString Reason = menu_votereason.GetGenericRep( CVAR_String ).String;
- - V_EscapeBacklashes( Reason );
- -
- - if ( iVoteType >= 5 || iVoteType < 0 )
- - return;
- -
- - // Execute the command.
- - char szString[512];
- - sprintf( szString, "callvote %s %d \"%s\"", limitvote_Types[iVoteType].name, iLimit, Reason.Left( 25 ).GetChars() );
- - AddCommandString( szString );
- - M_ClearMenus( );
- -}
- -
- -//*****************************************************************************
- -//
- -static menuitem_t limitvotemenu_Items[] =
- -{
- - { discrete, "Type of limit", {&menu_limitvote_type}, {5.0}, {0.0}, {0.0}, {limitvote_Types} },
- - { string, "New value", {&menu_limitvote_value}, {0.0}, {0.0}, {0.0}, {NULL} },
- - { redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} },
- - { string, "Reason for change:",{&menu_votereason}, {0.0}, {0.0}, {0.0}, {NULL} },
- - { more, "Vote!", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)limitvotemenu_Vote} },
- -};
- -
- -//*****************************************************************************
- -//
- -menu_t limitvoteMenu = {
- - "CHANGE LIMIT",
- - 0,
- - countof(limitvotemenu_Items),
- - 0,
- - limitvotemenu_Items,
- - 0,
- - 0,
- -};
- -
- -//*****************************************************************************
- -//
- -void limitvotemenu_Show( void )
- -{
- - M_SwitchMenu( &limitvoteMenu );
- -}
- -
- -//====================================================================================
- -//
- // Call Vote Menu
- //
- //====================================================================================
- +// [Dusk]
- +CVAR( Int, menu_votetype, 0, CVAR_ARCHIVE )
- +CVAR( String, menu_votearg, "", CVAR_ARCHIVE )
- +CVAR( Int, menu_votenumarg, 0, CVAR_ARCHIVE )
- +CVAR( String, menu_votereason, "", 0 )
- +
- +// [Dusk] Call a VOTEDEF-based vote
- +static void votemenu_go( )
- +{
- + M_ClearMenus();
- +
- + VoteDef* def = VoteDef::findByIndex( menu_votetype );
- + if ( !def )
- + return;
- +
- + VoteDef::ApplyInput in;
- + VoteDef::ApplyResult out;
- + in.type = menu_votetype;
- + in.caller = consoleplayer;
- +
- + // [Dusk] Determine the argument to callvote.
- + if ( def->argType() == VoteDef::MapType )
- + {
- + // [Dusk] If this is a map, we need to pass the string argument
- + in.arg = menu_votearg;
- + }
- + else if ( def->argType() == VoteDef::Player && !( def->flags() & VoteDef::PlayerIndex ))
- + {
- + // [Dusk] A player's name is wanted - pass that.
- + in.arg = players[menu_votenumarg].userinfo.netname;
- + V_ColorizeString( in.arg );
- + V_RemoveColorCodes( in.arg );
- + }
- + else // [Dusk] Otherwise pass the numeric value
- + in.arg.Format( "%d", (int) menu_votenumarg );
- +
- + // [Dusk] Validate the vote command now
- + if ( VoteDef::applyCommand( in, out ))
- + {
- + // [Dusk] Vote seems good, call it now.
- + CLIENTCOMMANDS_CallVote( menu_votetype, in.arg, menu_votereason );
- + NETWORK_LaunchPacket( CLIENT_GetLocalBuffer( ), CLIENT_GetServerAddress( ));
- + NETWORK_ClearBuffer( CLIENT_GetLocalBuffer( ));
- + }
- + else
- + {
- + // [Dusk] Failed - tell the user why.
- + sprintf( g_VoteMenuFailure, "Couldn't call that: %s\n\npress any key.", out.error.GetChars() );
- + M_StartMessage( g_VoteMenuFailure, NULL, false );
- + }
- +}
- +
- static menuitem_t CallVoteItems[] =
- {
- - { more, "Kick a player", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)kickplayermenu_Show} },
- - { more, "Change the map", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)mapvotemenu_Show} },
- - { more, "Change a limit", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)limitvotemenu_Show} },
- + { votetype, "Vote action", {&menu_votetype}, {0.0}, {100.0}, {1.0}, {NULL} },
- + { string, "Vote argument", {&menu_votearg}, {0.0}, {0.0}, {0.0}, {NULL} },
- + { string, "Reason for vote", {&menu_votereason}, {0.0}, {0.0}, {0.0}, {NULL} },
- + { redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} },
- + { more, "Call the vote", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *) votemenu_go} },
- };
- menu_t CallVoteMenu = {
- @@ -2127,6 +1983,7 @@
- void M_StartBrowserMenu( void );
- void M_Spectate( void );
- void M_CallVote( void );
- +void M_VoteTypeChanged( bool first );
- void M_ChangeTeam( void );
- void M_Skirmish( void );
- @@ -2140,7 +1997,7 @@
- { more, "Spectate", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)M_Spectate} },
- { more, "Switch teams", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)M_ChangeTeam} },
- { redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} },
- - { more, "Call a vote", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)M_CallVote} },
- + { more, "Call a vote", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)M_CallVote} },
- { more, "Ignore a player", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)ignoreplayermenu_Show} },
- { redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} },
- { discrete, "Allow skins", {&cl_skins}, {3.0}, {0.0}, {0.0}, {AllowSkinVals} },
- @@ -2191,10 +2048,69 @@
- return;
- }
- + M_VoteTypeChanged( true );
- M_SwitchMenu( &CallVoteMenu );
- }
- //*****************************************************************************
- +// [Dusk] Hmm. Now that votes are generalized the argument passed is of variable
- +// type. Thus, we have to change the argument field dynamically based on the type
- +// of the argument of the vote we scrolled to.
- +//
- +// This also resets the argument, first because the argument of one type may be
- +// out of bounds or otherwise of completely different meaning for another.
- +void M_VoteTypeChanged( bool first )
- +{
- + VoteDef* def = VoteDef::findByIndex( menu_votetype );
- + if ( !def )
- + return;
- +
- + VoteDef::ArgumentType argtype = def->argType();
- + menuitem_t* item = &CallVoteItems[1];
- + item->label = "Vote argument";
- +
- + switch ( argtype )
- + {
- + case VoteDef::Player:
- + // Set up the player selection slider.
- + playerslider_BuildList( false );
- + item->type = discretes;
- + item->a.intcvar = &menu_votenumarg;
- + item->b.numvalues = static_cast<float>( AvailablePlayers.Size( ));
- + item->e.valuestrings = &AvailablePlayers[0];
- +
- + if ( !first )
- + menu_votenumarg = AvailablePlayers[0].value;
- + break;
- +
- + case VoteDef::Int:
- + case VoteDef::Float:
- + item->type = number;
- + item->a.intcvar = &menu_votenumarg;
- + item->b.min = def->min();
- + item->c.max = def->max();
- + item->d.step = 1.0f;
- +
- + if ( !first )
- + menu_votenumarg = def->min();
- + break;
- +
- + case VoteDef::MapType:
- + item->type = string;
- + item->a.stringcvar = &menu_votearg;
- +
- + if ( !first )
- + menu_votearg = "";
- + break;
- +
- + case VoteDef::NumArgTypes:
- + item->type = redtext;
- + item->label = "";
- + break;
- + }
- +}
- +
- +//*****************************************************************************
- //
- void M_SkulltagVersionDrawer( void )
- {
- @@ -5097,6 +5013,24 @@
- screen->DrawText( SmallFont, CR_GREY, x, y, szString, DTA_Clean, true, TAG_DONE );
- }
- break;
- +
- + // [Dusk]
- + case votetype:
- + {
- + VoteDef* def = VoteDef::findByIndex( *item->a.intcvar );
- + FString text;
- +
- + if ( !def )
- + text = "UNKNOWN";
- + else if ( def->description( ).IsNotEmpty( ))
- + text = def->description( );
- + else
- + text = def->name( );
- +
- + screen->DrawText( SmallFont, CR_GREY, x, y, text.GetChars(), DTA_Clean, true, TAG_DONE );
- + }
- + break;
- +
- default:
- break;
- }
- @@ -5989,6 +5923,21 @@
- S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
- break;
- + // [Dusk]
- + case votetype:
- + {
- + int i = *item->a.intcvar;
- + i--;
- +
- + if ( i < 0 )
- + i = VoteDef::numTypes() - 1;
- +
- + *item->a.intcvar = i;
- + }
- + M_VoteTypeChanged( false );
- + S_Sound( CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE );
- + break;
- +
- default:
- break;
- }
- @@ -6421,6 +6370,21 @@
- S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
- break;
- + // [Dusk]
- + case votetype:
- + {
- + int i = *item->a.intcvar;
- + i++;
- +
- + if ( i >= (int) VoteDef::numTypes() )
- + i = 0;
- +
- + *item->a.intcvar = i;
- + }
- + M_VoteTypeChanged( false );
- + S_Sound( CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE );
- + break;
- +
- default:
- break;
- }
- diff -r af45c72387f5 src/network.cpp
- --- a/src/network.cpp Sat Jul 27 09:47:16 2013 +0200
- +++ b/src/network.cpp Fri Aug 02 02:25:44 2013 +0300
- @@ -307,6 +307,8 @@
- lumpsToAuthenticateMode.push_back( ALL_LUMPS );
- lumpsToAuthenticate.push_back( "GAMEMODE" );
- lumpsToAuthenticateMode.push_back( ALL_LUMPS );
- + lumpsToAuthenticate.push_back( "VOTEDEF" );
- + lumpsToAuthenticateMode.push_back( ALL_LUMPS );
- FString checksum, longChecksum;
- bool noProtectedLumpsAutoloaded = true;
- diff -r af45c72387f5 src/sv_commands.cpp
- --- a/src/sv_commands.cpp Sat Jul 27 09:47:16 2013 +0200
- +++ b/src/sv_commands.cpp Fri Aug 02 02:25:44 2013 +0300
- @@ -5348,31 +5348,14 @@
- //*****************************************************************************
- //*****************************************************************************
- //
- -void SERVERCOMMANDS_CallVote( ULONG ulPlayer, FString Command, FString Parameters, FString Reason, ULONG ulPlayerExtra, ULONG ulFlags )
- -{
- - ULONG ulIdx;
- -
- - if ( PLAYER_IsValidPlayer( ulPlayer ) == false )
- - return;
- -
- - for ( ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ )
- - {
- - if ( SERVER_IsValidClient( ulIdx ) == false )
- - continue;
- -
- - if ((( ulFlags & SVCF_SKIPTHISCLIENT ) && ( ulPlayerExtra == ulIdx )) ||
- - (( ulFlags & SVCF_ONLYTHISCLIENT ) && ( ulPlayerExtra != ulIdx )))
- - {
- - continue;
- - }
- -
- - SERVER_CheckClientBuffer( ulIdx, 2 + ULONG( Command.Len() ) + ULONG ( Parameters.Len() ), true );
- - NETWORK_WriteHeader( &SERVER_GetClient( ulIdx )->PacketBuffer.ByteStream, SVC_CALLVOTE );
- - NETWORK_WriteByte( &SERVER_GetClient( ulIdx )->PacketBuffer.ByteStream, ulPlayer );
- - NETWORK_WriteString( &SERVER_GetClient( ulIdx )->PacketBuffer.ByteStream, Command.GetChars() );
- - NETWORK_WriteString( &SERVER_GetClient( ulIdx )->PacketBuffer.ByteStream, Parameters.GetChars() );
- - NETWORK_WriteString( &SERVER_GetClient( ulIdx )->PacketBuffer.ByteStream, Reason.GetChars() );
- - }
- +void SERVERCOMMANDS_CallVote( ULONG ulPlayer, ULONG Command, FString Parameters, FString Reason, ULONG ulPlayerExtra, ULONG ulFlags )
- +{
- + NetCommand command( SVC_CALLVOTE );
- + command.addByte( ulPlayer );
- + command.addLong( Command );
- + command.addString( Parameters );
- + command.addString( Reason );
- + command.sendCommandToClients( ulPlayerExtra, ulFlags );
- }
- //*****************************************************************************
- diff -r af45c72387f5 src/sv_commands.h
- --- a/src/sv_commands.h Sat Jul 27 09:47:16 2013 +0200
- +++ b/src/sv_commands.h Fri Aug 02 02:25:44 2013 +0300
- @@ -272,7 +272,7 @@
- void SERVERCOMMANDS_StopSectorSequence( sector_t *pSector, ULONG ulPlayerExtra = MAXPLAYERS, ULONG ulFlags = 0 );
- // Voting commands. These handle the voting.
- -void SERVERCOMMANDS_CallVote( ULONG ulPlayer, FString Command, FString Parameters, FString Reason, ULONG ulPlayerExtra = MAXPLAYERS, ULONG ulFlags = 0 );
- +void SERVERCOMMANDS_CallVote( ULONG ulPlayer, ULONG Command, FString Parameters, FString Reason, ULONG ulPlayerExtra = MAXPLAYERS, ULONG ulFlags = 0 );
- void SERVERCOMMANDS_PlayerVote( ULONG ulPlayer, bool bVoteYes, ULONG ulPlayerExtra = MAXPLAYERS, ULONG ulFlags = 0 );
- void SERVERCOMMANDS_VoteEnded( bool bVotePassed, ULONG ulPlayerExtra = MAXPLAYERS, ULONG ulFlags = 0 );
- diff -r af45c72387f5 src/sv_main.cpp
- --- a/src/sv_main.cpp Sat Jul 27 09:47:16 2013 +0200
- +++ b/src/sv_main.cpp Fri Aug 02 02:25:44 2013 +0300
- @@ -113,6 +113,7 @@
- #include "domination.h"
- #include "a_movingcamera.h"
- #include "cl_main.h"
- +#include "votedef.h"
- //*****************************************************************************
- // MISC CRAP THAT SHOULDN'T BE HERE BUT HAS TO BE BECAUSE OF SLOPPY CODING
- @@ -5802,61 +5803,21 @@
- }
- // Check if the specific type of vote is allowed.
- - bool bVoteAllowed = false;
- - switch ( ulVoteCmd )
- - {
- - case VOTECMD_KICK:
- -
- - bVoteAllowed = !sv_nokickvote;
- - sprintf( szCommand, "kick" );
- - break;
- - case VOTECMD_MAP:
- -
- - bVoteAllowed = !sv_nomapvote;
- - sprintf( szCommand, "map" );
- - break;
- - case VOTECMD_CHANGEMAP:
- -
- - bVoteAllowed = !sv_nochangemapvote;
- - sprintf( szCommand, "changemap" );
- - break;
- - case VOTECMD_FRAGLIMIT:
- -
- - bVoteAllowed = !sv_nofraglimitvote;
- - sprintf( szCommand, "fraglimit" );
- - break;
- - case VOTECMD_TIMELIMIT:
- -
- - bVoteAllowed = !sv_notimelimitvote;
- - sprintf( szCommand, "timelimit" );
- - break;
- - case VOTECMD_WINLIMIT:
- -
- - bVoteAllowed = !sv_nowinlimitvote;
- - sprintf( szCommand, "winlimit" );
- - break;
- - case VOTECMD_DUELLIMIT:
- -
- - bVoteAllowed = !sv_noduellimitvote;
- - sprintf( szCommand, "duellimit" );
- - break;
- - case VOTECMD_POINTLIMIT:
- -
- - bVoteAllowed = !sv_nopointlimitvote;
- - sprintf( szCommand, "pointlimit" );
- - break;
- - default:
- -
- - return ( false );
- - }
- -
- - // Begin the vote, if that type is allowed.
- - if ( bVoteAllowed )
- - CALLVOTE_BeginVote( szCommand, Parameters, Reason, g_lCurrentClient );
- - else
- - SERVER_PrintfPlayer( PRINT_HIGH, g_lCurrentClient, "%s votes are disabled on this server.\n", szCommand );
- -
- - return ( false );
- + // [Dusk] VOTEDEFized
- + VoteDef* pVoteType = VoteDef::findByIndex( ulVoteCmd );
- + if( !pVoteType )
- + return false; // Unknown vote type
- +
- + if( pVoteType->forbidCVar()->GetGenericRep( CVAR_Bool ).Bool )
- + {
- + SERVER_PrintfPlayer( PRINT_HIGH, g_lCurrentClient, "%s votes are disabled on this server.\n",
- + pVoteType->name().GetChars( ));
- + return false;
- + }
- +
- + // Begin the vote
- + CALLVOTE_BeginVote( ulVoteCmd, Parameters, Reason, g_lCurrentClient );
- + return false;
- }
- //*****************************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement