Revert "Replace usage of ThinkerIterator and BlockThingsIterator in various places where we can instead loop through sector thing lists."

This reverts commit 2bd1cb0657.
This commit is contained in:
Mari the Deer 2023-07-29 13:48:33 +02:00
commit 3b10e684b6
17 changed files with 220 additions and 113 deletions

View file

@ -3,6 +3,7 @@
extend Class SWWMHandler
{
ui SWWMProjectionData projdata;
transient ui ThinkerIterator dbgti;
private ui void DrawWorldLine( RenderEvent e, Vector3 apos, Vector3 bpos, Color col )
{
@ -102,7 +103,10 @@ extend Class SWWMHandler
if ( !swwm_debugview ) return;
// prepare projection data, we're going to need this
SWWMUtility.PrepareProjData(projdata,e.ViewPos,e.ViewAngle,e.ViewPitch,e.ViewRoll,players[consoleplayer].fov);
foreach ( s:level.Sectors ) for ( Actor a=s.thinglist; a; a=a.snext )
if ( !dbgti ) dbgti = ThinkerIterator.Create("Actor");
else dbgti.Reinit();
Actor a;
while ( a = Actor(dbgti.Next()) )
{
if ( (a == players[consoleplayer].Camera) && !(players[consoleplayer].cheats&CF_CHASECAM) ) continue;
if ( a.bINVISIBLE && !(a is 'DynamicLight') ) continue;

View file

@ -178,18 +178,14 @@ extend Class SWWMHandler
// copies the floatbob of overlapping identical items, so it doesn't look weird
private void CopyFloatBob( Actor a )
{
bool breakout = false;
foreach ( s:level.Sectors )
let bt = BlockThingsIterator.Create(a,16);
while ( bt.Next() )
{
for ( Actor t=s.thinglist; t; t=t.snext )
{
if ( (t == a) || !(t is 'Inventory') || !(t.spawnpoint ~== a.spawnpoint) ) continue;
a.floatbobphase = t.floatbobphase;
a.angle = t.angle; // also copy angle
breakout = true;
break;
}
if ( breakout ) break;
let t = bt.Thing;
if ( !t || (t == a) || !(t is 'Inventory') || !(t.spawnpoint ~== a.spawnpoint) ) continue;
a.floatbobphase = t.floatbobphase;
a.angle = t.angle; // also copy angle
break;
}
}

View file

@ -98,9 +98,11 @@ extend Class SWWMHandler
}
bool enteredcombat = false;
// add new entries
if ( !cti ) cti = ThinkerIterator.Create("Actor");
else cti.Reinit();
Actor a, keyactor = null;
bool bossfound = false;
// we can use this instead of a thinker iterator as only actors that EXIST physically could count as combatants
foreach ( s:level.Sectors ) for ( Actor a=s.thinglist; a; a=a.snext )
while ( a = Actor(cti.Next()) )
{
if ( !a.player && !a.bISMONSTER ) continue;
// ignore the dead
@ -204,12 +206,12 @@ extend Class SWWMHandler
}
mapclearagain++;
if ( !iwantdie ) return;
for ( int i=0; i<MAXPLAYERS; i++ )
let ti = ThinkerIterator.Create("SWWMStats",Thinker.STAT_STATIC);
SWWMStats s;
while ( s = SWWMStats(ti.Next()) )
{
if ( !playeringame[i] ) continue;
let demo = Demolitionist(players[i].mo);
if ( !demo || !demo.mystats ) continue;
if ( demo.mystats.deaths > 0 ) return;
if ( s.deaths > 0 )
return;
}
SWWMUtility.MarkAchievement("wantdie",players[consoleplayer]);
}
@ -277,9 +279,11 @@ extend Class SWWMHandler
}
// update trackers for anything around the player
double viewdist = SWWMStatusBar.MAPVIEWDIST*swwm_mm_zoom;
// still about as expensive as using a BlockThingsIterator, but without the need to allocate one every tic
foreach ( s:level.Sectors ) for ( Actor a=s.thinglist; a; a=a.snext )
BlockThingsIterator bt = BlockThingsIterator.Create(players[consoleplayer].Camera,viewdist);
while ( bt.Next() )
{
let a = bt.Thing;
if ( !a ) continue;
Vector2 rv = a.pos.xy-players[consoleplayer].Camera.pos.xy;
if ( max(abs(rv.x)-a.radius,abs(rv.y)-a.radius) > viewdist )
continue;
@ -321,15 +325,19 @@ extend Class SWWMHandler
continue;
SWWMSimpleTracker.Track(self,a);
}
bt.Destroy();
// oh boy here we go
int thisgroup = players[consoleplayer].Camera.CurSector.portalgroup;
for ( int i=0; i<level.GetPortalGroupCount(); i++ )
{
if ( i == thisgroup ) continue;
Vector2 relpos = players[consoleplayer].Camera.pos.xy+level.GetDisplacement(thisgroup,i);
// still about as expensive as using a BlockThingsIterator, but without the need to allocate one every tic
foreach ( s:level.Sectors ) for ( Actor a=s.thinglist; a; a=a.snext )
if ( bt ) bt.Destroy();
bt = BlockThingsIterator.CreateFromPos(relpos.x,relpos.y,players[consoleplayer].Camera.pos.z,players[consoleplayer].Camera.pos.z+players[consoleplayer].Camera.height,viewdist,false);
while ( bt.Next() )
{
let a = bt.Thing;
if ( !a ) continue;
Vector2 rv = a.pos.xy-relpos;
if ( max(abs(rv.x)-a.radius,abs(rv.y)-a.radius) > viewdist )
continue;