diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 3eb3c810eb..0d18e9e018 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -154,6 +154,8 @@ struct FLevelData struct FLevelLocals : public FLevelData { + FLevelLocals() : tagManager(this) {} + friend class MapLoader; void Tick(); diff --git a/src/p_tags.cpp b/src/p_tags.cpp index bd012094df..db113daab7 100644 --- a/src/p_tags.cpp +++ b/src/p_tags.cpp @@ -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; } diff --git a/src/p_tags.h b/src/p_tags.h index aadeb8e7aa..7452ef755d 100644 --- a/src/p_tags.h +++ b/src/p_tags.h @@ -29,6 +29,7 @@ class FTagManager friend struct FLevelLocals; friend class UDMFParser; + FLevelLocals *Level; TArray allTags; TArray allIDs; TArray 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();