]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' of git://de.git.xonotic.org/xonotic/xonotic-data.pk3dir
authorRudolf Polzer <divVerent@xonotic.org>
Tue, 26 Jul 2011 12:17:07 +0000 (14:17 +0200)
committerRudolf Polzer <divVerent@xonotic.org>
Tue, 26 Jul 2011 12:17:07 +0000 (14:17 +0200)
defaultXonotic.cfg
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/hud.qc
qcsrc/client/movetypes.qc
qcsrc/common/constants.qh
qcsrc/server/clientcommands.qc
qcsrc/server/ctf.qc
qcsrc/server/mutators/gamemode_freezetag.qc
qcsrc/server/vote.qc
qcsrc/server/vote.qh

index 27ab53efc715dd34111bd703be3353ca0b36fe46..58d54e41d092d5ec4660397f76863d513f1b33b1 100644 (file)
@@ -702,7 +702,7 @@ set g_ctf_flagcarrier_selfforce 1
 set g_ctf_fullbrightflags 0
 set g_ctf_dynamiclights 0
 set g_ctf_allow_drop 1 "dropping allows circumventing carrierkill score, so enable this with care!"
-set g_ctf_reverse 0    "when 1, bases/flags are switched :P you have to capture your OWN flag by bringing it to the ENEMY's"
+set g_ctf_reverse 0    "if enabled, flags positions are switched: you have to capture the enemy's flag from your own base by bringing it to your own flag in the enemy base"
 set g_balance_ctf_delay_collect 1.0
 set g_balance_ctf_damageforcescale 1
 
@@ -1268,7 +1268,7 @@ alias "g_waypointsprite_team_danger_p"    "impulse 38"
 alias "g_waypointsprite_team_danger_d" "impulse 39"
 alias "g_waypointsprite_clear_personal"        "impulse 47"
 alias "g_waypointsprite_clear" "impulse 48"
-alias "g_waypointsprite_toggle"        "impulse 49"
+alias "g_waypointsprite_toggle"        "toggle cl_hidewaypoints"
 // key for that?
 seta cl_hidewaypoints 0 "disable static waypoints, only show team waypoints"
 
index 95a01ab0e767501ac9b257ff2b266536dbe893cf..0b0faa31084dd773ae2336727e5dd21a5fa833ec 100644 (file)
@@ -847,13 +847,26 @@ void Ent_Nagger()
 {
        float nags, i, j, b, f;
 
-       nags = ReadByte();
+       nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
 
        if(!(nags & 4))
        {
                if(vote_called_vote)
                        strunzone(vote_called_vote);
                vote_called_vote = string_null;
+               vote_active = 0;
+       }
+       else
+       {
+               vote_active = 1;
+       }
+
+       if(nags & 64)
+       {
+               vote_yescount = ReadByte();
+               vote_nocount = ReadByte();
+               vote_needed = ReadByte();
+               vote_highlighted = ReadChar();
        }
 
        if(nags & 128)
@@ -1300,22 +1313,6 @@ void Net_ReadPingPLReport()
        playerslots[e].ping_movementloss = ml / 255.0;
 }
 
