Lunatic: fix _digitalnumber, remove player._INPUT_BITS, add sprite.all().

git-svn-id: https://svn.eduke32.com/eduke32@4047 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-09-05 17:37:42 +00:00
parent 3b69417792
commit 1b7c622f31
5 changed files with 32 additions and 9 deletions

View file

@ -903,7 +903,7 @@ end
function _digitalnumber(tilenum, x, y, num, shade, pal,
orientation, cx1, cy1, cx2, cy2, zoom)
if (not (tilenum >= 0 and tilenum >= ffiC.MAXTILES-9)) then
if (not (tilenum >= 0 and tilenum < ffiC.MAXTILES-9)) then
error("invalid base tile number "..tilenum, 2)
end

View file

@ -749,6 +749,7 @@ end
local player_static_members = {}
--[[
player_static_members._INPUT_BITS = defs_c.conststruct
{
JUMP = 1,
@ -791,6 +792,7 @@ player_static_members._INPUT_EXT_BITS = defs_c.conststruct
TURN_LEFT = 16,
TURN_RIGHT = 32,
}
--]]
local band = bit.band
local lsh = bit.lshift
@ -2424,17 +2426,17 @@ end
--printkv('_G AFTER DECLS', _G)
local index_error_mt = {
__index = function(_, key)
error("attempt to read undeclared variable '"..key.."'", 2)
end,
__metatable = true,
}
-- PiL 14.2 continued
-- We need this at the end because we were previously doing just that!
setmetatable(
G_, {
__index = function (_, n)
error("attempt to read undeclared variable '"..n.."'", 2)
end,
__metatable = true,
})
setmetatable(G_, index_error_mt)
local global_mt = {
__index = G_,
@ -2479,6 +2481,9 @@ if (concode) then
table.remove(modname_stack)
local function protect_con_table(tab)
-- NOTE: Some of our code specifically excepts the name tables to be
-- indexable with nonexistent keys. See e.g. control.c: _A_SpawnGlass()
-- tab = setmetatable(tab, index_error_mt)
return setmtonce({}, { __index=tab, __newindex=basemod_newidx })
end

View file

@ -897,6 +897,18 @@ local bitar = require("bitar")
-- machines. This sucks.
static_members.sector.showbitmap = bitar.new(ffiC.MAXSECTORS-1, ffi.cast("int32_t *", ffiC.show2dsector))
local function iter_allsprites(_, curi)
for i=curi+1,ffiC.MAXSPRITES-1 do
if (ffiC.sprite[i].statnum ~= ffiC.MAXSTATUS) then
return i
end
end
end
function static_members.sprite.all()
return iter_allsprites, nil, -1
end
local sms = static_members.sprite
sms._headspritesect = creategtab(ffiC.headspritesect, ffiC.MAXSECTORS, 'headspritesect[]')
-- NOTE: don't allow freelist access

View file

@ -812,6 +812,10 @@ _`index_of_spr`_ is the sprite index corresponding to `spr`. This method is
provided for convenience, but may be slower than the static function
`updatesect`.
===== `sprite` iterators
+*for* i *in* sprite.all()+::
Iterates over all sprites currently in the game world.
===== `sprite` static functions

View file

@ -226,6 +226,7 @@ gameevent{gv.EVENT_JUMP,
end
}
--[[
gameevent
{
"PROCESSINPUT",
@ -244,6 +245,7 @@ gameevent
end
end
}
--]]
local D = require("CON.DEFS")
local WEAPON = gv.WEAPON