From 3ca41992dd7d784887cb2b8409a6657dd8d265f8 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 9 Dec 2011 19:11:47 +0000 Subject: [PATCH] Fix sintable[] access with out-of-bounds values in core engine functions (getzrange, hitscan, clipmove, drawmapview). They're reproducible with DNE1.3D; Since these angle values most likely come from CON code, my suggestion would be to bit-and all values representing angles with 2047 when setting the from CON, but I'd have to think about potential side-effects of doing this. git-svn-id: https://svn.eduke32.com/eduke32@2170 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/engine.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 05036963b..cf0064e21 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -8690,7 +8690,7 @@ void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang) if ((spr->cstat&4) > 0) xoff = -xoff; if ((spr->cstat&8) > 0) yoff = -yoff; - k = spr->ang; + k = spr->ang&2047; // FIXME ? See DNE_BUG_HERE cosang = sintable[(k+512)&2047]; sinang = sintable[k]; xspan = tilesizx[tilenum]; xrepeat = spr->xrepeat; yspan = tilesizy[tilenum]; yrepeat = spr->yrepeat; @@ -11230,7 +11230,7 @@ restart_grand: if ((cstat&4) > 0) xoff = -xoff; if ((cstat&8) > 0) yoff = -yoff; - ang = spr->ang; + ang = spr->ang&2047; // FIXME ? See DNE_BUG_HERE cosang = sintable[(ang+512)&2047]; sinang = sintable[ang]; xspan = tilesizx[tilenum]; xrepeat = spr->xrepeat; yspan = tilesizy[tilenum]; yrepeat = spr->yrepeat; @@ -12042,7 +12042,7 @@ int32_t clipmove(vec3_t *pos, int16_t *sectnum, if ((cstat&4) > 0) xoff = -xoff; if ((cstat&8) > 0) yoff = -yoff; - k = spr->ang; + k = spr->ang&2047; // FIXME ? See DNE_BUG_HERE cosang = sintable[(k+512)&2047]; sinang = sintable[k]; xspan = tilesizx[tilenum]; xrepeat = spr->xrepeat; yspan = tilesizy[tilenum]; yrepeat = spr->yrepeat; @@ -12844,7 +12844,10 @@ restart_grand: if ((cstat&4) > 0) xoff = -xoff; if ((cstat&8) > 0) yoff = -yoff; - ang = spr->ang; + // &2047: FIXME ? DNE_BUG_HERE + // DNE 1.3D lights camera action (1st level), spr->ang==2306 + ang = spr->ang&2047; + cosang = sintable[(ang+512)&2047]; sinang = sintable[ang]; xspan = tilesizx[tilenum]; xrepeat = spr->xrepeat; yspan = tilesizy[tilenum]; yrepeat = spr->yrepeat;