From a456d5a4e2122f73d3fded8cd6855ac82c4c637a Mon Sep 17 00:00:00 2001 From: Mario <mario.mario@y7mail.com> Date: Fri, 10 Jan 2025 01:26:58 +0000 Subject: [PATCH] Add a workaround for projectile fade rates in the event of ticrate being 0 --- qcsrc/client/weapons/projectile.qc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/qcsrc/client/weapons/projectile.qc b/qcsrc/client/weapons/projectile.qc index a10b09df9e..cf2e86e646 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 { -- 2.39.5