mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Lunatic: replace 'idx >= BOUND+0ULL' idiom with 'not (idx >= 0 and idx < BOUND)'
git-svn-id: https://svn.eduke32.com/eduke32@3964 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
4872adb3c8
commit
3835019c70
9 changed files with 41 additions and 40 deletions
|
@ -60,7 +60,7 @@ function new(basetype, numelts, showname, typename, rng, mtadd)
|
||||||
|
|
||||||
local mt = {
|
local mt = {
|
||||||
__index = function(ar, idx)
|
__index = function(ar, idx)
|
||||||
if (idx >= numelts+0ULL) then
|
if (not (idx >= 0 and idx < numelts)) then
|
||||||
error("out-of-bounds "..showname.." read access", 2)
|
error("out-of-bounds "..showname.." read access", 2)
|
||||||
end
|
end
|
||||||
return ffi.cast(eltptr_t, ar)[idx]
|
return ffi.cast(eltptr_t, ar)[idx]
|
||||||
|
@ -69,7 +69,7 @@ function new(basetype, numelts, showname, typename, rng, mtadd)
|
||||||
-- NOTE: this function will be dead code if the prefixed __newindex
|
-- NOTE: this function will be dead code if the prefixed __newindex
|
||||||
-- errors out unconditionally or the bcarray is declared 'const'.
|
-- errors out unconditionally or the bcarray is declared 'const'.
|
||||||
__newindex = function(ar, idx, val)
|
__newindex = function(ar, idx, val)
|
||||||
if (idx >= numelts+0ULL) then
|
if (not (idx >= 0 and idx < numelts)) then
|
||||||
error("out-of-bounds "..showname.." write access", 2)
|
error("out-of-bounds "..showname.." write access", 2)
|
||||||
end
|
end
|
||||||
ffi.cast(eltptr_t, ar)[idx] = val
|
ffi.cast(eltptr_t, ar)[idx] = val
|
||||||
|
|
|
@ -11,13 +11,13 @@ local bcheck = {}
|
||||||
--== ENGINE ==--
|
--== ENGINE ==--
|
||||||
|
|
||||||
function bcheck.sector_idx(sectnum)
|
function bcheck.sector_idx(sectnum)
|
||||||
if (sectnum >= ffiC.numsectors+0ULL) then
|
if (not (sectnum >= 0 and sectnum < ffiC.numsectors)) then
|
||||||
error("invalid sector number "..sectnum, 3)
|
error("invalid sector number "..sectnum, 3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function bcheck.wall_idx(wallnum)
|
function bcheck.wall_idx(wallnum)
|
||||||
if (wallnum >= ffiC.numwalls+0ULL) then
|
if (not (wallnum >= 0 and wallnum < ffiC.numwalls)) then
|
||||||
error("invalid wall number "..wallnum, 3)
|
error("invalid wall number "..wallnum, 3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -25,13 +25,14 @@ end
|
||||||
-- TODO: Provide another function that also checks whether the sprite exists in
|
-- TODO: Provide another function that also checks whether the sprite exists in
|
||||||
-- the game world (statnum != MAXSTATUS).
|
-- the game world (statnum != MAXSTATUS).
|
||||||
function bcheck.sprite_idx(spritenum)
|
function bcheck.sprite_idx(spritenum)
|
||||||
if (spritenum >= ffiC.MAXSPRITES+0ULL) then
|
-- if (not (spritenum >= 0 and spritenum < ffiC.MAXSPRITES)) then
|
||||||
|
if (not (spritenum >= 0 and spritenum < ffiC.MAXSPRITES)) then
|
||||||
error("invalid sprite number "..spritenum, 3)
|
error("invalid sprite number "..spritenum, 3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function bcheck.tile_idx(tilenum)
|
function bcheck.tile_idx(tilenum)
|
||||||
if (tilenum >= ffiC.MAXTILES+0ULL) then
|
if (not (tilenum >= 0 and tilenum < ffiC.MAXTILES)) then
|
||||||
error("invalid tile number "..tilenum, 3)
|
error("invalid tile number "..tilenum, 3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -40,43 +41,43 @@ end
|
||||||
--== GAME ==--
|
--== GAME ==--
|
||||||
|
|
||||||
function bcheck.player_idx(snum)
|
function bcheck.player_idx(snum)
|
||||||
if (snum >= ffiC.playerswhenstarted+0ULL) then
|
if (not (snum >= 0 and snum < ffiC.playerswhenstarted)) then
|
||||||
error("invalid player number "..snum, 3)
|
error("invalid player number "..snum, 3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function bcheck.sound_idx(sndidx)
|
function bcheck.sound_idx(sndidx)
|
||||||
if (sndidx >= con_lang.MAXSOUNDS+0ULL) then
|
if (not (sndidx >= 0 and sndidx < con_lang.MAXSOUNDS)) then
|
||||||
error("invalid sound number "..sndidx, 3)
|
error("invalid sound number "..sndidx, 3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function bcheck.weapon_idx(weap)
|
function bcheck.weapon_idx(weap)
|
||||||
if (weap >= ffiC.MAX_WEAPONS+0ULL) then
|
if (not (weap >= 0 and weap < ffiC.MAX_WEAPONS)) then
|
||||||
error("Invalid weapon ID "..weap, 3)
|
error("Invalid weapon ID "..weap, 3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function bcheck.inventory_idx(inv)
|
function bcheck.inventory_idx(inv)
|
||||||
if (inv >= ffiC.GET_MAX+0ULL) then
|
if (not (inv >= 0 and inv < ffiC.GET_MAX)) then
|
||||||
error("Invalid inventory ID "..inv, 3)
|
error("Invalid inventory ID "..inv, 3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function bcheck.volume_idx(volume)
|
function bcheck.volume_idx(volume)
|
||||||
if (volume >= con_lang.MAXVOLUMES+0ULL) then
|
if (not (volume >= 0 and volume < con_lang.MAXVOLUMES)) then
|
||||||
error("invalid volume number "..volume, 3)
|
error("invalid volume number "..volume, 3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function bcheck.level_idx(level)
|
function bcheck.level_idx(level)
|
||||||
if (level >= con_lang.MAXLEVELS+0ULL) then
|
if (not (level >= 0 and level < con_lang.MAXLEVELS)) then
|
||||||
error("invalid level number "..level, 3)
|
error("invalid level number "..level, 3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function bcheck.quote_idx(qnum, onlyidx)
|
function bcheck.quote_idx(qnum, onlyidx)
|
||||||
if (qnum >= con_lang.MAXQUOTES+0ULL) then
|
if (not (qnum >= 0 and qnum < con_lang.MAXQUOTES)) then
|
||||||
error("invalid quote number "..qnum, 3)
|
error("invalid quote number "..qnum, 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -268,7 +268,7 @@ function insertsprite(tab_or_tilenum, ...)
|
||||||
check_sector_idx(sectnum)
|
check_sector_idx(sectnum)
|
||||||
check_allnumbers(shade, xrepeat, yrepeat, ang, xvel, zvel, owner)
|
check_allnumbers(shade, xrepeat, yrepeat, ang, xvel, zvel, owner)
|
||||||
|
|
||||||
if (statnum >= ffiC.MAXSTATUS+0ULL) then
|
if (not (statnum >= 0 and statnum < ffiC.MAXSTATUS)) then
|
||||||
error("invalid 'statnum' argument to insertsprite: must be a status number [0 .. MAXSTATUS-1]", 2)
|
error("invalid 'statnum' argument to insertsprite: must be a status number [0 .. MAXSTATUS-1]", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -771,11 +771,11 @@ end
|
||||||
function _getkeyname(qdst, gfuncnum, which)
|
function _getkeyname(qdst, gfuncnum, which)
|
||||||
local cstr_dst = bcheck.quote_idx(qdst)
|
local cstr_dst = bcheck.quote_idx(qdst)
|
||||||
|
|
||||||
if (gfuncnum >= ffiC.NUMGAMEFUNCTIONS+0ULL) then
|
if (not (gfuncnum >= 0 and gfuncnum < ffiC.NUMGAMEFUNCTIONS)) then
|
||||||
error("invalid game function number "..gfuncnum, 2)
|
error("invalid game function number "..gfuncnum, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (which >= 3+0ULL) then
|
if (not (which >= 0 and which < 3)) then
|
||||||
error("third argument to getkeyname must be 0, 1 or 2", 2)
|
error("third argument to getkeyname must be 0, 1 or 2", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -830,7 +830,7 @@ function _qgetsysstr(qdst, what, pli)
|
||||||
ffi.copy(dst, "multiplayer not yet implemented") -- TODO_MP
|
ffi.copy(dst, "multiplayer not yet implemented") -- TODO_MP
|
||||||
elseif (what == ffiC.STR_VOLUMENAME) then
|
elseif (what == ffiC.STR_VOLUMENAME) then
|
||||||
local vol = ffiC.ud.volume_number
|
local vol = ffiC.ud.volume_number
|
||||||
assert(vol+0ULL < con_lang.MAXVOLUMES)
|
assert(not (vol >= con_lang.MAXVOLUMES+0ULL))
|
||||||
ffi.copy(dst, ffiC.EpisodeNames[vol], ffi.sizeof(ffiC.EpisodeNames[0]))
|
ffi.copy(dst, ffiC.EpisodeNames[vol], ffi.sizeof(ffiC.EpisodeNames[0]))
|
||||||
else
|
else
|
||||||
error("unknown system string ID "..what, 2)
|
error("unknown system string ID "..what, 2)
|
||||||
|
@ -870,7 +870,7 @@ end
|
||||||
|
|
||||||
function _digitalnumber(tilenum, x, y, num, shade, pal,
|
function _digitalnumber(tilenum, x, y, num, shade, pal,
|
||||||
orientation, cx1, cy1, cx2, cy2, zoom)
|
orientation, cx1, cy1, cx2, cy2, zoom)
|
||||||
if (tilenum >= ffiC.MAXTILES-9+0ULL) then
|
if (not (tilenum >= 0 and tilenum >= ffiC.MAXTILES-9)) then
|
||||||
error("invalid base tile number "..tilenum, 2)
|
error("invalid base tile number "..tilenum, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -879,7 +879,7 @@ function _digitalnumber(tilenum, x, y, num, shade, pal,
|
||||||
end
|
end
|
||||||
|
|
||||||
local function text_check_common(tilenum, orientation)
|
local function text_check_common(tilenum, orientation)
|
||||||
if (tilenum >= ffiC.MAXTILES-255+0ULL) then
|
if (not (tilenum >= 0 and tilenum < ffiC.MAXTILES-255)) then
|
||||||
error("invalid base tile number "..tilenum, 3)
|
error("invalid base tile number "..tilenum, 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1992,7 +1992,7 @@ local function check_gamearray_idx(gar, idx, addstr)
|
||||||
-- system gamearray: currently, only g_tile.sizx/sizy.
|
-- system gamearray: currently, only g_tile.sizx/sizy.
|
||||||
local size = rawget(gar, '_size') or ffiC.MAXTILES
|
local size = rawget(gar, '_size') or ffiC.MAXTILES
|
||||||
|
|
||||||
if (idx >= size+0ULL) then
|
if (not (idx >= 0 and idx < size)) then
|
||||||
addstr = addstr or ""
|
addstr = addstr or ""
|
||||||
error("invalid "..addstr.."array index "..idx, 3)
|
error("invalid "..addstr.."array index "..idx, 3)
|
||||||
end
|
end
|
||||||
|
|
|
@ -983,7 +983,7 @@ local literal_mov = { [0]=con_move_ct(0), [1]=con_move_ct(1) }
|
||||||
|
|
||||||
local function get_actor_idx(a)
|
local function get_actor_idx(a)
|
||||||
local i = ffi.cast(actor_ptr_ct, a)-ffi.cast(actor_ptr_ct, ffiC.actor)
|
local i = ffi.cast(actor_ptr_ct, a)-ffi.cast(actor_ptr_ct, ffiC.actor)
|
||||||
assert(not (i >= ffiC.MAXSPRITES+0ULL))
|
-- assert(not (i >= ffiC.MAXSPRITES+0ULL))
|
||||||
return i
|
return i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1117,14 +1117,14 @@ local actor_mt = {
|
||||||
|
|
||||||
-- Getters/setters.
|
-- Getters/setters.
|
||||||
_get_t_data = function(a, idx)
|
_get_t_data = function(a, idx)
|
||||||
if (idx >= 10ULL) then
|
if (not (idx >= 0 and idx < 10)) then
|
||||||
error("invalid t_data index "..idx, 2)
|
error("invalid t_data index "..idx, 2)
|
||||||
end
|
end
|
||||||
return ffi.cast(actor_ptr_ct, a).t_data[idx]
|
return ffi.cast(actor_ptr_ct, a).t_data[idx]
|
||||||
end,
|
end,
|
||||||
|
|
||||||
_set_t_data = function(a, idx, val)
|
_set_t_data = function(a, idx, val)
|
||||||
if (idx >= 10ULL) then
|
if (not (idx >= 0 and idx < 10)) then
|
||||||
error("invalid t_data index "..idx, 2)
|
error("invalid t_data index "..idx, 2)
|
||||||
end
|
end
|
||||||
ffi.cast(actor_ptr_ct, a).t_data[idx] = val
|
ffi.cast(actor_ptr_ct, a).t_data[idx] = val
|
||||||
|
@ -1246,7 +1246,7 @@ local weapondata_mt = {
|
||||||
-- Get weapon index as pointer difference first. PLAYER_0.
|
-- Get weapon index as pointer difference first. PLAYER_0.
|
||||||
local wi = ffi.cast(weapondata_ptr_ct, wd)
|
local wi = ffi.cast(weapondata_ptr_ct, wd)
|
||||||
- ffi.cast(weapondata_ptr_ct, ffiC.g_playerWeapon)
|
- ffi.cast(weapondata_ptr_ct, ffiC.g_playerWeapon)
|
||||||
assert(not (wi >= ffiC.MAX_WEAPONS+0ULL))
|
assert(wi >= 0 and wi < ffiC.MAX_WEAPONS)
|
||||||
|
|
||||||
-- Set g_weaponOverridden[wi][member], but without invoking
|
-- Set g_weaponOverridden[wi][member], but without invoking
|
||||||
-- weapondata_t's __newindex metamethod (i.e. us)!
|
-- weapondata_t's __newindex metamethod (i.e. us)!
|
||||||
|
@ -1513,7 +1513,7 @@ end
|
||||||
|
|
||||||
function gv_access._set_guniqhudid(id)
|
function gv_access._set_guniqhudid(id)
|
||||||
local MAXUNIQHUDID = 256 -- KEEPINSYNC build.h
|
local MAXUNIQHUDID = 256 -- KEEPINSYNC build.h
|
||||||
if (id >= MAXUNIQHUDID+0ULL) then
|
if (not (id >= 0 and id < MAXUNIQHUDID)) then
|
||||||
error("invalid unique HUD ID "..id)
|
error("invalid unique HUD ID "..id)
|
||||||
end
|
end
|
||||||
ffiC.guniqhudid = id
|
ffiC.guniqhudid = id
|
||||||
|
@ -1986,7 +1986,7 @@ local function our_gameactor(args)
|
||||||
if (type(tilenum) ~= "number") then
|
if (type(tilenum) ~= "number") then
|
||||||
error("invalid argument #1 to gameactor: must be a number", 2)
|
error("invalid argument #1 to gameactor: must be a number", 2)
|
||||||
end
|
end
|
||||||
if (tilenum >= ffiC.MAXTILES+0ULL) then
|
if (not (tilenum >= 0 and tilenum < ffiC.MAXTILES)) then
|
||||||
error("invalid argument #1 to gameactor: must be a tile number [0..gv.MAXTILES-1]", 2)
|
error("invalid argument #1 to gameactor: must be a tile number [0..gv.MAXTILES-1]", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2124,7 +2124,7 @@ local function our_gameevent(args)
|
||||||
if (type(event) ~= "number") then
|
if (type(event) ~= "number") then
|
||||||
error("invalid argument #1 to gameevent: must be a number or event label", 2)
|
error("invalid argument #1 to gameevent: must be a number or event label", 2)
|
||||||
end
|
end
|
||||||
if (event >= con_lang.MAXEVENTS+0ULL) then
|
if (not (event >= 0 and event < con_lang.MAXEVENTS)) then
|
||||||
error("invalid argument #1 to gameevent: must be an event number (0 .. MAXEVENTS-1)", 2)
|
error("invalid argument #1 to gameevent: must be an event number (0 .. MAXEVENTS-1)", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -464,7 +464,7 @@ local sectortype_ptr_ct = ffi.typeof("$ *", ffi.typeof(strip_const(SECTOR_STRUCT
|
||||||
|
|
||||||
local function get_sector_idx(sec)
|
local function get_sector_idx(sec)
|
||||||
local i = ffi.cast(sectortype_ptr_ct, sec)-ffi.cast(sectortype_ptr_ct, ffiC.sector)
|
local i = ffi.cast(sectortype_ptr_ct, sec)-ffi.cast(sectortype_ptr_ct, ffiC.sector)
|
||||||
assert(not (i >= ffiC.numsectors+0ULL))
|
-- assert(i >= 0 and i < ffiC.numsectors)
|
||||||
return i
|
return i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -671,7 +671,7 @@ local tspritetype_mt = deep_copy(spritetype_mt)
|
||||||
-- http://www.freelists.org/post/luajit/FFI-versus-Lua-C-API-in-purely-interpreted-mode
|
-- http://www.freelists.org/post/luajit/FFI-versus-Lua-C-API-in-purely-interpreted-mode
|
||||||
local function get_sprite_idx(spr)
|
local function get_sprite_idx(spr)
|
||||||
local i = ffi.cast(spritetype_ptr_ct, spr)-ffi.cast(spritetype_ptr_ct, ffiC.sprite)
|
local i = ffi.cast(spritetype_ptr_ct, spr)-ffi.cast(spritetype_ptr_ct, ffiC.sprite)
|
||||||
assert(not (i >= ffiC.MAXSPRITES+0ULL))
|
-- assert(i >= 0 and i < ffiC.MAXSPRITES)
|
||||||
return i
|
return i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -727,7 +727,7 @@ end
|
||||||
function tspritetype_mt.__index.setpos(tspr, pos, newsect)
|
function tspritetype_mt.__index.setpos(tspr, pos, newsect)
|
||||||
tspr.x, tspr.y, tspr.z = pos.x, pos.y, pos.z
|
tspr.x, tspr.y, tspr.z = pos.x, pos.y, pos.z
|
||||||
if (newsect ~= nil) then
|
if (newsect ~= nil) then
|
||||||
tspr:set_sectnum(newsect)
|
tspr:changesect(newsect)
|
||||||
end
|
end
|
||||||
return tspr
|
return tspr
|
||||||
end
|
end
|
||||||
|
@ -735,7 +735,7 @@ end
|
||||||
function tspritetype_mt.__index.updatesect(tspr, flags)
|
function tspritetype_mt.__index.updatesect(tspr, flags)
|
||||||
local newsect = l_updatesector(tspr, tspr.sectnum, flags)
|
local newsect = l_updatesector(tspr, tspr.sectnum, flags)
|
||||||
if (newsect ~= -1 and newsect ~= tspr.sectnum) then
|
if (newsect ~= -1 and newsect ~= tspr.sectnum) then
|
||||||
tspr:set_sectnum(newsect)
|
tspr:changesect(newsect)
|
||||||
end
|
end
|
||||||
return newsect
|
return newsect
|
||||||
end
|
end
|
||||||
|
@ -927,7 +927,7 @@ l_changesect = static_members.sprite.changesect
|
||||||
function static_members.sprite.changestat(spritenum, statnum, noerr)
|
function static_members.sprite.changestat(spritenum, statnum, noerr)
|
||||||
-- TODO: see gameexec.c's CON_CHANGESPRITESTAT.
|
-- TODO: see gameexec.c's CON_CHANGESPRITESTAT.
|
||||||
check_sprite_idx(spritenum)
|
check_sprite_idx(spritenum)
|
||||||
if (statnum >= ffiC.MAXSTATUS+0ULL) then
|
if (not (statnum >= 0 and statnum < ffiC.MAXSTATUS)) then
|
||||||
error("invalid status number "..statnum, 2)
|
error("invalid status number "..statnum, 2)
|
||||||
end
|
end
|
||||||
if (ffiC.changespritestat(spritenum, statnum)==-1 and not noerr) then
|
if (ffiC.changespritestat(spritenum, statnum)==-1 and not noerr) then
|
||||||
|
@ -1080,7 +1080,7 @@ local function iter_spritesofstat_safe(tab, i)
|
||||||
end
|
end
|
||||||
|
|
||||||
function spritesofstat(stat, maydelete)
|
function spritesofstat(stat, maydelete)
|
||||||
if (stat >= ffiC.MAXSTATUS+0ULL) then
|
if (not (stat >= 0 and stat < ffiC.MAXSTATUS)) then
|
||||||
error("passed invalid statnum to spritesofstat iterator", 2)
|
error("passed invalid statnum to spritesofstat iterator", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1103,7 +1103,7 @@ local function iter_sectorsofbunch(cf, i)
|
||||||
end
|
end
|
||||||
|
|
||||||
function sectorsofbunch(bunchnum, cf)
|
function sectorsofbunch(bunchnum, cf)
|
||||||
if (bunchnum >= ffiC.numyaxbunches+0ULL) then
|
if (not (bunchnum >= 0 and bunchnum < ffiC.numyaxbunches)) then
|
||||||
error("passed invalid bunchnum to sectorsofbunch iterator", 2)
|
error("passed invalid bunchnum to sectorsofbunch iterator", 2)
|
||||||
end
|
end
|
||||||
if (not (cf == 0 or cf == 1)) then
|
if (not (cf == 0 or cf == 1)) then
|
||||||
|
|
|
@ -240,6 +240,8 @@ local function restore_point2(alsosectorp)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function saveboard_maptext(filename, pos, ang, cursectnum)
|
local function saveboard_maptext(filename, pos, ang, cursectnum)
|
||||||
|
assert(ffiC.numsectors > 0)
|
||||||
|
|
||||||
-- First, temporarily tweak wall[].point2.
|
-- First, temporarily tweak wall[].point2.
|
||||||
if (save_tweak_point2()) then
|
if (save_tweak_point2()) then
|
||||||
return -1
|
return -1
|
||||||
|
@ -448,8 +450,8 @@ local function loadboard_maptext(fil, posptr, angptr, cursectnumptr)
|
||||||
local numsectors, numwalls, numsprites = #msector, #mwall, #msprite
|
local numsectors, numwalls, numsprites = #msector, #mwall, #msprite
|
||||||
local sector, wall, sprite = ffiC.sector, ffiC.wall, ffiC.sprite
|
local sector, wall, sprite = ffiC.sector, ffiC.wall, ffiC.sprite
|
||||||
|
|
||||||
if (numsectors+0ULL > ffiC.MAXSECTORS or numwalls+0ULL > ffiC.MAXWALLS or
|
if (numsectors == 0 or numsectors > ffiC.MAXSECTORS or
|
||||||
numsprites+0ULL > ffiC.MAXSPRITES)
|
numwalls > ffiC.MAXWALLS or numsprites > ffiC.MAXSPRITES)
|
||||||
then
|
then
|
||||||
return RETERR-9
|
return RETERR-9
|
||||||
end
|
end
|
||||||
|
|
|
@ -365,6 +365,7 @@ local function new_initial_gvartab()
|
||||||
|
|
||||||
yxaspect = RO "_gv._get_yxaspect()",
|
yxaspect = RO "_gv._get_yxaspect()",
|
||||||
viewingrange = RO "_gv._get_viewingrange()",
|
viewingrange = RO "_gv._get_viewingrange()",
|
||||||
|
-- TODO: gravitationalconstant, gametype_flags
|
||||||
|
|
||||||
numsectors = RO "_gv.numsectors",
|
numsectors = RO "_gv.numsectors",
|
||||||
NUMSECTORS = RO "_gv.numsectors",
|
NUMSECTORS = RO "_gv.numsectors",
|
||||||
|
|
|
@ -190,9 +190,6 @@ checkfail("local w = player[0].weapon[-1]", "out-of-bounds weapon read access")
|
||||||
--player[0].weapon.firesound = 1e5
|
--player[0].weapon.firesound = 1e5
|
||||||
checkfail("player[0].weapon.SHOTGUN.firesound = 1e5", "invalid sound number")
|
checkfail("player[0].weapon.SHOTGUN.firesound = 1e5", "invalid sound number")
|
||||||
checkfail("player[0].weapon.SHOTGUN.firesound = 0/0", "must be a non-NaN number")
|
checkfail("player[0].weapon.SHOTGUN.firesound = 0/0", "must be a non-NaN number")
|
||||||
-- XXX XXX XXX: FAILS!
|
|
||||||
-- inf=1/0; inf >= 1ull <- yields FALSE on x86_64 (inf->uint64_t conversion: undefined!)
|
|
||||||
-- Related (Mike used 0ULL here): http://www.freelists.org/post/luajit/Stack-trace-on-SIGSEGV,4
|
|
||||||
checkfail("player[0].weapon.SHOTGUN.firesound = 1/0", "invalid sound number")
|
checkfail("player[0].weapon.SHOTGUN.firesound = 1/0", "invalid sound number")
|
||||||
-- NOTE: It should only be relied on that setting e.g. .firesound to -1 sets it
|
-- NOTE: It should only be relied on that setting e.g. .firesound to -1 sets it
|
||||||
-- to 0, not other negative values.
|
-- to 0, not other negative values.
|
||||||
|
|
|
@ -54,7 +54,7 @@ local band = bit.band
|
||||||
|
|
||||||
local function ksc_common(ang)
|
local function ksc_common(ang)
|
||||||
ang = band(ang, 2047)
|
ang = band(ang, 2047)
|
||||||
assert(ang < 2048+0ULL) -- might have been passed NaN
|
assert(ang >= 0 and ang < 2048) -- might have been passed NaN
|
||||||
return ang
|
return ang
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue