]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/vote.qc
Survival: show hunters to other hunters in the scoreboard. It fixes #2844
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / vote.qc
index 6af0a28e4a79deb902c1e2e90ecfdaf7bc715f6a..a3d146c75f7529cbe8a9e9689e717a983ceefe43 100644 (file)
@@ -25,6 +25,7 @@
 #include <server/scores.qh>
 #include <server/teamplay.qh>
 #include <server/weapons/accuracy.qh>
+#include <server/weapons/selection.qh>
 #include <server/world.qh>
 
 // =============================================
@@ -124,8 +125,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 +153,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 +174,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);
 }
 
@@ -205,7 +216,6 @@ void VoteSpam(float notvoters, float mincount, string result)
 
 void VoteCount(float first_count)
 {
-       // declarations
        vote_accept_count = vote_reject_count = vote_abstain_count = 0;
 
        float vote_player_count = 0, notvoters = 0;
@@ -217,7 +227,7 @@ void VoteCount(float first_count)
        Nagger_VoteCountChanged();
 
        // add up all the votes from each connected client
-       FOREACH_CLIENT(IS_REAL_CLIENT(it), {
+       FOREACH_CLIENT(IS_REAL_CLIENT(it) || autocvar_sv_vote_debug, {
                ++vote_player_count;
                if (IS_PLAYER(it) || INGAME(it)) ++vote_real_player_count;
                switch (it.vote_selection)
@@ -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;
        }
 
@@ -407,6 +417,13 @@ void reset_map(bool is_fake_round_start)
                        it.avelocity = '0 0 0';
                        CS(it).movement = '0 0 0';
                        PutClientInServer(it);
+
+                       if(IS_BOT_CLIENT(it))
+                       {
+                               .entity weaponentity = weaponentities[0];
+                               if(it.(weaponentity).m_weapon == WEP_Null)
+                                       W_NextWeapon(it, 0, weaponentity);
+                       }
                });
        }
 }
@@ -427,7 +444,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)
@@ -737,6 +754,29 @@ int VoteCommand_parse(entity caller, string vote_command, string vote_list, floa
 
        switch (first_command) // now go through and parse the proper commands to adjust as needed.
        {
+               case "movetoauto":
+               case "movetored":
+               case "movetoblue":
+               case "movetoyellow":
+               case "movetopink":
+               case "movetospec":
+               {
+                       entity victim = GetIndexedEntity(argc, (startpos + 1));
+                       float accepted = VerifyClientEntity(victim, true, false);
+                       if (accepted > 0)
+                       {
+                               vote_parsed_command = vote_command;
+                               vote_parsed_display = sprintf("^1%s #%d ^7%s", first_command, etof(victim), victim.netname);
+                       }
+                       else
+                       {
+                               print_to(caller, strcat("vcall: ", GetClientErrorString(accepted, argv(startpos + 1)), ".\n"));
+                               return 0;
+                       }
+
+                       break;
+               }
+
                case "kick":
                case "kickban":    // catch all kick/kickban commands
                {
@@ -789,6 +829,22 @@ int VoteCommand_parse(entity caller, string vote_command, string vote_list, floa
                        break;
                }
 
+               case "fraglimit": // include restrictions on the maximum votable frag limit
+               {
+                       float fraglimit_vote = stof(argv(startpos + 1));
+                       float fraglimit_min = 0;
+                       float fraglimit_max = 999999;
+                       if(fraglimit_vote > fraglimit_max || fraglimit_vote < fraglimit_min)
+                       {
+                               print_to(caller, strcat("Invalid fraglimit vote, accepted values are between ", ftos(fraglimit_min), " and ", ftos(fraglimit_max), "."));
+                               return -1;
+                       }
+                       vote_parsed_command = strcat("fraglimit ", ftos(fraglimit_vote));
+                       vote_parsed_display = strzone(strcat("^1", vote_parsed_command));
+
+                       break;
+               }
+
                case "timelimit": // include restrictions on the maximum votable time limit
                {
                        float timelimit_vote = stof(argv(startpos + 1));
@@ -797,7 +853,6 @@ int VoteCommand_parse(entity caller, string vote_command, string vote_list, floa
                                print_to(caller, strcat("Invalid timelimit vote, accepted values are between ", ftos(autocvar_timelimit_min), " and ", ftos(autocvar_timelimit_max), "."));
                                return -1;
                        }
-                       timelimit_vote = bound(autocvar_timelimit_min, timelimit_vote, autocvar_timelimit_max);
                        vote_parsed_command = strcat("timelimit ", ftos(timelimit_vote));
                        vote_parsed_display = strzone(strcat("^1", vote_parsed_command));
 
@@ -968,6 +1023,8 @@ void VoteCommand_call(int request, entity caller, int argc, string vote_command)
                                FOREACH_CLIENT(IS_REAL_CLIENT(it), { ++tmp_playercount; });
 
                                bprint("\{1}^2* ^3", OriginalCallerName(), "^2 calls a vote for ", vote_called_display, "\n");
+                               if (autocvar_sv_vote_debug)
+                                       bprint("\{1}^2* ^3", "^6DEBUG MODE ACTIVE: bots can vote too\n"); // so servers don't forget it on
                                if (autocvar_sv_eventlog)
                                        GameLogEcho(strcat(":vote:vcall:", ftos(vote_caller.playerid), ":", vote_called_display));
                                Nagger_VoteChanged();
@@ -1134,7 +1191,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 +1245,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;
                }