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)"
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 = {
posx = PL".pos.x",
@ -491,7 +493,7 @@ local PlayerLabels = {
oang = PL".oang",
angvel = PL".angvel",
cursectnum = PL".cursectnum",
cursectnum = { PL".cursectnum", PL":set_cursectnum(%%s)" },
look_ang = PL".look_ang",
last_extra = PL".last_extra",
@ -566,7 +568,7 @@ local PlayerLabels = {
last_quick_kick = PL".last_quick_kick",
return_to_center = PL".return_to_center",
reloading = PL".reloading",
reloading = PLBOOL".reloading",
weapreccnt = { PL".weapreccnt" },
aim_mode = PL".aim_mode",
@ -581,29 +583,29 @@ local PlayerLabels = {
kickback_pic = PL".kickback_pic",
gm = PL".gm",
on_warping_sector = PL".on_warping_sector",
on_warping_sector = PLBOOL".on_warping_sector",
footprintcount = PL".footprintcount",
hurt_delay = PL".hurt_delay",
hbomb_on = PL".hbomb_on",
jumping_toggle = PL".jumping_toggle",
rapid_fire_hold = PL".rapid_fire_hold",
on_ground = PL".on_ground",
hbomb_on = PLBOOL".hbomb_on",
jumping_toggle = PLBOOL".jumping_toggle",
rapid_fire_hold = PLBOOL".rapid_fire_hold",
on_ground = PLBOOL".on_ground",
inven_icon = PL".inven_icon",
buttonpalette = PL".buttonpalette",
over_shoulder_on = PL".over_shoulder_on",
over_shoulder_on = PLBOOL".over_shoulder_on",
show_empty_weapon = PL".show_empty_weapon",
jetpack_on = PL".jetpack_on",
spritebridge = PL".spritebridge",
jetpack_on = PLBOOL".jetpack_on",
spritebridge = PLBOOL".spritebridge",
lastrandomspot = PL".lastrandomspot",
scuba_on = PL".scuba_on",
scuba_on = PLBOOL".scuba_on",
footprintpal = PL".footprintpal",
heat_on = PL".heat_on",
heat_on = PLBOOL".heat_on",
invdisptime = PL".invdisptime",
holster_weapon = PL".holster_weapon",
holster_weapon = PLBOOL".holster_weapon",
falling_counter = PL".falling_counter",
footprintshade = PL".footprintshade",
@ -615,7 +617,7 @@ local PlayerLabels = {
hard_landing = PL".hard_landing",
fist_incs = PL".fist_incs",
toggle_key_flag = PL".toggle_key_flag",
toggle_key_flag = PLBOOL".toggle_key_flag",
knuckle_incs = PL".knuckle_incs",
knee_incs = PL".knee_incs",
access_incs = PL".access_incs",

View file

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

View file

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

View file

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

View file

@ -470,7 +470,7 @@ local function reset_labels()
-- NOTE: these are read-only gamevars in C-CON
CLIPMASK0 = 65536+1, -- blocking
CLIPMASK1 = (256*65536)+64, -- hittable
-- TODO...?
-- TODO_MP
COOP = 0,
MULTIMODE = 0,
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: 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)
else
addcodef("%s=%d", gv.name, initval)

View file

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