mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 11:10:39 +00:00
LunaCON: check reserved bits for sound and ai movement flags.
git-svn-id: https://svn.eduke32.com/eduke32@3882 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
878ba20af9
commit
4a49da94c1
1 changed files with 20 additions and 13 deletions
|
@ -772,6 +772,14 @@ function lookup.composite(labeltype, pos, identifier)
|
||||||
return val
|
return val
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function check_reserved_bits(flags, allowedbits, suffix)
|
||||||
|
local rbits = bit.bnot(allowedbits)
|
||||||
|
if (bit.band(flags, rbits) ~= 0) then
|
||||||
|
warnprintf("set one or more reserved bits (0x%s) "..suffix,
|
||||||
|
bit.tohex(bit.band(flags, rbits)))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function do_define_composite(labeltype, identifier, ...)
|
local function do_define_composite(labeltype, identifier, ...)
|
||||||
local oldtype = g_labeltype[identifier]
|
local oldtype = g_labeltype[identifier]
|
||||||
local oldval = g_labeldef[identifier]
|
local oldval = g_labeldef[identifier]
|
||||||
|
@ -802,10 +810,12 @@ local function do_define_composite(labeltype, identifier, ...)
|
||||||
|
|
||||||
-- OR together the flags
|
-- OR together the flags
|
||||||
for i=#args,LABEL.AI+1, -1 do
|
for i=#args,LABEL.AI+1, -1 do
|
||||||
-- TODO: check?
|
|
||||||
args[LABEL.AI] = bit.bor(args[LABEL.AI], args[i])
|
args[LABEL.AI] = bit.bor(args[LABEL.AI], args[i])
|
||||||
args[i] = nil
|
args[i] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check whether movflags use reserved bits.
|
||||||
|
check_reserved_bits(args[LABEL.AI], 4096+2047, "for ai's movflags")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Make a string out of that.
|
-- Make a string out of that.
|
||||||
|
@ -1051,11 +1061,7 @@ function Cmd.defineprojectile(tilenum, what, val)
|
||||||
local ok = check.tile_idx(tilenum)
|
local ok = check.tile_idx(tilenum)
|
||||||
|
|
||||||
if (what==PROJ.WORKSLIKE) then
|
if (what==PROJ.WORKSLIKE) then
|
||||||
local rbits = bit.bnot(2^21-1)
|
check_reserved_bits(val, 2^21-1, "for PROJ_WORKSLIKE")
|
||||||
if (bit.band(val, rbits) ~= 0) then
|
|
||||||
warnprintf("set one or more reserved bits (0x%s) for PROJ_WORKSLIKE",
|
|
||||||
bit.tohex(bit.band(rbits, val)))
|
|
||||||
end
|
|
||||||
elseif (what==PROJ.SOUND or what==PROJ.ISOUND or what==PROJ.BSOUND) then
|
elseif (what==PROJ.SOUND or what==PROJ.ISOUND or what==PROJ.BSOUND) then
|
||||||
ok = ok and (val==-1 or check.sound_idx(val))
|
ok = ok and (val==-1 or check.sound_idx(val))
|
||||||
elseif (what==PROJ.SPAWNS or what==PROJ.DECAL or what==PROJ.TRAIL) then
|
elseif (what==PROJ.SPAWNS or what==PROJ.DECAL or what==PROJ.TRAIL) then
|
||||||
|
@ -1139,7 +1145,9 @@ function Cmd.definesound(sndlabel, fn, ...)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local params = {...} -- TODO: sanity-check them
|
local params = {...} -- TODO: sanity-check them some more
|
||||||
|
check_reserved_bits(params[4], 31+128, "for sound flags")
|
||||||
|
|
||||||
if (ffi) then
|
if (ffi) then
|
||||||
local cparams = ffi.new("int32_t [5]", params)
|
local cparams = ffi.new("int32_t [5]", params)
|
||||||
assert(type(fn)=="string")
|
assert(type(fn)=="string")
|
||||||
|
@ -1822,21 +1830,20 @@ local handle =
|
||||||
end,
|
end,
|
||||||
|
|
||||||
dynNYI = function()
|
dynNYI = function()
|
||||||
-- XXX: what if file name contains a double quote? (Similarly commands below.)
|
return format([[print(%q..":%d: `%s' not yet implemented")]],
|
||||||
return format([[print("%s:%d: `%s' not yet implemented")]],
|
|
||||||
g_filename, getlinecol(g_lastkwpos), g_lastkw)
|
g_filename, getlinecol(g_lastkwpos), g_lastkw)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
addlog = function()
|
addlog = function()
|
||||||
return format("print('%s:%d: addlog')", g_filename, getlinecol(g_lastkwpos))
|
return format("print(%q..':%d: addlog')", g_filename, getlinecol(g_lastkwpos))
|
||||||
end,
|
end,
|
||||||
|
|
||||||
addlogvar = function(val)
|
addlogvar = function(val)
|
||||||
return format("printf('%s:%d: addlogvar %%s', %s)", g_filename, getlinecol(g_lastkwpos), val)
|
return format("printf(%q..':%d: addlogvar %%s', %s)", g_filename, getlinecol(g_lastkwpos), val)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
debug = function(val)
|
debug = function(val)
|
||||||
return format("print('%s:%d: debug %d')", g_filename, getlinecol(g_lastkwpos), val)
|
return format("print(%q..':%d: debug %d')", g_filename, getlinecol(g_lastkwpos), val)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getzrange = function(...)
|
getzrange = function(...)
|
||||||
|
@ -2299,7 +2306,7 @@ local Cinner = {
|
||||||
/ "%1=_con._qstrlen(%2)",
|
/ "%1=_con._qstrlen(%2)",
|
||||||
qstrncat = cmd(R,R)
|
qstrncat = cmd(R,R)
|
||||||
/ handle.NYI,
|
/ handle.NYI,
|
||||||
qsubstr = cmd(R,R)
|
qsubstr = cmd(R,R,R,R)
|
||||||
/ handle.NYI,
|
/ handle.NYI,
|
||||||
quote = cmd(D)
|
quote = cmd(D)
|
||||||
/ "_con._quote(_pli,%1)",
|
/ "_con._quote(_pli,%1)",
|
||||||
|
|
Loading…
Reference in a new issue