Lunatic: fix weapondata_t read access, Lua->CON line mapping for if* commands.

git-svn-id: https://svn.eduke32.com/eduke32@3595 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-03-24 18:53:06 +00:00
parent b7ea1cb205
commit ea118fe436
3 changed files with 25 additions and 4 deletions

View File

@ -1188,6 +1188,10 @@ function _cansee(aci, ps)
local spr = sprite[aci]
local s = sprite[ps.i]
-- This is kind of redundant, but points the error messages to the CON code.
check_sector_idx(spr.sectnum)
check_sector_idx(s.sectnum)
if (ps.holoduke_on >= 0) then
-- If holoduke is on, let them target holoduke first.
local hs = sprite[ps.holoduke_on]

View File

@ -913,6 +913,11 @@ ffi.metatype("actor_t", actor_mt)
--- PER-PLAYER WEAPON SETTINGS
local weapondata_mt = {
__index = function(wd, member)
-- Handle protected members that are renamed (e.g. shoots/_shoots).
return ffi.cast(weapondata_ptr_ct, wd)[member]
end,
__newindex = function(wd, member, val)
if (string.match(member, "sound")) then
if (val < 0) then

View File

@ -2567,11 +2567,15 @@ local function after_if_cmd_Cmt(subj, pos, ...)
local capts = {...}
assert(capts[1] ~= nil)
assert(#capts <= 3)
for i=1,#capts do
assert(type(capts[i]=="string"))
for i=#capts,1, -1 do
assert(type(capts[i])=="string" or type(capts[i])=="table")
end
-- TODO: make if* commands have line numbers.
-- IF_LINE_NUMBERING
local firstistab = (type(capts[1])=="table")
attachlinenum(firstistab and capts[1] or capts, pos)
return true, unpack(capts)
end
@ -2750,6 +2754,7 @@ function on.if_else_end(ifconds, ifstmt, elsestmt, ...)
-- and it's always idempotent (executing it multiple times has the same
-- effect as executing it once), so generate code for it only once, too.
local deferred = { nil, nil }
local linenum = ""
local ifcondstr = {}
for i=1,#ifconds do
@ -2759,6 +2764,13 @@ function on.if_else_end(ifconds, ifstmt, elsestmt, ...)
ifcondstr[i] = hasmore and cond[1] or cond
assert(type(ifcondstr[i])=="string")
-- IF_LINE_NUMBERING
local tlinum = assert(ifcondstr[i]:match("^.*(%-%-[0-9]+)$"))
ifcondstr[i] = assert(ifcondstr[i]:match("^(.*)%-%-[0-9]+$"))
if (linenum == "") then
linenum = tlinum
end
if (hasmore) then
for i=1,2 do
if (deferred[i]==nil) then
@ -2772,7 +2784,7 @@ function on.if_else_end(ifconds, ifstmt, elsestmt, ...)
local conds = "(" .. table.concat(ifcondstr, ")and(") .. ")"
local code = {
format("if %s then", conds),
format("if %s then%s", conds, linenum),
assert(ifstmt),
}