mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
Return early from A_IncurDamage() if actor[].picnum ("htpicnum" in CON) is < 0.
With this change, it is impossible for negative values to be used as array indices inside this function, and I believe that it is also impossible that they escape to somewhere they might be used as such. For Lunatic, allow setting actor[].picnum to negative values and in the translator, add (commented out) code to warn whenever it is set to a constant negative value. Also, fix a _sound call in _addphealth in control.lua. git-svn-id: https://svn.eduke32.com/eduke32@3626 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
6c624a6221
commit
53f6d749df
4 changed files with 13 additions and 4 deletions
|
@ -889,7 +889,8 @@ int32_t A_IncurDamage(int32_t sn)
|
|||
spritetype *const targ = &sprite[sn];
|
||||
actor_t *const dmg = &actor[sn];
|
||||
|
||||
if (dmg->extra < 0 || targ->extra < 0)
|
||||
// dmg->picnum check: safety, since it might have been set to <0 from CON.
|
||||
if (dmg->extra < 0 || targ->extra < 0 || dmg->picnum < 0)
|
||||
{
|
||||
dmg->extra = -1;
|
||||
return -1;
|
||||
|
@ -1913,7 +1914,7 @@ ACTOR_STATIC void G_MoveStandables(void)
|
|||
|
||||
if (s->picnum == FIREEXT)
|
||||
{
|
||||
if (A_IncurDamage(i) == -1)
|
||||
if (A_IncurDamage(i) < 0)
|
||||
goto BOLT;
|
||||
|
||||
for (k=0; k<16; k++)
|
||||
|
|
|
@ -1014,7 +1014,7 @@ function _addphealth(ps, aci, hlthadd)
|
|||
local qmaxhlth = bit.rshift(ps.max_player_health, 2)
|
||||
if (j-hlthadd < qmaxhlth and j >= qmaxhlth) then
|
||||
-- XXX: DUKE_GOTHEALTHATLOW
|
||||
_sound(229, aci)
|
||||
_sound(aci, 229)
|
||||
end
|
||||
|
||||
ps.last_extra = j
|
||||
|
|
|
@ -917,7 +917,9 @@ local actor_mt = {
|
|||
end,
|
||||
|
||||
set_picnum = function(a, picnum)
|
||||
check_tile_idx(picnum)
|
||||
if (picnum >= 0) then
|
||||
check_tile_idx(picnum)
|
||||
end
|
||||
ffi.cast(actor_ptr_ct, a).picnum = picnum
|
||||
end,
|
||||
|
||||
|
|
|
@ -1596,6 +1596,12 @@ end
|
|||
local function SetStructCmd(accessfunc, pattern)
|
||||
local function capfunc(idx, memb, var)
|
||||
local membercode, ismethod = accessfunc(true, idx, memb)
|
||||
--[[
|
||||
local member = memb[1]:lower()
|
||||
if (type(var)=="number" and var<0 and member:match("picnum")) then
|
||||
warnprintf("member '.%s' is set to a negative value", member)
|
||||
end
|
||||
--]]
|
||||
if (ismethod) then
|
||||
-- METHOD_MEMBER syntax
|
||||
|
||||
|
|
Loading…
Reference in a new issue