From 02ed899a38194405a4eb2dc23914d9da10791a40 Mon Sep 17 00:00:00 2001 From: Penguinum Date: Tue, 19 May 2015 12:14:21 +0300 Subject: [PATCH] Fixed probable division by zero (didn't affect anything in test map, though). --- qcsrc/client/wall.qc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/qcsrc/client/wall.qc b/qcsrc/client/wall.qc index 6fc2e1926..f1b250e32 100644 --- a/qcsrc/client/wall.qc +++ b/qcsrc/client/wall.qc @@ -13,10 +13,23 @@ void Ent_Wall_PreDraw() if(!checkpvs(org, self)) self.alpha = 0; else if(self.fade_start) { - vector player_dist = org - self.origin - 0.5 * (self.mins + self.maxs); - self.alpha = (self.alpha_min + self.alpha_max * bound(0, - (self.fade_end - vlen(player_dist)) + float player_dist = vlen(org - self.origin - 0.5 * (self.mins + self.maxs)); + if (self.fade_end == self.fade_start) + { + if (player_dist >= self.fade_start) { + self.alpha = 0; + } + else + { + self.alpha = 1; + } + } + else + { + self.alpha = (self.alpha_min + self.alpha_max * bound(0, + (self.fade_end - player_dist) / (self.fade_end - self.fade_start), 1)) / 100.0; + } } else { -- 2.39.2