From 8d8f62baefdcbb1b71d75d505b95e3cc4a675056 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Fri, 28 May 2021 23:59:39 -0400 Subject: [PATCH 01/10] Add additional multitagging functionality --- extras/conf/SRB2-22.cfg | 14 ++++++++++++++ src/p_setup.c | 33 +++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index d36c16b75..ad930a485 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -640,22 +640,36 @@ linedeftypes prefix = "(63)"; } + 96 + { + title = "Apply Tag to Tagged Sectors"; + prefix = "(96)"; + flags8192text = "[13] Use Front Side Offsets"; + flags32768text = "[15] Use Back Side Offsets"; + } + 97 { title = "Apply Tag to Front Sector"; prefix = "(97)"; + flags8192text = "[13] Use Front Side Offsets"; + flags32768text = "[15] Use Back Side Offsets"; } 98 { title = "Apply Tag to Back Sector"; prefix = "(98)"; + flags8192text = "[13] Use Front Side Offsets"; + flags32768text = "[15] Use Back Side Offsets"; } 99 { title = "Apply Tag to Front and Back Sectors"; prefix = "(99)"; + flags8192text = "[13] Use Front Side Offsets"; + flags32768text = "[15] Use Back Side Offsets"; } 540 diff --git a/src/p_setup.c b/src/p_setup.c index 16c080248..6375decac 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2952,19 +2952,44 @@ static void P_LinkMapData(void) // For maps in binary format, add multi-tags from linedef specials. This must be done // before any linedef specials have been processed. +static void P_AddBinaryMapTagsFromLine(sector_t *sector, line_t *line) +{ + Tag_Add(§or->tags, Tag_FGet(&line->tags)); + if (line->flags & ML_EFFECT6) { + if (sides[line->sidenum[0]].textureoffset) + Tag_Add(§or->tags, (INT32)sides[line->sidenum[0]].textureoffset); + if (sides[line->sidenum[0]].rowoffset) + Tag_Add(§or->tags, (INT32)sides[line->sidenum[0]].rowoffset); + } + if (line->flags & ML_TFERLINE) { + if (sides[line->sidenum[1]].textureoffset) + Tag_Add(§or->tags, (INT32)sides[line->sidenum[1]].textureoffset); + if (sides[line->sidenum[1]].rowoffset) + Tag_Add(§or->tags, (INT32)sides[line->sidenum[1]].rowoffset); + } +} + static void P_AddBinaryMapTags(void) { size_t i; for (i = 0; i < numlines; i++) { + // 96: Apply Tag to Tagged Sectors // 97: Apply Tag to Front Sector // 98: Apply Tag to Back Sector // 99: Apply Tag to Front and Back Sectors - if (lines[i].special == 97 || lines[i].special == 99) - Tag_Add(&lines[i].frontsector->tags, Tag_FGet(&lines[i].tags)); - if (lines[i].special == 98 || lines[i].special == 99) - Tag_Add(&lines[i].backsector->tags, Tag_FGet(&lines[i].tags)); + if (lines[i].special == 96) { + mtag_t tag = Tag_FGet(&lines[i].frontsector->tags); + INT32 s; + TAG_ITER_DECLARECOUNTER(0); + TAG_ITER_SECTORS(0, tag, s) + P_AddBinaryMapTagsFromLine(§ors[s], &lines[i]); + } else if (lines[i].special == 97 || lines[i].special == 99) { + P_AddBinaryMapTagsFromLine(lines[i].frontsector, &lines[i]); + } else if (lines[i].special == 98 || lines[i].special == 99) { + P_AddBinaryMapTagsFromLine(lines[i].backsector, &lines[i]); + } } } From 7d71d534d47941faaa5dbe962a20b52ab850a8b8 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sat, 29 May 2021 00:40:06 -0400 Subject: [PATCH 02/10] Add missing "/ FRACUNIT" to texture offset code --- src/p_setup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 6375decac..4bb47c943 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2957,15 +2957,15 @@ static void P_AddBinaryMapTagsFromLine(sector_t *sector, line_t *line) Tag_Add(§or->tags, Tag_FGet(&line->tags)); if (line->flags & ML_EFFECT6) { if (sides[line->sidenum[0]].textureoffset) - Tag_Add(§or->tags, (INT32)sides[line->sidenum[0]].textureoffset); + Tag_Add(§or->tags, (INT32)sides[line->sidenum[0]].textureoffset / FRACUNIT); if (sides[line->sidenum[0]].rowoffset) - Tag_Add(§or->tags, (INT32)sides[line->sidenum[0]].rowoffset); + Tag_Add(§or->tags, (INT32)sides[line->sidenum[0]].rowoffset / FRACUNIT); } if (line->flags & ML_TFERLINE) { if (sides[line->sidenum[1]].textureoffset) - Tag_Add(§or->tags, (INT32)sides[line->sidenum[1]].textureoffset); + Tag_Add(§or->tags, (INT32)sides[line->sidenum[1]].textureoffset / FRACUNIT); if (sides[line->sidenum[1]].rowoffset) - Tag_Add(§or->tags, (INT32)sides[line->sidenum[1]].rowoffset); + Tag_Add(§or->tags, (INT32)sides[line->sidenum[1]].rowoffset / FRACUNIT); } } From eee894581aecc4575baf0edb4cb46941806efbf8 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sat, 29 May 2021 00:54:31 -0400 Subject: [PATCH 03/10] Make linedef 96 skip the control sector --- src/p_setup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 4bb47c943..336cf9886 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2983,8 +2983,10 @@ static void P_AddBinaryMapTags(void) mtag_t tag = Tag_FGet(&lines[i].frontsector->tags); INT32 s; TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(0, tag, s) - P_AddBinaryMapTagsFromLine(§ors[s], &lines[i]); + TAG_ITER_SECTORS(0, tag, s) { + if (s != lines[i].frontsector - sectors) // Skip the control sector + P_AddBinaryMapTagsFromLine(§ors[s], &lines[i]); + } } else if (lines[i].special == 97 || lines[i].special == 99) { P_AddBinaryMapTagsFromLine(lines[i].frontsector, &lines[i]); } else if (lines[i].special == 98 || lines[i].special == 99) { From 93de054786147c7f64360177cd271ed70eedb2fb Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sat, 29 May 2021 11:08:46 -0400 Subject: [PATCH 04/10] Fix linedef type 96 (I had it all wrong) --- src/p_setup.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 336cf9886..0d061aaab 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2980,12 +2980,36 @@ static void P_AddBinaryMapTags(void) // 98: Apply Tag to Back Sector // 99: Apply Tag to Front and Back Sectors if (lines[i].special == 96) { + size_t j; mtag_t tag = Tag_FGet(&lines[i].frontsector->tags); - INT32 s; - TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(0, tag, s) { - if (s != lines[i].frontsector - sectors) // Skip the control sector - P_AddBinaryMapTagsFromLine(§ors[s], &lines[i]); + mtag_t target_tags[5]; + target_tags[0] = Tag_FGet(&lines[i].tags); + if (lines[i].flags & ML_EFFECT6) { + target_tags[1] = (INT32)sides[lines[i].sidenum[0]].textureoffset / FRACUNIT; + target_tags[2] = (INT32)sides[lines[i].sidenum[0]].rowoffset / FRACUNIT; + } else { + target_tags[1] = target_tags[2] = 0; + } + if (lines[i].flags & ML_TFERLINE) { + target_tags[3] = (INT32)sides[lines[i].sidenum[1]].textureoffset / FRACUNIT; + target_tags[4] = (INT32)sides[lines[i].sidenum[1]].rowoffset / FRACUNIT; + } else { + target_tags[3] = target_tags[4] = 0; + } + + for (j = 0; j < numsectors; j++) { + CONS_Printf("Sector %zu (tag %d):\n", j, Tag_FGet(§ors[j].tags)); + size_t k; for (k = 0; k < 5; k++) { + if (k > 0 && !target_tags[k]) + continue; + if (Tag_Find(§ors[j].tags, target_tags[k])) { + Tag_Add(§ors[j].tags, tag); + CONS_Printf(" Tag %d found, added tag %d\n", target_tags[k], tag); + break; + } else { + CONS_Printf(" Tag %d not found\n", target_tags[k]); + } + } } } else if (lines[i].special == 97 || lines[i].special == 99) { P_AddBinaryMapTagsFromLine(lines[i].frontsector, &lines[i]); From 5090de58097eed382a58402af0f3217eb3493381 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sat, 29 May 2021 12:09:30 -0400 Subject: [PATCH 05/10] Remove leftover debug printfs --- src/p_setup.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 0d061aaab..ea655f5f9 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2998,16 +2998,13 @@ static void P_AddBinaryMapTags(void) } for (j = 0; j < numsectors; j++) { - CONS_Printf("Sector %zu (tag %d):\n", j, Tag_FGet(§ors[j].tags)); size_t k; for (k = 0; k < 5; k++) { if (k > 0 && !target_tags[k]) continue; if (Tag_Find(§ors[j].tags, target_tags[k])) { Tag_Add(§ors[j].tags, tag); - CONS_Printf(" Tag %d found, added tag %d\n", target_tags[k], tag); break; } else { - CONS_Printf(" Tag %d not found\n", target_tags[k]); } } } From 2d4411d077a0d36a78707e655863b94afd127ec4 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sat, 29 May 2021 12:23:35 -0400 Subject: [PATCH 06/10] Remove empty 'else' block (also leftover) --- src/p_setup.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index ea655f5f9..095524203 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3004,7 +3004,6 @@ static void P_AddBinaryMapTags(void) if (Tag_Find(§ors[j].tags, target_tags[k])) { Tag_Add(§ors[j].tags, tag); break; - } else { } } } From f8fe763df22285af086f51389186ebf8ab15b2b8 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sat, 29 May 2021 12:28:06 -0400 Subject: [PATCH 07/10] Fix linedef type 99 --- src/p_setup.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 095524203..f60af94ed 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3007,10 +3007,11 @@ static void P_AddBinaryMapTags(void) } } } - } else if (lines[i].special == 97 || lines[i].special == 99) { - P_AddBinaryMapTagsFromLine(lines[i].frontsector, &lines[i]); - } else if (lines[i].special == 98 || lines[i].special == 99) { - P_AddBinaryMapTagsFromLine(lines[i].backsector, &lines[i]); + } else { + if (lines[i].special == 97 || lines[i].special == 99) + P_AddBinaryMapTagsFromLine(lines[i].frontsector, &lines[i]); + if (lines[i].special == 98 || lines[i].special == 99) + P_AddBinaryMapTagsFromLine(lines[i].backsector, &lines[i]); } } } From 0b51b391f1a7e61f1e64992c92cd96e483b1ed08 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sun, 30 May 2021 12:16:15 -0400 Subject: [PATCH 08/10] Make 96's flags consistent with 97-99 by default --- extras/conf/SRB2-22.cfg | 17 +++++++++-------- src/p_setup.c | 35 +++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index ad930a485..5a464eb5d 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -644,32 +644,33 @@ linedeftypes { title = "Apply Tag to Tagged Sectors"; prefix = "(96)"; - flags8192text = "[13] Use Front Side Offsets"; - flags32768text = "[15] Use Back Side Offsets"; + flags1024text = "[10] Offsets are target tags"; + flags8192text = "[13] Use front side offsets"; + flags32768text = "[15] Use back side offsets"; } 97 { title = "Apply Tag to Front Sector"; prefix = "(97)"; - flags8192text = "[13] Use Front Side Offsets"; - flags32768text = "[15] Use Back Side Offsets"; + flags8192text = "[13] Use front side offsets"; + flags32768text = "[15] Use back side offsets"; } 98 { title = "Apply Tag to Back Sector"; prefix = "(98)"; - flags8192text = "[13] Use Front Side Offsets"; - flags32768text = "[15] Use Back Side Offsets"; + flags8192text = "[13] Use front side offsets"; + flags32768text = "[15] Use back side offsets"; } 99 { title = "Apply Tag to Front and Back Sectors"; prefix = "(99)"; - flags8192text = "[13] Use Front Side Offsets"; - flags32768text = "[15] Use Back Side Offsets"; + flags8192text = "[13] Use front side offsets"; + flags32768text = "[15] Use back side offsets"; } 540 diff --git a/src/p_setup.c b/src/p_setup.c index f60af94ed..7ecaf2ff4 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2982,28 +2982,31 @@ static void P_AddBinaryMapTags(void) if (lines[i].special == 96) { size_t j; mtag_t tag = Tag_FGet(&lines[i].frontsector->tags); - mtag_t target_tags[5]; - target_tags[0] = Tag_FGet(&lines[i].tags); + mtag_t target_tag = Tag_FGet(&lines[i].tags); + mtag_t offset_tags[4]; + memset(offset_tags, 0, sizeof(mtag_t)*4); if (lines[i].flags & ML_EFFECT6) { - target_tags[1] = (INT32)sides[lines[i].sidenum[0]].textureoffset / FRACUNIT; - target_tags[2] = (INT32)sides[lines[i].sidenum[0]].rowoffset / FRACUNIT; - } else { - target_tags[1] = target_tags[2] = 0; + offset_tags[1] = (INT32)sides[lines[i].sidenum[0]].textureoffset / FRACUNIT; + offset_tags[2] = (INT32)sides[lines[i].sidenum[0]].rowoffset / FRACUNIT; } if (lines[i].flags & ML_TFERLINE) { - target_tags[3] = (INT32)sides[lines[i].sidenum[1]].textureoffset / FRACUNIT; - target_tags[4] = (INT32)sides[lines[i].sidenum[1]].rowoffset / FRACUNIT; - } else { - target_tags[3] = target_tags[4] = 0; + offset_tags[3] = (INT32)sides[lines[i].sidenum[1]].textureoffset / FRACUNIT; + offset_tags[4] = (INT32)sides[lines[i].sidenum[1]].rowoffset / FRACUNIT; } for (j = 0; j < numsectors; j++) { - size_t k; for (k = 0; k < 5; k++) { - if (k > 0 && !target_tags[k]) - continue; - if (Tag_Find(§ors[j].tags, target_tags[k])) { - Tag_Add(§ors[j].tags, tag); - break; + boolean matches_target_tag = Tag_Find(§ors[j].tags, target_tag); + size_t k; for (k = 0; k < 4; k++) { + if (lines[i].flags & ML_EFFECT5) { + if (matches_target_tag || offset_tags[k] && Tag_Find(§ors[j].tags, offset_tags[k])) { + Tag_Add(§ors[j].tags, tag); + break; + } + } else if (matches_target_tag) { + if (k == 0) + Tag_Add(§ors[j].tags, tag); + if (offset_tags[k]) + Tag_Add(§ors[j].tags, offset_tags[k]); } } } From 172454f108ea17ee4c0b289df4924fc4dd8b1b02 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Tue, 1 Jun 2021 10:09:57 -0400 Subject: [PATCH 09/10] Fix offset_tags array indices --- src/p_setup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 7ecaf2ff4..50b073a21 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2986,12 +2986,12 @@ static void P_AddBinaryMapTags(void) mtag_t offset_tags[4]; memset(offset_tags, 0, sizeof(mtag_t)*4); if (lines[i].flags & ML_EFFECT6) { - offset_tags[1] = (INT32)sides[lines[i].sidenum[0]].textureoffset / FRACUNIT; - offset_tags[2] = (INT32)sides[lines[i].sidenum[0]].rowoffset / FRACUNIT; + offset_tags[0] = (INT32)sides[lines[i].sidenum[0]].textureoffset / FRACUNIT; + offset_tags[1] = (INT32)sides[lines[i].sidenum[0]].rowoffset / FRACUNIT; } if (lines[i].flags & ML_TFERLINE) { - offset_tags[3] = (INT32)sides[lines[i].sidenum[1]].textureoffset / FRACUNIT; - offset_tags[4] = (INT32)sides[lines[i].sidenum[1]].rowoffset / FRACUNIT; + offset_tags[2] = (INT32)sides[lines[i].sidenum[1]].textureoffset / FRACUNIT; + offset_tags[3] = (INT32)sides[lines[i].sidenum[1]].rowoffset / FRACUNIT; } for (j = 0; j < numsectors; j++) { From 115254efc9e2b42c15c93d478611d0a64f4a27bd Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Tue, 1 Jun 2021 17:10:29 -0400 Subject: [PATCH 10/10] Fix compiler warning related to precedence --- src/p_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index 50b073a21..61d1a5e46 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2998,7 +2998,7 @@ static void P_AddBinaryMapTags(void) boolean matches_target_tag = Tag_Find(§ors[j].tags, target_tag); size_t k; for (k = 0; k < 4; k++) { if (lines[i].flags & ML_EFFECT5) { - if (matches_target_tag || offset_tags[k] && Tag_Find(§ors[j].tags, offset_tags[k])) { + if (matches_target_tag || (offset_tags[k] && Tag_Find(§ors[j].tags, offset_tags[k]))) { Tag_Add(§ors[j].tags, tag); break; }