From cad282142d60dcb1ed53c9545ad4616a4e92542b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Apr 2015 18:22:39 +0200 Subject: [PATCH] - fixed some last issues with the tag manager. --- src/p_setup.cpp | 2 +- src/p_tags.cpp | 29 +++++++++++++++++++++++++---- src/p_tags.h | 6 ++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 166230e3d..f22979eac 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -2223,7 +2223,7 @@ void P_LoadLineDefs2 (MapData * map) mld = (maplinedef2_t *)mldf; ld = lines; - for (i = numlines; i > 0; i--, mld++, ld++) + for (i = 0; i < numlines; i++, mld++, ld++) { int j; diff --git a/src/p_tags.cpp b/src/p_tags.cpp index f4164184f..7e958dcca 100644 --- a/src/p_tags.cpp +++ b/src/p_tags.cpp @@ -269,6 +269,29 @@ bool FTagManager::LineHasID(const line_t *line, int tag) const return LineHasID(lineindex(line), tag); } +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void FTagManager::DumpTags() +{ + for (unsigned i = 0; i < allTags.Size(); i++) + { + Printf("Sector %d, tag %d\n", allTags[i].target, allTags[i].tag); + } + for (unsigned i = 0; i < allIDs.Size(); i++) + { + Printf("Line %d, ID %d\n", allIDs[i].target, allIDs[i].tag); + } +} + +CCMD(dumptags) +{ + tagManager.DumpTags(); +} + //----------------------------------------------------------------------------- // // RETURN NEXT SECTOR # THAT LINE TAG REFERS TO @@ -290,7 +313,7 @@ int FSectorTagIterator::Next() { while (start >= 0 && tagManager.allTags[start].tag != searchtag) start = tagManager.allTags[start].nexttag; if (start == -1) return -1; - ret = start; + ret = tagManager.allTags[start].target; start = start = tagManager.allTags[start].nexttag; } return ret; @@ -324,9 +347,7 @@ int FLineIdIterator::Next() { while (start >= 0 && tagManager.allIDs[start].tag != searchtag) start = tagManager.allIDs[start].nexttag; if (start == -1) return -1; - int ret = start; + int ret = tagManager.allIDs[start].target; start = start = tagManager.allIDs[start].nexttag; return ret; } - - diff --git a/src/p_tags.h b/src/p_tags.h index 7a63ca74b..2195821c1 100644 --- a/src/p_tags.h +++ b/src/p_tags.h @@ -36,6 +36,10 @@ class FTagManager return sect >= 0 && sect < (int)startForSector.Size() && startForSector[sect] >= 0; } + bool LineHasIDs(int sect) const + { + return sect >= 0 && sect < (int)startForLine.Size() && startForLine[sect] >= 0; + } public: void Clear() @@ -59,6 +63,8 @@ public: void AddSectorTag(int sector, int tag); void AddLineID(int line, int tag); void RemoveSectorTags(int sect); + + void DumpTags(); }; extern FTagManager tagManager;