- give the tag manager a reference to the level.

This is needed for the compatibility search of the sector tag iterator which linearly searches the sector array.
This commit is contained in:
Christoph Oelckers 2019-01-28 01:33:52 +01:00
parent a7746278a8
commit 7211c1db0f
3 changed files with 8 additions and 3 deletions

View File

@ -154,6 +154,8 @@ struct FLevelData
struct FLevelLocals : public FLevelData
{
FLevelLocals() : tagManager(this) {}
friend class MapLoader;
void Tick();

View File

@ -346,11 +346,11 @@ int FSectorTagIterator::Next()
else
{
// with the tag manager, searching for tag 0 has to be different, because it won't create entries for untagged sectors.
while (start < (int)level.sectors.Size() && tagManager.SectorHasTags(start))
while (start < (int)tagManager.Level->sectors.Size() && tagManager.SectorHasTags(start))
{
start++;
}
if (start == (int)level.sectors.Size()) return -1;
if (start == (int)tagManager.Level->sectors.Size()) return -1;
ret = start;
start++;
}
@ -367,7 +367,7 @@ int FSectorTagIterator::NextCompat(bool compat, int start)
{
if (!compat) return Next();
for (unsigned i = start + 1; i < level.sectors.Size(); i++)
for (unsigned i = start + 1; i < tagManager.Level->sectors.Size(); i++)
{
if (level.SectorHasTag(i, searchtag)) return i;
}

View File

@ -29,6 +29,7 @@ class FTagManager
friend struct FLevelLocals;
friend class UDMFParser;
FLevelLocals *Level;
TArray<FTagItem> allTags;
TArray<FTagItem> allIDs;
TArray<int> startForSector;
@ -46,6 +47,8 @@ class FTagManager
return sect >= 0 && sect < (int)startForLine.Size() && startForLine[sect] >= 0;
}
FTagManager(FLevelLocals *l) : Level(l) {}
void Clear()
{
allTags.Clear();