Lunatic translator: fix some codegen and some commands.

git-svn-id: https://svn.eduke32.com/eduke32@3537 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-03-03 16:06:22 +00:00
parent 07c7363d0f
commit deeb6306a9
6 changed files with 32 additions and 27 deletions

View file

@ -439,6 +439,8 @@ ActorLabels.sectnum[2] = "sprite.changesect(%s,%%s)"
ActorLabels.statnum[2] = "sprite.changestat(%s,%%s)" ActorLabels.statnum[2] = "sprite.changestat(%s,%%s)"
local PL = function(memb) return "player[%s]"..memb end local PL = function(memb) return "player[%s]"..memb end
-- Access to DukePlayer_t's bool members: they must be read as numbers.
local PLBOOL = function(memb) return { "("..PL(memb).." and 1 or 0)", PL(memb) } end
local PlayerLabels = { local PlayerLabels = {
posx = PL".pos.x", posx = PL".pos.x",
@ -491,7 +493,7 @@ local PlayerLabels = {
oang = PL".oang", oang = PL".oang",
angvel = PL".angvel", angvel = PL".angvel",
cursectnum = PL".cursectnum", cursectnum = { PL".cursectnum", PL":set_cursectnum(%%s)" },
look_ang = PL".look_ang", look_ang = PL".look_ang",
last_extra = PL".last_extra", last_extra = PL".last_extra",
@ -566,7 +568,7 @@ local PlayerLabels = {
last_quick_kick = PL".last_quick_kick", last_quick_kick = PL".last_quick_kick",
return_to_center = PL".return_to_center", return_to_center = PL".return_to_center",
reloading = PL".reloading", reloading = PLBOOL".reloading",
weapreccnt = { PL".weapreccnt" }, weapreccnt = { PL".weapreccnt" },
aim_mode = PL".aim_mode", aim_mode = PL".aim_mode",
@ -581,29 +583,29 @@ local PlayerLabels = {
kickback_pic = PL".kickback_pic", kickback_pic = PL".kickback_pic",
gm = PL".gm", gm = PL".gm",
on_warping_sector = PL".on_warping_sector", on_warping_sector = PLBOOL".on_warping_sector",
footprintcount = PL".footprintcount", footprintcount = PL".footprintcount",
hurt_delay = PL".hurt_delay", hurt_delay = PL".hurt_delay",
hbomb_on = PL".hbomb_on", hbomb_on = PLBOOL".hbomb_on",
jumping_toggle = PL".jumping_toggle", jumping_toggle = PLBOOL".jumping_toggle",
rapid_fire_hold = PL".rapid_fire_hold", rapid_fire_hold = PLBOOL".rapid_fire_hold",
on_ground = PL".on_ground", on_ground = PLBOOL".on_ground",
inven_icon = PL".inven_icon", inven_icon = PL".inven_icon",
buttonpalette = PL".buttonpalette", buttonpalette = PL".buttonpalette",
over_shoulder_on = PL".over_shoulder_on", over_shoulder_on = PLBOOL".over_shoulder_on",
show_empty_weapon = PL".show_empty_weapon", show_empty_weapon = PL".show_empty_weapon",
jetpack_on = PL".jetpack_on", jetpack_on = PLBOOL".jetpack_on",
spritebridge = PL".spritebridge", spritebridge = PLBOOL".spritebridge",
lastrandomspot = PL".lastrandomspot", lastrandomspot = PL".lastrandomspot",
scuba_on = PL".scuba_on", scuba_on = PLBOOL".scuba_on",
footprintpal = PL".footprintpal", footprintpal = PL".footprintpal",
heat_on = PL".heat_on", heat_on = PLBOOL".heat_on",
invdisptime = PL".invdisptime", invdisptime = PL".invdisptime",
holster_weapon = PL".holster_weapon", holster_weapon = PLBOOL".holster_weapon",
falling_counter = PL".falling_counter", falling_counter = PL".falling_counter",
footprintshade = PL".footprintshade", footprintshade = PL".footprintshade",
@ -615,7 +617,7 @@ local PlayerLabels = {
hard_landing = PL".hard_landing", hard_landing = PL".hard_landing",
fist_incs = PL".fist_incs", fist_incs = PL".fist_incs",
toggle_key_flag = PL".toggle_key_flag", toggle_key_flag = PLBOOL".toggle_key_flag",
knuckle_incs = PL".knuckle_incs", knuckle_incs = PL".knuckle_incs",
knee_incs = PL".knee_incs", knee_incs = PL".knee_incs",
access_incs = PL".access_incs", access_incs = PL".access_incs",

View file

@ -1568,7 +1568,9 @@ function _startlevel(volume, level)
bcheck.level_idx(level) bcheck.level_idx(level)
ffiC.ud.m_volume_number = volume ffiC.ud.m_volume_number = volume
ffiC.ud.volume_number = volume
ffiC.ud.m_level_number = level ffiC.ud.m_level_number = level
ffiC.ud.level_number = level
ffiC.ud.display_bonus_screen = 0 ffiC.ud.display_bonus_screen = 0

View file

@ -956,10 +956,13 @@ local player_mt = {
ffi.cast(player_ptr_ct, p).ftq = ftq ffi.cast(player_ptr_ct, p).ftq = ftq
end, end,
set_cursectnum = function(p, sectnum)
check_sector_idx(sectnum)
ffi.cast(player_ptr_ct, p).cursectnum = sectnum
end,
set_customexitsound = function(p, soundnum) set_customexitsound = function(p, soundnum)
if (soundnum >= con_lang.MAXSOUNDS+0ULL) then check_sound_idx(soundnum)
error("Invalid sound number "..soundnum, 2)
end
ffi.cast(player_ptr_ct, p).customexitsound = soundnum ffi.cast(player_ptr_ct, p).customexitsound = soundnum
end, end,

View file

@ -860,22 +860,19 @@ end
-- TODO: should these rather be one function, and the specific kind of updating -- TODO: should these rather be one function, and the specific kind of updating
-- controlled by an argument? -- controlled by an argument?
function updatesector(pos, sectnum) function updatesector(pos, sectnum)
local sect = ffi.new("int16_t [1]") local sect = ffi.new("int16_t [1]", sectnum)
sect[0] = sectnum
ffiC.updatesector(pos.x, pos.y, sect) ffiC.updatesector(pos.x, pos.y, sect)
return sect[0] return sect[0]
end end
function updatesectorbreadth(pos, sectnum) function updatesectorbreadth(pos, sectnum)
local sect = ffi.new("int16_t [1]") local sect = ffi.new("int16_t [1]", sectnum)
sect[0] = sectnum
ffiC.updatesectorbreadth(pos.x, pos.y, sect) ffiC.updatesectorbreadth(pos.x, pos.y, sect)
return sect[0] return sect[0]
end end
function updatesectorz(pos, sectnum) function updatesectorz(pos, sectnum)
local sect = ffi.new("int16_t [1]") local sect = ffi.new("int16_t [1]", sectnum)
sect[0] = sectnum
ffiC.updatesectorz(pos.x, pos.y, pos.z, sect) ffiC.updatesectorz(pos.x, pos.y, pos.z, sect)
return sect[0] return sect[0]
end end

View file

@ -470,7 +470,7 @@ local function reset_labels()
-- NOTE: these are read-only gamevars in C-CON -- NOTE: these are read-only gamevars in C-CON
CLIPMASK0 = 65536+1, -- blocking CLIPMASK0 = 65536+1, -- blocking
CLIPMASK1 = (256*65536)+64, -- hittable CLIPMASK1 = (256*65536)+64, -- hittable
-- TODO...? -- TODO_MP
COOP = 0, COOP = 0,
MULTIMODE = 0, MULTIMODE = 0,
numplayers = 1, numplayers = 1,
@ -1045,7 +1045,7 @@ function Cmd.gamevar(identifier, initval, flags)
-- TODO: Write gamevar system on the Lunatic side and hook it up. -- TODO: Write gamevar system on the Lunatic side and hook it up.
-- TODO: per-player gamevars -- TODO: per-player gamevars
if (flags==GVFLAG.PERACTOR) then if (bit.band(flags, GVFLAG.PERX_MASK)==GVFLAG.PERACTOR) then
addcodef("%s=_con.peractorvar(%d)", gv.name, initval) addcodef("%s=_con.peractorvar(%d)", gv.name, initval)
else else
addcodef("%s=%d", gv.name, initval) addcodef("%s=%d", gv.name, initval)

View file

@ -106,7 +106,8 @@ end
function rotate(pos, pivot, ang) function rotate(pos, pivot, ang)
local p = geom.tovec3(pos)-pivot local p = geom.tovec3(pos)-pivot
local c, s = cosb(ang), sinb(ang) local c, s = cosb(ang), sinb(ang)
p.x = pivot.x + (c*p.x - s*p.y) local x, y = p.x, p.y
p.y = pivot.y + (c*p.y + s*p.x) p.x = pivot.x + (c*x - s*y)
p.y = pivot.y + (c*y + s*x)
return p return p
end end