From 35a5c82c42834cd5fc86fc9ccea007ba44f3cd70 Mon Sep 17 00:00:00 2001
From: Eidolon <furyhunter600@gmail.com>
Date: Fri, 27 May 2022 13:36:55 -0500
Subject: [PATCH] Update triggertag on sector tag fset

Fixes STJr/SRB2#865
---
 src/taglist.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/taglist.c b/src/taglist.c
index 9bc6021b09..e933b71fde 100644
--- a/src/taglist.c
+++ b/src/taglist.c
@@ -14,6 +14,7 @@
 #include "taglist.h"
 #include "z_zone.h"
 #include "r_data.h"
+#include "r_defs.h"
 
 // Bit array of whether a tag exists for sectors/lines/things.
 bitarray_t tags_available[BIT_ARRAY_SIZE (MAXTAGS)];
@@ -454,6 +455,13 @@ void Tag_SectorFSet (const size_t id, const mtag_t tag)
 	Taggroup_Remove(tags_sectors, curtag, id);
 	Taggroup_Add(tags_sectors, tag, id);
 	Tag_FSet(&sec->tags, tag);
+
+	// Sectors with linedef trigger effects need to have their trigger tag updated too
+	// This is a bit of a hack...
+	if (sec->flags & MSF_TRIGGERLINE_PLANE || sec->flags & MSF_TRIGGERLINE_MOBJ)
+	{
+		sec->triggertag = tag;
+	}
 }
 
 mtag_t Tag_NextUnused(mtag_t start)
-- 
GitLab