diff --git a/polymer/eduke32/source/lunatic/bcheck.lua b/polymer/eduke32/source/lunatic/bcheck.lua index 0b33726a7..f41ab5a92 100644 --- a/polymer/eduke32/source/lunatic/bcheck.lua +++ b/polymer/eduke32/source/lunatic/bcheck.lua @@ -4,8 +4,6 @@ local ffiC = require("ffi").C local type = type local error = error -local con_lang = require("con_lang") - local bcheck = {} --== ENGINE ==-- @@ -38,7 +36,27 @@ function bcheck.tile_idx(tilenum) end +--== HELPERS ==-- + +function bcheck.number(val, errlev) + if (type(val)~="number" or val~=val) then + error("invalid argument: must be a non-NaN number", errlev or 3) + end +end + +function bcheck.type(val, typestr, errlev) + if (type(val)~=typestr) then + error("invalid argument: must be a "..typestr, errlev or 3) + end +end + + --== GAME ==-- +if (ffiC.LUNATIC_CLIENT == ffiC.LUNATIC_CLIENT_MAPSTER32) then + return bcheck +end + +local con_lang = require("con_lang") function bcheck.player_idx(snum) if (not (snum >= 0 and snum < ffiC.playerswhenstarted)) then @@ -99,16 +117,4 @@ function bcheck.top_level(funcname) end end -function bcheck.number(val, errlev) - if (type(val)~="number" or val~=val) then - error("invalid argument: must be a non-NaN number", errlev or 3) - end -end - -function bcheck.type(val, typestr, errlev) - if (type(val)~=typestr) then - error("invalid argument: must be a "..typestr, errlev or 3) - end -end - return bcheck diff --git a/polymer/eduke32/source/lunatic/defs_common.lua b/polymer/eduke32/source/lunatic/defs_common.lua index 58f56f3e9..178dd4b5f 100644 --- a/polymer/eduke32/source/lunatic/defs_common.lua +++ b/polymer/eduke32/source/lunatic/defs_common.lua @@ -290,13 +290,8 @@ ffi.typeof(maybe_strip_const(SPRITE_STRUCT))) if (not _LUNATIC_AUX) then -- Define the "palette_t" type, which for us has .{r,g,b} fields and a -- bound-checking array of length 3 overlaid. - local rgbarray_t = require("bcarray").new("uint8_t", 3, "RGB array", "palette_t", - { "r", "g", "b", "f" }) - ffi.cdef("typedef union { \ - struct { uint8_t r, g, b, f; }; \ - $ col; \ - } palette_t", rgbarray_t) - + require("bcarray").new("uint8_t", 3, "RGB array", "palette_t", + { "r", "g", "b", "f" }) assert(ffi.alignof("palette_t")==1) end