From 60dd8dab3c92dff4cdd236644db189ca151c47f6 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Mon, 6 Jun 2016 18:11:23 +0100 Subject: [PATCH 01/12] 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 68fb1696f..aa795a153 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 02/12] 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 aa795a153..e15eae747 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 03/12] 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 e15eae747..6a6736793 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 20c2d84c78a3423beeef30d5d50a4a777b1b1dad Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 9 Jun 2016 20:37:36 +0100 Subject: [PATCH 04/12] 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 11b4c8aef..a2487771b 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 05/12] 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 a2487771b..07fe554c2 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 06/12] 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 b36bf0b80..0beb3be30 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 07/12] 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 0beb3be30..087ca6332 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 14c1c945f..bd6ab4d73 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 08/12] "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 087ca6332..d7d169e6b 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 09/12] 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 d7d169e6b..755f32a85 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 10/12] 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 07fe554c2..1ee9777d0 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 11/12] 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 755f32a85..8dcfa6d91 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 12/12] 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 8dcfa6d91..6c14e3614 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); }