mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 11:10:47 +00:00
Lunatic: spritesof{stat,sect} iterators that allow deletion inside the loop.
Also, - an optimization for sprite[]:setpos(). Calls to get_sprite_index() seem to be pretty slow (at least when they're not compiled). - add getzrange to the dynsymlists git-svn-id: https://svn.eduke32.com/eduke32@3560 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
83bc10791f
commit
0173c0908a
3 changed files with 46 additions and 5 deletions
|
@ -542,7 +542,9 @@ function spritetype_mt.__index.setpos(spr, pos) -- setsprite() clone
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (spr.sectnum ~= newsect) then
|
||||||
ffiC.changespritesect(get_sprite_idx(spr), newsect)
|
ffiC.changespritesect(get_sprite_idx(spr), newsect)
|
||||||
|
end
|
||||||
return newsect
|
return newsect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -757,9 +759,28 @@ local function iter_spritesofsect(sect, i)
|
||||||
if (i >= 0) then return i end
|
if (i >= 0) then return i end
|
||||||
end
|
end
|
||||||
|
|
||||||
function spritesofsect(sect)
|
-- sprites of sectnum iterator that allows deleting the iterated sprite
|
||||||
|
local function iter_spritesofsect_safe(tab, i)
|
||||||
|
if (i < 0) then
|
||||||
|
i = ffiC.headspritesect[-i]
|
||||||
|
else
|
||||||
|
i = tab[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
if (i >= 0) then
|
||||||
|
tab[1] = ffiC.nextspritesect[i]
|
||||||
|
return i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function spritesofsect(sect, maydelete)
|
||||||
check_sector_idx(sect)
|
check_sector_idx(sect)
|
||||||
|
|
||||||
|
if (maydelete) then
|
||||||
|
return iter_spritesofsect_safe, { -1 }, -sect
|
||||||
|
else
|
||||||
return iter_spritesofsect, sect, -1
|
return iter_spritesofsect, sect, -1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function iter_spritesofstat(stat, i)
|
local function iter_spritesofstat(stat, i)
|
||||||
|
@ -772,12 +793,30 @@ local function iter_spritesofstat(stat, i)
|
||||||
if (i >= 0) then return i end
|
if (i >= 0) then return i end
|
||||||
end
|
end
|
||||||
|
|
||||||
function spritesofstat(stat)
|
-- sprites of statnum iterator that allows deleting the iterated sprite
|
||||||
|
local function iter_spritesofstat_safe(tab, i)
|
||||||
|
if (i < 0) then
|
||||||
|
i = ffiC.headspritestat[-i]
|
||||||
|
else
|
||||||
|
i = tab[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
if (i >= 0) then
|
||||||
|
tab[1] = ffiC.nextspritestat[i]
|
||||||
|
return i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function spritesofstat(stat, maydelete)
|
||||||
if (stat >= ffiC.MAXSTATUS+0ULL) then
|
if (stat >= ffiC.MAXSTATUS+0ULL) then
|
||||||
error("passed invalid statnum to spritesofstat iterator", 2)
|
error("passed invalid statnum to spritesofstat iterator", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (maydelete) then
|
||||||
|
return iter_spritesofstat_safe, { -1 }, -stat
|
||||||
|
else
|
||||||
return iter_spritesofstat, stat, -1
|
return iter_spritesofstat, stat, -1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--== TROR iterators ==--
|
--== TROR iterators ==--
|
||||||
|
|
|
@ -51,6 +51,7 @@ getangle;
|
||||||
cansee;
|
cansee;
|
||||||
hitscan;
|
hitscan;
|
||||||
neartag;
|
neartag;
|
||||||
|
getzrange;
|
||||||
rotatesprite;
|
rotatesprite;
|
||||||
|
|
||||||
dist;
|
dist;
|
||||||
|
|
|
@ -51,6 +51,7 @@ getangle;
|
||||||
cansee;
|
cansee;
|
||||||
hitscan;
|
hitscan;
|
||||||
neartag;
|
neartag;
|
||||||
|
getzrange;
|
||||||
rotatesprite;
|
rotatesprite;
|
||||||
|
|
||||||
dist;
|
dist;
|
||||||
|
|
Loading…
Reference in a new issue