- defined the iterators.

This commit is contained in:
Christoph Oelckers 2020-10-17 09:14:31 +02:00
parent 78afb67c7f
commit 0f2c19522e
3 changed files with 53 additions and 1 deletions

View file

@ -44,6 +44,7 @@ This file is a combination of code from the following sources:
#include "names.h"
#include "stats.h"
#include "constants.h"
#include "dukeactor.h"
BEGIN_DUKE_NS

View file

@ -0,0 +1,50 @@
#pragma once
#include "dobject.h"
#include "build.h"
BEGIN_DUKE_NS
// Iterator wrappers that return an actor pointer, not an index.
class DukeStatIterator : public StatIterator
{
public:
DukeStatIterator(int stat) : StatIterator(stat)
{
}
DDukeActor *Next()
{
int n = NextIndex();
return n >= 0? &hittype[n] : nullptr;
}
DDukeActor *Peek()
{
int n = PeekIndex();
return n >= 0? &hittype[n] : nullptr;
}
};
class DukeSectIterator : public SectIterator
{
public:
DukeSectIterator(int stat) : SectIterator(stat)
{
}
DDukeActor *Next()
{
int n = NextIndex();
return n >= 0? &hittype[n] : nullptr;
}
DDukeActor *Peek()
{
int n = PeekIndex();
return n >= 0? &hittype[n] : nullptr;
}
};
END_DUKE_NS

View file

@ -44,11 +44,12 @@ struct weaponhit
floorz = ceilingz = lastvx = lastvy = bposx = bposy = bposz = aflags = 0;
memset(temp_data, 0, sizeof(temp_data));
}
int GetIndex() const { return this - array(); }
};
extern weaponhit hittype[MAXSPRITES + 1];
inline weaponhit* weaponhit::array() { return hittype; }
using DDukeActor = weaponhit; // we do not really want that stupid name in our interface (but also not rename the struct yet.)
using DDukeActor = weaponhit; // we do not really want that stupid name in our interface (but also not rename the struct yet.) The preceding 'D' is for the DObject interface this should be transitioned to later.
struct animwalltype
{