Commit MetaInfo

Revisionbb0847e0ac03293f3ea68f9887a9b9bd886d0d49 (tree)
Time2021-06-01 13:37:29
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Added the function CALLVOTE_GetPlayerVoteChoice which returns whatever choice a player made during a vote.

Change Summary

Incremental Difference

diff -r 11588fe5ac80 -r bb0847e0ac03 src/callvote.cpp
--- a/src/callvote.cpp Mon May 31 23:54:44 2021 -0400
+++ b/src/callvote.cpp Tue Jun 01 00:37:29 2021 -0400
@@ -85,6 +85,7 @@
8585 static ULONG g_ulPlayersWhoVotedNo[(MAXPLAYERS / 2) + 1];
8686 static NETADDRESS_s g_KickVoteVictimAddress;
8787 static std::list<VOTE_s> g_PreviousVotes;
88+static ULONG g_ulPlayerVoteChoice[MAXPLAYERS]; // [AK]
8889
8990 //*****************************************************************************
9091 // PROTOTYPES
@@ -289,6 +290,10 @@
289290 g_ulPlayersWhoVotedNo[ulIdx] = MAXPLAYERS;
290291 }
291292
293+ // [AK] Reset the choices of all players.
294+ for ( ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ )
295+ g_ulPlayerVoteChoice[ulIdx] = VOTE_UNDECIDED;
296+
292297 g_bVoteCancelled = false;
293298 }
294299
@@ -353,6 +358,9 @@
353358 }
354359 }
355360
361+ // [AK] Update this player's choice to "yes".
362+ g_ulPlayerVoteChoice[ulPlayer] = VOTE_YES;
363+
356364 // Display the message in the console.
357365 if ( NETWORK_GetState( ) == NETSTATE_SERVER )
358366 Printf( "%s (%s) votes \"yes\".\n", players[ulPlayer].userinfo.GetName(), SERVER_GetClient( ulPlayer )->Address.ToString() );
@@ -447,6 +455,9 @@
447455 }
448456 }
449457
458+ // [AK] Update this player's choice to "no".
459+ g_ulPlayerVoteChoice[ulPlayer] = VOTE_NO;
460+
450461 // Display the message in the console.
451462 if ( NETWORK_GetState( ) == NETSTATE_SERVER )
452463 Printf( "%s (%s) votes \"no\".\n", players[ulPlayer].userinfo.GetName(), SERVER_GetClient( ulPlayer )->Address.ToString() );
@@ -561,6 +572,17 @@
561572
562573 //*****************************************************************************
563574 //
575+ULONG CALLVOTE_GetPlayerVoteChoice( ULONG ulPlayer )
576+{
577+ // [AK] Sanity check.
578+ if ( ulPlayer > MAXPLAYERS )
579+ return VOTE_UNDECIDED;
580+
581+ return ( g_ulPlayerVoteChoice[ulPlayer] );
582+}
583+
584+//*****************************************************************************
585+//
564586 void CALLVOTE_DisconnectedVoter( ULONG ulPlayer )
565587 {
566588 ULONG ulIdx;
diff -r 11588fe5ac80 -r bb0847e0ac03 src/callvote.h
--- a/src/callvote.h Mon May 31 23:54:44 2021 -0400
+++ b/src/callvote.h Tue Jun 01 00:37:29 2021 -0400
@@ -60,6 +60,11 @@
6060 #define VOTE_COUNTDOWN_TIME 15
6161 #define VOTE_PASSED_TIME 4
6262
63+// [AK] Definitions for whether we (the local player) voted yes or no.
64+#define VOTE_UNDECIDED 0
65+#define VOTE_YES 1
66+#define VOTE_NO 2
67+
6368 //*****************************************************************************
6469 enum
6570 {
@@ -136,6 +141,7 @@
136141 ULONG *CALLVOTE_GetPlayersWhoVotedYes( void );
137142 ULONG *CALLVOTE_GetPlayersWhoVotedNo( void );
138143 bool CALLVOTE_ShouldShowVoteScreen( void );
144+ULONG CALLVOTE_GetPlayerVoteChoice( ULONG ulPlayer );
139145
140146 //*****************************************************************************
141147 // EXTERNAL CONSOLE VARIABLES
Show on old repository browser