fixed negative time delta problem with sbar item flashing
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 21 Jan 2007 11:52:29 +0000 (11:52 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 21 Jan 2007 11:52:29 +0000 (11:52 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6712 d7cf8633-e32d-0410-b094-e92efae38249

sbar.c

diff --git a/sbar.c b/sbar.c
index 6bed527..88a6ba9 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -710,7 +710,7 @@ void Sbar_DrawInventory (void)
                if (cl.stats[STAT_ITEMS] & (IT_SHOTGUN<<i) )
                {
                        time = cl.item_gettime[i];
-                       flashon = (int)((cl.time - time)*10);
+                       flashon = (int)(max(0, cl.time - time)*10);
                        if (flashon >= 10)
                        {
                                if ( cl.stats[STAT_ACTIVEWEAPON] == (IT_SHOTGUN<<i)  )
@@ -734,7 +734,7 @@ void Sbar_DrawInventory (void)
                {
                        if (cl.stats[STAT_ITEMS] & (1<<hipweapons[i]) )
                        {
-                               time = cl.item_gettime[hipweapons[i]];
+                               time = max(0, cl.item_gettime[hipweapons[i]]);
                                flashon = (int)((cl.time - time)*10);
                                if (flashon >= 10)
                                {
@@ -1122,7 +1122,7 @@ void Sbar_Draw (void)
                                int redflag, blueflag;
 
                                // we have a max time 2s (min time = 0)
-                               if ((time = cl.time - cl.weapontime) < 2)
+                               if ((time = max(0, cl.time - cl.weapontime)) < 2)
                                {
                                        fade = (1.0 - 0.5 * time);
                                        fade *= fade;