Skip to content
Snippets Groups Projects
Commit fdc2c3ad authored by Monster Iestyn's avatar Monster Iestyn
Browse files

Fix up lib_finetangent so tan() returns values starting from "0" in Lua...

Fix up lib_finetangent so tan() returns values starting from "0" in Lua (finetangent itself hasn't been touched)

Also fixed how the function went out of the array's bounds for ANGLE_180 and above (or negative angles)
parent d4976d67
Branches
Tags
No related merge requests found
...@@ -77,7 +77,9 @@ static int lib_finecosine(lua_State *L) ...@@ -77,7 +77,9 @@ static int lib_finecosine(lua_State *L)
static int lib_finetangent(lua_State *L) static int lib_finetangent(lua_State *L)
{ {
lua_pushfixed(L, FINETANGENT((luaL_checkangle(L, 1)>>ANGLETOFINESHIFT) & FINEMASK)); // 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; return 1;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment