From: terencehill Date: Wed, 13 Jul 2011 15:52:39 +0000 (+0200) Subject: Change how pps are calculated: every time a control point (cp) is captured recalculat... X-Git-Tag: xonotic-v0.5.0~148^2~10^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4b1f3d2ede33ea69d8f1c5602c573471d67cfc7f;p=xonotic%2Fxonotic-data.pk3dir.git Change how pps are calculated: every time a control point (cp) is captured recalculate all the stats from all the cps. This is mainly to avoid stats breakage when g_domination_point_amt and/or g_domination_point_rate are changed during a match. --- diff --git a/qcsrc/server/domination.qc b/qcsrc/server/domination.qc index cf0584b72..747927a7e 100644 --- a/qcsrc/server/domination.qc +++ b/qcsrc/server/domination.qc @@ -34,7 +34,6 @@ float pps_yellow; float pps_pink; void set_dom_state(entity e) { - // BIG ugly hack to make stat sending work e.dom_total_pps = total_pps; e.dom_pps_red = pps_red; e.dom_pps_blue = pps_blue; @@ -130,48 +129,32 @@ void dompoint_captured () self.delay = old_delay; self.team = old_team; - switch(self.team) + total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0; + for(head = world; (head = find(head, classname, "dom_controlpoint")) != world; ) { - // "fix" pps when slightly under 0 because of approximation errors - case COLOR_TEAM1: - pps_red -= (points/wait_time); - if (pps_red < 0) pps_red = 0; - break; - case COLOR_TEAM2: - pps_blue -= (points/wait_time); - if (pps_blue < 0) pps_blue = 0; - break; - case COLOR_TEAM3: - pps_yellow -= (points/wait_time); - if (pps_yellow < 0) pps_yellow = 0; - break; - case COLOR_TEAM4: - pps_pink -= (points/wait_time); - if (pps_pink < 0) pps_pink = 0; - } - - switch(self.goalentity.team) - { - // "fix" pps when slightly over total_pps because of approximation errors - case COLOR_TEAM1: - pps_red += (points/wait_time); - if (pps_red > total_pps) pps_red = total_pps; - WaypointSprite_UpdateSprites(self.sprite, "dom-red", "", ""); - break; - case COLOR_TEAM2: - pps_blue += (points/wait_time); - if (pps_blue > total_pps) pps_blue = total_pps; - WaypointSprite_UpdateSprites(self.sprite, "dom-blue", "", ""); - break; - case COLOR_TEAM3: - pps_yellow += (points/wait_time); - if (pps_yellow > total_pps) pps_yellow = total_pps; - WaypointSprite_UpdateSprites(self.sprite, "dom-yellow", "", ""); - break; - case COLOR_TEAM4: - pps_pink += (points/wait_time); - if (pps_pink > total_pps) pps_pink = total_pps; - WaypointSprite_UpdateSprites(self.sprite, "dom-pink", "", ""); + if (autocvar_g_domination_point_amt) + points = autocvar_g_domination_point_amt; + else + points = head.frags; + if (autocvar_g_domination_point_rate) + wait_time = autocvar_g_domination_point_rate; + else + wait_time = head.wait; + switch(head.goalentity.team) + { + case COLOR_TEAM1: + pps_red += points/wait_time; + break; + case COLOR_TEAM2: + pps_blue += points/wait_time; + break; + case COLOR_TEAM3: + pps_yellow += points/wait_time; + break; + case COLOR_TEAM4: + pps_pink += points/wait_time; + } + total_pps += points/wait_time; } WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, colormapPaletteColor(self.goalentity.team - 1, 0));