]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Store the name of the vote caller
authorMattia Basaglia <mattia.basaglia@gmail.com>
Sun, 10 May 2015 09:10:08 +0000 (11:10 +0200)
committerMattia Basaglia <mattia.basaglia@gmail.com>
Sun, 10 May 2015 09:10:08 +0000 (11:10 +0200)
qcsrc/server/command/vote.qc
qcsrc/server/command/vote.qh

index 72263dc1e3051e913cb4c6b476add8d6bf6f3027..4be48e124e82b98d38fb26c41c5df7dfe18efc29 100644 (file)
@@ -115,6 +115,13 @@ void Nagger_ReadyCounted()
                nagger.SendFlags |= 1;
 }
 
+// If the vote_caller is still here, return their name, otherwise vote_caller_name
+string OriginalCallerName()
+{
+       if (IS_REAL_CLIENT(vote_caller))
+               return vote_caller.netname;
+       return vote_caller_name;
+}
 
 // =======================
 //  Game logic for voting
@@ -130,10 +137,12 @@ void VoteReset()
        {
                strunzone(vote_called_command);
                strunzone(vote_called_display);
+               strunzone(vote_caller_name);
        }
 
        vote_called = VOTE_NULL;
        vote_caller = world;
+       vote_caller_name = string_null;
        vote_endtime = 0;
 
        vote_called_command = string_null;
@@ -147,7 +156,7 @@ void VoteReset()
 
 void VoteStop(entity stopper)
 {
-       bprint("\{1}^2* ^3", GetCallerName(stopper), "^2 stopped ^3", GetCallerName(vote_caller), "^2's vote\n");
+       bprint("\{1}^2* ^3", GetCallerName(stopper), "^2 stopped ^3", OriginalCallerName(), "^2's vote\n");
        if(autocvar_sv_eventlog) { GameLogEcho(strcat(":vote:vstop:", ftos(stopper.playerid))); }
 
        // Don't force them to wait for next vote, this way they can e.g. correct their vote.
@@ -158,7 +167,7 @@ void VoteStop(entity stopper)
 
 void VoteAccept()
 {
-       bprint("\{1}^2* ^3", GetCallerName(vote_caller), "^2's vote for ^1", vote_called_display, "^2 was accepted\n");
+       bprint("\{1}^2* ^3", OriginalCallerName(), "^2's vote for ^1", vote_called_display, "^2 was accepted\n");
 
        if((vote_called == VOTE_MASTER) && vote_caller)
                vote_caller.vote_master = 1;
@@ -173,14 +182,14 @@ void VoteAccept()
 
 void VoteReject()
 {
-       bprint("\{1}^2* ^3", GetCallerName(vote_caller), "^2's vote for ", vote_called_display, "^2 was rejected\n");
+       bprint("\{1}^2* ^3", OriginalCallerName(), "^2's vote for ", vote_called_display, "^2 was rejected\n");
        VoteReset();
        Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_VOTE_FAIL);
 }
 
 void VoteTimeout()
 {
-       bprint("\{1}^2* ^3", GetCallerName(vote_caller), "^2's vote for ", vote_called_display, "^2 timed out\n");
+       bprint("\{1}^2* ^3", OriginalCallerName(), "^2's vote for ", vote_called_display, "^2 timed out\n");
        VoteReset();
        Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_VOTE_FAIL);
 }
@@ -821,6 +830,7 @@ void VoteCommand_call(float request, entity caller, float argc, string vote_comm
                        else // everything went okay, continue with calling the vote
                        {
                                vote_caller = caller; // remember who called the vote
+                               vote_caller_name = strzone(GetCallerName(vote_caller));
                                vote_called = VOTE_NORMAL;
                                vote_called_command = strzone(vote_parsed_command);
                                vote_called_display = strzone(vote_parsed_display);
@@ -836,7 +846,7 @@ void VoteCommand_call(float request, entity caller, float argc, string vote_comm
                                FOR_EACH_REALCLIENT(tmp_player) { ++tmp_playercount; }
                                if(tmp_playercount > 1) { Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_VOTE_CALL); } // don't announce a "vote now" sound if player is alone
 
-                               bprint("\{1}^2* ^3", GetCallerName(vote_caller), "^2 calls a vote for ", vote_called_display, "\n");
+                               bprint("\{1}^2* ^3", OriginalCallerName(), "^2 calls a vote for ", vote_called_display, "\n");
                                if(autocvar_sv_eventlog) { GameLogEcho(strcat(":vote:vcall:", ftos(vote_caller.playerid), ":", vote_called_display)); }
                                Nagger_VoteChanged();
                                VoteCount(true); // needed if you are the only one
@@ -917,6 +927,7 @@ void VoteCommand_master(float request, entity caller, float argc, string vote_co
                                                else // everything went okay, continue with creating vote
                                                {
                                                        vote_caller = caller;
+                                                       vote_caller_name = strzone(GetCallerName(vote_caller));
                                                        vote_called = VOTE_MASTER;
                                                        vote_called_command = strzone("XXX");
                                                        vote_called_display = strzone("^3master");
@@ -925,7 +936,7 @@ void VoteCommand_master(float request, entity caller, float argc, string vote_co
                                                        caller.vote_selection = VOTE_SELECT_ACCEPT;
                                                        caller.vote_waittime = time + autocvar_sv_vote_wait;
 
-                                                       bprint("\{1}^2* ^3", GetCallerName(vote_caller), "^2 calls a vote to become ^3master^2.\n");
+                                                       bprint("\{1}^2* ^3", OriginalCallerName(), "^2 calls a vote to become ^3master^2.\n");
                                                        if(autocvar_sv_eventlog) { GameLogEcho(strcat(":vote:vcall:", ftos(vote_caller.playerid), ":", vote_called_display)); }
                                                        Nagger_VoteChanged();
                                                        VoteCount(true); // needed if you are the only one
@@ -989,7 +1000,7 @@ void VoteCommand_status(float request, entity caller) // BOTH
                case CMD_REQUEST_COMMAND:
                {
                        if(vote_called)
-                               print_to(caller, strcat("^7Vote for ", vote_called_display, "^7 called by ^7", GetCallerName(vote_caller), "^7."));
+                               print_to(caller, strcat("^7Vote for ", vote_called_display, "^7 called by ^7", OriginalCallerName(), "^7."));
                        else
                                print_to(caller, "^1No vote called.");
 
index 3c2845451d49653dacded2e1fbb712b808ba7141..f80785e2a12f8c4935654a8e1853141fb4c5653a 100644 (file)
@@ -24,6 +24,7 @@ const float VOTE_MASTER = 2;
 
 // global vote information declarations
 entity vote_caller; // original caller of the current vote
+string vote_caller_name; // name of the vote caller
 float vote_called; // stores status of current vote (See VOTE_*)
 float vote_endtime; // time when the vote is finished
 float vote_accept_count; // total amount of players who accept the vote (counted by VoteCount() function)