add CountSectorTags/CountSectorTags/CountLineIDs/GetLineID

This commit is contained in:
Ricardo Luís Vaz Silva 2023-01-17 21:55:46 -03:00 committed by Rachael Alexanderson
parent 239a288a9a
commit 793d6af5d1
4 changed files with 144 additions and 0 deletions

View file

@ -314,6 +314,92 @@ void FTagManager::DumpTags()
}
}
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
int FTagManager::CountSectorTags(const sector_t *sector)
{
int i = sector->Index();
if (SectorHasTags(i))
{
const int n = allTags.Size();
int j = startForSector[i];
int c = 0;
while(j < n && allTags[j].target == i)
{
j++;
c++;
}
return c;
}
return 0;
}
int FTagManager::GetSectorTag(const sector_t *sector, int index)
{
int i = sector->Index();
if (SectorHasTags(i))
{
const int n = allTags.Size();
int j = startForSector[i] + index;
return (j < n && allTags[j].target == i) ? allTags[j].tag : 0;
}
}
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
int FTagManager::CountLineIDs(const line_t *line)
{
int i = line->Index();
if (LineHasIDs(i))
{
const int n = allTags.Size();
int j = startForLine[i];
int c = 0;
while(j < n && allTags[j].target == i)
{
j++;
c++;
}
return c;
}
return 0;
}
int FTagManager::GetLineID(const line_t *line, int index)
{
int i = line->Index();
if (LineHasIDs(i))
{
const int n = allTags.Size();
int j = startForLine[i] + index;
return (j < n && allTags[j].target == i) ? allTags[j].tag : 0;
}
}
//-----------------------------------------------------------------------------
//
// RETURN NEXT SECTOR # THAT LINE TAG REFERS TO

View file

@ -77,6 +77,12 @@ public: // The ones below are called by functions that cannot be declared as fri
void RemoveLineIDs(int line);
void DumpTags();
int CountSectorTags(const sector_t *sector);
int GetSectorTag(const sector_t *sector, int index);
int CountLineIDs(const line_t *line);
int GetLineID(const line_t *line, int index);
};
class FSectorTagIterator

View file

@ -1139,6 +1139,29 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetXOffset, SetXOffset)
ACTION_RETURN_INT(self->e->XFloor.attached.Size());
}
static int CountSectorTags(const sector_t *self)
{
return level.tagManager.CountSectorTags(self);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, CountTags, CountSectorTags)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
ACTION_RETURN_INT(level.tagManager.CountSectorTags(self));
}
static int GetSectorTag(const sector_t *self, int index)
{
return level.tagManager.GetSectorTag(self, index);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetTag, GetSectorTag)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(index);
ACTION_RETURN_INT(level.tagManager.GetSectorTag(self, index));
}
static int Get3DFloorTexture(F3DFloor *self, int pos)
{
if ( pos )
@ -1240,6 +1263,29 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetXOffset, SetXOffset)
ACTION_RETURN_INT(LineIndex(self));
}
static int CountLineIDs(const line_t *self)
{
return level.tagManager.CountLineIDs(self);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Line, CountIDs, CountLineIDs)
{
PARAM_SELF_STRUCT_PROLOGUE(line_t);
ACTION_RETURN_INT(level.tagManager.CountLineIDs(self));
}
static int GetLineID(const line_t *self, int index)
{
return level.tagManager.GetLineID(self, index);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Line, GetID, GetLineID)
{
PARAM_SELF_STRUCT_PROLOGUE(line_t);
PARAM_INT(index);
ACTION_RETURN_INT(level.tagManager.GetLineID(self, index));
}
//===========================================================================
//
// side_t exports

View file

@ -254,6 +254,9 @@ struct Line native play
native clearscope int GetHealth() const;
native void SetHealth(int newhealth);
native int CountIDs() const;
native int GetID(int index) const;
}
struct SecPlane native play
@ -646,6 +649,9 @@ struct Sector native play
native clearscope int GetHealth(SectorPart part) const;
native void SetHealth(SectorPart part, int newhealth);
native int CountTags() const;
native int GetTag(int index) const;
}
class SectorTagIterator : Object native