From 5e50a51386d85dcd6df3e84525c6db57d140660e Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Fri, 6 May 2016 17:48:28 -0500 Subject: [PATCH 1/2] [2.1.15] Restore backwards compatibility for tan() DO NOT MERGE THIS INTO THE INTERNAL REPO. This is a temporary 2.1.15 only fix. This commit allows an optional boolean for tan(), which when true will automatically shift angles by ANGLE_90. --- src/lua_mathlib.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index d78cb23a4..8ae432fc5 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -81,9 +81,15 @@ 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)); + // 2.1.15 ONLY HACK: optional boolean argument, only add ANGLE_90 if true + boolean newtan = lua_optboolean(L, 2); + + if (newtan) + // 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)); + else + lua_pushfixed(L, FINETANGENT((luaL_checkangle(L, 1)>>ANGLETOFINESHIFT) & 4095)); return 1; } From d253571b38abfc34f695701f1ba5b16aae932303 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 6 May 2016 23:26:33 -0400 Subject: [PATCH 2/2] Revert "[2.1.15] Restore backwards compatibility for tan()" This reverts commit 5e50a51386d85dcd6df3e84525c6db57d140660e. --- src/lua_mathlib.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index 8ae432fc5..d78cb23a4 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -81,15 +81,9 @@ static int lib_finecosine(lua_State *L) static int lib_finetangent(lua_State *L) { - // 2.1.15 ONLY HACK: optional boolean argument, only add ANGLE_90 if true - boolean newtan = lua_optboolean(L, 2); - - if (newtan) - // 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)); - else - lua_pushfixed(L, FINETANGENT((luaL_checkangle(L, 1)>>ANGLETOFINESHIFT) & 4095)); + // 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)); return 1; }