From 507dc10e4f4a11d26300a497950e48a3d9f2fa9e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 11 Dec 2021 09:56:28 +0100 Subject: [PATCH] - Duke/RR: Fixed sprite validation checks in animatesprites. --- source/games/duke/src/animatesprites_d.cpp | 4 +++- source/games/duke/src/animatesprites_r.cpp | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index f8bd53533..4033bc1cb 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -557,8 +557,10 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int t->picnum += k + ScriptCode[t4] + l * t3; if (l > 0) - while (!tileGetTexture(t->picnum)->isValid() && t->picnum > 0) + { + while (t->picnum >= 0 && t->picnum < MAXTILES && !tileGetTexture(t->picnum)->isValid()) t->picnum -= l; //Hack, for actors + } if (h->dispicnum >= 0) h->dispicnum = t->picnum; diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index 6f2753174..a94fa9f32 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -703,8 +703,11 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int t->picnum += k + ScriptCode[t4] + l * t3; if (l > 0) - while (t->picnum >= 0 && t->picnum < MAXTILES && !tileGetTexture(t->picnum)->isValid() && t->picnum > 0) + { + while (t->picnum >= 0 && t->picnum < MAXTILES && !tileGetTexture(t->picnum)->isValid()) t->picnum -= l; //Hack, for actors + } + if (t->picnum < 0 || t->picnum >= MAXTILES) { t->picnum = 0;