- got rid of the sole linear sprite iterator in Exhumed and deleted the iterator code entirely.

This commit is contained in:
Christoph Oelckers 2021-12-04 13:08:44 +01:00
parent 8c298de114
commit e13a275cfc
5 changed files with 24 additions and 33 deletions

View file

@ -286,29 +286,6 @@ public:
}
};
// For iterating linearly over map spawned sprites. Will later only be valid on map load
template<class TActor>
class TLinearSpriteIterator
{
int index = 0;
public:
void Reset()
{
index = 0;
}
TActor* Next()
{
while (index < MAXSPRITES)
{
auto p = actorArray[index++];
if (p->s().statnum != MAXSTATUS) return static_cast<TActor*>(p);
}
return nullptr;
}
};
using CoreSectIterator = TSectIterator<DCoreActor>;

View file

@ -431,7 +431,6 @@ void allocateMapArrays(int numsprites)
memset(sector.Data(), 0, sizeof(sectortype) * numsectors);
wall.Resize(numwalls);
memset(wall.Data(), 0, sizeof(walltype) * numwalls);
memset(sprite, 0, sizeof(*sprite) * MAXSPRITES);
memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES + MAXUNIQHUDID));

View file

@ -87,7 +87,7 @@ extern int Counters[kNumCounters];
void SnapSectors(sectortype* pSectorA, sectortype* pSectorB, int b);
void LoadObjects();
void LoadObjects(TArray<DExhumedActor*>& actors);
// light

View file

@ -61,7 +61,6 @@ using Collision = TCollision<DExhumedActor>;
using ExhumedStatIterator = TStatIterator<DExhumedActor>;
using ExhumedSectIterator = TSectIterator<DExhumedActor>;
using ExhumedSpriteIterator = TSpriteIterator<DExhumedActor>;
using ExhumedLinearSpriteIterator = TLinearSpriteIterator<DExhumedActor>;
inline FSerializer& Serialize(FSerializer& arc, const char* keyname, DExhumedActor*& w, DExhumedActor** def)

View file

@ -57,6 +57,23 @@ int Counters[kNumCounters];
uint8_t bIsVersion6 = true;
//---------------------------------------------------------------------------
//
// this is just a dummy for now to provide the intended setup.
//
//---------------------------------------------------------------------------
static TArray<DExhumedActor*> spawnactors(SpawnSpriteDef& spawns)
{
insertAllSprites(spawns);
TArray<DExhumedActor*> actorlist;
for (unsigned i = 0; i < spawns.sprites.Size(); i++)
{
if (exhumedActors[i].exists()) actorlist.Push(&exhumedActors[i]);
}
return actorlist;
}
uint8_t LoadLevel(MapRecord* map)
@ -124,7 +141,7 @@ uint8_t LoadLevel(MapRecord* map)
inity = startPos.y;
initz = startPos.z;
initsectp = &sector[initsect];
insertAllSprites(spawned);
auto actors = spawnactors(spawned);
int i;
@ -149,7 +166,7 @@ uint8_t LoadLevel(MapRecord* map)
flash = 0;
precache();
LoadObjects();
LoadObjects(actors);
return true;
}
@ -707,13 +724,12 @@ void ProcessSpriteTag(DExhumedActor* pActor, int nLotag, int nHitag)
DeleteActor(pActor);
}
void ExamineSprites()
void ExamineSprites(TArray<DExhumedActor*>& actors)
{
nNetStartSprites = 0;
nCurStartSprite = 0;
ExhumedLinearSpriteIterator it;
while (auto ac = it.Next())
for(auto& ac : actors)
{
auto pSprite = &ac->s();
@ -751,7 +767,7 @@ void ExamineSprites()
}
}
void LoadObjects()
void LoadObjects(TArray<DExhumedActor*>& actors)
{
runlist_InitRun();
runlist_InitChan();
@ -796,7 +812,7 @@ void LoadObjects()
}
}
ExamineSprites();
ExamineSprites(actors);
PostProcess();
InitRa();
InitChunks();