]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Check for spectatee_status changes only when it's updated; also write a check properl...
authorterencehill <piuntn@gmail.com>
Sun, 24 Apr 2011 23:13:35 +0000 (01:13 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 25 Apr 2011 09:58:19 +0000 (11:58 +0200)
qcsrc/client/Defs.qc
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/hud.qc

index afdd9f31f683a2ddc6cd4e6a64fcc001e04b24dd..b3b0569489d992798c0ea9355f3a7a5296730968 100644 (file)
@@ -221,7 +221,6 @@ float nb_pb_period;
 
 // Spectating
 float spectatee_status;
-float prev_spectatee_status;
 
 // short mapname
 string shortmapname;
index e9a4c4017b08496351cbba8a44c263b42c80f0cd..84fe1ff393bdf18538bf7d121f722f0e16eec9d0 100644 (file)
@@ -835,6 +835,23 @@ void Ent_ClientData()
                race_laptime = 0;
                race_checkpointtime = 0;
        }
+       if (autocvar_hud_panel_healtharmor_progressbar_gfx)
+       {
+               if ( (spectatee_status == -1 && newspectatee_status > 0) //before observing, now spectating
+                 || (spectatee_status > 0 && newspectatee_status > 0 && spectatee_status != newspectatee_status) //changed spectated player
+               )
+               {
+                       //no effect
+                       saved_health = 0;
+                       saved_armor = 0;
+                       health_time = 0;
+                       armor_time = 0;
+               }
+               else if(spectatee_status && !newspectatee_status) //before observing/spectating, now playing
+               {
+                       health_time = -1;
+               }
+       }
        spectatee_status = newspectatee_status;
 }
 
index 10f60613edea9bef1fcf58a71bf99200720b4acd..7ae320b89bccdcead7dc5c54aae76328d1526efb 100644 (file)
@@ -1253,8 +1253,6 @@ void CSQC_UpdateView(float w, float h)
                cvar_set("vid_conheight", h0);
        }
 
-       prev_spectatee_status = spectatee_status;
-
        if(autocvar__hud_configure)
                HUD_Panel_Mouse();
 
index 7203c87ec09c8b59eca148ff8286ccef8bc84c3c..05b268d63a109655797fe8d4426740c187baa7d3 100644 (file)
@@ -1330,31 +1330,18 @@ void HUD_HealthArmor(void)
                        health_time = -1;
                        return;
                }
-               if (autocvar_hud_panel_healtharmor_progressbar_gfx)
-               {
-                       if ( (prev_spectatee_status == -1 && spectatee_status > 0) //before observing, now spectating
-                         || (prev_spectatee_status > 0 && spectatee_status > 0 && prev_spectatee_status != spectatee_status) //changed spectated player
-                       )
-                       {
-                               //no effect
-                               saved_health = 0;
-                               saved_armor = 0;
-                               health_time = 0;
-                               armor_time = 0;
-                       }
-                       else if(prev_spectatee_status == -1 || (prev_spectatee_status > 0 && !spectatee_status)) //before spectating/observing, now playing
-                               health_time = -1;
 
-                       if (health_time == -1)
-                       {
-                               //start the load effect
-                               saved_health = -2;
-                               saved_armor = -2;
-                               health_time = time;
-                               armor_time = time;
-                               prev_health = 0;
-                               prev_armor = 0;
-                       }
+               // code to check for spectatee_status changes is in Ent_ClientData()
+
+               if (health_time == -1)
+               {
+                       //start the load effect
+                       saved_health = -2;
+                       saved_armor = -2;
+                       health_time = time;
+                       armor_time = time;
+                       prev_health = 0;
+                       prev_armor = 0;
                }
                armor = getstati(STAT_ARMOR);
                fuel = getstati(STAT_FUEL);