From a2aeece419b3632ea3d783a38a424195290b3384 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 30 May 2016 21:53:29 +0100 Subject: [PATCH 01/18] Significant rework of main seg-rendering code, to eliminate the possibility of drawing off-screen and crashing the game as result NOTE: HOMs sometimes appear in the sky in maps like AGZ (map40), so this isn't completely fine yet. I'll fix that later --- src/r_segs.c | 110 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 42 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 11b4c8ae..931b79a6 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1453,34 +1453,45 @@ static void R_RenderSegLoop (void) frontscale[rw_x] = rw_scale; // draw the wall tiers - if (midtexture && yl <= yh && yh < vid.height && yh > 0) + if (midtexture) { // single sided line - dc_yl = yl; - dc_yh = yh; - dc_texturemid = rw_midtexturemid; - dc_source = R_GetColumn(midtexture,texturecolumn); - dc_texheight = textureheight[midtexture]>>FRACBITS; + if (yl <= yh && yh >= 0 && yl < viewheight) + { + dc_yl = yl; + dc_yh = yh; + dc_texturemid = rw_midtexturemid; + dc_source = R_GetColumn(midtexture,texturecolumn); + dc_texheight = textureheight[midtexture]>>FRACBITS; - //profile stuff --------------------------------------------------------- + //profile stuff --------------------------------------------------------- #ifdef TIMING - ProfZeroTimer(); + ProfZeroTimer(); #endif - colfunc(); + colfunc(); #ifdef TIMING - RDMSR(0x10,&mycount); - mytotal += mycount; //64bit add + RDMSR(0x10,&mycount); + mytotal += mycount; //64bit add - if (nombre--==0) - I_Error("R_DrawColumn CPU Spy reports: 0x%d %d\n", *((INT32 *)&mytotal+1), - (INT32)mytotal); + if (nombre--==0) + I_Error("R_DrawColumn CPU Spy reports: 0x%d %d\n", *((INT32 *)&mytotal+1), + (INT32)mytotal); #endif - //profile stuff --------------------------------------------------------- + //profile stuff --------------------------------------------------------- - // dont draw anything more for this column, since - // a midtexture blocks the view - ceilingclip[rw_x] = (INT16)viewheight; - floorclip[rw_x] = -1; + // dont draw anything more for this column, since + // a midtexture blocks the view + ceilingclip[rw_x] = (INT16)viewheight; + floorclip[rw_x] = -1; + } + else + { + // note: don't use min/max macros here + if (markceiling && yl >= 0) + ceilingclip[rw_x] = (yl-1 > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); + if (markfloor && yh < viewheight) + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + } } else { @@ -1494,21 +1505,27 @@ static void R_RenderSegLoop (void) if (mid >= floorclip[rw_x]) mid = floorclip[rw_x]-1; - if (mid >= yl && yh < vid.height && yh > 0) + if (yl < 0) + ; // do nothing, off-screen + else if (mid >= yl && yl < viewheight) { - dc_yl = yl; - dc_yh = mid; - dc_texturemid = rw_toptexturemid; - dc_source = R_GetColumn(toptexture,texturecolumn); - dc_texheight = textureheight[toptexture]>>FRACBITS; - colfunc(); - ceilingclip[rw_x] = (INT16)mid; + if (mid >= 0) + { + dc_yl = yl; + dc_yh = mid; + dc_texturemid = rw_toptexturemid; + dc_source = R_GetColumn(toptexture,texturecolumn); + dc_texheight = textureheight[toptexture]>>FRACBITS; + colfunc(); + ceilingclip[rw_x] = (INT16)mid; + } + // else do nothing, off-screen } else - ceilingclip[rw_x] = (INT16)((INT16)yl - 1); + ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); } - else if (markceiling) // no top wall - ceilingclip[rw_x] = (INT16)((INT16)yl - 1); + else if (markceiling && yl >= 0) // no top wall + ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); if (bottomtexture) { @@ -1520,24 +1537,33 @@ static void R_RenderSegLoop (void) if (mid <= ceilingclip[rw_x]) mid = ceilingclip[rw_x]+1; - if (mid <= yh && yh < vid.height && yh > 0) + if (yh >= viewheight) + ; // do nothing, off-screen + else if (mid <= yh && yh >= 0) { - dc_yl = mid; - dc_yh = yh; - dc_texturemid = rw_bottomtexturemid; - dc_source = R_GetColumn(bottomtexture, - texturecolumn); - dc_texheight = textureheight[bottomtexture]>>FRACBITS; - colfunc(); - floorclip[rw_x] = (INT16)mid; + if (mid < viewheight) + { + dc_yl = mid; + dc_yh = yh; + dc_texturemid = rw_bottomtexturemid; + dc_source = R_GetColumn(bottomtexture, + texturecolumn); + dc_texheight = textureheight[bottomtexture]>>FRACBITS; + colfunc(); + floorclip[rw_x] = (INT16)mid; + } + // else do nothing, off-screen } else - floorclip[rw_x] = (INT16)((INT16)yh + 1); + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); } - else if (markfloor) // no bottom wall - floorclip[rw_x] = (INT16)((INT16)yh + 1); + else if (markfloor && yh < viewheight) // no bottom wall + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1), -1; } + if (floorclip[rw_x] > viewheight) + I_Error("floorclip[%d] > viewheight (value is %d)", rw_x, floorclip[rw_x]); + if (maskedtexture || numthicksides) { // save texturecol From eb90f4f50deec77b35d31224a456144683cd096a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 30 May 2016 22:53:22 +0100 Subject: [PATCH 02/18] welp no success in fixing the sky HOMs yet, committing progress anyway --- src/r_segs.c | 58 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 931b79a6..99324d03 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1487,10 +1487,20 @@ static void R_RenderSegLoop (void) else { // note: don't use min/max macros here - if (markceiling && yl >= 0) - ceilingclip[rw_x] = (yl-1 > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); - if (markfloor && yh < viewheight) - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + if (markceiling) + { + if (yl >= 0) + ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); + else + ceilingclip[rw_x] = -1; + } + else if (markfloor) + { + if (yh < viewheight) + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + else + floorclip[rw_x] = (INT16)viewheight; + } } } else @@ -1505,9 +1515,7 @@ static void R_RenderSegLoop (void) if (mid >= floorclip[rw_x]) mid = floorclip[rw_x]-1; - if (yl < 0) - ; // do nothing, off-screen - else if (mid >= yl && yl < viewheight) + if (mid >= yl && yl < viewheight) { if (mid >= 0) { @@ -1519,13 +1527,21 @@ static void R_RenderSegLoop (void) colfunc(); ceilingclip[rw_x] = (INT16)mid; } - // else do nothing, off-screen + else + ceilingclip[rw_x] = -1; } - else + else if (yl >= 0) ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); + else + ceilingclip[rw_x] = -1; + } + else if (markceiling) // no top wall + { + if (yl >= 0) + ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); + else + ceilingclip[rw_x] = -1; } - else if (markceiling && yl >= 0) // no top wall - ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); if (bottomtexture) { @@ -1537,9 +1553,7 @@ static void R_RenderSegLoop (void) if (mid <= ceilingclip[rw_x]) mid = ceilingclip[rw_x]+1; - if (yh >= viewheight) - ; // do nothing, off-screen - else if (mid <= yh && yh >= 0) + if (mid <= yh && yh >= 0) { if (mid < viewheight) { @@ -1552,13 +1566,21 @@ static void R_RenderSegLoop (void) colfunc(); floorclip[rw_x] = (INT16)mid; } - // else do nothing, off-screen + else + floorclip[rw_x] = (INT16)viewheight; } - else + else if (yh < viewheight) floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + else + floorclip[rw_x] = (INT16)viewheight; + } + else if (markfloor) // no bottom wall + { + if (yh < viewheight) + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + else + floorclip[rw_x] = (INT16)viewheight; } - else if (markfloor && yh < viewheight) // no bottom wall - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1), -1; } if (floorclip[rw_x] > viewheight) From 8b2b49fb043ee32a8269ff4a0fe2db74c47e3d1a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 31 May 2016 16:08:29 +0100 Subject: [PATCH 03/18] Just some final cleanup of the code I changed --- src/r_segs.c | 59 ++++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 41 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 99324d03..ec3eaa18 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1486,21 +1486,11 @@ static void R_RenderSegLoop (void) } else { - // note: don't use min/max macros here + // note: don't use min/max macros, since casting from INT32 to INT16 is involved here if (markceiling) - { - if (yl >= 0) - ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); - else - ceilingclip[rw_x] = -1; - } - else if (markfloor) - { - if (yh < viewheight) - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); - else - floorclip[rw_x] = (INT16)viewheight; - } + ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; + if (markfloor) + floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; } } else @@ -1515,9 +1505,11 @@ static void R_RenderSegLoop (void) if (mid >= floorclip[rw_x]) mid = floorclip[rw_x]-1; - if (mid >= yl && yl < viewheight) + if (mid >= yl) // back ceiling lower than front ceiling ? { - if (mid >= 0) + if (yl >= viewheight) // entirely off bottom of screen + ceilingclip[rw_x] = (INT16)viewheight; + else if (mid >= 0) // safe to draw top texture { dc_yl = yl; dc_yh = mid; @@ -1527,21 +1519,14 @@ static void R_RenderSegLoop (void) colfunc(); ceilingclip[rw_x] = (INT16)mid; } - else + else // entirely off top of screen ceilingclip[rw_x] = -1; } - else if (yl >= 0) - ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); else - ceilingclip[rw_x] = -1; + ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; } else if (markceiling) // no top wall - { - if (yl >= 0) - ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); - else - ceilingclip[rw_x] = -1; - } + ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; if (bottomtexture) { @@ -1553,9 +1538,11 @@ static void R_RenderSegLoop (void) if (mid <= ceilingclip[rw_x]) mid = ceilingclip[rw_x]+1; - if (mid <= yh && yh >= 0) + if (mid <= yh) // back floor higher than front floor ? { - if (mid < viewheight) + if (yh < 0) // entirely off top of screen + floorclip[rw_x] = -1; + else if (mid < viewheight) // safe to draw bottom texture { dc_yl = mid; dc_yh = yh; @@ -1566,26 +1553,16 @@ static void R_RenderSegLoop (void) colfunc(); floorclip[rw_x] = (INT16)mid; } - else + else // entirely off bottom of screen floorclip[rw_x] = (INT16)viewheight; } - else if (yh < viewheight) - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); else - floorclip[rw_x] = (INT16)viewheight; + floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; } else if (markfloor) // no bottom wall - { - if (yh < viewheight) - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); - else - floorclip[rw_x] = (INT16)viewheight; - } + floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; } - if (floorclip[rw_x] > viewheight) - I_Error("floorclip[%d] > viewheight (value is %d)", rw_x, floorclip[rw_x]); - if (maskedtexture || numthicksides) { // save texturecol From 60dd8dab3c92dff4cdd236644db189ca151c47f6 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Mon, 6 Jun 2016 18:11:23 +0100 Subject: [PATCH 04/18] Backported clipping fix for FF_REVERSEPLATFORM collision. --- src/p_mobj.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 68fb1696..aa795a15 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2018,7 +2018,8 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp mo->floorz = topheight; } if (bottomheight < mo->ceilingz && abs(delta1) >= abs(delta2) - && !(rover->flags & FF_PLATFORM)) + && !(rover->flags & FF_PLATFORM) + && ((mo->momz > 0) || (!(rover->flags & FF_REVERSEPLATFORM)))) // Only clip for FOFs that are intangible from the top if you're coming from below { mo->ceilingz = bottomheight; } From 7c0eee6ff1b37488f4a84af37b7ab68e4b8bcf28 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Mon, 6 Jun 2016 20:53:29 +0100 Subject: [PATCH 05/18] The fix now takes reverse gravity platform step-up into account properly. --- src/p_mobj.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index aa795a15..e15eae74 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2013,13 +2013,14 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp delta1 = mo->z - (bottomheight + ((topheight - bottomheight)/2)); delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); if (topheight > mo->floorz && abs(delta1) < abs(delta2) - && !(rover->flags & FF_REVERSEPLATFORM)) + && !(rover->flags & FF_REVERSEPLATFORM) + && ((P_MobjFlip(mo)*mo->momz < 0) || (!(rover->flags & FF_PLATFORM)))) // In reverse gravity, only clip for FOFs that are intangible from their bottom (the "top" you're falling through) if you're coming from above ("below" in your frame of reference) { mo->floorz = topheight; } if (bottomheight < mo->ceilingz && abs(delta1) >= abs(delta2) && !(rover->flags & FF_PLATFORM) - && ((mo->momz > 0) || (!(rover->flags & FF_REVERSEPLATFORM)))) // Only clip for FOFs that are intangible from the top if you're coming from below + && ((P_MobjFlip(mo)*mo->momz > 0) || (!(rover->flags & FF_REVERSEPLATFORM)))) // In normal gravity, only clip for FOFs that are intangible from the top if you're coming from below { mo->ceilingz = bottomheight; } From 26744c2a6b914150719f923e7ef0c9112fb82d85 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Mon, 6 Jun 2016 21:02:47 +0100 Subject: [PATCH 06/18] woops #1 --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index e15eae74..6a673679 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2014,7 +2014,7 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); if (topheight > mo->floorz && abs(delta1) < abs(delta2) && !(rover->flags & FF_REVERSEPLATFORM) - && ((P_MobjFlip(mo)*mo->momz < 0) || (!(rover->flags & FF_PLATFORM)))) // In reverse gravity, only clip for FOFs that are intangible from their bottom (the "top" you're falling through) if you're coming from above ("below" in your frame of reference) + && ((P_MobjFlip(mo)*mo->momz > 0) || (!(rover->flags & FF_PLATFORM)))) // In reverse gravity, only clip for FOFs that are intangible from their bottom (the "top" you're falling through) if you're coming from above ("below" in your frame of reference) { mo->floorz = topheight; } From 0b920ee2492566d245c93f7a624418b6896e9080 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 9 Jun 2016 00:02:50 +0100 Subject: [PATCH 07/18] You know that problem where you bumped on the edges of Mario blocks and Bustable blocks and Bouncy FOFs sometimes? Wham. Bam. In the van. Issue was caused by attempting to traverse the sector's thing-touching-list across all the things in the sector (which would inevitably have the same sector as the first node in mobj->touching_sectorlist) instead of traversing the thing's sector-touching-list (which has the same thing but different sector references). I wonder how many times AJ copypasted this code with absolutely no idea why it wasn't working properly. I'll figure that out tomorrow, maybe set up some compiler macros so this mistake is never made again. For now, I must sleeb. --- src/p_mobj.c | 4 ++-- src/p_user.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 68fb1696..759fa0d8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1530,7 +1530,7 @@ static void P_PushableCheckBustables(mobj_t *mo) mo->y += mo->momy; P_SetThingPosition(mo); - for (node = mo->touching_sectorlist; node; node = node->m_snext) + for (node = mo->touching_sectorlist; node; node = node->m_tnext) { if (!node->m_sector) break; @@ -2880,7 +2880,7 @@ nightsdone: if (CheckForMarioBlocks && !(netgame && mo->player->spectator)) // Only let the player punch { // Search the touching sectors, from side-to-side... - for (node = mo->touching_sectorlist; node; node = node->m_snext) + for (node = mo->touching_sectorlist; node; node = node->m_tnext) { ffloor_t *rover; if (!node->m_sector->ffloors) diff --git a/src/p_user.c b/src/p_user.c index 4117cfc4..fab8cd37 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1684,7 +1684,7 @@ static void P_CheckBustableBlocks(player_t *player) player->mo->y += player->mo->momy; P_SetThingPosition(player->mo); - for (node = player->mo->touching_sectorlist; node; node = node->m_snext) + for (node = player->mo->touching_sectorlist; node; node = node->m_tnext) { if (!node->m_sector) break; @@ -1801,7 +1801,7 @@ static void P_CheckBouncySectors(player_t *player) player->mo->z += player->mo->momz; P_SetThingPosition(player->mo); - for (node = player->mo->touching_sectorlist; node; node = node->m_snext) + for (node = player->mo->touching_sectorlist; node; node = node->m_tnext) { if (!node->m_sector) break; From 17e0adcbacc98f6b71b5d7e9a8ebc7d67ec251b2 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 9 Jun 2016 14:16:02 +0100 Subject: [PATCH 08/18] Renamed some struct variables so the problem this branch sets out to fix is more obvious at a glance. * m_snext ==> m_thinglist_next * m_sprev ==> m_thinglist_prev * m_tnext ==> m_sectorlist_next * m_tprev ==> m_sectorlist_prev --- src/p_floor.c | 10 +++--- src/p_map.c | 96 +++++++++++++++++++++++++-------------------------- src/p_mobj.c | 14 ++++---- src/p_spec.c | 24 ++++++------- src/p_user.c | 8 ++--- src/r_defs.h | 20 +++++------ 6 files changed, 86 insertions(+), 86 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index 1c396c87..91121301 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1163,7 +1163,7 @@ void T_SpikeSector(levelspecthink_t *spikes) node = spikes->sector->touching_thinglist; // things touching this sector - for (; node; node = node->m_snext) + for (; node; node = node->m_thinglist_next) { thing = node->m_thing; if (!thing->player) @@ -1316,7 +1316,7 @@ void T_BridgeThinker(levelspecthink_t *bridge) controlsec = §ors[k]; // Is a player standing on me? - for (node = sector->touching_thinglist; node; node = node->m_snext) + for (node = sector->touching_thinglist; node; node = node->m_thinglist_next) { thing = node->m_thing; @@ -1739,7 +1739,7 @@ wegotit: static mobj_t *SearchMarioNode(msecnode_t *node) { mobj_t *thing = NULL; - for (; node; node = node->m_snext) + for (; node; node = node->m_thinglist_next) { // Things which should NEVER be ejected from a MarioBlock, by type. switch (node->m_thing->type) @@ -2003,7 +2003,7 @@ void T_NoEnemiesSector(levelspecthink_t *nobaddies) goto foundenemy; } - node = node->m_snext; + node = node->m_thinglist_next; } } } @@ -2288,7 +2288,7 @@ void T_RaiseSector(levelspecthink_t *raise) sector = §ors[i]; // Is a player standing on me? - for (node = sector->touching_thinglist; node; node = node->m_snext) + for (node = sector->touching_thinglist; node; node = node->m_thinglist_next) { thing = node->m_thing; diff --git a/src/p_map.c b/src/p_map.c index 71adf2e1..44df3001 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3365,7 +3365,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) for (i = 0; i < sector->numattached; i++) { sec = §ors[sector->attached[i]]; - for (n = sec->touching_thinglist; n; n = n->m_snext) + for (n = sec->touching_thinglist; n; n = n->m_thinglist_next) n->visited = false; sec->moved = true; @@ -3377,7 +3377,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) do { - for (n = sec->touching_thinglist; n; n = n->m_snext) + for (n = sec->touching_thinglist; n; n = n->m_thinglist_next) if (!n->visited) { n->visited = true; @@ -3398,12 +3398,12 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) // Mark all things invalid sector->moved = true; - for (n = sector->touching_thinglist; n; n = n->m_snext) + for (n = sector->touching_thinglist; n; n = n->m_thinglist_next) n->visited = false; do { - for (n = sector->touching_thinglist; n; n = n->m_snext) // go through list + for (n = sector->touching_thinglist; n; n = n->m_thinglist_next) // go through list if (!n->visited) // unprocessed thing found { n->visited = true; // mark thing as processed @@ -3427,7 +3427,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) for (i = 0; i < sector->numattached; i++) { sec = §ors[sector->attached[i]]; - for (n = sec->touching_thinglist; n; n = n->m_snext) + for (n = sec->touching_thinglist; n; n = n->m_thinglist_next) n->visited = false; sec->moved = true; @@ -3439,7 +3439,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) do { - for (n = sec->touching_thinglist; n; n = n->m_snext) + for (n = sec->touching_thinglist; n; n = n->m_thinglist_next) if (!n->visited) { n->visited = true; @@ -3457,12 +3457,12 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) // Mark all things invalid sector->moved = true; - for (n = sector->touching_thinglist; n; n = n->m_snext) + for (n = sector->touching_thinglist; n; n = n->m_thinglist_next) n->visited = false; do { - for (n = sector->touching_thinglist; n; n = n->m_snext) // go through list + for (n = sector->touching_thinglist; n; n = n->m_thinglist_next) // go through list if (!n->visited) // unprocessed thing found { n->visited = true; // mark thing as processed @@ -3502,7 +3502,7 @@ static msecnode_t *P_GetSecnode(void) if (headsecnode) { node = headsecnode; - headsecnode = headsecnode->m_snext; + headsecnode = headsecnode->m_thinglist_next; } else node = Z_Calloc(sizeof (*node), PU_LEVEL, NULL); @@ -3516,7 +3516,7 @@ static mprecipsecnode_t *P_GetPrecipSecnode(void) if (headprecipsecnode) { node = headprecipsecnode; - headprecipsecnode = headprecipsecnode->m_snext; + headprecipsecnode = headprecipsecnode->m_thinglist_next; } else node = Z_Calloc(sizeof (*node), PU_LEVEL, NULL); @@ -3527,14 +3527,14 @@ static mprecipsecnode_t *P_GetPrecipSecnode(void) static inline void P_PutSecnode(msecnode_t *node) { - node->m_snext = headsecnode; + node->m_thinglist_next = headsecnode; headsecnode = node; } // Tails 08-25-2002 static inline void P_PutPrecipSecnode(mprecipsecnode_t *node) { - node->m_snext = headprecipsecnode; + node->m_thinglist_next = headprecipsecnode; headprecipsecnode = node; } @@ -3555,7 +3555,7 @@ static msecnode_t *P_AddSecnode(sector_t *s, mobj_t *thing, msecnode_t *nextnode node->m_thing = thing; // Yes. Setting m_thing says 'keep it'. return nextnode; } - node = node->m_tnext; + node = node->m_sectorlist_next; } // Couldn't find an existing node for this sector. Add one at the head @@ -3568,17 +3568,17 @@ static msecnode_t *P_AddSecnode(sector_t *s, mobj_t *thing, msecnode_t *nextnode node->m_sector = s; // sector node->m_thing = thing; // mobj - node->m_tprev = NULL; // prev node on Thing thread - node->m_tnext = nextnode; // next node on Thing thread + node->m_sectorlist_prev = NULL; // prev node on Thing thread + node->m_sectorlist_next = nextnode; // next node on Thing thread if (nextnode) - nextnode->m_tprev = node; // set back link on Thing + nextnode->m_sectorlist_prev = node; // set back link on Thing // Add new node at head of sector thread starting at s->touching_thinglist - node->m_sprev = NULL; // prev node on sector thread - node->m_snext = s->touching_thinglist; // next node on sector thread + node->m_thinglist_prev = NULL; // prev node on sector thread + node->m_thinglist_next = s->touching_thinglist; // next node on sector thread if (s->touching_thinglist) - node->m_snext->m_sprev = node; + node->m_thinglist_next->m_thinglist_prev = node; s->touching_thinglist = node; return node; } @@ -3596,7 +3596,7 @@ static mprecipsecnode_t *P_AddPrecipSecnode(sector_t *s, precipmobj_t *thing, mp node->m_thing = thing; // Yes. Setting m_thing says 'keep it'. return nextnode; } - node = node->m_tnext; + node = node->m_sectorlist_next; } // Couldn't find an existing node for this sector. Add one at the head @@ -3609,17 +3609,17 @@ static mprecipsecnode_t *P_AddPrecipSecnode(sector_t *s, precipmobj_t *thing, mp node->m_sector = s; // sector node->m_thing = thing; // mobj - node->m_tprev = NULL; // prev node on Thing thread - node->m_tnext = nextnode; // next node on Thing thread + node->m_sectorlist_prev = NULL; // prev node on Thing thread + node->m_sectorlist_next = nextnode; // next node on Thing thread if (nextnode) - nextnode->m_tprev = node; // set back link on Thing + nextnode->m_sectorlist_prev = node; // set back link on Thing // Add new node at head of sector thread starting at s->touching_thinglist - node->m_sprev = NULL; // prev node on sector thread - node->m_snext = s->touching_preciplist; // next node on sector thread + node->m_thinglist_prev = NULL; // prev node on sector thread + node->m_thinglist_next = s->touching_preciplist; // next node on sector thread if (s->touching_preciplist) - node->m_snext->m_sprev = node; + node->m_thinglist_next->m_thinglist_prev = node; s->touching_preciplist = node; return node; } @@ -3641,24 +3641,24 @@ static msecnode_t *P_DelSecnode(msecnode_t *node) // Unlink from the Thing thread. The Thing thread begins at // sector_list and not from mobj_t->touching_sectorlist. - tp = node->m_tprev; - tn = node->m_tnext; + tp = node->m_sectorlist_prev; + tn = node->m_sectorlist_next; if (tp) - tp->m_tnext = tn; + tp->m_sectorlist_next = tn; if (tn) - tn->m_tprev = tp; + tn->m_sectorlist_prev = tp; // Unlink from the sector thread. This thread begins at // sector_t->touching_thinglist. - sp = node->m_sprev; - sn = node->m_snext; + sp = node->m_thinglist_prev; + sn = node->m_thinglist_next; if (sp) - sp->m_snext = sn; + sp->m_thinglist_next = sn; else node->m_sector->touching_thinglist = sn; if (sn) - sn->m_sprev = sp; + sn->m_thinglist_prev = sp; // Return this node to the freelist @@ -3680,24 +3680,24 @@ static mprecipsecnode_t *P_DelPrecipSecnode(mprecipsecnode_t *node) // Unlink from the Thing thread. The Thing thread begins at // sector_list and not from mobj_t->touching_sectorlist. - tp = node->m_tprev; - tn = node->m_tnext; + tp = node->m_sectorlist_prev; + tn = node->m_sectorlist_next; if (tp) - tp->m_tnext = tn; + tp->m_sectorlist_next = tn; if (tn) - tn->m_tprev = tp; + tn->m_sectorlist_prev = tp; // Unlink from the sector thread. This thread begins at // sector_t->touching_thinglist. - sp = node->m_sprev; - sn = node->m_snext; + sp = node->m_thinglist_prev; + sn = node->m_thinglist_next; if (sp) - sp->m_snext = sn; + sp->m_thinglist_next = sn; else node->m_sector->touching_preciplist = sn; if (sn) - sn->m_sprev = sp; + sn->m_thinglist_prev = sp; // Return this node to the freelist @@ -3812,7 +3812,7 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) while (node) { node->m_thing = NULL; - node = node->m_tnext; + node = node->m_sectorlist_next; } P_SetTarget(&tmthing, thing); @@ -3850,11 +3850,11 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) if (!node->m_thing) { if (node == sector_list) - sector_list = node->m_tnext; + sector_list = node->m_sectorlist_next; node = P_DelSecnode(node); } else - node = node->m_tnext; + node = node->m_sectorlist_next; } /* cph - @@ -3895,7 +3895,7 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) while (node) { node->m_thing = NULL; - node = node->m_tnext; + node = node->m_sectorlist_next; } tmprecipthing = thing; @@ -3929,11 +3929,11 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) if (!node->m_thing) { if (node == precipsector_list) - precipsector_list = node->m_tnext; + precipsector_list = node->m_sectorlist_next; node = P_DelPrecipSecnode(node); } else - node = node->m_tnext; + node = node->m_sectorlist_next; } /* cph - diff --git a/src/p_mobj.c b/src/p_mobj.c index 759fa0d8..0141c47d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1530,7 +1530,7 @@ static void P_PushableCheckBustables(mobj_t *mo) mo->y += mo->momy; P_SetThingPosition(mo); - for (node = mo->touching_sectorlist; node; node = node->m_tnext) + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) { if (!node->m_sector) break; @@ -2703,7 +2703,7 @@ static void P_PlayerZMovement(mobj_t *mo) msecnode_t *node; boolean stopmovecut = false; - for (node = mo->touching_sectorlist; node; node = node->m_snext) + for (node = mo->touching_sectorlist; node; node = node->m_thinglist_next) { sector_t *sec = node->m_sector; subsector_t *newsubsec; @@ -2880,7 +2880,7 @@ nightsdone: if (CheckForMarioBlocks && !(netgame && mo->player->spectator)) // Only let the player punch { // Search the touching sectors, from side-to-side... - for (node = mo->touching_sectorlist; node; node = node->m_tnext) + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) { ffloor_t *rover; if (!node->m_sector->ffloors) @@ -3648,7 +3648,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) if (!(netgame && mobj->player->spectator)) { // Crumbling platforms - for (node = mobj->touching_sectorlist; node; node = node->m_snext) + for (node = mobj->touching_sectorlist; node; node = node->m_thinglist_next) { fixed_t topheight, bottomheight; ffloor_t *rover; @@ -3673,7 +3673,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) { boolean thereiswater = false; - for (node = mobj->touching_sectorlist; node; node = node->m_snext) + for (node = mobj->touching_sectorlist; node; node = node->m_thinglist_next) { if (node->m_sector->ffloors) { @@ -3694,7 +3694,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) } if (thereiswater) { - for (node = mobj->touching_sectorlist; node; node = node->m_snext) + for (node = mobj->touching_sectorlist; node; node = node->m_thinglist_next) { if (node->m_sector->ffloors) { @@ -3807,7 +3807,7 @@ void P_RecalcPrecipInSector(sector_t *sector) sector->moved = true; // Recalc lighting and things too, maybe - for (psecnode = sector->touching_preciplist; psecnode; psecnode = psecnode->m_snext) + for (psecnode = sector->touching_preciplist; psecnode; psecnode = psecnode->m_thinglist_next) CalculatePrecipFloor(psecnode->m_thing); } diff --git a/src/p_spec.c b/src/p_spec.c index 9e4c3f07..25e32e57 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1642,7 +1642,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller mo = node->m_thing; if (mo->flags & MF_PUSHABLE) numpush++; - node = node->m_snext; + node = node->m_thinglist_next; } if (triggerline->flags & ML_NOCLIMB) // Need at least or more @@ -3144,7 +3144,7 @@ void P_SetupSignExit(player_t *player) thinker_t *think; INT32 numfound = 0; - for (; node; node = node->m_snext) + for (; node; node = node->m_thinglist_next) { thing = node->m_thing; if (thing->type != MT_SIGN) @@ -3308,7 +3308,7 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n return rover->master->frontsector; } - for (node = player->mo->touching_sectorlist; node; node = node->m_snext) + for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) { if (GETSECSPECIAL(node->m_sector->special, section) == number) { @@ -4657,7 +4657,7 @@ void P_PlayerInSpecialSector(player_t *player) P_RunSpecialSectorCheck(player, sector); // Iterate through touching_sectorlist - for (node = player->mo->touching_sectorlist; node; node = node->m_snext) + for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) { sector = node->m_sector; @@ -5308,7 +5308,7 @@ void T_LaserFlash(laserthink_t *flash) S_StartSound(§or->soundorg, sfx_laser); // Seek out objects to DESTROY! MUAHAHHAHAHAA!!!*cough* - for (node = sector->touching_thinglist; node && node->m_thing; node = node->m_snext) + for (node = sector->touching_thinglist; node && node->m_thing; node = node->m_thinglist_next) { thing = node->m_thing; @@ -6579,7 +6579,7 @@ void T_Scroll(scroll_t *s) sector_t *psec; psec = sectors + sect; - for (node = psec->touching_thinglist; node; node = node->m_snext) + for (node = psec->touching_thinglist; node; node = node->m_thinglist_next) { thing = node->m_thing; @@ -6601,7 +6601,7 @@ void T_Scroll(scroll_t *s) if (!is3dblock) { - for (node = sec->touching_thinglist; node; node = node->m_snext) + for (node = sec->touching_thinglist; node; node = node->m_thinglist_next) { thing = node->m_thing; @@ -6642,7 +6642,7 @@ void T_Scroll(scroll_t *s) sector_t *psec; psec = sectors + sect; - for (node = psec->touching_thinglist; node; node = node->m_snext) + for (node = psec->touching_thinglist; node; node = node->m_thinglist_next) { thing = node->m_thing; @@ -6664,7 +6664,7 @@ void T_Scroll(scroll_t *s) if (!is3dblock) { - for (node = sec->touching_thinglist; node; node = node->m_snext) + for (node = sec->touching_thinglist; node; node = node->m_thinglist_next) { thing = node->m_thing; @@ -7014,7 +7014,7 @@ void T_Friction(friction_t *f) { if (thing->floorz != P_GetSpecialTopZ(thing, referrer, sec)) { - node = node->m_snext; + node = node->m_thinglist_next; continue; } @@ -7032,7 +7032,7 @@ void T_Friction(friction_t *f) thing->movefactor = f->movefactor; } } - node = node->m_snext; + node = node->m_thinglist_next; } } @@ -7372,7 +7372,7 @@ void T_Pusher(pusher_t *p) // constant pushers p_wind and p_current node = sec->touching_thinglist; // things touching this sector - for (; node; node = node->m_snext) + for (; node; node = node->m_thinglist_next) { thing = node->m_thing; if (thing->flags & (MF_NOGRAVITY | MF_NOCLIP) diff --git a/src/p_user.c b/src/p_user.c index fab8cd37..2156f0fc 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1684,7 +1684,7 @@ static void P_CheckBustableBlocks(player_t *player) player->mo->y += player->mo->momy; P_SetThingPosition(player->mo); - for (node = player->mo->touching_sectorlist; node; node = node->m_tnext) + for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { if (!node->m_sector) break; @@ -1801,7 +1801,7 @@ static void P_CheckBouncySectors(player_t *player) player->mo->z += player->mo->momz; P_SetThingPosition(player->mo); - for (node = player->mo->touching_sectorlist; node; node = node->m_tnext) + for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { if (!node->m_sector) break; @@ -2855,7 +2855,7 @@ static void P_DoTeeter(player_t *player) boolean checkedforteeter = false; const fixed_t tiptop = FixedMul(MAXSTEPMOVE, player->mo->scale); // Distance you have to be above the ground in order to teeter. - for (node = player->mo->touching_sectorlist; node; node = node->m_snext) + for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) { // Ledge teetering. Check if any nearby sectors are low enough from your current one. checkedforteeter = true; @@ -7037,7 +7037,7 @@ static void P_MovePlayer(player_t *player) player->mo->y += player->mo->momy; P_SetThingPosition(player->mo); - for (node = player->mo->touching_sectorlist; node; node = node->m_snext) + for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) { if (!node->m_sector) break; diff --git a/src/r_defs.h b/src/r_defs.h index 84870816..2c5860ee 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -500,10 +500,10 @@ typedef struct subsector_s // Sector list node showing all sectors an object appears in. // // There are two threads that flow through these nodes. The first thread -// starts at touching_thinglist in a sector_t and flows through the m_snext +// starts at touching_thinglist in a sector_t and flows through the m_thinglist_next // links to find all mobjs that are entirely or partially in the sector. // The second thread starts at touching_sectorlist in an mobj_t and flows -// through the m_tnext links to find all sectors a thing touches. This is +// through the m_sectorlist_next links to find all sectors a thing touches. This is // useful when applying friction or push effects to sectors. These effects // can be done as thinkers that act upon all objects touching their sectors. // As an mobj moves through the world, these nodes are created and @@ -515,10 +515,10 @@ typedef struct msecnode_s { sector_t *m_sector; // a sector containing this object struct mobj_s *m_thing; // this object - struct msecnode_s *m_tprev; // prev msecnode_t for this thing - struct msecnode_s *m_tnext; // next msecnode_t for this thing - struct msecnode_s *m_sprev; // prev msecnode_t for this sector - struct msecnode_s *m_snext; // next msecnode_t for this sector + struct msecnode_s *m_sectorlist_prev; // prev msecnode_t for this thing + struct msecnode_s *m_sectorlist_next; // next msecnode_t for this thing + struct msecnode_s *m_thinglist_prev; // prev msecnode_t for this sector + struct msecnode_s *m_thinglist_next; // next msecnode_t for this sector boolean visited; // used in search algorithms } msecnode_t; @@ -526,10 +526,10 @@ typedef struct mprecipsecnode_s { sector_t *m_sector; // a sector containing this object struct precipmobj_s *m_thing; // this object - struct mprecipsecnode_s *m_tprev; // prev msecnode_t for this thing - struct mprecipsecnode_s *m_tnext; // next msecnode_t for this thing - struct mprecipsecnode_s *m_sprev; // prev msecnode_t for this sector - struct mprecipsecnode_s *m_snext; // next msecnode_t for this sector + struct mprecipsecnode_s *m_sectorlist_prev; // prev msecnode_t for this thing + struct mprecipsecnode_s *m_sectorlist_next; // next msecnode_t for this thing + struct mprecipsecnode_s *m_thinglist_prev; // prev msecnode_t for this sector + struct mprecipsecnode_s *m_thinglist_next; // next msecnode_t for this sector boolean visited; // used in search algorithms } mprecipsecnode_t; From 7af14c20ed0b38531e86ee86e1f4e0f143ae5f12 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 9 Jun 2016 14:56:24 +0100 Subject: [PATCH 09/18] Everywhere in the code that was doing things wrong has been changed. Two interesting points of note: * The touchspecial sector flag seems to actually do its job now. * Detection of sectors with polyobjects in seems to have done this incorrectly, but this doesn't mess with anything about touching the polies themselves so it seems to really only handle edge cases where the polyobject was too close to the border of another sector (which would've likely made rendering glitches anyways). * There was a whole swathe of teetering code that was basically never run properly because of this mistake. I did a simple fix at first, but you started teetering whenever you were slightly less than your radius away from a sector's edge, which was completely different and undesirable behaviour. Instead, I cut out the code that was never running, and just left the hacky method in instead since it was more accurate to what we want in general. --- src/p_mobj.c | 8 +++--- src/p_spec.c | 4 +-- src/p_user.c | 80 ++-------------------------------------------------- 3 files changed, 8 insertions(+), 84 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 0141c47d..d65ecee3 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2703,7 +2703,7 @@ static void P_PlayerZMovement(mobj_t *mo) msecnode_t *node; boolean stopmovecut = false; - for (node = mo->touching_sectorlist; node; node = node->m_thinglist_next) + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) { sector_t *sec = node->m_sector; subsector_t *newsubsec; @@ -3648,7 +3648,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) if (!(netgame && mobj->player->spectator)) { // Crumbling platforms - for (node = mobj->touching_sectorlist; node; node = node->m_thinglist_next) + for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) { fixed_t topheight, bottomheight; ffloor_t *rover; @@ -3673,7 +3673,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) { boolean thereiswater = false; - for (node = mobj->touching_sectorlist; node; node = node->m_thinglist_next) + for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) { if (node->m_sector->ffloors) { @@ -3694,7 +3694,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) } if (thereiswater) { - for (node = mobj->touching_sectorlist; node; node = node->m_thinglist_next) + for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) { if (node->m_sector->ffloors) { diff --git a/src/p_spec.c b/src/p_spec.c index 25e32e57..0bd53027 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3308,7 +3308,7 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n return rover->master->frontsector; } - for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) + for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { if (GETSECSPECIAL(node->m_sector->special, section) == number) { @@ -4657,7 +4657,7 @@ void P_PlayerInSpecialSector(player_t *player) P_RunSpecialSectorCheck(player, sector); // Iterate through touching_sectorlist - for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) + for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { sector = node->m_sector; diff --git a/src/p_user.c b/src/p_user.c index 2156f0fc..c9ac9f54 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2849,86 +2849,10 @@ static boolean PIT_CheckSolidsTeeter(mobj_t *thing) // static void P_DoTeeter(player_t *player) { - msecnode_t *node; boolean teeter = false; boolean roverfloor; // solid 3d floors? - boolean checkedforteeter = false; const fixed_t tiptop = FixedMul(MAXSTEPMOVE, player->mo->scale); // Distance you have to be above the ground in order to teeter. - for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) - { - // Ledge teetering. Check if any nearby sectors are low enough from your current one. - checkedforteeter = true; - roverfloor = false; - if (node->m_sector->ffloors) - { - ffloor_t *rover; - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) continue; - - if (P_CheckSolidLava(player->mo, rover)) - ; - else if (!(rover->flags & FF_BLOCKPLAYER || rover->flags & FF_QUICKSAND)) - continue; // intangible 3d floor - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (*rover->bottomheight > node->m_sector->ceilingheight) // Above the ceiling - continue; - - if (*rover->bottomheight > player->mo->z + player->mo->height + tiptop - || (*rover->topheight < player->mo->z - && player->mo->z + player->mo->height < node->m_sector->ceilingheight - tiptop)) - { - teeter = true; - roverfloor = true; - } - else - { - teeter = false; - roverfloor = true; - break; - } - } - else - { - if (*rover->topheight < node->m_sector->floorheight) // Below the floor - continue; - - if (*rover->topheight < player->mo->z - tiptop - || (*rover->bottomheight > player->mo->z + player->mo->height - && player->mo->z > node->m_sector->floorheight + tiptop)) - { - teeter = true; - roverfloor = true; - } - else - { - teeter = false; - roverfloor = true; - break; - } - } - } - } - - if (!teeter && !roverfloor) - { - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (node->m_sector->ceilingheight > player->mo->z + player->mo->height + tiptop) - teeter = true; - } - else - { - if (node->m_sector->floorheight < player->mo->z - tiptop) - teeter = true; - } - } - } - - if (checkedforteeter && !teeter) // Backup code { subsector_t *subsec[4]; // changed abcd into array instead UINT8 i; @@ -3147,7 +3071,7 @@ teeterdone: if ((player->mo->state == &states[S_PLAY_STND] || player->mo->state == &states[S_PLAY_TAP1] || player->mo->state == &states[S_PLAY_TAP2] || player->mo->state == &states[S_PLAY_SUPERSTAND])) P_SetPlayerMobjState(player->mo, S_PLAY_TEETER1); } - else if (checkedforteeter && (player->mo->state == &states[S_PLAY_TEETER1] || player->mo->state == &states[S_PLAY_TEETER2] || player->mo->state == &states[S_PLAY_SUPERTEETER])) + else if ((player->mo->state == &states[S_PLAY_TEETER1] || player->mo->state == &states[S_PLAY_TEETER2] || player->mo->state == &states[S_PLAY_SUPERTEETER])) P_SetPlayerMobjState(player->mo, S_PLAY_STND); } @@ -7037,7 +6961,7 @@ static void P_MovePlayer(player_t *player) player->mo->y += player->mo->momy; P_SetThingPosition(player->mo); - for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) + for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { if (!node->m_sector) break; From 20c2d84c78a3423beeef30d5d50a4a777b1b1dad Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 9 Jun 2016 20:37:36 +0100 Subject: [PATCH 10/18] Fix single side line midtexture skewing Red apparently left in code for single-sided linedefs to NOT skew their midtextures ...but it doesn't work because it doesn't stop the skewing code from running instead, regardless of whether Effect 1 is on or not. If it's decided single-sided line midtextures shouldn't do this though, the non-skew code could just as well be thrown out lol (or something else I guess?) --- src/r_segs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/r_segs.c b/src/r_segs.c index 11b4c8ae..a2487771 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1862,8 +1862,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (linedef->flags & ML_DONTPEGBOTTOM) rw_midtexturemid = frontsector->floorheight + textureheight[sidedef->midtexture] - viewz; else - rw_midtexturemid = frontsector->ceilingheight; + rw_midtexturemid = frontsector->ceilingheight - viewz; } + else #endif if (linedef->flags & ML_DONTPEGBOTTOM) { From a04fcce3a998025b765a567791595b3129ae414d Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 9 Jun 2016 22:07:43 +0100 Subject: [PATCH 11/18] Hack to fix midtextures for polyobjects being mucked up "frontsector" in this part of the code isn't actually the polyobject's sector for back-side polyobject segs, it's the in-level sector the polyobject as a whole is being rendered in it turns out. --- src/r_segs.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/r_segs.c b/src/r_segs.c index a2487771..07fe554c 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2483,6 +2483,15 @@ void R_StoreWallRange(INT32 start, INT32 stop) #ifdef ESLOPE maskedtextureheight = ds_p->maskedtextureheight; // note to red, this == &(ds_p->maskedtextureheight[0]) +#ifdef POLYOBJECTS + if (curline->polyseg) { // use REAL front and back floors please, so midtexture rendering isn't mucked up + rw_midtextureslide = rw_midtexturebackslide = 0; + if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) + rw_midtexturemid = rw_midtextureback = max(curline->frontsector->floorheight, curline->backsector->floorheight) - viewz; + else + rw_midtexturemid = rw_midtextureback = min(curline->frontsector->ceilingheight, curline->backsector->ceilingheight) - viewz; + } else +#endif // Set midtexture starting height if (linedef->flags & ML_EFFECT2) { // Ignore slopes when texturing rw_midtextureslide = rw_midtexturebackslide = 0; From df92dc8d9ea84a58f66ba1d6c187d6d4ebeecbc4 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Jun 2016 16:14:08 +0100 Subject: [PATCH 12/18] Print debugging message if sector->linecount is zero --- src/p_setup.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index b36bf0b8..0beb3be3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1931,10 +1931,18 @@ static void P_GroupLines(void) // allocate linebuffers for each sector for (i = 0, sector = sectors; i < numsectors; i++, sector++) { - sector->lines = Z_Calloc(sector->linecount * sizeof(line_t*), PU_LEVEL, NULL); + if (sector->linecount == 0) // no lines found? + { + sector->lines = NULL; + CONS_Debug(DBG_SETUP, "P_GroupLines: sector %d has no lines\n", i); + } + else + { + sector->lines = Z_Calloc(sector->linecount * sizeof(line_t*), PU_LEVEL, NULL); - // zero the count, since we'll later use this to track how many we've recorded - sector->linecount = 0; + // zero the count, since we'll later use this to track how many we've recorded + sector->linecount = 0; + } } // iterate through lines, assigning them to sectors' linebuffers, @@ -1952,11 +1960,14 @@ static void P_GroupLines(void) { M_ClearBox(bbox); - for (j = 0; j < sector->linecount; j++) + if (sector->linecount != 0) { - li = sector->lines[j]; - M_AddToBox(bbox, li->v1->x, li->v1->y); - M_AddToBox(bbox, li->v2->x, li->v2->y); + for (j = 0; j < sector->linecount; j++) + { + li = sector->lines[j]; + M_AddToBox(bbox, li->v1->x, li->v1->y); + M_AddToBox(bbox, li->v2->x, li->v2->y); + } } // set the degenmobj_t to the middle of the bounding box From a7a7a7ee6d6f3b89fd85046b9b66d0a711e1a88b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Jun 2016 18:45:56 +0100 Subject: [PATCH 13/18] Added P_LoadReject function to properly check if REJECT lump is valid or not when loading it, so P_CheckSight can avoid accessing it if not. This should mean that maps built with ZBSDP (no reject) should have less or no problems in netgames compared to the standard ZenNode maps now, hopefully. =) --- src/p_setup.c | 27 ++++++++++++++++++++++++++- src/p_sight.c | 9 ++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 0beb3be3..087ca633 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1977,6 +1977,31 @@ static void P_GroupLines(void) } } +// +// P_LoadReject +// +// Detect if the REJECT lump is valid, +// if not, rejectmatrix will be NULL +static void P_LoadReject(lumpnum_t lumpnum) +{ + size_t count; + const char *lumpname = W_CheckNameForNum(lumpnum); + + // Check if the lump exists, and if it's named "REJECT" + if (!lumpname || memcmp(lumpname, "REJECT", 8) != 0) + { + rejectmatrix = NULL; + return; + } + + count = W_LumpLength(lumpnum); + + if (!count) // zero length, someone probably used ZDBSP + rejectmatrix = NULL; + else + rejectmatrix = W_CacheLumpNum(lumpnum, PU_LEVEL); +} + #if 0 static char *levellumps[] = { @@ -2585,7 +2610,7 @@ boolean P_SetupLevel(boolean skipprecip) P_LoadSubsectors(lastloadedmaplumpnum + ML_SSECTORS); P_LoadNodes(lastloadedmaplumpnum + ML_NODES); P_LoadSegs(lastloadedmaplumpnum + ML_SEGS); - rejectmatrix = W_CacheLumpNum(lastloadedmaplumpnum + ML_REJECT, PU_LEVEL); + P_LoadReject(lastloadedmaplumpnum + ML_REJECT); P_GroupLines(); numdmstarts = numredctfstarts = numbluectfstarts = 0; diff --git a/src/p_sight.c b/src/p_sight.c index 14c1c945..bd6ab4d7 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -325,9 +325,12 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2) s2 = t2->subsector->sector; pnum = (s1-sectors)*numsectors + (s2-sectors); - // Check in REJECT table. - if (rejectmatrix[pnum>>3] & (1 << (pnum&7))) // can't possibly be connected - return false; + if (rejectmatrix != NULL) + { + // Check in REJECT table. + if (rejectmatrix[pnum>>3] & (1 << (pnum&7))) // can't possibly be connected + return false; + } // killough 11/98: shortcut for melee situations // same subsector? obviously visible From 1d0e74f9c0c268bb37b2e2375b1fac0529687ea9 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Jun 2016 21:19:16 +0100 Subject: [PATCH 14/18] "REJECT" is only 5 chars long, not 8. --- 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 087ca633..d7d169e6 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1988,7 +1988,7 @@ static void P_LoadReject(lumpnum_t lumpnum) const char *lumpname = W_CheckNameForNum(lumpnum); // Check if the lump exists, and if it's named "REJECT" - if (!lumpname || memcmp(lumpname, "REJECT", 8) != 0) + if (!lumpname || memcmp(lumpname, "REJECT", 5) != 0) { rejectmatrix = NULL; return; From 472dce1ae65df01972acda0e13d3d00e629a3508 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sat, 11 Jun 2016 21:42:02 -0400 Subject: [PATCH 15/18] Do not why we are not checking REJECT\0\0, let fix this check --- 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 d7d169e6..755f32a8 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1988,7 +1988,7 @@ static void P_LoadReject(lumpnum_t lumpnum) const char *lumpname = W_CheckNameForNum(lumpnum); // Check if the lump exists, and if it's named "REJECT" - if (!lumpname || memcmp(lumpname, "REJECT", 5) != 0) + if (!lumpname || memcmp(lumpname, "REJECT", 7) != 0) { rejectmatrix = NULL; return; From 305d32870f537c90c9035b75dc175ee00e148287 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 12 Jun 2016 18:47:27 +0100 Subject: [PATCH 16/18] Effect 2 (No Midtexture Skew) now toggles off skewing for midtextures on single-sided lines, which was what was intended for them to begin with apparently. This means the current skewing-by-default effect isn't changed, and OpenGL's equivalent code doesn't have to be touched since apparently it was already like that. --- src/r_segs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_segs.c b/src/r_segs.c index 07fe554c..1ee9777d 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1858,7 +1858,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) // a single sided line is terminal, so it must mark ends markfloor = markceiling = true; #ifdef ESLOPE - if (!(linedef->flags & ML_EFFECT1)) { + if (linedef->flags & ML_EFFECT2) { if (linedef->flags & ML_DONTPEGBOTTOM) rw_midtexturemid = frontsector->floorheight + textureheight[sidedef->midtexture] - viewz; else From f94dd510adb882147528c150d5fdd682ec27fdb6 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 12 Jun 2016 21:16:41 +0100 Subject: [PATCH 17/18] change back to 8, add \0s --- 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 755f32a8..8dcfa6d9 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1988,7 +1988,7 @@ static void P_LoadReject(lumpnum_t lumpnum) const char *lumpname = W_CheckNameForNum(lumpnum); // Check if the lump exists, and if it's named "REJECT" - if (!lumpname || memcmp(lumpname, "REJECT", 7) != 0) + if (!lumpname || memcmp(lumpname, "REJECT\0\0", 8) != 0) { rejectmatrix = NULL; return; From 9b037164bcef8410a006ab3d44dbda97303b6ceb Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 12 Jun 2016 21:51:27 +0100 Subject: [PATCH 18/18] Added debug messages for when REJECT lump is not loaded --- src/p_setup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index 8dcfa6d9..6c14e361 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1991,13 +1991,17 @@ static void P_LoadReject(lumpnum_t lumpnum) if (!lumpname || memcmp(lumpname, "REJECT\0\0", 8) != 0) { rejectmatrix = NULL; + CONS_Debug(DBG_SETUP, "P_LoadReject: No valid REJECT lump found\n"); return; } count = W_LumpLength(lumpnum); if (!count) // zero length, someone probably used ZDBSP + { rejectmatrix = NULL; + CONS_Debug(DBG_SETUP, "P_LoadReject: REJECT lump has size 0, will not be loaded\n"); + } else rejectmatrix = W_CacheLumpNum(lumpnum, PU_LEVEL); }