From 5aa4243327afb65b5ea11d3e199fbc3250125d63 Mon Sep 17 00:00:00 2001 From: Mitch Richters Date: Tue, 7 Dec 2021 22:55:08 +1100 Subject: [PATCH] - Duke: Test tsprite's sector in `animatesprites_d()` following crash while noclipping in Duke WT's E5L1. Apply same fix to `animatesprites_r()` as well. --- source/games/duke/src/animatesprites_d.cpp | 10 ++-------- source/games/duke/src/animatesprites_r.cpp | 15 ++------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index 8e0cb39c65f..f8bd535336d 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -134,14 +134,8 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int continue; } - if (t->sector()->ceilingstat & 1) - l = t->sector()->ceilingshade; - else - l = t->sector()->floorshade; - - if (l < -127) l = -127; - if (l > 128) l = 127; - t->shade = l; + if (t->insector()) + t->shade = clamp(t->sector()->ceilingstat & 1 ? t->sector()->ceilingshade : t->sector()->floorshade, -127, 127); } diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index 3ff153e8664..6f2753174f0 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -119,19 +119,8 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int } } - if (t->sector()->ceilingstat & 1) - { - if (badguy(s)) - l = s->shade; - else - l = s->shade; - } - else - l = t->sector()->floorshade; - - if (l < -127) l = -127; - if (l > 128) l = 127; - t->shade = l; + if (t->insector()) + t->shade = clamp(t->sector()->ceilingstat & 1 ? s->shade : t->sector()->floorshade, -127, 127); }