-void Net_VoteDialog(float highlight) {
-       if(highlight) {
-               vote_highlighted = ReadByte();
-               return;
-       }
-
-       vote_yescount = ReadByte();
-       vote_nocount = ReadByte();
-       vote_needed = ReadByte();
-       vote_active = 1;
-}
-
-void Net_VoteDialogReset() {
-       vote_active = 0;
-}
-
 void Net_Notify() {
        float type;
        type = ReadByte();
@@ -1385,14 +1382,6 @@ float CSQC_Parse_TempEntity()
                        Net_TeamNagger();
                        bHandled = true;
                        break;
-               case TE_CSQC_VOTE:
-                       Net_VoteDialog(ReadByte());
-                       bHandled = true;
-                       break;
-               case TE_CSQC_VOTERESET:
-                       Net_VoteDialogReset();
-                       bHandled = true;
-                       break;
                case TE_CSQC_LIGHTNINGARC:
                        Net_ReadLightningarc();
                        bHandled = true;
index 48566db5739ae1d9b43e401a16613d71aa6edc7d..e6dc7309832da9e182e0661d6dc0c9d4d898adb3 100644 (file)
@@ -175,11 +175,15 @@ vector GetCurrentFov(float fov)
        else
                setsensitivityscale(1);
 
-       velocityzoom = bound(0, drawframetime / max(0.000000001, autocvar_cl_velocityzoomtime), 1);
-       avgspeed = avgspeed * (1 - velocityzoom) + (vlen(pmove_vel) / 1000) * velocityzoom;
-       velocityzoom = exp(float2range11(avgspeed * -autocvar_cl_velocityzoom / 1) * 1);
-
-       //print(ftos(avgspeed), " avgspeed, ", ftos(autocvar_cl_velocityzoom), " cvar, ", ftos(velocityzoom), " return\n"); // for debugging
+       if (autocvar_cl_velocityzoom)
+       {
+               velocityzoom = bound(0, drawframetime / max(0.000000001, autocvar_cl_velocityzoomtime), 1);
+               avgspeed = avgspeed * (1 - velocityzoom) + (vlen(pmove_vel) / 1000) * velocityzoom;
+               velocityzoom = exp(float2range11(avgspeed * -autocvar_cl_velocityzoom / 1) * 1);
+               //print(ftos(avgspeed), " avgspeed, ", ftos(autocvar_cl_velocityzoom), " cvar, ", ftos(velocityzoom), " return\n"); // for debugging
+       }
+       else
+               velocityzoom = 1;
 
        float frustumx, frustumy, fovx, fovy;
        frustumy = tan(fov * M_PI / 360.0) * 0.75 * current_viewzoom * velocityzoom;
index 6b11719567d055e4234fd81ddb8344f3ba4316e8..260b2c5c5993925456fecda0cbc9c1ca770cdf5b 100644 (file)
@@ -3117,7 +3117,7 @@ void HUD_VoteWindow(void)
        pos = panel_pos;
        mySize = panel_size;
 
-       a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
+       a = vote_alpha * (vote_highlighted ? autocvar_hud_panel_vote_alreadyvoted_alpha : 1);
        HUD_Panel_DrawBg(a);
        a = panel_fg_alpha * a;
 
@@ -3168,7 +3168,7 @@ void HUD_VoteWindow(void)
                drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
                drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
        }
-       else if(vote_highlighted == 2) {
+       else if(vote_highlighted == -1) {
                drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
                drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
        }
@@ -3187,10 +3187,6 @@ void HUD_VoteWindow(void)
        }
 
        drawresetcliparea();
-
-       if(!vote_active) {
-               vote_highlighted = 0;
-       }
 }
 
 // Mod icons panel (#10)
index 9a17dea35694f9ee005b836f603d65071a2ac7ba..4dcdae90bf1bb7e5b85aad0c472afbb450d5c170 100644 (file)
@@ -1,3 +1,7 @@
+float STAT_MOVEFLAGS = 225;
+float MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE = 4;
+#define GRAVITY_UNAFFECTED_BY_TICRATE (getstati(STAT_MOVEFLAGS) & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE)
+
 .entity move_groundentity;
 .float move_suspendedinair;
 .float move_didgravity;
@@ -232,11 +236,21 @@ void _Movetype_Physics_Toss(float dt) // SV_Physics_Toss
 
        if(self.move_movetype == MOVETYPE_BOUNCE || self.move_movetype == MOVETYPE_TOSS)
        {
-               self.move_didgravity = TRUE;
-               if(self.gravity)
-                       self.move_velocity_z -= dt * self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+               self.move_didgravity = 1;
+               if(GRAVITY_UNAFFECTED_BY_TICRATE)
+               {
+                       if(self.gravity)
+                               self.move_velocity_z -= 0.5 * dt * self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+                       else
+                               self.move_velocity_z -= 0.5 * dt * getstatf(STAT_MOVEVARS_GRAVITY);
+               }
                else
-                       self.move_velocity_z -= dt * getstatf(STAT_MOVEVARS_GRAVITY);
+               {
+                       if(self.gravity)
+                               self.move_velocity_z -= dt * self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+                       else
+                               self.move_velocity_z -= dt * getstatf(STAT_MOVEVARS_GRAVITY);
+               }
        }
 
        self.move_angles = self.move_angles + self.move_avelocity * dt;
