Revert "Abyss crash prevention code", but make the overflow explicit.

git-svn-id: https://svn.eduke32.com/eduke32@3028 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-09-26 22:53:53 +00:00
parent aba1ce9e7f
commit 5957e0f143

View file

@ -11667,10 +11667,14 @@ restart_grand:
if ((cstat&64) != 0) if ((cstat&64) != 0)
if ((sv->z > intz) == ((cstat&8)==0)) continue; if ((sv->z > intz) == ((cstat&8)==0)) continue;
#if 0 // Abyss crash prevention code ((intz-sv->z)*zx overflowing a 8-bit word) #if 1
zz=(int32_t)((intz-sv->z)*vx); // Abyss crash prevention code ((intz-sv->z)*zx overflowing a 8-bit word)
// PK: the reason for the crash is not the overflowing (even if it IS a problem;
// signed overflow is undefined behavior in C), but rather the idiv trap when
// the resulting quotient doesn't fit into a *signed* 32-bit integer.
zz = (uint32_t)(intz-sv->z) * vx;
intx = sv->x+scale(zz,1,vz); intx = sv->x+scale(zz,1,vz);
zz=(int32_t)((intz-sv->z)*vy); zz = (uint32_t)(intz-sv->z) * vy;
inty = sv->y+scale(zz,1,vz); inty = sv->y+scale(zz,1,vz);
#else #else
intx = sv->x+scale(intz-sv->z,vx,vz); intx = sv->x+scale(intz-sv->z,vx,vz);