From 6063a6eab897e6f4d28665163e0410f54a7eb9e5 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 20 Jan 2022 21:51:47 -0800 Subject: [PATCH 1/2] Check both front and backside for tripwire --- src/p_setup.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 8c5f5d59b..3f6a57566 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1939,6 +1939,30 @@ static void P_LoadTextmap(void) } } +static boolean P_CheckLineSideTripWire(line_t *ld, int p) +{ + INT32 n; + + side_t *sda; + side_t *sdb; + + terrain_t *terrain; + + boolean tripwire; + + n = ld->sidenum[p]; + + if (n == 0xffff) + return false; + + sda = &sides[n]; + + terrain = K_GetTerrainForTextureNum(sda->midtexture); + tripwire = terrain && (terrain->flags & TRF_TRIPWIRE); + + return tripwire; +} + static void P_ProcessLinedefsAfterSidedefs(void) { size_t i = numlines; @@ -1946,16 +1970,13 @@ static void P_ProcessLinedefsAfterSidedefs(void) for (; i--; ld++) { - INT32 midtexture = sides[ld->sidenum[0]].midtexture; - terrain_t *terrain = K_GetTerrainForTextureNum(midtexture); - ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; - if (terrain != NULL && (terrain->flags & TRF_TRIPWIRE)) - { - ld->tripwire = true; - } + // Check for tripwire on either side + ld->tripwire = + P_CheckLineSideTripWire(ld, 0) || + P_CheckLineSideTripWire(ld, 1); switch (ld->special) { From b23c4abb83f15430dc915a4524e237ff770ed998 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 20 Jan 2022 21:52:10 -0800 Subject: [PATCH 2/2] Copy tripwire texture to opposite side and automatically mirror texture alignment --- src/p_setup.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index 3f6a57566..9c1288acc 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1939,6 +1939,24 @@ static void P_LoadTextmap(void) } } +static fixed_t +P_MirrorTextureOffset +( fixed_t offset, + fixed_t source_width, + fixed_t actual_width) +{ + /* + Adjusting the horizontal alignment is a bit ASS... + Textures on the opposite side of the line will begin + drawing from the opposite end. + + Start with the texture width and subtract the seg + length to account for cropping/wrapping. Subtract the + offset to mirror the alignment. + */ + return source_width - actual_width - offset; +} + static boolean P_CheckLineSideTripWire(line_t *ld, int p) { INT32 n; @@ -1960,6 +1978,28 @@ static boolean P_CheckLineSideTripWire(line_t *ld, int p) terrain = K_GetTerrainForTextureNum(sda->midtexture); tripwire = terrain && (terrain->flags & TRF_TRIPWIRE); + if (tripwire) + { + // copy midtexture to other side + n = ld->sidenum[!p]; + + if (n != 0xffff) + { + fixed_t linelength = FixedHypot(ld->dx, ld->dy); + texture_t *tex = textures[sda->midtexture]; + + sdb = &sides[n]; + + sdb->midtexture = sda->midtexture; + sdb->rowoffset = sda->rowoffset; + + // mirror texture alignment + sdb->textureoffset = P_MirrorTextureOffset( + sda->textureoffset, tex->width * FRACUNIT, + linelength); + } + } + return tripwire; } @@ -1973,7 +2013,8 @@ static void P_ProcessLinedefsAfterSidedefs(void) ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; - // Check for tripwire on either side + // Check for tripwire, if either side matches then + // copy that (mid)texture to the other side. ld->tripwire = P_CheckLineSideTripWire(ld, 0) || P_CheckLineSideTripWire(ld, 1);