Lunatic: error on invalid static data read like 'sprite.picnum'.

git-svn-id: https://svn.eduke32.com/eduke32@4209 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-12-24 09:44:19 +00:00
parent 02e0929ca7
commit a4510e35a1
4 changed files with 28 additions and 8 deletions

View file

@ -755,7 +755,7 @@ end
--== "player" global, needed by the "control" module ==-- --== "player" global, needed by the "control" module ==--
local player_static_members = {} local player_static_members = defs_c.static_members_tab()
--[[ --[[
player_static_members._INPUT_BITS = defs_c.conststruct player_static_members._INPUT_BITS = defs_c.conststruct
@ -837,7 +837,7 @@ end
local player_holdskey = player_static_members.holdskey local player_holdskey = player_static_members.holdskey
-- Actor flags -- Actor flags
local actor_static_members = {} local actor_static_members = defs_c.static_members_tab()
do do
local our_SFLAG = {} local our_SFLAG = {}
local ext_SFLAG = con_lang.labels[4] -- external actor flags only local ext_SFLAG = con_lang.labels[4] -- external actor flags only
@ -923,7 +923,7 @@ function actor_static_members.delete(i)
CF.A_DeleteSprite(i) CF.A_DeleteSprite(i)
end end
local tile_static_members = {} local tile_static_members = defs_c.static_members_tab()
do do
tile_static_members.sizx = defs_c.creategtab(ffiC.tilesizx, ffiC.MAXTILES, "tilesizx[]") tile_static_members.sizx = defs_c.creategtab(ffiC.tilesizx, ffiC.MAXTILES, "tilesizx[]")
tile_static_members.sizy = defs_c.creategtab(ffiC.tilesizy, ffiC.MAXTILES, "tilesizy[]") tile_static_members.sizy = defs_c.creategtab(ffiC.tilesizy, ffiC.MAXTILES, "tilesizy[]")
@ -2430,6 +2430,7 @@ if (ffiC._DEBUG_LUNATIC ~= 0) then
local codestr = [[ local codestr = [[
do do
local _bit,_math=require'bit',require'math' local _bit,_math=require'bit',require'math'
local _con=require'con'
local _band,_gv=_bit.band,gv local _band,_gv=_bit.band,gv
local tmp=]].. local tmp=]]..
membaccode:gsub("%%s","0").." end" membaccode:gsub("%%s","0").." end"

View file

@ -878,9 +878,25 @@ function conststruct(tab)
return ffi.new(table.concat(strtab)) return ffi.new(table.concat(strtab))
end end
do
local smt_mt = {
__index = function()
error("invalid access to static data", 2)
end
}
function static_members_tab()
return setmtonce({}, smt_mt)
end
end
-- Static, non-instance members. Used to hold constants, for example -- Static, non-instance members. Used to hold constants, for example
-- sprite.CSTAT.TRANS1 -- sprite.CSTAT.TRANS1
local static_members = { sector={}, wall={}, sprite={} } local static_members = {
sector = static_members_tab(),
wall = static_members_tab(),
sprite = static_members_tab(),
}
static_members.sector.STAT = conststruct static_members.sector.STAT = conststruct
{ {

View file

@ -1769,10 +1769,10 @@ The total number of frames in the animation.
The number of consecutive tiles used to construct one frame of the animation, The number of consecutive tiles used to construct one frame of the animation,
as viewed from different angles. Valid values are 1, 3, 5, 7 and 8. In as viewed from different angles. Valid values are 1, 3, 5, 7 and 8. In
addition, -5 and -7 are allowed, which behave like the corresponding positive addition, -5 and -7 are allowed, which behave like the corresponding positive
++viewtype++s, but effectively mirror the actor on the vertical axis. This can ++viewtype++s, but effectively mirror the actor around the vertical axis. This
be useful if tile data is available that has the opposite orientation of what can be useful if tile data is available that has the opposite orientation of
EDuke32 uses. See the {wiki_action}[Action entry] in the EDuke32 wiki for how what EDuke32 uses. See the {wiki_action}[Action entry] in the EDuke32 wiki for
the views are constructed for different `viewtype` values. how the views are constructed for different `viewtype` values.
`[4] incval` (default: 1):: `[4] incval` (default: 1)::
The value to add the actor's _current frame_ on each frame advance. May be -1, The value to add the actor's _current frame_ on each frame advance. May be -1,

View file

@ -141,6 +141,9 @@ gameevent
-- actor[].t_data[] is not accessible for now -- actor[].t_data[] is not accessible for now
checkfail('local i = actor[0].t_data[15]', "has no member named 't_data'") checkfail('local i = actor[0].t_data[15]', "has no member named 't_data'")
-- sprite.picnum may happen as a thinko/typo kind of error (spr.picnum was meant)
checkfail("local pic = sprite.picnum", "invalid access to static data")
end end
} }