From: Mario Date: Fri, 10 Jan 2025 01:26:58 +0000 (+0000) Subject: Add a workaround for projectile fade rates in the event of ticrate being 0 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a456d5a4e2122f73d3fded8cd6855ac82c4c637a;p=xonotic%2Fxonotic-data.pk3dir.git Add a workaround for projectile fade rates in the event of ticrate being 0 --- diff --git a/qcsrc/client/weapons/projectile.qc b/qcsrc/client/weapons/projectile.qc index a10b09df9..cf2e86e64 100644 --- a/qcsrc/client/weapons/projectile.qc +++ b/qcsrc/client/weapons/projectile.qc @@ -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 {