]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Revert "Network dom pps data in a more efficient way" <---- Lies.
authorFruitieX <fruitiex@gmail.com>
Wed, 15 Dec 2010 12:11:53 +0000 (14:11 +0200)
committerFruitieX <fruitiex@gmail.com>
Wed, 15 Dec 2010 12:11:53 +0000 (14:11 +0200)
This reverts commit 02d238e88f088f567092b524a09001bfcacc8d75.

Conflicts:

qcsrc/server/domination.qc

qcsrc/client/Defs.qc
qcsrc/client/Main.qc
qcsrc/client/hud.qc
qcsrc/common/constants.qh
qcsrc/server/cl_client.qc
qcsrc/server/domination.qc

index 5f5974a1aac5a33c9f281737514897fdc806ecb2..2d780381eedced49f15c67549f6455c535ae3a67 100644 (file)
@@ -216,13 +216,6 @@ float race_status;
 string race_status_name;
 float race_myrank;
 
-// DOM
-float dom_total_pps;
-float dom_pps_red;
-float dom_pps_blue;
-float dom_pps_yellow;
-float dom_pps_pink;
-
 // Nexball
 float nb_pb_period;
 
index d37a971eaebc7b3dd9ebe71b0ad58f5d2794916c..6df7dfa09f360f39a646ed0f87147c46df9840e6 100644 (file)
@@ -1253,20 +1253,6 @@ void Net_ReadRace()
        }
 }
 
