From f9b1acb8139fb613335d363d30bf5a7ed5a30a92 Mon Sep 17 00:00:00 2001
From: Nev3r <apophycens@gmail.com>
Date: Wed, 15 Apr 2020 09:41:21 +0200
Subject: [PATCH] reworked Tag_FindLineSpecial()

---
 src/taglist.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/taglist.c b/src/taglist.c
index 61b8a147dd..f00f62ca4f 100644
--- a/src/taglist.c
+++ b/src/taglist.c
@@ -114,16 +114,20 @@ INT32 Tag_Iterate_Things (const INT16 tag, const size_t p)
 
 INT32 Tag_FindLineSpecial(const INT16 special, const INT16 tag)
 {
-	TAG_ITER_C
 	INT32 i;
 
-	TAG_ITER_LINES(tag, i)
+	if (tag == -1)
 	{
-		if (i == -1)
-			return -1;
-
-		if (lines[i].special == special)
-			return i;
+		for (i = 0; i < numlines; i++)
+			if (lines[i].special == special)
+				return i;
+	}
+	else if (tags_lines[tag])
+	{
+		taggroup_t *tagged = tags_lines[tag];
+		for (i = 0; i < tagged->count; i++)
+			if (lines[tagged->elements[i]].special == special)
+				return tagged->elements[i];
 	}
 	return -1;
 }
-- 
GitLab