@@ -318,12 +332,22 @@ void _Movetype_Physics_Toss(float dt) // SV_Physics_Toss
                        break;
        }
 
+       if(GRAVITY_UNAFFECTED_BY_TICRATE)
+       if(self.move_didgravity > 0)
+       if(!(self.move_flags & FL_ONGROUND))
+       {
+               if(self.gravity)
+                       self.move_velocity_z -= 0.5 * dt * self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+               else
+                       self.move_velocity_z -= 0.5 * dt * getstatf(STAT_MOVEVARS_GRAVITY);
+       }
+
        _Movetype_CheckWaterTransition();
 }
 
 void _Movetype_Physics_Frame(float movedt)
 {
-       self.move_didgravity = FALSE;
+       self.move_didgravity = -1;
        switch(self.move_movetype)
        {
                case MOVETYPE_PUSH:
@@ -364,9 +388,6 @@ void Movetype_Physics_NoMatchServer() // optimized
        movedt = time - self.move_time;
        self.move_time = time;
 
-       //self.move_didgravity = ((self.move_movetype == MOVETYPE_BOUNCE || self.move_movetype == MOVETYPE_TOSS) && !(self.move_flags & FL_ONGROUND));
-       // we use the field as set by the last run of this
-
        _Movetype_Physics_Frame(movedt);
        if(wasfreed(self))
                return;
@@ -399,8 +420,8 @@ void Movetype_Physics_MatchTicrate(float tr, float sloppy) // SV_Physics_Entity
        dt -= n * tr;
        self.move_time += n * tr;
 
-       //self.move_didgravity = ((self.move_movetype == MOVETYPE_BOUNCE || self.move_movetype == MOVETYPE_TOSS) && !(self.move_flags & FL_ONGROUND));
-       // we use the field as set by the last run of this
+       if(!self.move_didgravity)
+               self.move_didgravity = ((self.move_movetype == MOVETYPE_BOUNCE || self.move_movetype == MOVETYPE_TOSS) && !(self.move_flags & FL_ONGROUND));
 
        for(i = 0; i < n; ++i)
        {
@@ -415,12 +436,23 @@ void Movetype_Physics_MatchTicrate(float tr, float sloppy) // SV_Physics_Entity
        {
                // now continue the move from move_time to time
                self.velocity = self.move_velocity;
-               if(self.move_didgravity)
+
+               if(self.move_didgravity > 0)
                {
-                       if(self.gravity)
-                               self.velocity_z -= dt * self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+                       if(GRAVITY_UNAFFECTED_BY_TICRATE)
+                       {
+                               if(self.gravity)
+                                       self.velocity_z -= 0.5 * dt * self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+                               else
+                                       self.velocity_z -= 0.5 * dt * getstatf(STAT_MOVEVARS_GRAVITY);
+                       }
                        else
-                               self.velocity_z -= dt * getstatf(STAT_MOVEVARS_GRAVITY);
+                       {
+                               if(self.gravity)
+                                       self.velocity_z -= dt * self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+                               else
+                                       self.velocity_z -= dt * getstatf(STAT_MOVEVARS_GRAVITY);
+                       }
                }
 
                self.angles = self.move_angles + dt * self.avelocity;
@@ -435,6 +467,17 @@ void Movetype_Physics_MatchTicrate(float tr, float sloppy) // SV_Physics_Entity
                        if(!trace_startsolid)
                                setorigin(self, trace_endpos);
                }
+
+               if(self.move_didgravity > 0)
+               {
+                       if(GRAVITY_UNAFFECTED_BY_TICRATE)
+                       {
+                               if(self.gravity)
+                                       self.velocity_z -= 0.5 * dt * self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+                               else
+                                       self.velocity_z -= 0.5 * dt * getstatf(STAT_MOVEVARS_GRAVITY);
+                       }
+               }
        }
        else
        {
index e253ee5c71a3b5f32318edc47d17185449ea4f85..939f6f9700352a4ec402e2e8b68b1b25598d3c47 100644 (file)
@@ -55,8 +55,6 @@ const float TE_CSQC_NEXGUNBEAMPARTICLE = 104;
 const float TE_CSQC_LIGHTNINGARC = 105;
 const float TE_CSQC_TEAMNAGGER = 106;
 const float TE_CSQC_PINGPLREPORT = 107;
-const float TE_CSQC_VOTE = 108;
-const float TE_CSQC_VOTERESET = 109;
 const float TE_CSQC_ANNOUNCE = 110;
 const float TE_CSQC_TARGET_MUSIC = 111;
 const float TE_CSQC_NOTIFY = 112;
index ac08cc916a43bc343ce896afed07fe208d108825..c1d3162a5739da2da60f6604d6f4a72368414aaa 100644 (file)
@@ -1,11 +1,22 @@
 entity nagger;
 float readycount;
+
 float Nagger_SendEntity(entity to, float sendflags)
 {
        float nags, i, f, b;
        entity e;
        WriteByte(MSG_ENTITY, ENT_CLIENT_NAGGER);
 
+       // bits:
+       //   1 = ready
+       //   2 = player needs to ready up
+       //   4 = vote
+       //   8 = player needs to vote
+       //  16 = warmup
+       // sendflags:
+       //  64 = vote counts
+       // 128 = vote string
+
        nags = 0;
        if(readycount)
        {
@@ -22,19 +33,28 @@ float Nagger_SendEntity(entity to, float sendflags)
        if(inWarmupStage)
                nags |= 16;
 
+       if(sendflags & 64)
+               nags |= 64;
+
        if(sendflags & 128)
                nags |= 128;
 
        if(!(nags & 4)) // no vote called? send no string
-               nags &~= 128;
+               nags &~= (64 | 128);
 
        WriteByte(MSG_ENTITY, nags);
 
-       if(nags & 128)
+       if(nags & 64)
        {
-               WriteString(MSG_ENTITY, votecalledvote_display);
+               WriteByte(MSG_ENTITY, vote_yescount);
+               WriteByte(MSG_ENTITY, vote_nocount);
+               WriteByte(MSG_ENTITY, vote_needed_absolute);
+               WriteChar(MSG_ENTITY, to.vote_vote);
        }
 
+       if(nags & 128)
+               WriteString(MSG_ENTITY, votecalledvote_display);
+
        if(nags & 1)
        {
                for(i = 1; i <= maxclients; i += 8)
@@ -60,7 +80,7 @@ void Nagger_VoteChanged()
 void Nagger_VoteCountChanged()
 {
        if(nagger)
-               nagger.SendFlags |= 1;
+               nagger.SendFlags |= 64;
 }
 void Nagger_ReadyCounted()
 {
index a54ee6a8ac68ced40bc09fa337f0a80cf1dddcf0..93446ed5ba811bd430c8d0eb30b8dfe0f7b3e3ee 100644 (file)
@@ -765,6 +765,7 @@ Keys:
  (default ctf/respawn.wav)
 */
 
+void spawnfunc_item_flag_team2();
 void spawnfunc_item_flag_team1()
 {
        if (!g_ctf)
@@ -773,21 +774,22 @@ void spawnfunc_item_flag_team1()
                return;
        }
 
+       if (g_ctf_reverse)
+       {
+               float old_g_ctf_reverse = g_ctf_reverse;
+               g_ctf_reverse = 0; // avoid an endless loop
+               spawnfunc_item_flag_team2();
+               g_ctf_reverse = old_g_ctf_reverse;
+               return;
+       }
+
        // link flag into ctf_worldflaglist
        self.ctf_worldflagnext = ctf_worldflaglist;
        ctf_worldflaglist = self;
 
        self.classname = "item_flag_team";
-       if(g_ctf_reverse)
-       {
-               self.team = COLOR_TEAM2; // color 13 team (blue)
-               self.items = IT_KEY1; // silver key (bluish enough)
-       }
-       else
-       {
-               self.team = COLOR_TEAM1; // color 4 team (red)
-               self.items = IT_KEY2; // gold key (redish enough)
-       }
+       self.team = COLOR_TEAM1; // color 4 team (red)
+       self.items = IT_KEY2; // gold key (redish enough)
        self.netname = "^1RED^7 flag";
        self.target = "###item###";
        self.skin = autocvar_g_ctf_flag_red_skin;
@@ -871,21 +873,22 @@ void spawnfunc_item_flag_team2()
                return;
        }
 
+       if (g_ctf_reverse)
+       {
+               float old_g_ctf_reverse = g_ctf_reverse;
+               g_ctf_reverse = 0; // avoid an endless loop
+               spawnfunc_item_flag_team1();
+               g_ctf_reverse = old_g_ctf_reverse;
+               return;
+       }
+
        // link flag into ctf_worldflaglist
        self.ctf_worldflagnext = ctf_worldflaglist;
        ctf_worldflaglist = self;
 
        self.classname = "item_flag_team";
-       if(g_ctf_reverse)
-       {
-               self.team = COLOR_TEAM1; // color 4 team (red)
-               self.items = IT_KEY2; // gold key (redish enough)
-       }
-       else
-       {
-               self.team = COLOR_TEAM2; // color 13 team (blue)
-               self.items = IT_KEY1; // silver key (bluish enough)
-       }
+       self.team = COLOR_TEAM2; // color 13 team (blue)
+       self.items = IT_KEY1; // silver key (bluish enough)
        self.netname = "^4BLUE^7 flag";
        self.target = "###item###";
        self.skin = autocvar_g_ctf_flag_blue_skin;
index c3d9272598fa720683113018f14efc241237ab8d..f74c9951fd4d49027e518057685823896b6a7def 100644 (file)
@@ -69,6 +69,7 @@ void freezetag_Freeze(entity attacker)
                return;
        self.freezetag_frozen = 1;
        self.freezetag_revive_progress = 0;
+       self.health = 1;
 
        entity ice;
        ice = spawn();
@@ -113,6 +114,7 @@ void freezetag_Unfreeze(entity attacker)
 {
        self.freezetag_frozen = 0;
        self.freezetag_revive_progress = 0;
+       self.health = autocvar_g_balance_health_start;
 
        // remove the ice block
        entity ice;
@@ -183,7 +185,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerDies)
                bprint("^7", frag_target.netname, "^1 was frozen by ^7", frag_attacker.netname, ".\n");
        }
 
-       frag_target.health = autocvar_g_balance_health_start; // "respawn" the player :P
+       frag_target.health = 1; // "respawn" the player :P
 
        freezetag_CheckWinner();
 
@@ -244,6 +246,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerPreThink)
        if(n && self.freezetag_frozen) // OK, there is at least one teammate reviving us
        {
                self.freezetag_revive_progress = bound(0, self.freezetag_revive_progress + frametime * autocvar_g_freezetag_revive_speed, 1);
+               self.health = max(1, self.freezetag_revive_progress * autocvar_g_balance_health_start);
 
                if(self.freezetag_revive_progress >= 1)
                {
@@ -292,6 +295,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerPreThink)
        else if(!n && self.freezetag_frozen) // only if no teammate is nearby will we reset
        {
                self.freezetag_revive_progress = bound(0, self.freezetag_revive_progress - frametime * autocvar_g_freezetag_revive_clearspeed, 1);
+               self.health = max(1, self.freezetag_revive_progress * autocvar_g_balance_health_start);
        }
        else if(!n)
        {
index bad3eafe40d3c78b5b1d2d6438c08537d7469e76..1690cf437b828c9f91538af05a4b982ab0827caf 100644 (file)
@@ -116,18 +116,6 @@ float RemapVote(string vote, string cmd, entity e)
        return TRUE;
 }
 
-void VoteDialog_UpdateHighlight(float selected) {
-       WriteByte(MSG_ONE, SVC_TEMPENTITY);
-       WriteByte(MSG_ONE, TE_CSQC_VOTE);
-       WriteByte(MSG_ONE, 1);
-       WriteByte(MSG_ONE, selected);
-}
-
-void VoteDialog_Reset() {
-       WriteByte(MSG_ALL, SVC_TEMPENTITY);
-       WriteByte(MSG_ALL, TE_CSQC_VOTERESET);
-}
-
 float GameCommand_Vote(string s, entity e) {
        local float playercount;
        float argc;
@@ -180,10 +168,9 @@ float GameCommand_Vote(string s, entity e) {
                                                bprint("\{1}^2* ^3", VoteNetname(votecaller), "^2 calls a vote for ", votecalledvote_display, "\n");
                                                if(autocvar_sv_eventlog)
                                                        GameLogEcho(strcat(":vote:vcall:", ftos(votecaller.playerid), ":", votecalledvote_display));
-                                               VoteCount(); // needed if you are the only one
                                                Nagger_VoteChanged();
+                                               VoteCount(); // needed if you are the only one
                                                msg_entity = e;
-                                               VoteDialog_UpdateHighlight(1);
 
                                                local entity player;
                                                FOR_EACH_REALCLIENT(player)
@@ -203,13 +190,10 @@ float GameCommand_Vote(string s, entity e) {
                        if(!votecalled) {
                                print_to(e, "^1No vote called.");
                        } else if(e == votecaller) { // the votecaller can stop a vote
-                               VoteDialog_Reset();
                                VoteStop(e);
                        } else if(!e) { // server admin / console can too
-                               VoteDialog_Reset();
                                VoteStop(e);
                        } else if(e.vote_master) { // masters can too
-                               VoteDialog_Reset();
                                VoteStop(e);
                        } else {
                                print_to(e, "^1You are not allowed to stop that Vote.");
@@ -232,8 +216,8 @@ float GameCommand_Vote(string s, entity e) {
                                        bprint("\{1}^2* ^3", VoteNetname(votecaller), "^2 calls a vote to become ^3master^2.\n");
                                        if(autocvar_sv_eventlog)
                                                GameLogEcho(strcat(":vote:vcall:", ftos(votecaller.playerid), ":", votecalledvote_display));
-                                       VoteCount(); // needed if you are the only one
                                        Nagger_VoteChanged();
+                                       VoteCount(); // needed if you are the only one
                                }
                        } else {
                                print_to(e, "^1Vote to become master is NOT allowed.");
@@ -284,7 +268,6 @@ float GameCommand_Vote(string s, entity e) {
                        } else if(e.vote_vote == 0
                                  || autocvar_sv_vote_change) {
                                msg_entity = e;
-                               VoteDialog_UpdateHighlight(1);
                                print_to(e, "^1You accepted the vote.");
                                e.vote_vote = 1;
                                centerprint_expire(e, CENTERPRIO_VOTE);
@@ -302,7 +285,6 @@ float GameCommand_Vote(string s, entity e) {
                        } else if(e.vote_vote == 0
                                  || autocvar_sv_vote_change) {
                                msg_entity = e;
-                               VoteDialog_UpdateHighlight(2);
                                print_to(e, "^1You rejected the vote.");
                                e.vote_vote = -1;
                                centerprint_expire(e, CENTERPRIO_VOTE);
@@ -320,7 +302,6 @@ float GameCommand_Vote(string s, entity e) {
                        } else if(e.vote_vote == 0
                                  || autocvar_sv_vote_change) {
                                msg_entity = e;
-                               VoteDialog_UpdateHighlight(3);
                                print_to(e, "^1You abstained from your vote.");
                                e.vote_vote = -2;
                                centerprint_expire(e, CENTERPRIO_VOTE);
@@ -525,54 +506,42 @@ void VoteStop(entity stopper) {
        VoteReset();
 }
 
-void VoteSpam(float yescount, float nocount, float abstaincount, float notvoters, float mincount, string result)
+void VoteSpam(float notvoters, float mincount, string result)
 {
        string s;
        if(mincount >= 0)
        {
-               s = strcat("\{1}^2* vote results: ^1", ftos(yescount), "^2:^1");
-               s = strcat(s, ftos(nocount), "^2 (^1");
+               s = strcat("\{1}^2* vote results: ^1", ftos(vote_yescount), "^2:^1");
+               s = strcat(s, ftos(vote_nocount), "^2 (^1");
                s = strcat(s, ftos(mincount), "^2 needed), ^1");
-               s = strcat(s, ftos(abstaincount), "^2 didn't care, ^1");
+               s = strcat(s, ftos(vote_abstaincount), "^2 didn't care, ^1");
                s = strcat(s, ftos(notvoters), "^2 didn't vote\n");
        }
        else
        {
-               s = strcat("\{1}^2* vote results: ^1", ftos(yescount), "^2:^1");
-               s = strcat(s, ftos(nocount), "^2, ^1");
-               s = strcat(s, ftos(abstaincount), "^2 didn't care, ^1");
+               s = strcat("\{1}^2* vote results: ^1", ftos(vote_yescount), "^2:^1");
+               s = strcat(s, ftos(vote_nocount), "^2, ^1");
+               s = strcat(s, ftos(vote_abstaincount), "^2 didn't care, ^1");
                s = strcat(s, ftos(notvoters), "^2 didn't have to vote\n");
        }
        bprint(s);
        if(autocvar_sv_eventlog)
        {
-               s = strcat(":vote:v", result, ":", ftos(yescount));
-               s = strcat(s, ":", ftos(nocount));
-               s = strcat(s, ":", ftos(abstaincount));
+               s = strcat(":vote:v", result, ":", ftos(vote_yescount));
+               s = strcat(s, ":", ftos(vote_nocount));
+               s = strcat(s, ":", ftos(vote_abstaincount));
                s = strcat(s, ":", ftos(notvoters));
                s = strcat(s, ":", ftos(mincount));
                GameLogEcho(s);
        }
 }
 
-void VoteDialog_Update(float msg, float vyes, float vno, float needed) {
-       WriteByte(msg, SVC_TEMPENTITY);
-       WriteByte(msg, TE_CSQC_VOTE);
-       WriteByte(msg, 0);
-       WriteByte(msg, vyes);
-       WriteByte(msg, vno);
-       WriteByte(msg, needed);
-}
-
 void VoteCount() {
        local float playercount;
        playercount = 0;
-       local float yescount;
-       yescount = 0;
-       local float nocount;
-       nocount = 0;
-       local float abstaincount;
-       abstaincount = 0;
+       vote_yescount = 0;
+       vote_nocount = 0;
+       vote_abstaincount = 0;
        local entity player;
        //same for real players
        local float realplayercount;
@@ -581,14 +550,16 @@ void VoteCount() {
        local float realplayerabstaincount;
        realplayercount = realplayernocount = realplayerabstaincount = realplayeryescount = 0;
 
+       Nagger_VoteCountChanged();
+
        FOR_EACH_REALCLIENT(player)
        {
                if(player.vote_vote == -1) {
-                       ++nocount;
+                       ++vote_nocount;
                } else if(player.vote_vote == 1) {
-                       ++yescount;
+                       ++vote_yescount;
                } else if(player.vote_vote == -2) {
-                       ++abstaincount;
+                       ++vote_abstaincount;
                }
                ++playercount;
                //do the same for real players
@@ -607,18 +578,25 @@ void VoteCount() {
        //in tournament mode, if we have at least one player then don't make the vote dependent on spectators (so specs don't have to press F1)
        if(autocvar_sv_vote_nospectators)
        if(realplayercount > 0) {
-               yescount = realplayeryescount;
-               nocount = realplayernocount;
-               abstaincount = realplayerabstaincount;
+               vote_yescount = realplayeryescount;
+               vote_nocount = realplayernocount;
+               vote_abstaincount = realplayerabstaincount;
                playercount = realplayercount;
        }
 
        float votefactor, simplevotefactor;
        votefactor = bound(0.5, autocvar_sv_vote_majority_factor, 0.999);
        simplevotefactor = autocvar_sv_vote_simple_majority_factor;
-       float needed;
-       needed = floor((playercount - abstaincount) * max(votefactor, simplevotefactor)) + 1;
-       VoteDialog_Update(MSG_ALL, yescount, nocount, needed);
+
+       // FIXME this number is a guess
+       vote_needed_absolute = floor((playercount - vote_abstaincount) * votefactor) + 1;
+       if(simplevotefactor)
+       {
+               simplevotefactor = bound(votefactor, simplevotefactor, 0.999);
+               vote_needed_simple = floor((vote_yescount + vote_nocount) * simplevotefactor) + 1;
+       }
+       else
+               vote_needed_simple = 0;
 
        if(votecalledmaster
           && playercount == 1) {
@@ -634,31 +612,28 @@ void VoteCount() {
                }
                VoteReset();
        } else {
-               if(yescount > (playercount - abstaincount) * votefactor)
+               if(vote_yescount >= vote_needed_absolute)
                {
-                       VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, -1, "yes");
+                       VoteSpam(playercount - vote_yescount - vote_nocount - vote_abstaincount, -1, "yes");
                        VoteAccept();
-                       VoteDialog_Reset();
                }
-               else if(nocount >= (playercount - abstaincount) * (1 - votefactor)) // that means, yescount cannot reach minyes any more
+               else if(vote_nocount > playercount - vote_abstaincount - vote_needed_absolute) // that means, vote_yescount cannot reach vote_needed_absolute any more
                {
-                       VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, -1, "no");
+                       VoteSpam(playercount - vote_yescount - vote_nocount - vote_abstaincount, -1, "no");
                        VoteReject();
-                       VoteDialog_Reset();
                }
                else if(time > votefinished)
                {
                        if(simplevotefactor)
                        {
                                string result;
-                               simplevotefactor = bound(votefactor, simplevotefactor, 0.999);
-                               if(yescount > (yescount + nocount) * simplevotefactor)
+                               if(vote_yescount >= vote_needed_simple)
                                        result = "yes";
-                               else if(yescount + nocount > 0)
+                               else if(vote_yescount + vote_nocount > 0)
                                        result = "no";
                                else
                                        result = "timeout";
-                               VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, floor(min((playercount - abstaincount) * votefactor, (yescount + nocount) * simplevotefactor)) + 1, result);
+                               VoteSpam(playercount - vote_yescount - vote_nocount - vote_abstaincount, min(vote_needed_absolute, vote_needed_simple), result);
                                if(result == "yes")
                                        VoteAccept();
                                else if(result == "no")
@@ -668,10 +643,9 @@ void VoteCount() {
                        }
                        else
                        {
-                               VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, floor((playercount - abstaincount) * votefactor) + 1, "timeout");
+                               VoteSpam(playercount - vote_yescount - vote_nocount - vote_abstaincount, vote_needed_absolute, "timeout");
                                VoteTimeout();
                        }
-               VoteDialog_Reset();
                }
        }
 }
index 7d937a93c1c1668b7a61a368012046df797f041d..75eda9849e6a235860da66917ce2eb7863fbaf56 100644 (file)
@@ -7,6 +7,11 @@ float votefinished;
 .float vote_master;
 .float vote_next;
 .float vote_vote;
+float vote_yescount;
+float vote_nocount;
+float vote_abstaincount;
+float vote_needed_absolute;
+float vote_needed_simple;
 
 float VoteCheckNasty(string cmd);
 entity GetKickVoteVictim(string vote, string cmd, entity caller);
@@ -22,5 +27,5 @@ void VoteAccept();
 void VoteReject();
 void VoteTimeout();
 void VoteStop(entity stopper);
-void VoteSpam(float yescount, float nocount, float abstaincount, float notvoters, float mincount, string result);
+void VoteSpam(float notvoters, float mincount, string result);
 void VoteCount();