]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a workaround for projectile fade rates in the event of ticrate being 0
authorMario <mario.mario@y7mail.com>
Fri, 10 Jan 2025 01:26:58 +0000 (01:26 +0000)
committerterencehill <piuntn@gmail.com>
Fri, 10 Jan 2025 01:26:58 +0000 (01:26 +0000)
qcsrc/client/weapons/projectile.qc

index a10b09df9efcf428e109b8cb9afb4ffa8f7b2cc8..cf2e86e64671728186e77d1ac21740d0c2e60ef2 100644 (file)
@@ -145,6 +145,7 @@ void Projectile_Draw(entity this)
                }
        }
 
+       // negation used to ensure a zero fade_(time/rate) does not affect opacity
        a = 1 - (time - this.fade_time) * this.fade_rate;
        this.alpha = bound(0, this.alphamod * a, 1);
        if (this.alpha <= 0)
@@ -275,8 +276,21 @@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew)
 
                if (f & 0x20)
                {
-                       this.fade_time = time + ReadByte() * ticrate;
-                       this.fade_rate = 1 / (ReadByte() * ticrate);
+                       float fadetime = ReadByte();
+                       float faderate = ReadByte();
+
+                       // workaround for division by 0
+                       // TODO: apply fade settings WITHOUT ticrate here and multiply during use cases
+                       if(ticrate <= 0)
+                       {
+                               this.fade_time = 0;
+                               this.fade_rate = 0;
+                       }
+                       else
+                       {
+                               this.fade_time = time + fadetime * ticrate;
+                               this.fade_rate = 1 / (faderate * ticrate);
+                       }
                }
                else
                {