mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
LunaCON: add codegen option -fbad-getactorvar-use-pli for C-CON compatibility.
Also, improve -Wnumber-conversion warning by printing the resulting number. BUILD_LUNATIC. git-svn-id: https://svn.eduke32.com/eduke32@4266 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
8b7cb9e6c9
commit
3a85134e31
2 changed files with 22 additions and 6 deletions
|
@ -127,8 +127,9 @@ one.
|
||||||
When enabled, produces an error whenever a global or per-player gamevar is
|
When enabled, produces an error whenever a global or per-player gamevar is
|
||||||
attempted to be read using ++getactorvar++. Otherwise, a warning is emitted. In
|
attempted to be read using ++getactorvar++. Otherwise, a warning is emitted. In
|
||||||
this case, the generated code is either a read of the (global) gamevar, or an
|
this case, the generated code is either a read of the (global) gamevar, or an
|
||||||
access of the per-player gamevar with an actor index, which is probably not
|
access of the per-player gamevar with the given index or the current player
|
||||||
what the coder intended.
|
index (depending on `-fbad-getactorvar-use-pli`), which is probably not what
|
||||||
|
the coder intended.
|
||||||
|
|
||||||
`-Wnot-redefined` (default: on)::
|
`-Wnot-redefined` (default: on)::
|
||||||
Warns whenever a `define` directive was ignored because it attempted to
|
Warns whenever a `define` directive was ignored because it attempted to
|
||||||
|
@ -167,6 +168,12 @@ If enabled, an attempt to call a `state` that was not previously defined
|
||||||
results in an error. Otherwise, a warning is issued and no code is generated
|
results in an error. Otherwise, a warning is issued and no code is generated
|
||||||
for the `state` invocation.
|
for the `state` invocation.
|
||||||
|
|
||||||
|
`-fbad-getactorvar-use-pli` (default: off)::
|
||||||
|
If enabled and `-Werror-bad-getactorvar` is off, a `getactorvar` of a
|
||||||
|
per-player variable will result the gamevar being indexed with the current
|
||||||
|
player instead of the provided index. This is the (probably unintended)
|
||||||
|
behavior of C-CON.
|
||||||
|
|
||||||
`-fplayervar` (default: on)::
|
`-fplayervar` (default: on)::
|
||||||
If enabled, per-player `gamevar` definitions really generate `con.playervar`
|
If enabled, per-player `gamevar` definitions really generate `con.playervar`
|
||||||
initializations in the translated Lua code. Otherwise, per-player gamevars are
|
initializations in the translated Lua code. Otherwise, per-player gamevars are
|
||||||
|
|
|
@ -124,7 +124,8 @@ local g_warn = { ["not-redefined"]=true, ["bad-identifier"]=false,
|
||||||
-- Code generation and output options.
|
-- Code generation and output options.
|
||||||
local g_cgopt = { ["no"]=false, ["debug-lineinfo"]=false, ["gendir"]=nil,
|
local g_cgopt = { ["no"]=false, ["debug-lineinfo"]=false, ["gendir"]=nil,
|
||||||
["cache-sap"]=false, ["error-nostate"]=true,
|
["cache-sap"]=false, ["error-nostate"]=true,
|
||||||
["playervar"]=true, ["trapv"]=false, ["wrapv"]=false, }
|
["playervar"]=true, ["trapv"]=false, ["wrapv"]=false,
|
||||||
|
["bad-getactorvar-use-pli"]=false, }
|
||||||
|
|
||||||
local function csapp() return g_cgopt["cache-sap"] end
|
local function csapp() return g_cgopt["cache-sap"] end
|
||||||
|
|
||||||
|
@ -690,10 +691,10 @@ local function parse_number(pos, numstr)
|
||||||
num = NaN
|
num = NaN
|
||||||
end
|
end
|
||||||
elseif (num >= 0x80000000) then
|
elseif (num >= 0x80000000) then
|
||||||
if (not hex and g_warn["number-conversion"]) then
|
|
||||||
pwarnprintf(pos, "number %s converted to a negative one", numstr)
|
|
||||||
end
|
|
||||||
num = bit.tobit(num)
|
num = bit.tobit(num)
|
||||||
|
if (not hex and g_warn["number-conversion"]) then
|
||||||
|
pwarnprintf(pos, "number %s converted to %d", numstr, num)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- printf("numstr:%s, num=%d (0x%s) '%s', resnum=%d (0x%s)",
|
-- printf("numstr:%s, num=%d (0x%s) '%s', resnum=%d (0x%s)",
|
||||||
|
@ -2075,6 +2076,14 @@ local function GetOrSetPerxvarCmd(Setp, Actorp)
|
||||||
local xprintf = warnp and warnprintf or errprintf
|
local xprintf = warnp and warnprintf or errprintf
|
||||||
|
|
||||||
xprintf("gamevar `%s' is not per-%s", perxvarname, Actorp and "actor" or "player")
|
xprintf("gamevar `%s' is not per-%s", perxvarname, Actorp and "actor" or "player")
|
||||||
|
|
||||||
|
if (warnp and bit.band(gv.flags, GVFLAG.PERX_MASK)==GVFLAG.PERPLAYER
|
||||||
|
and g_cgopt["bad-getactorvar-use-pli"]) then
|
||||||
|
-- For getactorvar[] accesses to per-player gamevars, if
|
||||||
|
-- -fbad-getactorvar-use-pli is provided, use current player
|
||||||
|
-- index, for compatibility with CON.
|
||||||
|
idx = "_pli"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (not Actorp) then
|
if (not Actorp) then
|
||||||
|
|
Loading…
Reference in a new issue