diff --git a/polymer/eduke32/source/lunatic/con_lang.lua b/polymer/eduke32/source/lunatic/con_lang.lua index 8fc254e3e..8cf801676 100644 --- a/polymer/eduke32/source/lunatic/con_lang.lua +++ b/polymer/eduke32/source/lunatic/con_lang.lua @@ -807,7 +807,7 @@ for member, code in pairs(ProjectileLabels) do end end -local UD = function(memb) return "_gv._ud"..memb end +local UD = function(memb) return "_gud(_pli)"..memb end local UDRO = function(memb) return { UD(memb) } end -- NOTE: Only members that actually encountered in existing mods are added here. diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index c6551e253..47a24de6c 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -516,6 +516,14 @@ function _getsap(aci, pli) return (aci>=0) and sprite[aci], (aci>=0) and actor[aci], (pli>=0) and player[pli] end +function _gud(pli) + if (pli ~= ffiC.myconnectindex) then + error(format("userdefs access with non-local current player %d (we: %d)", + pli, ffiC.myconnectindex), 2) + end + return ffiC.ud +end + --- player/actor/sprite searching functions --- local xmath = require("xmath") diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index 7b2e7980a..1d2af56fe 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -603,6 +603,7 @@ decl("map_t MapInfo[$*$];", con_lang.MAXVOLUMES+1, con_lang.MAXLEVELS) decl("char EpisodeNames[$][33];", con_lang.MAXVOLUMES) decl[[ +const int32_t myconnectindex; int32_t g_RETURN; int32_t g_elCONSize; char *g_elCON; diff --git a/polymer/eduke32/source/lunatic/dynsymlist b/polymer/eduke32/source/lunatic/dynsymlist index a4bb73501..6525a16a3 100644 --- a/polymer/eduke32/source/lunatic/dynsymlist +++ b/polymer/eduke32/source/lunatic/dynsymlist @@ -117,6 +117,7 @@ g_sizes_of; g_elFirstTime; g_elCallDepth; block_deletesprite; +myconnectindex; g_RETURN; g_elModules; g_modDir; diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index 85edba8d5..3219a0b78 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -305,6 +305,7 @@ 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", -- * CON "states" (subroutines) and -- * Switch function table, indexed by global switch sequence number: diff --git a/polymer/eduke32/source/lunatic/test/getuserdef.con b/polymer/eduke32/source/lunatic/test/getuserdef.con new file mode 100644 index 000000000..a9869d201 --- /dev/null +++ b/polymer/eduke32/source/lunatic/test/getuserdef.con @@ -0,0 +1,17 @@ +// XXX: should be allowed to override existing modes? (Probably yes.) +// XXX: but currently, this ensues badness? (g_numGametypes becomes inconsistent?) +definegametype 0 46051 Cooperative + +gamevar temp 0 0 + +// Original version by Fox, from +// http://forums.duke4.net/topic/775-eduke32-20-and-polymer/page__view__findpost__p__183890 +onevent EVENT_DISPLAYREST +// getuserdef[THISACTOR].statusbarscale temp + // NOTE: index (THISACTOR) is never used. + // NOTE: incorrect if screenpeek != myconnectindex, e.g. by pressing [K]: + getuserdef .statusbarscale temp + redefinequote 0 %ld + qsprintf 0 0 temp + gametext STARTALPHANUM 10 10 0 0 0 0 0 0 xdim ydim +endevent