Replace usage of ThinkerIterator and BlockThingsIterator in various places where we can instead loop through sector thing lists.
While in the latter case this may result in longer loops, it also reduces GC thrashing by not needing to allocate an iterator every time. This also simplifies the DoBlast code as there is no longer a need to manually traverse portals vertically.
This commit is contained in:
parent
ea86ab99d0
commit
2bd1cb0657
17 changed files with 113 additions and 220 deletions
|
|
@ -5,18 +5,15 @@ extend Class Demolitionist
|
|||
{
|
||||
if ( player.cmd.buttons&BT_USER3 )
|
||||
{
|
||||
let bt = BlockThingsIterator.Create(self,800);
|
||||
while ( bt.Next() )
|
||||
foreach ( s:level.Sectors ) for ( Actor i=s.thinglist; i; i=i.snext )
|
||||
{
|
||||
let i = bt.Thing;
|
||||
if ( !i || (!(i is 'Inventory') && !(i is 'Chancebox') && !(i is 'SWWMRespawnTimer')) ) continue;
|
||||
if ( !(i is 'Inventory') && !(i is 'Chancebox') && !(i is 'SWWMRespawnTimer') ) continue;
|
||||
if ( (i is 'Inventory') && (i.bINVISIBLE || !i.bSPECIAL || Inventory(i).Owner) ) continue;
|
||||
if ( (i is 'Chancebox') && (i.CurState != i.SpawnState) ) continue;
|
||||
if ( !SWWMUtility.SphereIntersect(i,pos,800) ) continue;
|
||||
if ( !level.allmap && !i.CheckSight(self,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) ) continue;
|
||||
SWWMItemSense.Spawn(self,i);
|
||||
}
|
||||
bt.Destroy();
|
||||
}
|
||||
SWWMItemsense itm = itemsense;
|
||||
SWWMItemsense prev = null, next;
|
||||
|
|
@ -53,11 +50,9 @@ extend Class Demolitionist
|
|||
}
|
||||
if ( (magitem_cnt < 8) && !swwm_usetopickup )
|
||||
{
|
||||
let bt = BlockThingsIterator.Create(self,500);
|
||||
while ( bt.Next() )
|
||||
foreach ( s:level.Sectors ) for ( Actor t=s.thinglist; t; t=t.snext )
|
||||
{
|
||||
let t = bt.Thing;
|
||||
if ( !t || !(t is 'Inventory') || !t.bSPECIAL || !t.bDROPPED || t.bINVISIBLE || Inventory(t).Owner || !SWWMUtility.SphereIntersect(t,pos,500) || !CheckSight(t,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) )
|
||||
if ( !(t is 'Inventory') || !t.bSPECIAL || !t.bDROPPED || t.bINVISIBLE || Inventory(t).Owner || !SWWMUtility.SphereIntersect(t,pos,500) || !CheckSight(t,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) )
|
||||
continue;
|
||||
let i = Inventory(t);
|
||||
Class<Inventory> cls = i.GetClass();
|
||||
|
|
@ -87,7 +82,6 @@ extend Class Demolitionist
|
|||
magitem = nmi;
|
||||
magitem_cnt++;
|
||||
}
|
||||
bt.Destroy();
|
||||
}
|
||||
SWWMMagItem itm = magitem;
|
||||
SWWMMagItem prev = null, next;
|
||||
|
|
@ -529,14 +523,13 @@ extend Class Demolitionist
|
|||
Vector3 viewdir = SWWMUtility.Vec3FromAngles(angle,pitch);
|
||||
// look for things we could potentially bump into
|
||||
bool bumped = false;
|
||||
let bi = BlockThingsIterator.Create(self,500);
|
||||
let raging = RagekitPower(FindInventory("RagekitPower"));
|
||||
double maxmass = max(mass*spd/40.,200);
|
||||
if ( raging ) maxmass *= 2;
|
||||
while ( (spd > 0) && bi.Next() )
|
||||
foreach ( s:level.Sectors ) for ( Actor a=s.thinglist; a; a=a.snext )
|
||||
{
|
||||
a = bi.Thing;
|
||||
if ( !a || (a == self) || (!a.bSOLID && !a.bSHOOTABLE) || a.bTHRUACTORS || a.bCORPSE || !CanCollideWith(a,false) || !a.CanCollideWith(self,true) ) continue;
|
||||
if ( spd <= 0 ) break;
|
||||
if ( (a == self) || (!a.bSOLID && !a.bSHOOTABLE) || a.bTHRUACTORS || a.bCORPSE || !CanCollideWith(a,false) || !a.CanCollideWith(self,true) ) continue;
|
||||
if ( !SWWMUtility.ExtrudeIntersect(self,a,dir*(spd+radius),8) ) continue;
|
||||
if ( (a.pos.z <= a.floorz) && (a.height <= MaxStepHeight) ) continue;
|
||||
Vector3 diff = level.Vec3Diff(pos,a.pos);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue