From 6d8ea48257a568377da2e05fdc9489b6dda50a0c Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 1 Feb 2014 16:19:59 +0000 Subject: [PATCH] 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 --- polymer/eduke32/source/lunatic/control.lua | 6 +++++- polymer/eduke32/source/lunatic/doc/lunacon.txt | 5 +++++ polymer/eduke32/source/lunatic/lunacon.lua | 6 ++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index 47a24de6c..4b2f8fa83 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -516,7 +516,7 @@ function _getsap(aci, pli) return (aci>=0) and sprite[aci], (aci>=0) and actor[aci], (pli>=0) and player[pli] end -function _gud(pli) +function _get_userdef_check(pli) if (pli ~= ffiC.myconnectindex) then error(format("userdefs access with non-local current player %d (we: %d)", pli, ffiC.myconnectindex), 2) @@ -524,6 +524,10 @@ function _gud(pli) return ffiC.ud end +function _get_userdef(pli) + return ffiC.ud +end + --- player/actor/sprite searching functions --- local xmath = require("xmath") diff --git a/polymer/eduke32/source/lunatic/doc/lunacon.txt b/polymer/eduke32/source/lunatic/doc/lunacon.txt index 54de10c7f..285569963 100644 --- a/polymer/eduke32/source/lunatic/doc/lunacon.txt +++ b/polymer/eduke32/source/lunatic/doc/lunacon.txt @@ -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 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):: If enabled and `-Werror-bad-getactorvar` is off, a `getactorvar` of a per-player variable will result the gamevar being indexed with the current diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index cbf558330..fb8e65c17 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -125,7 +125,8 @@ local g_warn = { ["not-redefined"]=true, ["bad-identifier"]=false, local g_cgopt = { ["no"]=false, ["debug-lineinfo"]=false, ["gendir"]=nil, ["cache-sap"]=false, ["error-nostate"]=true, ["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 @@ -305,7 +306,8 @@ local function new_initial_codetab() "local _band, _bor, _bxor = _bit.band, _bit.bor, _bit.bxor", "local _lsh, _rsh, _arsh = _bit.lshift, _bit.rshift, _bit.arshift", "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 -- * Switch function table, indexed by global switch sequence number: