From 6f0caee4babaa517281cdb44b7d0c4b86b4bc917 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 4 May 2015 08:55:31 +0200 Subject: [PATCH] - fixed: Searching for tag 0 was no longer possible. The new tag manager considers tag 0 'untagged' and won't create entries in its tag list for it, so the normal search algorithm can not find any such sector. It now uses a linear search over all sectors instead, if tag 0 is looked for. --- src/p_tags.cpp | 13 ++++++++++++- src/p_tags.h | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/p_tags.cpp b/src/p_tags.cpp index e773b691fc..851c4ee94d 100644 --- a/src/p_tags.cpp +++ b/src/p_tags.cpp @@ -309,13 +309,24 @@ int FSectorTagIterator::Next() ret = start; start = -1; } - else + else if (searchtag != 0) { while (start >= 0 && tagManager.allTags[start].tag != searchtag) start = tagManager.allTags[start].nexttag; if (start == -1) return -1; ret = tagManager.allTags[start].target; start = tagManager.allTags[start].nexttag; } + else + { + // with the tag manager, searching for tag 0 has to be different, because it won't create entries for untagged sectors. + while (start < numsectors && tagManager.SectorHasTags(start)) + { + start++; + } + if (start == numsectors) return -1; + ret = start; + start++; + } return ret; } diff --git a/src/p_tags.h b/src/p_tags.h index 2195821c15..75d397d8d3 100644 --- a/src/p_tags.h +++ b/src/p_tags.h @@ -79,7 +79,7 @@ public: FSectorTagIterator(int tag) { searchtag = tag; - start = tagManager.TagHashFirst[((unsigned int)tag) % FTagManager::TAG_HASH_SIZE]; + start = tag == 0 ? 0 : tagManager.TagHashFirst[((unsigned int)tag) % FTagManager::TAG_HASH_SIZE]; } // Special constructor for actions that treat tag 0 as 'back of activation line'