Skip to content

Lua changes

Yukita Mayako requested to merge lua-32bit-changes into next

This branch makes the following changes to Lua:

  • ALL7EMERALDS has been changed to the Boolean type (returns false or true instead of 0 or 1, as it is intended to!)
  • EvalMath has been removed (use _G[] to convert strings to their proper enumerated value and do the math yourself)
  • lua_Number has been changed from ptrdiff_t to an explicit INT32
  • angle_t now goes through a bit shift conversion when passed to Lua or retrieved, making angles in Lua no longer wrap around to the negative values and instead range from 0 to FRACUNIT.
  • Adds sidedef texture (by number) and offset manipulation to Lua.
  • Fixes a potential tmthing sanity check crash when manipulating sector heights outside of P_MapStart and P_MapEnd
  • Completely rewrote lua_hooklib.c to marginalize its use of the Lua stack.

Most of these changes are made in their own independent commits and can be cherry-picked as needed.

Changing Lua's use of angle_t in this manner is consistent with how ZDoom's ACS handles the same problem, and enables modders access to just using FixedDiv/FixedMul functions on FRACUNIT to come up with their own intermediate angles.

To facilitate this, all cases where Lua passes a number from C or retrieves a number to C where that number is expected to be a fixed_t or an angle_t have been given their own unique macro defines, namely luaL_checkfixed, luaL_checkangle, lua_pushfixed, and lua_pushangle. This keeps the code clean of bit-shifting conversions when moving angle_t between Lua and C, and allows future revisions to potentially add similar special handling for fixed_t values (although right now fixed_t == INT32 so it is a nonissue)

Edited by Monster Iestyn

Merge request reports

Loading