]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
When the match is over notify that the vote in progress is canceled
authorterencehill <piuntn@gmail.com>
Thu, 21 Jul 2022 20:18:44 +0000 (22:18 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 27 May 2023 22:17:39 +0000 (00:17 +0200)
qcsrc/server/command/vote.qc
qcsrc/server/command/vote.qh
qcsrc/server/world.qc

index 6af0a28e4a79deb902c1e2e90ecfdaf7bc715f6a..5ee0ebfb3b0c6fb71760334292e367f2eaab18f9 100644 (file)
@@ -124,8 +124,15 @@ string OriginalCallerName()
 //  Game logic for voting
 // =======================
 
-void VoteReset()
+void VoteStop(entity stopper, bool show_name);
+void VoteReset(bool verbose)
 {
+       if (verbose && vote_called)
+       {
+               VoteStop(NULL, true);
+               return;
+       }
+
        FOREACH_CLIENT(true, { it.vote_selection = 0; });
 
        if (vote_called)
@@ -145,13 +152,16 @@ void VoteReset()
        Nagger_VoteChanged();
 }
 
-void VoteStop(entity stopper)
+void VoteStop(entity stopper, bool canceled)
 {
-       bprint("\{1}^2* ^3", GetCallerName(stopper), "^2 stopped ^3", OriginalCallerName(), "^2's vote\n");
+       if (canceled)
+               bprint("\{1}^2* ^3", OriginalCallerName(), "^2's vote was canceled\n");
+       else
+               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.
        if ((vote_caller) && (stopper == vote_caller))   vote_caller.vote_waittime = time + autocvar_sv_vote_stop;
-       VoteReset();
+       VoteReset(false);
 }
 
 void VoteAccept()
@@ -163,21 +173,21 @@ void VoteAccept()
 
        if (vote_caller)   vote_caller.vote_waittime = 0;  // people like your votes, you don't need to wait to vote again
 
-       VoteReset();
+       VoteReset(false);
        Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_VOTE_ACCEPT);
 }
 
 void VoteReject()
 {
        bprint("\{1}^2* ^3", OriginalCallerName(), "^2's vote for ", vote_called_display, "^2 was rejected\n");
-       VoteReset();
+       VoteReset(false);
        Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_VOTE_FAIL);
 }
 
 void VoteTimeout()
 {
        bprint("\{1}^2* ^3", OriginalCallerName(), "^2's vote for ", vote_called_display, "^2 timed out\n");
-       VoteReset();
+       VoteReset(false);
        Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_VOTE_FAIL);
 }
 
@@ -243,7 +253,7 @@ void VoteCount(float first_count)
        {
                if (vote_caller)   vote_caller.vote_waittime = 0;
                print_to(vote_caller, "^1There are not enough players on this server to allow you to become vote master.");
-               VoteReset();
+               VoteReset(false);
                return;
        }
 
@@ -427,7 +437,7 @@ void ReadyRestart_force(bool is_fake_round_start)
        if (!is_fake_round_start && !autocvar_g_campaign)
                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_COUNTDOWN_RESTART);
 
-       VoteReset();
+       VoteReset(true);
 
        // clear overtime, we have to decrease timelimit to its original value again.
        if (checkrules_overtimesadded > 0 && g_race_qualifying != 2)
@@ -1134,7 +1144,7 @@ void VoteCommand_no(int request, entity caller)  // CLIENT ONLY
                        }
                        else if (((caller == vote_caller) || caller.vote_master) && autocvar_sv_vote_no_stops_vote)
                        {
-                               VoteStop(caller);
+                               VoteStop(caller, true);
                        }
 
                        else  // everything went okay, continue changing vote
@@ -1188,7 +1198,7 @@ void VoteCommand_stop(int request, entity caller)  // BOTH
                case CMD_REQUEST_COMMAND:
                {
                        if (!vote_called)   print_to(caller, "^1No vote called.");
-                       else if ((caller == vote_caller) || !caller || caller.vote_master)   VoteStop(caller);
+                       else if ((caller == vote_caller) || !caller || caller.vote_master)   VoteStop(caller, false);
                        else   print_to(caller, "^1You are not allowed to stop that vote.");
                        return;
                }
index 3e8aaa33f3b1e7f4dc50d822f579c72d452123fa..3f555ed8d8a89086b3d5182d4f9a0386e8fb645a 100644 (file)
@@ -56,7 +56,7 @@ string vote_parsed_display; // visual string which is fixed after being parsed
 
 // allow functions to be used in other code like world.qc and teamplay.qc
 void VoteThink();
-void VoteReset();
+void VoteReset(bool verbose);
 void VoteCommand(int request, entity caller, int argc, string vote_command);
 
 // warmup and nagger stuff
index b3b31ff1b9381c80761fd80ff416bbbb97130d79..56d293f98076b0091ffdd50efb848f6a5142dec0 100644 (file)
@@ -687,7 +687,7 @@ void GameplayMode_DelayedInit(entity this)
 
 void InitGameplayMode()
 {
-       VoteReset();
+       VoteReset(false);
 
        // find out good world mins/maxs bounds, either the static bounds found by looking for solid, or the mapinfo specified bounds
        get_mi_min_max(1);
@@ -1337,7 +1337,7 @@ void NextLevel()
 
        //pos = FindIntermission ();
 
-       VoteReset();
+       VoteReset(true);
 
        DumpStats(true);