diff --git a/polymer/eduke32/source/lunatic/con_lang.lua b/polymer/eduke32/source/lunatic/con_lang.lua index 8978404b5..a3b54640f 100644 --- a/polymer/eduke32/source/lunatic/con_lang.lua +++ b/polymer/eduke32/source/lunatic/con_lang.lua @@ -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", diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index 851209cec..3675f391f 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -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 diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index c8ec36b47..0890f025f 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -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, diff --git a/polymer/eduke32/source/lunatic/defs_common.lua b/polymer/eduke32/source/lunatic/defs_common.lua index 52e22a2e2..d8e3a2427 100644 --- a/polymer/eduke32/source/lunatic/defs_common.lua +++ b/polymer/eduke32/source/lunatic/defs_common.lua @@ -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 diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index 359d1d576..fdb9349fd 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -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) diff --git a/polymer/eduke32/source/lunatic/xmath.lua b/polymer/eduke32/source/lunatic/xmath.lua index 426e673ce..0d1d958a3 100644 --- a/polymer/eduke32/source/lunatic/xmath.lua +++ b/polymer/eduke32/source/lunatic/xmath.lua @@ -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