-void Net_ReadDom()
-{
-       if (dom_total_pps == 0)
-               dom_total_pps = ReadShort() / 100.0;
-       dom_pps_red = ReadShort() / 100.0;
-       dom_pps_blue = ReadShort() / 100.0;
-       //if dom_pps_yellow/dom_pps_pink was negative the first time we read it,
-       //it means the relative team doesn't exist and we don't have to read its value anymore
-       if (dom_pps_yellow >= 0)
-               dom_pps_yellow = ReadShort() / 100.0;
-       if (dom_pps_pink >= 0)
-               dom_pps_pink = ReadShort() / 100.0;
-}
-
 void Net_ReadSpawn()
 {
        zoomin_effect = 1;
@@ -1361,10 +1347,6 @@ float CSQC_Parse_TempEntity()
                        Net_ReadRace();
                        bHandled = true;
                        break;
-               case TE_CSQC_DOM:
-                       Net_ReadDom();
-                       bHandled = true;
-                       break;
                case TE_CSQC_SPAWN:
                        Net_ReadSpawn();
                        bHandled = true;
index c796f4cc751734404b05c01c40846a94dead334e..f02827de1c98ba37b56e2bf50d042e1afd6da68f 100644 (file)
@@ -4732,32 +4732,32 @@ void HUD_Mod_Race(vector pos, vector mySize)
 
 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
 {
-       float dom_pps, dom_pps_ratio;
+       float stat, pps_ratio;
        string pic;
        vector color;
        switch(i)
        {
                case 0:
-                       dom_pps = dom_pps_red;
+                       stat = getstatf(STAT_DOM_PPS_RED);
                        pic = "dom_icon_red";
                        color = '1 0 0';
                        break;
                case 1:
-                       dom_pps = dom_pps_blue;
+                       stat = getstatf(STAT_DOM_PPS_BLUE);
                        pic = "dom_icon_blue";
                        color = '0 0 1';
                        break;
                case 2:
-                       dom_pps = dom_pps_yellow;
+                       stat = getstatf(STAT_DOM_PPS_YELLOW);
                        pic = "dom_icon_yellow";
                        color = '1 1 0';
                        break;
                case 3:
-                       dom_pps = dom_pps_pink;
+                       stat = getstatf(STAT_DOM_PPS_PINK);
                        pic = "dom_icon_pink";
                        color = '1 0 1';
        }
-       dom_pps_ratio = dom_pps / dom_total_pps;
+       pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
 
        if(mySize_x/mySize_y > aspect_ratio)
        {
@@ -4775,18 +4775,18 @@ void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout,
        if (layout) // show text too
        {
                //draw the text
-               color *= 0.5 + dom_pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
+               color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
                if (layout == 2) // average pps
-                       drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(dom_pps, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
                else // percentage of average pps
-                       drawstring_aspect(myPos + eX * mySize_y, strcat( ftos(floor(dom_pps_ratio*100 + 0.5)), "%" ), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(myPos + eX * mySize_y, strcat( ftos(floor(pps_ratio*100 + 0.5)), "%" ), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
        }
 
        //draw the icon
        drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-       if (dom_pps > 0)
+       if (stat > 0)
        {
-               drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - dom_pps_ratio), mySize_y, mySize_y * dom_pps_ratio);
+               drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
                drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                drawresetcliparea();
        }
index 3c502201844586187b33ad98b0b53e34adcba6ee..524f9171d535992dd2e285d790a7f844eecb2ccb 100644 (file)
@@ -64,7 +64,6 @@ const float TE_CSQC_WEAPONCOMPLAIN = 113;
 const float TE_CSQC_CAMPINGRIFLE_SCOPE = 115;
 const float TE_CSQC_NEX_SCOPE = 116;
 const float TE_CSQC_CR_MAXBULLETS = 117;
-const float TE_CSQC_DOM = 119;
 
 const float RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder
 const float RACE_NET_CHECKPOINT_CLEAR = 1;
@@ -352,6 +351,12 @@ const float STAT_PINKALIVE = 103;
 const float STAT_FROZEN = 104;
 const float STAT_REVIVE_PROGRESS = 105;
 
+const float STAT_DOM_TOTAL_PPS = 100;
+const float STAT_DOM_PPS_RED = 101;
+const float STAT_DOM_PPS_BLUE = 102;
+const float STAT_DOM_PPS_PINK = 103;
+const float STAT_DOM_PPS_YELLOW = 104;
+
 //const float STAT_SPIDERBOT_AIM     53 // compressShotOrigin
 //const float STAT_SPIDERBOT_TARGET  54 // compressShotOrigin
 
index e59d453ab3df1e7bbfbd1744360594a571714121..9a7f6f36036ea0cb28bf479f97ab1ce4c204c854 100644 (file)
@@ -1500,7 +1500,7 @@ Called when a client connects to the server
 string ColoredTeamName(float t);
 void DecodeLevelParms (void);
 //void dom_player_join_team(entity pl);
-void send_CSQC_dom_all();
+void set_dom_state(void);
 void ClientConnect (void)
 {
        float t;
@@ -1743,7 +1743,7 @@ void ClientConnect (void)
                send_CSQC_teamnagger();
 
        if (g_domination)
-               send_CSQC_dom_all();
+               set_dom_state();
        send_CSQC_cr_maxbullets(self);
 
        CheatInitClient();
index 74c5edaddb188cbf12a1f63d7980fd4501b16862..0f80cdac0b259aaa47c5a23905d9b16aeff25fc8 100644 (file)
@@ -22,32 +22,30 @@ Note: The only teams who can use dom control points are identified by spawnfunc_
 .float captime;
 
 // pps: points per second
-float dom_total_pps;
-float dom_pps_red;
-float dom_pps_blue;
-float dom_pps_yellow;
-float dom_pps_pink;
-void send_CSQC_dom_state()
+.float dom_total_pps;
+.float dom_pps_red;
+.float dom_pps_blue;
+.float dom_pps_yellow;
+.float dom_pps_pink;
+float total_pps;
+float pps_red;
+float pps_blue;
+float pps_yellow;
+float pps_pink;
+void set_dom_state(void)
 {
-       WriteByte(MSG_ALL, SVC_TEMPENTITY);
-       WriteByte(MSG_ALL, TE_CSQC_DOM);
-       WriteShort(MSG_ALL, dom_pps_red * 100.0);
-       WriteShort(MSG_ALL, dom_pps_blue * 100.0);
-       if (c3 >= 0) WriteShort(MSG_ALL, dom_pps_yellow * 100.0);
-       if (c4 >= 0) WriteShort(MSG_ALL, dom_pps_pink * 100.0);
-}
-//Must be called ONLY when a client connects to send total pps and state
-//If yellow/pink team doesn't exist sends a negative dom_pps_yellow/dom_pps_pink
-//to let know the client to not read these values anymore
-void send_CSQC_dom_all()
-{
-       WriteByte(MSG_ALL, SVC_TEMPENTITY);
-       WriteByte(MSG_ALL, TE_CSQC_DOM);
-       WriteShort(MSG_ALL, dom_total_pps * 100.0);
-       WriteShort(MSG_ALL, dom_pps_red * 100.0);
-       WriteShort(MSG_ALL, dom_pps_blue * 100.0);
-       WriteShort(MSG_ALL, dom_pps_yellow * 100.0);
-       WriteShort(MSG_ALL, dom_pps_pink * 100.0);
+       // BIG ugly hack to make stat sending work
+       self.dom_total_pps = total_pps;
+       self.dom_pps_red = pps_red;
+       self.dom_pps_blue = pps_blue;
+       if(c3 >= 0)
+       {
+               self.dom_pps_yellow = pps_yellow;
+       }
+       if(c4 >= 0)
+       {
+               self.dom_pps_pink = pps_pink;
+       }
 }
 
 void() dom_controlpoint_setup;
@@ -140,47 +138,48 @@ void dompoint_captured ()
        {
                // "fix" pps when slightly under 0 because of approximation errors
                case COLOR_TEAM1:
-                       dom_pps_red -= (points/wait_time);
-                       if (dom_pps_red < 0) dom_pps_red = 0;
+                       pps_red -= (points/wait_time);
+                       if (pps_red < 0) pps_red = 0;
                        break;
                case COLOR_TEAM2:
-                       dom_pps_blue -= (points/wait_time);
-                       if (dom_pps_blue < 0) dom_pps_blue = 0;
+                       pps_blue -= (points/wait_time);
+                       if (pps_blue < 0) pps_blue = 0;
                        break;
                case COLOR_TEAM3:
-                       dom_pps_yellow -= (points/wait_time);
-                       if (dom_pps_yellow < 0) dom_pps_yellow = 0;
+                       pps_yellow -= (points/wait_time);
+                       if (pps_yellow < 0) pps_yellow = 0;
                        break;
                case COLOR_TEAM4:
-                       dom_pps_pink -= (points/wait_time);
-                       if (dom_pps_pink < 0) dom_pps_pink = 0;
+                       pps_pink -= (points/wait_time);
+                       if (pps_pink < 0) pps_pink = 0;
        }
 
        switch(self.goalentity.team)
        {
-               // "fix" pps when slightly over dom_total_pps because of approximation errors
+               // "fix" pps when slightly over total_pps because of approximation errors
                case COLOR_TEAM1:
-                       dom_pps_red += (points/wait_time);
-                       if (dom_pps_red > dom_total_pps) dom_pps_red = dom_total_pps;
+                       pps_red += (points/wait_time);
+                       if (pps_red > total_pps) pps_red = total_pps;
                        WaypointSprite_UpdateSprites(self.sprite, "dom-red", "", "");
                        break;
                case COLOR_TEAM2:
-                       dom_pps_blue += (points/wait_time);
-                       if (dom_pps_blue > dom_total_pps) dom_pps_blue = dom_total_pps;
+                       pps_blue += (points/wait_time);
+                       if (pps_blue > total_pps) pps_blue = total_pps;
                        WaypointSprite_UpdateSprites(self.sprite, "dom-blue", "", "");
                        break;
                case COLOR_TEAM3:
-                       dom_pps_yellow += (points/wait_time);
-                       if (dom_pps_yellow > dom_total_pps) dom_pps_yellow = dom_total_pps;
+                       pps_yellow += (points/wait_time);
+                       if (pps_yellow > total_pps) pps_yellow = total_pps;
                        WaypointSprite_UpdateSprites(self.sprite, "dom-yellow", "", "");
                        break;
                case COLOR_TEAM4:
-                       dom_pps_pink += (points/wait_time);
-                       if (dom_pps_pink > dom_total_pps) dom_pps_pink = dom_total_pps;
+                       pps_pink += (points/wait_time);
+                       if (pps_pink > total_pps) pps_pink = total_pps;
                        WaypointSprite_UpdateSprites(self.sprite, "dom-pink", "", "");
        }
 
-       send_CSQC_dom_state();
+       FOR_EACH_PLAYER(self)
+               set_dom_state();
 
        WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, colormapPaletteColor(self.goalentity.team - 1, 0));
        WaypointSprite_Ping(self.sprite);
@@ -380,7 +379,7 @@ void dom_controlpoint_setup()
        else
                waittime = self.wait;
 
-       dom_total_pps += points/waittime;
+       total_pps += points/waittime;
 
        if(!self.t_width)
                self.t_width = 0.02; // frame animation rate
@@ -704,8 +703,6 @@ void dom_delayedinit()
                        }
                }
        }
-       if (c3 == -1) dom_pps_yellow = -1;
-       if (c4 == -1) dom_pps_pink = -1;
 
        ScoreRules_dom();
 };
@@ -722,5 +719,11 @@ void dom_init()
        precache_model("models/domination/dom_unclaimed.md3");
        precache_sound("domination/claim.wav");
        InitializeEntity(world, dom_delayedinit, INITPRIO_GAMETYPE);
+
+       addstat(STAT_DOM_TOTAL_PPS, AS_FLOAT, dom_total_pps);
+       addstat(STAT_DOM_PPS_RED, AS_FLOAT, dom_pps_red);
+       addstat(STAT_DOM_PPS_BLUE, AS_FLOAT, dom_pps_blue);
+       if(c3 >= 0) addstat(STAT_DOM_PPS_YELLOW, AS_FLOAT, dom_pps_yellow);
+       if(c4 >= 0) addstat(STAT_DOM_PPS_PINK, AS_FLOAT, dom_pps_pink);
 };