Lunatic: get rid of some now unneeded set-member methods, add others.

git-svn-id: https://svn.eduke32.com/eduke32@3652 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-04-07 15:20:37 +00:00
parent 478544acb6
commit fb41d91a50
6 changed files with 48 additions and 46 deletions

View file

@ -526,7 +526,7 @@ local PlayerLabels = {
ammo_amount = PL".ammo_amount[%s]" , ammo_amount = PL".ammo_amount[%s]" ,
-- NOTE: no direct access for .inv_amount (but see end) -- NOTE: no direct access for .inv_amount (but see end)
wackedbyactor = PL".wackedbyactor", wackedbyactor = { PL".wackedbyactor", PL":set_wackedbyactor(%%s)" },
pyoff = PL".pyoff", pyoff = PL".pyoff",
opyoff = PL".opyoff", opyoff = PL".opyoff",
@ -559,7 +559,7 @@ local PlayerLabels = {
random_club_frame = PL".random_club_frame", random_club_frame = PL".random_club_frame",
one_eighty_count = PL".one_eighty_count", one_eighty_count = PL".one_eighty_count",
dummyplayersprite = { PL".dummyplayersprite" }, dummyplayersprite = { PL".dummyplayersprite", PL":set_dummyplayersprite(%%s)" },
extra_extra8 = PL".extra_extra8", extra_extra8 = PL".extra_extra8",
actorsqu = PL".actorsqu", actorsqu = PL".actorsqu",
@ -602,7 +602,7 @@ local PlayerLabels = {
tipincs = PL".tipincs", tipincs = PL".tipincs",
hbomb_hold_delay = PL".hbomb_hold_delay", hbomb_hold_delay = PL".hbomb_hold_delay",
frag_ps = PL".frag_ps", frag_ps = { PL".frag_ps" },
kickback_pic = PL".kickback_pic", kickback_pic = PL".kickback_pic",
gm = PL".gm", gm = PL".gm",
@ -633,7 +633,7 @@ local PlayerLabels = {
footprintshade = PL".footprintshade", footprintshade = PL".footprintshade",
refresh_inventory = PL".refresh_inventory", refresh_inventory = PL".refresh_inventory",
last_full_weapon = PL".last_full_weapon", last_full_weapon = { PL".last_full_weapon" },
walking_snd_toggle = PL".walking_snd_toggle", walking_snd_toggle = PL".walking_snd_toggle",
palookup = PL".palookup", palookup = PL".palookup",
@ -649,10 +649,10 @@ local PlayerLabels = {
loogcnt = PL".loogcnt", loogcnt = PL".loogcnt",
scream_voice = PL".scream_voice", scream_voice = PL".scream_voice",
last_weapon = PL".last_weapon", last_weapon = { PL".last_weapon", PL":set_last_weapon(%%s)" },
cheat_phase = PL".cheat_phase", cheat_phase = PL".cheat_phase",
weapon_pos = PL".weapon_pos", weapon_pos = PL".weapon_pos",
wantweaponfire = PL".wantweaponfire", wantweaponfire = { PL".wantweaponfire" },
curr_weapon = { PL".curr_weapon", PL":set_curr_weapon(%%s)" }, curr_weapon = { PL".curr_weapon", PL":set_curr_weapon(%%s)" },

View file

@ -440,15 +440,15 @@ end
--- Helper functions (might be exported later) --- --- Helper functions (might be exported later) ---
local function have_ammo_at_max(ps, weap) local function have_ammo_at_max(ps, weap)
return (ps:get_ammo_amount(weap) >= ps:get_max_ammo_amount(weap)) return (ps.ammo_amount[weap] >= ps.max_ammo_amount[weap])
end end
local function P_AddAmmo(ps, weap, amount) local function P_AddAmmo(ps, weap, amount)
if (not have_ammo_at_max(ps, weap)) then if (not have_ammo_at_max(ps, weap)) then
local curamount = ps:get_ammo_amount(weap) local curamount = ps.ammo_amount[weap]
local maxamount = ps:get_max_ammo_amount(weap) local maxamount = ps.max_ammo_amount[weap]
-- NOTE: no clamping towards the bottom -- NOTE: no clamping towards the bottom
ps:set_ammo_amount(weap, math.min(curamount+amount, maxamount)) ps.ammo_amount[weap] = math.min(curamount+amount, maxamount)
end end
end end
@ -944,12 +944,12 @@ end
function _checkpinventory(ps, inv, amount, i) function _checkpinventory(ps, inv, amount, i)
if (inv==ffiC.GET_SHIELD) then if (inv==ffiC.GET_SHIELD) then
return ps:get_inv_amount(inv) ~= ps.max_shield_amount return ps.inv_amount[inv] ~= ps.max_shield_amount
elseif (inv==ffiC.GET_ACCESS) then elseif (inv==ffiC.GET_ACCESS) then
local palbit = PALBITS[sprite[i].pal] local palbit = PALBITS[sprite[i].pal]
return palbit and (bit.band(ps.got_access, palbit)~=0) return palbit and (bit.band(ps.got_access, palbit)~=0)
else else
return ps:get_inv_amount(inv) ~= amount return ps.inv_amount[inv] ~= amount
end end
end end
@ -966,7 +966,7 @@ local INV_SELECTION_ORDER = {
-- checkavailinven CON command -- checkavailinven CON command
function _selectnextinv(ps) function _selectnextinv(ps)
for _,inv in ipairs(INV_SELECTION_ORDER) do for _,inv in ipairs(INV_SELECTION_ORDER) do
if (ps:get_inv_amount(inv) > 0) then if (ps.inv_amount[inv] > 0) then
ps.inven_icon = ICONS[inv] ps.inven_icon = ICONS[inv]
return return
end end
@ -1413,7 +1413,7 @@ function _ifp(flags, pli, aci)
return true return true
elseif (band(l,2048)~=0 and ps.jetpack_on) then elseif (band(l,2048)~=0 and ps.jetpack_on) then
return true return true
elseif (band(l,4096)~=0 and ps:get_inv_amount(ffiC.GET_STEROIDS) > 0 and ps:get_inv_amount(ffiC.GET_STEROIDS) < 400) then elseif (band(l,4096)~=0 and ps.inv_amount.STEROIDS > 0 and ps.inv_amount.STEROIDS < 400) then
return true return true
elseif (band(l,8192)~=0 and ps.on_ground) then elseif (band(l,8192)~=0 and ps.on_ground) then
return true return true

View file

@ -215,7 +215,8 @@ __attribute__((packed)) struct {
int16_x_MAX_WEAPONS max_ammo_amount; int16_x_MAX_WEAPONS max_ammo_amount;
int16_x_MAX_WEAPONS ammo_amount; int16_x_MAX_WEAPONS ammo_amount;
int16_x_GET_MAX inv_amount; int16_x_GET_MAX inv_amount;
int16_t wackedbyactor, pyoff, opyoff; const int16_t wackedbyactor;
int16_t pyoff, opyoff;
int16_t horiz, horizoff, ohoriz, ohorizoff; int16_t horiz, horizoff, ohoriz, ohorizoff;
const int16_t newowner; const int16_t newowner;
@ -246,7 +247,9 @@ __attribute__((packed)) struct {
bool reloading; bool reloading;
const uint8_t weapreccnt; const uint8_t weapreccnt;
uint8_t aim_mode, auto_aim, weaponswitch, movement_lock, team; uint8_t aim_mode, auto_aim, weaponswitch, movement_lock, team;
uint8_t tipincs, hbomb_hold_delay, frag_ps, kickback_pic; uint8_t tipincs, hbomb_hold_delay;
const uint8_t frag_ps;
uint8_t kickback_pic;
uint8_t gm; uint8_t gm;
bool on_warping_sector; bool on_warping_sector;
@ -267,15 +270,17 @@ __attribute__((packed)) struct {
bool holster_weapon; bool holster_weapon;
uint8_t falling_counter, footprintshade; uint8_t falling_counter, footprintshade;
uint8_t refresh_inventory, last_full_weapon; uint8_t refresh_inventory;
const uint8_t last_full_weapon;
bool toggle_key_flag; bool toggle_key_flag;
uint8_t knuckle_incs, knee_incs, access_incs; uint8_t knuckle_incs, knee_incs, access_incs;
uint8_t walking_snd_toggle, palookup, hard_landing, fist_incs; uint8_t walking_snd_toggle, palookup, hard_landing, fist_incs;
int8_t numloogs, loogcnt, scream_voice; int8_t numloogs, loogcnt, scream_voice;
int8_t last_weapon, cheat_phase, weapon_pos, wantweaponfire; const int8_t last_weapon;
const int8_t curr_weapon; int8_t cheat_phase, weapon_pos;
const int8_t wantweaponfire, curr_weapon;
uint8_t palette; uint8_t palette;
palette_t _pals; palette_t _pals;
@ -1003,33 +1008,16 @@ ffi.metatype("weaponaccess_t", weaponaccess_mt)
local player_mt = { local player_mt = {
__index = { __index = {
--- Getters/setters --- Getters/setters
get_ammo_amount = function(p, weap)
return p.ammo_amount[weap]
end,
set_ammo_amount = function(p, weap, amount)
p.ammo_amount[weap] = amount
end,
get_max_ammo_amount = function(p, weap)
return p.max_ammo_amount[weap]
end,
set_max_ammo_amount = function(p, weap, amount)
p.max_ammo_amount[weap] = amount
end,
set_curr_weapon = function(p, weap) set_curr_weapon = function(p, weap)
check_weapon_idx(weap) check_weapon_idx(weap)
ffi.cast(player_ptr_ct, p).curr_weapon = weap ffi.cast(player_ptr_ct, p).curr_weapon = weap
end, end,
get_inv_amount = function(p, inv) set_last_weapon = function(p, weap)
return p.inv_amount[inv] if (not (weap < 0)) then
end, check_weapon_idx(weap)
end
set_inv_amount = function(p, inv, amount) ffi.cast(player_ptr_ct, p).last_weapon = weap
p.inv_amount[inv] = amount
end, end,
set_ftq = function(p, ftq) set_ftq = function(p, ftq)
@ -1049,6 +1037,20 @@ local player_mt = {
ffi.cast(player_ptr_ct, p).customexitsound = soundnum ffi.cast(player_ptr_ct, p).customexitsound = soundnum
end, end,
set_dummyplayersprite = function(p, spritenum)
if (not (spritenum < 0)) then
check_sprite_idx(spritenum)
end
ffi.cast(player_ptr_ct, p).dummyplayersprite = spritenum
end,
set_wackedbyactor = function(p, spritenum)
if (not (spritenum < 0)) then
check_sprite_idx(spritenum)
end
ffi.cast(player_ptr_ct, p).wackedbyactor = spritenum
end,
-- CON-like addammo/addweapon, but without the non-local control flow -- CON-like addammo/addweapon, but without the non-local control flow
-- (returns true if weapon's ammo was at the max. instead). -- (returns true if weapon's ammo was at the max. instead).
addammo = con._addammo, addammo = con._addammo,

View file

@ -2326,7 +2326,7 @@ local Cinner = {
showviewunbiased = cmd(R,R,R,R,R,R,R,R,R,R) -- 10R showviewunbiased = cmd(R,R,R,R,R,R,R,R,R,R) -- 10R
/ "", -- TODO / "", -- TODO
smaxammo = cmd(R,R) smaxammo = cmd(R,R)
/ PLS":set_max_ammo_amount(%1,%2)", / PLS".max_ammo_amount[%1]=%2",
gmaxammo = cmd(R,W) gmaxammo = cmd(R,W)
/ ("%2="..PLS".max_ammo_amount[%1]"), / ("%2="..PLS".max_ammo_amount[%1]"),
spriteflags = cmd(R) -- also see outer spriteflags = cmd(R) -- also see outer
@ -3207,7 +3207,7 @@ local function handle_cmdline_arg(str)
g_warn[warnstr] = val g_warn[warnstr] = val
ok = true ok = true
end end
elseif (str:sub(2)=="fno") then elseif (str:sub(2,4)=="fno") then -- NOTE: not ":sub(2)"
-- Disable printing code. -- Disable printing code.
if (#str >= 5 and str:sub(5)=="=onlycheck") then if (#str >= 5 and str:sub(5)=="=onlycheck") then
g_cgopt["no"] = "onlycheck" g_cgopt["no"] = "onlycheck"

View file

@ -4680,9 +4680,8 @@ void P_ProcessInput(int32_t snum)
{ {
if (p->on_ground == 1) if (p->on_ground == 1)
{ {
if (p->dummyplayersprite == -1) if (p->dummyplayersprite < 0)
p->dummyplayersprite = p->dummyplayersprite = A_Spawn(p->i,PLAYERONWATER);
A_Spawn(p->i,PLAYERONWATER);
sprite[p->dummyplayersprite].pal = sprite[p->i].pal; sprite[p->dummyplayersprite].pal = sprite[p->i].pal;
sprite[p->dummyplayersprite].cstat |= 32768; sprite[p->dummyplayersprite].cstat |= 32768;

View file

@ -161,6 +161,7 @@ typedef struct {
// * int16_t --> int8_t // * int16_t --> int8_t
// * char --> int8_t // * char --> int8_t
// Need to carefully think about implications! // Need to carefully think about implications!
// TODO: rearrange this is the opportunity arises!
// KEEPINSYNC lunatic/defs.ilua // KEEPINSYNC lunatic/defs.ilua
typedef struct { typedef struct {
vec3_t pos, opos, vel, npos; vec3_t pos, opos, vel, npos;