- added SectorTagIterator and LineIDIterator script classes.

This commit is contained in:
Christoph Oelckers 2017-03-09 17:05:51 +01:00
parent 420f71fc4f
commit 20c56f6dda
4 changed files with 97 additions and 13 deletions

View file

@ -1243,17 +1243,11 @@ void FMultiBlockThingsIterator::Reset()
class DBlockThingsIterator : public DObject, public FMultiBlockThingsIterator
{
DECLARE_CLASS(DBlockThingsIterator, DObject);
DECLARE_ABSTRACT_CLASS(DBlockThingsIterator, DObject);
FPortalGroupArray check;
protected:
DBlockThingsIterator()
:FMultiBlockThingsIterator(check)
{
}
public:
FMultiBlockThingsIterator::CheckResult cres;
public:
bool Next()
{
return FMultiBlockThingsIterator::Next(&cres);
@ -1276,7 +1270,7 @@ public:
}
};
IMPLEMENT_CLASS(DBlockThingsIterator, false, false);
IMPLEMENT_CLASS(DBlockThingsIterator, true, false);
DEFINE_ACTION_FUNCTION(DBlockThingsIterator, Create)
{

View file

@ -362,3 +362,65 @@ int FLineIdIterator::Next()
start = tagManager.allIDs[start].nexttag;
return ret;
}
class DSectorTagIterator : public DObject, public FSectorTagIterator
{
DECLARE_ABSTRACT_CLASS(DSectorTagIterator, DObject);
public:
DSectorTagIterator(int tag, line_t *line)
{
if (line == nullptr) Init(tag);
else Init(tag, line);
}
};
IMPLEMENT_CLASS(DSectorTagIterator, true, false);
DEFINE_ACTION_FUNCTION(DSectorTagIterator, Create)
{
PARAM_PROLOGUE;
PARAM_INT(tag);
PARAM_POINTER_DEF(line, line_t);
ACTION_RETURN_POINTER(new DSectorTagIterator(tag, line));
}
DEFINE_ACTION_FUNCTION(DSectorTagIterator, Next)
{
PARAM_SELF_PROLOGUE(DSectorTagIterator);
ACTION_RETURN_INT(self->Next());
}
DEFINE_ACTION_FUNCTION(DSectorTagIterator, NextCompat)
{
PARAM_SELF_PROLOGUE(DSectorTagIterator);
PARAM_BOOL(compat);
PARAM_INT(secnum);
ACTION_RETURN_INT(self->NextCompat(compat, secnum));
}
class DLineIdIterator : public DObject, public FLineIdIterator
{
DECLARE_ABSTRACT_CLASS(DLineIdIterator, DObject);
public:
DLineIdIterator(int tag)
: FLineIdIterator(tag)
{
}
};
IMPLEMENT_CLASS(DLineIdIterator, true, false);
DEFINE_ACTION_FUNCTION(DLineIdIterator, Create)
{
PARAM_PROLOGUE;
PARAM_INT(tag);
ACTION_RETURN_POINTER(new DLineIdIterator(tag));
}
DEFINE_ACTION_FUNCTION(DLineIdIterator, Next)
{
PARAM_SELF_PROLOGUE(DLineIdIterator);
ACTION_RETURN_INT(self->Next());
}

View file

@ -77,15 +77,18 @@ protected:
int searchtag;
int start;
public:
FSectorTagIterator(int tag)
FSectorTagIterator()
{
// For DSectorTagIterator
}
void Init(int tag)
{
searchtag = tag;
start = tag == 0 ? 0 : tagManager.TagHashFirst[((unsigned int)tag) % FTagManager::TAG_HASH_SIZE];
}
// Special constructor for actions that treat tag 0 as 'back of activation line'
FSectorTagIterator(int tag, line_t *line)
void Init(int tag, line_t *line)
{
if (tag == 0)
{
@ -99,6 +102,18 @@ public:
}
}
public:
FSectorTagIterator(int tag)
{
Init(tag);
}
// Special constructor for actions that treat tag 0 as 'back of activation line'
FSectorTagIterator(int tag, line_t *line)
{
Init(tag, line);
}
int Next();
int NextCompat(bool compat, int secnum);
};

View file

@ -440,3 +440,16 @@ struct Sector native play
}
}
class SectorTagIterator : Object native
{
native static SectorTagIterator(int tag, line defline = null);
native int Next();
native int NextCompat(bool compat, int secnum);
}
class LineIdIterator : Object native
{
native static LineIdIterator(int tag);
native int Next();
}