diff --git a/src/lua_maplib.c b/src/lua_maplib.c index c946b10ce220fd28e2415d46f68233fad4bc7f0b..2740c957f4f89e4c9616f32ee3dc8ca437895033 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -2695,7 +2695,7 @@ static int slope_set(lua_State *L) if (zangle == ANGLE_90 || zangle == ANGLE_270) return luaL_error(L, "invalid zangle for slope!"); slope->zangle = zangle; - slope->zdelta = -FINETANGENT(((slope->zangle+ANGLE_90)>>ANGLETOFINESHIFT) & 4095); + slope->zdelta = -FINETANGENT(((slope->zangle+ANGLE_90)>>ANGLETOFINESHIFT) & TANMASK); slope->dzdelta = FixedToDouble(slope->zdelta); P_CalculateSlopeNormal(slope); break; diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index 1bc6019dee9a507ebc6350a541807e75e53726d7..4dcee68c83997a5231739af2dad481f3add88110 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -83,8 +83,8 @@ static int lib_finecosine(lua_State *L) static int lib_finetangent(lua_State *L) { // HACK: add ANGLE_90 to make tan() in Lua start at 0 like it should - // use & 4095 instead of & FINEMASK (8191), so it doesn't go out of the array's bounds - lua_pushfixed(L, FINETANGENT(((luaL_checkangle(L, 1)+ANGLE_90)>>ANGLETOFINESHIFT) & 4095)); + // use & TANMASK (4095) instead of & FINEMASK (8191), so it doesn't go out of the array's bounds + lua_pushfixed(L, FINETANGENT(((luaL_checkangle(L, 1)+ANGLE_90)>>ANGLETOFINESHIFT) & TANMASK)); return 1; } diff --git a/src/r_segs.c b/src/r_segs.c index 510744ebce3853e36a09d8bc247c73e721329d97..bee349492e5b827f06820301e90cf5c6c3149585 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1463,7 +1463,7 @@ static void R_RenderSegLoop (void) //SoM: Calculate offsets for Thick fake floors. // calculate texture offset angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT; - textureoffset = rw_offset - FixedMul(FINETANGENT(angle), rw_distance); + textureoffset = rw_offset - FixedMul(FINETANGENT(angle & TANMASK), rw_distance); texturecolumn = FixedDiv(textureoffset, rw_invmidtexturescalex); // texturecolumn and lighting are independent of wall tiers diff --git a/src/tables.h b/src/tables.h index 3c0dd2a81ff97a6ccc382716bf136a897b1c4e75..43817e25d3ed6ab78e695e8c8512fb6cb1ea61d7 100644 --- a/src/tables.h +++ b/src/tables.h @@ -22,6 +22,7 @@ #define FINEANGLES 8192 #define FINEMASK (FINEANGLES - 1) +#define TANMASK 4095 #define ANGLETOFINESHIFT 19 // 0x100000000 to 0x2000 #define FINEANGLE_C(x) ((FixedAngle((x)*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK) // ((x*(ANGLE_45/45))>>ANGLETOFINESHIFT) & FINEMASK