Permalink
Browse files

- fixed: The sector tag iterator needs access to the level.

This is done through the tag manager to avoid #include dependency hell. Trying to reference FLevelLocals directly from the inline functions will inevitably create a circular dependency.
  • Loading branch information...
coelckers committed Jan 10, 2019
1 parent 72d09c0 commit 7e3ef4d72d6a2d33eadb9abf77581e2791a90c3e
Showing with 10 additions and 6 deletions.
  1. +5 −3 src/g_levellocals.h
  2. +3 −3 src/p_tags.cpp
  3. +2 −0 src/p_tags.h
@@ -110,9 +110,6 @@ struct FLevelData
TArray<FPlayerStart> AllPlayerStarts;

FBehaviorContainer Behaviors;

FTagManager tagManager;
AActor *TIDHash[128];

TArray<FStrifeDialogueNode *> StrifeDialogues;
FDialogueIDMap DialogueRoots;
@@ -124,6 +121,8 @@ struct FLevelData

struct FLevelLocals : public FLevelData
{
FLevelLocals() : tagManager(this) {}

void Tick();
void Mark();
void AddScroller(int secnum);
@@ -155,6 +154,9 @@ struct FLevelLocals : public FLevelData
memset(TIDHash, 0, sizeof(TIDHash));
}

FTagManager tagManager;
AActor *TIDHash[128];

DSectorMarker *SectorMarker;

uint8_t md5[16]; // for savegame validation. If the MD5 does not match the savegame won't be loaded.
@@ -328,11 +328,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++;
}
@@ -349,7 +349,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 (tagManager.SectorHasTag(i, searchtag)) return i;
}
@@ -24,6 +24,7 @@ class FTagManager
friend class FSectorTagIterator;
friend class FLineIdIterator;

FLevelLocals *Level;
TArray<FTagItem> allTags;
TArray<FTagItem> allIDs;
TArray<int> startForSector;
@@ -42,6 +43,7 @@ class FTagManager
}

public:
FTagManager(FLevelLocals *l) : Level(l) {}
void Clear()
{
allTags.Clear();

0 comments on commit 7e3ef4d

Please sign in to comment.