- 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 struct FLevelLocals : public FLevelData
{ {
FLevelLocals() : tagManager(this) {}
friend class MapLoader; friend class MapLoader;
void Tick(); void Tick();

View file

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

View file

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