LunaCON: add option -ferror-nonlocal-userdef, on by default.

BUILD_LUNATIC.

git-svn-id: https://svn.eduke32.com/eduke32@4290 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-02-01 16:19:59 +00:00
parent f04ec9e117
commit 6d8ea48257
3 changed files with 14 additions and 3 deletions

View file

@ -516,7 +516,7 @@ function _getsap(aci, pli)
return (aci>=0) and sprite[aci], (aci>=0) and actor[aci], (pli>=0) and player[pli] return (aci>=0) and sprite[aci], (aci>=0) and actor[aci], (pli>=0) and player[pli]
end end
function _gud(pli) function _get_userdef_check(pli)
if (pli ~= ffiC.myconnectindex) then if (pli ~= ffiC.myconnectindex) then
error(format("userdefs access with non-local current player %d (we: %d)", error(format("userdefs access with non-local current player %d (we: %d)",
pli, ffiC.myconnectindex), 2) pli, ffiC.myconnectindex), 2)
@ -524,6 +524,10 @@ function _gud(pli)
return ffiC.ud return ffiC.ud
end end
function _get_userdef(pli)
return ffiC.ud
end
--- player/actor/sprite searching functions --- --- player/actor/sprite searching functions ---
local xmath = require("xmath") local xmath = require("xmath")

View file

@ -168,6 +168,11 @@ 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.
`-ferror-nonlocal-userdef` (default: on)::
If enabled, an attept to issue `getuserdef` or `setuserdef` when the current
player doesn't equal the local player generates an error. Otherwise, the
userdef structure is accessible without restriction.
`-fbad-getactorvar-use-pli` (default: off):: `-fbad-getactorvar-use-pli` (default: off)::
If enabled and `-Werror-bad-getactorvar` is off, a `getactorvar` of a If enabled and `-Werror-bad-getactorvar` is off, a `getactorvar` of a
per-player variable will result the gamevar being indexed with the current per-player variable will result the gamevar being indexed with the current

View file

@ -125,7 +125,8 @@ local g_warn = { ["not-redefined"]=true, ["bad-identifier"]=false,
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, } ["bad-getactorvar-use-pli"]=false,
["error-nonlocal-userdef"]=true, }
local function csapp() return g_cgopt["cache-sap"] end local function csapp() return g_cgopt["cache-sap"] end
@ -305,7 +306,8 @@ local function new_initial_codetab()
"local _band, _bor, _bxor = _bit.band, _bit.bor, _bit.bxor", "local _band, _bor, _bxor = _bit.band, _bit.bor, _bit.bxor",
"local _lsh, _rsh, _arsh = _bit.lshift, _bit.rshift, _bit.arshift", "local _lsh, _rsh, _arsh = _bit.lshift, _bit.rshift, _bit.arshift",
"local _setsprite,_ssp = _con._setsprite,_con._ssp", "local _setsprite,_ssp = _con._setsprite,_con._ssp",
"local _gud=_con._gud", g_cgopt["error-nonlocal-userdef"]
and "local _gud=_con._get_userdef_check" or "local _gud=_con._get_userdef",
-- * CON "states" (subroutines) and -- * CON "states" (subroutines) and
-- * Switch function table, indexed by global switch sequence number: -- * Switch function table, indexed by global switch sequence number: