From f10063eec3af78a065a808c9d9ce7109e54a2529 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Wed, 23 Jan 2013 19:36:48 +0000 Subject: [PATCH] Lunatic: sync with preceding change, fix r3419. git-svn-id: https://svn.eduke32.com/eduke32@3427 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/lunatic/con_lang.lua | 1 + polymer/eduke32/source/lunatic/control.lua | 3 +++ polymer/eduke32/source/lunatic/defs.ilua | 13 ++++++------- polymer/eduke32/source/lunatic/lunacon.lua | 13 ++++++------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/polymer/eduke32/source/lunatic/con_lang.lua b/polymer/eduke32/source/lunatic/con_lang.lua index dcc63ac18..8ea6459fa 100644 --- a/polymer/eduke32/source/lunatic/con_lang.lua +++ b/polymer/eduke32/source/lunatic/con_lang.lua @@ -183,6 +183,7 @@ local SFLAG = { -- SFLAG_BADGUYSTAYPUT = 0x00008000, -- SFLAG_CACHE = 0x00010000, -- SFLAG_ROTFIXED = 0x00020000, +-- SPRITE_HARDCODED_BADGUY= 0x00040000, } STAT = { diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index 49f38eaa7..f700783a2 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -235,6 +235,9 @@ function _spawnmany(ow, tilenum, n) end function isenemytile(tilenum) + if (bit.band(ffiC.g_tile[tilenum].flags, 0x00040000)~=0) then + return true + end return (bit.band(ffiC.g_tile[tilenum].flags, ffiC.SFLAG_BADGUY)~=0) end diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index 07aa8cfd6..f2cdf7ec7 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -569,13 +569,6 @@ if (not good) then error("Some sizes don't match between C and LuaJIT/FFI.") end --- Add game-side metamethods to "spritetype" and register it with "metatype" -defs_c.spritetype_mt.__index.isenemy = function(s) - -- CODEDUP control.lua: isenemytile - return (bit.band(ffiC.g_tile[s.picnum].flags, ffiC.SFLAG_BADGUY)~=0) -end -ffi.metatype("spritetype", defs_c.spritetype_mt) - -- "player" global, needed by the "control" module local tmpmt = { __index = function(tab, key) @@ -598,6 +591,12 @@ actor = defs_c.creategtab(ffiC.actor, ffiC.MAXSPRITES, "actor[]") local con = require("control") local MV, AC, AI = con.MV, con.AC, con.AI +-- Add game-side metamethods to "spritetype" and register it with "metatype" +defs_c.spritetype_mt.__index.isenemy = function(s) + return con.isenemytile(s.picnum) +end +ffi.metatype("spritetype", defs_c.spritetype_mt) + -- All-zero action and move local nullac, nullmv = ffi.new("const struct action"), ffi.new("const struct move") diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index 7bf8b9cb2..926c7f83e 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -780,17 +780,15 @@ end --- GAMEVARS / GAMEARRAYS function Cmd.gamevar(identifier, initval, flags) - local failure_code = "local _INVALIDGV" - if (bit.band(flags, bit.bnot(GVFLAG.PERX_MASK)) ~= 0) then -- TODO: a couple of the presumably safe ones errprintf("gamevar flags other than PERPLAYER or PERACTOR: NYI or forbidden") - return failure_code + return end if (flags==GVFLAG.PERPLAYER+GVFLAG.PERACTOR) then errprintf("invalid gamevar flags: must be either PERPLAYER or PERACTOR, not both") - return failure_code + return end local ogv = g_gamevar[identifier] @@ -802,7 +800,7 @@ function Cmd.gamevar(identifier, initval, flags) -- Attempt to override a system gamevar. See if it's read-only... if (bit.band(oflags, GVFLAG.READONLY) ~= 0) then errprintf("attempt to override read-only system gamevar `%s'", identifier) - return failure_code + return end local flagsnosys = bit.band(oflags, bit.bnot(GVFLAG.SYSTEM)) @@ -821,13 +819,14 @@ function Cmd.gamevar(identifier, initval, flags) else addcodef("%s=%d", ogv.name, initval) end + return end errprintf("duplicate gamevar definition `%s' has different flags", identifier) - return failure_code + return else warnprintf("duplicate gamevar definition `%s' ignored", identifier) - return "" + return end end