From f52f72256bd7abbd36876f42a213ca2e02121634 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 7 Sep 2018 18:14:52 -0400 Subject: [PATCH 01/15] Thwomp fix: Don't trigger (look for players) when ~FF_EXISTS --- src/p_floor.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index 0e28b831f..bb6bf8d16 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1839,6 +1839,7 @@ void T_ThwompSector(levelspecthink_t *thwomp) #define ceilingwasheight vars[5] fixed_t thwompx, thwompy; sector_t *actionsector; + ffloor_t *rover = NULL; INT32 secnum; // If you just crashed down, wait a second before coming back up. @@ -1853,7 +1854,16 @@ void T_ThwompSector(levelspecthink_t *thwomp) secnum = P_FindSectorFromTag((INT16)thwomp->vars[0], -1); if (secnum > 0) + { actionsector = §ors[secnum]; + + // Look for thwomp FFloor + for (rover = actionsector->ffloors; rover; rover = rover->next) + { + if (rover->master == thwomp->sourceline) + break; + } + } else return; // Bad bad bad! @@ -1942,10 +1952,13 @@ void T_ThwompSector(levelspecthink_t *thwomp) { mobj_t *mp = (void *)&actionsector->soundorg; - if (thwomp->sourceline->flags & ML_EFFECT4) - S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); - else - S_StartSound(mp, sfx_thwomp); + if (!rover || (rover->flags & FF_EXISTS)) + { + if (thwomp->sourceline->flags & ML_EFFECT4) + S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); + else + S_StartSound(mp, sfx_thwomp); + } thwomp->direction = 1; // start heading back up thwomp->distance = TICRATE; // but only after a small delay @@ -1959,18 +1972,21 @@ void T_ThwompSector(levelspecthink_t *thwomp) thinker_t *th; mobj_t *mo; - // scan the thinkers to find players! - for (th = thinkercap.next; th != &thinkercap; th = th->next) + if (!rover || (rover->flags & FF_EXISTS)) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo = (mobj_t *)th; - if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight - && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + // scan the thinkers to find players! + for (th = thinkercap.next; th != &thinkercap; th = th->next) { - thwomp->direction = -1; - break; + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + + mo = (mobj_t *)th; + if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight + && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + { + thwomp->direction = -1; + break; + } } } From 76d7a54b2b5e1c4a125f3bfbfb5b4336cf50688c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 00:34:56 -0400 Subject: [PATCH 02/15] Fix player Z snap to floor on moving platform ~FF_EXISTS * Track player's old floorz by mo->floor_sectornum and floor_ffloornum * Track tmfloorz by tmfloorrover, tmfloor_sectornum, tmfloor_rovernum * Ceiling variants of the above --- src/p_map.c | 100 +++++++++++++++++++++++++++++++++++++++++++++----- src/p_mobj.h | 4 ++ src/p_saveg.c | 13 +++++++ 3 files changed, 108 insertions(+), 9 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index f951621e2..8d0a7aeb1 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -52,6 +52,8 @@ fixed_t tmfloorz, tmceilingz; static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector mobj_t *tmhitthing; // the solid thing you bumped into (for collisions) +ffloor_t *tmfloorrover, *tmceilingrover; +size_t tmfloor_sectornum, tmfloor_rovernum, tmceiling_sectornum, tmceiling_rovernum; #ifdef ESLOPE pslope_t *tmfloorslope, *tmceilingslope; #endif @@ -1417,6 +1419,8 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z + thing->height > tmfloorz) { tmfloorz = thing->z + thing->height; + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1437,6 +1441,8 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1445,6 +1451,8 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1461,6 +1469,8 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z < tmceilingz) { tmceilingz = thing->z; + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1481,6 +1491,8 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1489,6 +1501,8 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1640,6 +1654,8 @@ static boolean PIT_CheckLine(line_t *ld) { tmceilingz = opentop; ceilingline = ld; + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = opentopslope; #endif @@ -1648,6 +1664,8 @@ static boolean PIT_CheckLine(line_t *ld) if (openbottom > tmfloorz) { tmfloorz = openbottom; + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = openbottomslope; #endif @@ -1729,6 +1747,10 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) // will adjust them. tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmfloorslope = newsubsec->sector->f_slope; tmceilingslope = newsubsec->sector->c_slope; @@ -1738,6 +1760,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) if (newsubsec->sector->ffloors) { ffloor_t *rover; + size_t rovernum = 0; fixed_t delta1, delta2; INT32 thingtop = thing->z + thing->height; @@ -1746,7 +1769,10 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) fixed_t topheight, bottomheight; if (!(rover->flags & FF_EXISTS)) + { + rovernum++; continue; + } topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL); bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL); @@ -1772,6 +1798,9 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < topheight - sinklevel) { tmfloorz = topheight - sinklevel; + tmfloorrover = rover; + tmfloor_sectornum = newsubsec->sector - sectors; + tmfloor_rovernum = rovernum; #ifdef ESLOPE tmfloorslope = *rover->t_slope; #endif @@ -1781,12 +1810,16 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmceilingz > bottomheight + sinklevel) { tmceilingz = bottomheight + sinklevel; + tmceilingrover = rover; + tmceiling_sectornum = newsubsec->sector - sectors; + tmceiling_rovernum = rovernum; #ifdef ESLOPE tmceilingslope = *rover->b_slope; #endif } } } + rovernum++; continue; } @@ -1797,7 +1830,10 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) else if (!((rover->flags & FF_BLOCKPLAYER && thing->player) || (rover->flags & FF_BLOCKOTHERS && !thing->player) || rover->flags & FF_QUICKSAND)) + { + rovernum++; continue; + } if (rover->flags & FF_QUICKSAND) { @@ -1805,12 +1841,16 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < thing->z) { tmfloorz = thing->z; + tmfloorrover = rover; + tmfloor_sectornum = newsubsec->sector - sectors; + tmfloor_rovernum = rovernum; #ifdef ESLOPE tmfloorslope = NULL; #endif } } // Quicksand blocks never change heights otherwise. + rovernum++; continue; } @@ -1823,6 +1863,9 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(rover->flags & FF_REVERSEPLATFORM)) { tmfloorz = tmdropoffz = topheight; + tmfloorrover = rover; + tmfloor_sectornum = newsubsec->sector - sectors; + tmfloor_rovernum = rovernum; #ifdef ESLOPE tmfloorslope = *rover->t_slope; #endif @@ -1832,10 +1875,14 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE))) { tmceilingz = tmdrpoffceilz = bottomheight; + tmceilingrover = rover; + tmceiling_sectornum = newsubsec->sector - sectors; + tmceiling_rovernum = rovernum; #ifdef ESLOPE tmceilingslope = *rover->b_slope; #endif } + rovernum++; } } @@ -2328,6 +2375,12 @@ boolean PIT_PushableMoved(mobj_t *thing) mobj_t *oldthing = tmthing; line_t *oldceilline = ceilingline; line_t *oldblockline = blockingline; + ffloor_t *oldflrrover = tmfloorrover; + ffloor_t *oldceilrover = tmceilingrover; + size_t oldflrrover_sectornum = tmfloor_sectornum; + size_t oldflrrover_ffloornum = tmfloor_rovernum; + size_t oldceilrover_sectornum = tmceiling_sectornum; + size_t oldceilrover_ffloornum = tmceiling_rovernum; #ifdef ESLOPE pslope_t *oldfslope = tmfloorslope; pslope_t *oldcslope = tmceilingslope; @@ -2344,6 +2397,12 @@ boolean PIT_PushableMoved(mobj_t *thing) P_SetTarget(&tmthing, oldthing); ceilingline = oldceilline; blockingline = oldblockline; + tmfloorrover = oldflrrover; + tmceilingrover = oldceilrover; + tmfloor_sectornum = oldflrrover_sectornum; + tmfloor_rovernum = oldflrrover_ffloornum; + tmceiling_sectornum = oldceilrover_sectornum; + tmceiling_rovernum = oldceilrover_ffloornum; #ifdef ESLOPE tmfloorslope = oldfslope; tmceilingslope = oldcslope; @@ -2663,7 +2722,9 @@ static boolean P_ThingHeightClip(mobj_t *thing) { boolean floormoved; fixed_t oldfloorz = thing->floorz; + size_t oldfloor_sectornum = thing->floor_sectornum, oldfloor_rovernum = thing->floor_rovernum; boolean onfloor = P_IsObjectOnGround(thing);//(thing->z <= thing->floorz); + ffloor_t *rover = NULL; if (thing->flags & MF_NOCLIPHEIGHT) return true; @@ -2678,6 +2739,10 @@ static boolean P_ThingHeightClip(mobj_t *thing) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floor_sectornum = tmfloor_sectornum; + thing->floor_rovernum = tmfloor_rovernum; + thing->ceiling_sectornum = tmceiling_sectornum; + thing->ceiling_rovernum = tmceiling_rovernum; // Ugly hack?!?! As long as just ceilingz is the lowest, // you'll still get crushed, right? @@ -2686,16 +2751,33 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (onfloor && !(thing->flags & MF_NOGRAVITY) && floormoved) { - if (thing->eflags & MFE_VERTICALFLIP) - thing->pmomz = thing->ceilingz - (thing->z + thing->height); - else - thing->pmomz = thing->floorz - thing->z; - thing->eflags |= MFE_APPLYPMOMZ; + // Find FOF referenced by floorz + if (oldfloor_sectornum) + { + size_t rovernum = 0; + for (rover = sectors[oldfloor_sectornum].ffloors; rover; rover = rover->next) + { + if (rovernum == oldfloor_rovernum) + break; + rovernum++; + } + } - if (thing->eflags & MFE_VERTICALFLIP) - thing->z = thing->ceilingz - thing->height; - else - thing->z = thing->floorz; + // Match the Thing's old floorz to an FOF and check for FF_EXISTS + // If ~FF_EXISTS, don't set mobj Z. + if (!rover || (rover->flags & FF_EXISTS)) + { + if (thing->eflags & MFE_VERTICALFLIP) + thing->pmomz = thing->ceilingz - (thing->z + thing->height); + else + thing->pmomz = thing->floorz - thing->z; + thing->eflags |= MFE_APPLYPMOMZ; + + if (thing->eflags & MFE_VERTICALFLIP) + thing->z = thing->ceilingz - thing->height; + else + thing->z = thing->floorz; + } } else if (!tmfloorthing) { diff --git a/src/p_mobj.h b/src/p_mobj.h index afab6fda6..3a83a0f58 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -282,6 +282,10 @@ typedef struct mobj_s // The closest interval over all contacted sectors (or things). fixed_t floorz; // Nearest floor below. fixed_t ceilingz; // Nearest ceiling above. + size_t floor_sectornum; // FOF referred by floorz + size_t floor_rovernum; // FOF referred by floorz + size_t ceiling_sectornum; // FOF referred by ceilingz + size_t ceiling_rovernum; // FOF referred by ceilingz // For movement checking. fixed_t radius; diff --git a/src/p_saveg.c b/src/p_saveg.c index 22d43f358..33dfd1424 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1192,6 +1192,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->z); // Force this so 3dfloor problems don't arise. WRITEFIXED(save_p, mobj->floorz); WRITEFIXED(save_p, mobj->ceilingz); + WRITEUINT32(save_p, (UINT32)mobj->floor_sectornum); + WRITEUINT32(save_p, (UINT32)mobj->floor_rovernum); + WRITEUINT32(save_p, (UINT32)mobj->ceiling_sectornum); + WRITEUINT32(save_p, (UINT32)mobj->ceiling_rovernum); if (diff & MD_SPAWNPOINT) { @@ -1989,6 +1993,7 @@ static void LoadMobjThinker(actionf_p1 thinker) UINT16 diff2; INT32 i; fixed_t z, floorz, ceilingz; + size_t floor_sectornum, floor_rovernum, ceiling_sectornum, ceiling_rovernum; diff = READUINT32(save_p); if (diff & MD_MORE) @@ -2001,6 +2006,10 @@ static void LoadMobjThinker(actionf_p1 thinker) z = READFIXED(save_p); // Force this so 3dfloor problems don't arise. floorz = READFIXED(save_p); ceilingz = READFIXED(save_p); + floor_sectornum = (size_t)READUINT32(save_p); + floor_rovernum = (size_t)READUINT32(save_p); + ceiling_sectornum = (size_t)READUINT32(save_p); + ceiling_rovernum = (size_t)READUINT32(save_p); if (diff & MD_SPAWNPOINT) { @@ -2026,6 +2035,10 @@ static void LoadMobjThinker(actionf_p1 thinker) mobj->z = z; mobj->floorz = floorz; mobj->ceilingz = ceilingz; + mobj->floor_sectornum = floor_sectornum; + mobj->floor_rovernum = floor_rovernum; + mobj->ceiling_sectornum = ceiling_sectornum; + mobj->ceiling_rovernum = ceiling_rovernum; if (diff & MD_TYPE) mobj->type = READUINT32(save_p); From 7e3d5cd3734c5b2194dca7fb8875c9cfeca97dc4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 00:36:43 -0400 Subject: [PATCH 03/15] Comment out tmfloorrover and tmceilingrover because unused --- src/p_map.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 8d0a7aeb1..62f64922c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -52,7 +52,7 @@ fixed_t tmfloorz, tmceilingz; static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector mobj_t *tmhitthing; // the solid thing you bumped into (for collisions) -ffloor_t *tmfloorrover, *tmceilingrover; +//ffloor_t *tmfloorrover, *tmceilingrover; // unused for now size_t tmfloor_sectornum, tmfloor_rovernum, tmceiling_sectornum, tmceiling_rovernum; #ifdef ESLOPE pslope_t *tmfloorslope, *tmceilingslope; @@ -1419,7 +1419,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z + thing->height > tmfloorz) { tmfloorz = thing->z + thing->height; - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; @@ -1441,7 +1441,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; @@ -1451,7 +1451,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; @@ -1469,7 +1469,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z < tmceilingz) { tmceilingz = thing->z; - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; @@ -1491,7 +1491,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; @@ -1501,7 +1501,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; @@ -1654,7 +1654,7 @@ static boolean PIT_CheckLine(line_t *ld) { tmceilingz = opentop; ceilingline = ld; - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = opentopslope; @@ -1664,7 +1664,7 @@ static boolean PIT_CheckLine(line_t *ld) if (openbottom > tmfloorz) { tmfloorz = openbottom; - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = openbottomslope; @@ -1747,9 +1747,9 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) // will adjust them. tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmfloorslope = newsubsec->sector->f_slope; @@ -1798,7 +1798,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < topheight - sinklevel) { tmfloorz = topheight - sinklevel; - tmfloorrover = rover; + // tmfloorrover = rover; tmfloor_sectornum = newsubsec->sector - sectors; tmfloor_rovernum = rovernum; #ifdef ESLOPE @@ -1810,7 +1810,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmceilingz > bottomheight + sinklevel) { tmceilingz = bottomheight + sinklevel; - tmceilingrover = rover; + // tmceilingrover = rover; tmceiling_sectornum = newsubsec->sector - sectors; tmceiling_rovernum = rovernum; #ifdef ESLOPE @@ -1841,7 +1841,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < thing->z) { tmfloorz = thing->z; - tmfloorrover = rover; + // tmfloorrover = rover; tmfloor_sectornum = newsubsec->sector - sectors; tmfloor_rovernum = rovernum; #ifdef ESLOPE @@ -1863,7 +1863,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(rover->flags & FF_REVERSEPLATFORM)) { tmfloorz = tmdropoffz = topheight; - tmfloorrover = rover; + // tmfloorrover = rover; tmfloor_sectornum = newsubsec->sector - sectors; tmfloor_rovernum = rovernum; #ifdef ESLOPE @@ -1875,7 +1875,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE))) { tmceilingz = tmdrpoffceilz = bottomheight; - tmceilingrover = rover; + // tmceilingrover = rover; tmceiling_sectornum = newsubsec->sector - sectors; tmceiling_rovernum = rovernum; #ifdef ESLOPE @@ -2375,8 +2375,8 @@ boolean PIT_PushableMoved(mobj_t *thing) mobj_t *oldthing = tmthing; line_t *oldceilline = ceilingline; line_t *oldblockline = blockingline; - ffloor_t *oldflrrover = tmfloorrover; - ffloor_t *oldceilrover = tmceilingrover; + // ffloor_t *oldflrrover = tmfloorrover; + // ffloor_t *oldceilrover = tmceilingrover; size_t oldflrrover_sectornum = tmfloor_sectornum; size_t oldflrrover_ffloornum = tmfloor_rovernum; size_t oldceilrover_sectornum = tmceiling_sectornum; @@ -2397,8 +2397,8 @@ boolean PIT_PushableMoved(mobj_t *thing) P_SetTarget(&tmthing, oldthing); ceilingline = oldceilline; blockingline = oldblockline; - tmfloorrover = oldflrrover; - tmceilingrover = oldceilrover; + // tmfloorrover = oldflrrover; + // tmceilingrover = oldceilrover; tmfloor_sectornum = oldflrrover_sectornum; tmfloor_rovernum = oldflrrover_ffloornum; tmceiling_sectornum = oldceilrover_sectornum; From b629104197ada81d27c84c023430749965ed5dc6 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 01:02:17 -0400 Subject: [PATCH 04/15] Also check for FF_SOLID --- src/p_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_map.c b/src/p_map.c index 62f64922c..c275ba0be 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2765,7 +2765,7 @@ static boolean P_ThingHeightClip(mobj_t *thing) // Match the Thing's old floorz to an FOF and check for FF_EXISTS // If ~FF_EXISTS, don't set mobj Z. - if (!rover || (rover->flags & FF_EXISTS)) + if (!rover || ((rover->flags & FF_EXISTS) && (rover->flags & FF_SOLID))) { if (thing->eflags & MFE_VERTICALFLIP) thing->pmomz = thing->ceilingz - (thing->z + thing->height); From 231f19aaabb28bfc40b0a5e25546da8df186372d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 21:02:43 -0400 Subject: [PATCH 05/15] Revert "Merge branch 'random-fof-fixes' into fof-fixes-movingplatexists" This reverts commit cc114590548cb1b7f099d12499d556af2da2c993, reversing changes made to 7e3d5cd3734c5b2194dca7fb8875c9cfeca97dc4. --- src/p_floor.c | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index bb6bf8d16..0e28b831f 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1839,7 +1839,6 @@ void T_ThwompSector(levelspecthink_t *thwomp) #define ceilingwasheight vars[5] fixed_t thwompx, thwompy; sector_t *actionsector; - ffloor_t *rover = NULL; INT32 secnum; // If you just crashed down, wait a second before coming back up. @@ -1854,16 +1853,7 @@ void T_ThwompSector(levelspecthink_t *thwomp) secnum = P_FindSectorFromTag((INT16)thwomp->vars[0], -1); if (secnum > 0) - { actionsector = §ors[secnum]; - - // Look for thwomp FFloor - for (rover = actionsector->ffloors; rover; rover = rover->next) - { - if (rover->master == thwomp->sourceline) - break; - } - } else return; // Bad bad bad! @@ -1952,13 +1942,10 @@ void T_ThwompSector(levelspecthink_t *thwomp) { mobj_t *mp = (void *)&actionsector->soundorg; - if (!rover || (rover->flags & FF_EXISTS)) - { - if (thwomp->sourceline->flags & ML_EFFECT4) - S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); - else - S_StartSound(mp, sfx_thwomp); - } + if (thwomp->sourceline->flags & ML_EFFECT4) + S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); + else + S_StartSound(mp, sfx_thwomp); thwomp->direction = 1; // start heading back up thwomp->distance = TICRATE; // but only after a small delay @@ -1972,21 +1959,18 @@ void T_ThwompSector(levelspecthink_t *thwomp) thinker_t *th; mobj_t *mo; - if (!rover || (rover->flags & FF_EXISTS)) + // scan the thinkers to find players! + for (th = thinkercap.next; th != &thinkercap; th = th->next) { - // scan the thinkers to find players! - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; - mo = (mobj_t *)th; - if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight - && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) - { - thwomp->direction = -1; - break; - } + mo = (mobj_t *)th; + if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight + && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + { + thwomp->direction = -1; + break; } } From d01193df80d3164d437ceb02e9e75cbe304248e9 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 21:59:41 -0400 Subject: [PATCH 06/15] Apply ~FF_EXISTS moving plat fix for VERTICALFLIP --- src/p_map.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index c275ba0be..ab6c03da0 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2723,6 +2723,7 @@ static boolean P_ThingHeightClip(mobj_t *thing) boolean floormoved; fixed_t oldfloorz = thing->floorz; size_t oldfloor_sectornum = thing->floor_sectornum, oldfloor_rovernum = thing->floor_rovernum; + size_t oldceil_sectornum = thing->ceiling_sectornum, oldceil_rovernum = thing->ceiling_rovernum; boolean onfloor = P_IsObjectOnGround(thing);//(thing->z <= thing->floorz); ffloor_t *rover = NULL; @@ -2751,13 +2752,15 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (onfloor && !(thing->flags & MF_NOGRAVITY) && floormoved) { + size_t old_sectornum = (thing->eflags & MFE_VERTICALFLIP) ? oldceil_sectornum : oldfloor_sectornum; + size_t old_rovernum = (thing->eflags & MFE_VERTICALFLIP) ? oldceil_rovernum : oldfloor_rovernum; // Find FOF referenced by floorz - if (oldfloor_sectornum) + if (old_sectornum) { size_t rovernum = 0; - for (rover = sectors[oldfloor_sectornum].ffloors; rover; rover = rover->next) + for (rover = sectors[old_sectornum].ffloors; rover; rover = rover->next) { - if (rovernum == oldfloor_rovernum) + if (rovernum == old_rovernum) break; rovernum++; } From f33f9dd284f67a1a0cf4c1b8a3b671ce3bd30249 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 23:12:37 -0400 Subject: [PATCH 07/15] Replace sectornum/rovernum index vars with ffloor pointers --- src/p_map.c | 93 ++++++++++++++------------------------------------- src/p_mobj.h | 6 ++-- src/p_saveg.c | 48 +++++++++++++++++++------- 3 files changed, 62 insertions(+), 85 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index ab6c03da0..4bf06fa4b 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -52,8 +52,7 @@ fixed_t tmfloorz, tmceilingz; static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector mobj_t *tmhitthing; // the solid thing you bumped into (for collisions) -//ffloor_t *tmfloorrover, *tmceilingrover; // unused for now -size_t tmfloor_sectornum, tmfloor_rovernum, tmceiling_sectornum, tmceiling_rovernum; +ffloor_t *tmfloorrover, *tmceilingrover; #ifdef ESLOPE pslope_t *tmfloorslope, *tmceilingslope; #endif @@ -1419,8 +1418,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z + thing->height > tmfloorz) { tmfloorz = thing->z + thing->height; - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1441,8 +1439,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1451,8 +1448,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1469,8 +1465,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z < tmceilingz) { tmceilingz = thing->z; - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1491,8 +1486,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1501,8 +1495,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1654,8 +1647,7 @@ static boolean PIT_CheckLine(line_t *ld) { tmceilingz = opentop; ceilingline = ld; - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = opentopslope; #endif @@ -1664,8 +1656,7 @@ static boolean PIT_CheckLine(line_t *ld) if (openbottom > tmfloorz) { tmfloorz = openbottom; - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = openbottomslope; #endif @@ -1747,10 +1738,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) // will adjust them. tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmfloorrover = NULL; + tmceilingrover = NULL; #ifdef ESLOPE tmfloorslope = newsubsec->sector->f_slope; tmceilingslope = newsubsec->sector->c_slope; @@ -1798,9 +1787,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < topheight - sinklevel) { tmfloorz = topheight - sinklevel; - // tmfloorrover = rover; - tmfloor_sectornum = newsubsec->sector - sectors; - tmfloor_rovernum = rovernum; + tmfloorrover = rover; #ifdef ESLOPE tmfloorslope = *rover->t_slope; #endif @@ -1810,9 +1797,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmceilingz > bottomheight + sinklevel) { tmceilingz = bottomheight + sinklevel; - // tmceilingrover = rover; - tmceiling_sectornum = newsubsec->sector - sectors; - tmceiling_rovernum = rovernum; + tmceilingrover = rover; #ifdef ESLOPE tmceilingslope = *rover->b_slope; #endif @@ -1841,9 +1826,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < thing->z) { tmfloorz = thing->z; - // tmfloorrover = rover; - tmfloor_sectornum = newsubsec->sector - sectors; - tmfloor_rovernum = rovernum; + tmfloorrover = rover; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1863,9 +1846,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(rover->flags & FF_REVERSEPLATFORM)) { tmfloorz = tmdropoffz = topheight; - // tmfloorrover = rover; - tmfloor_sectornum = newsubsec->sector - sectors; - tmfloor_rovernum = rovernum; + tmfloorrover = rover; #ifdef ESLOPE tmfloorslope = *rover->t_slope; #endif @@ -1875,9 +1856,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE))) { tmceilingz = tmdrpoffceilz = bottomheight; - // tmceilingrover = rover; - tmceiling_sectornum = newsubsec->sector - sectors; - tmceiling_rovernum = rovernum; + tmceilingrover = rover; #ifdef ESLOPE tmceilingslope = *rover->b_slope; #endif @@ -2375,12 +2354,8 @@ boolean PIT_PushableMoved(mobj_t *thing) mobj_t *oldthing = tmthing; line_t *oldceilline = ceilingline; line_t *oldblockline = blockingline; - // ffloor_t *oldflrrover = tmfloorrover; - // ffloor_t *oldceilrover = tmceilingrover; - size_t oldflrrover_sectornum = tmfloor_sectornum; - size_t oldflrrover_ffloornum = tmfloor_rovernum; - size_t oldceilrover_sectornum = tmceiling_sectornum; - size_t oldceilrover_ffloornum = tmceiling_rovernum; + ffloor_t *oldflrrover = tmfloorrover; + ffloor_t *oldceilrover = tmceilingrover; #ifdef ESLOPE pslope_t *oldfslope = tmfloorslope; pslope_t *oldcslope = tmceilingslope; @@ -2397,12 +2372,8 @@ boolean PIT_PushableMoved(mobj_t *thing) P_SetTarget(&tmthing, oldthing); ceilingline = oldceilline; blockingline = oldblockline; - // tmfloorrover = oldflrrover; - // tmceilingrover = oldceilrover; - tmfloor_sectornum = oldflrrover_sectornum; - tmfloor_rovernum = oldflrrover_ffloornum; - tmceiling_sectornum = oldceilrover_sectornum; - tmceiling_rovernum = oldceilrover_ffloornum; + tmfloorrover = oldflrrover; + tmceilingrover = oldceilrover; #ifdef ESLOPE tmfloorslope = oldfslope; tmceilingslope = oldcslope; @@ -2722,8 +2693,8 @@ static boolean P_ThingHeightClip(mobj_t *thing) { boolean floormoved; fixed_t oldfloorz = thing->floorz; - size_t oldfloor_sectornum = thing->floor_sectornum, oldfloor_rovernum = thing->floor_rovernum; - size_t oldceil_sectornum = thing->ceiling_sectornum, oldceil_rovernum = thing->ceiling_rovernum; + ffloor_t *oldfloorrover = thing->floorrover; + ffloor_t *oldceilingrover = thing->ceilingrover; boolean onfloor = P_IsObjectOnGround(thing);//(thing->z <= thing->floorz); ffloor_t *rover = NULL; @@ -2740,10 +2711,8 @@ static boolean P_ThingHeightClip(mobj_t *thing) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; - thing->floor_sectornum = tmfloor_sectornum; - thing->floor_rovernum = tmfloor_rovernum; - thing->ceiling_sectornum = tmceiling_sectornum; - thing->ceiling_rovernum = tmceiling_rovernum; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; // Ugly hack?!?! As long as just ceilingz is the lowest, // you'll still get crushed, right? @@ -2752,19 +2721,7 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (onfloor && !(thing->flags & MF_NOGRAVITY) && floormoved) { - size_t old_sectornum = (thing->eflags & MFE_VERTICALFLIP) ? oldceil_sectornum : oldfloor_sectornum; - size_t old_rovernum = (thing->eflags & MFE_VERTICALFLIP) ? oldceil_rovernum : oldfloor_rovernum; - // Find FOF referenced by floorz - if (old_sectornum) - { - size_t rovernum = 0; - for (rover = sectors[old_sectornum].ffloors; rover; rover = rover->next) - { - if (rovernum == old_rovernum) - break; - rovernum++; - } - } + rover = (thing->eflags & MFE_VERTICALFLIP) ? oldceilingrover : oldfloorrover; // Match the Thing's old floorz to an FOF and check for FF_EXISTS // If ~FF_EXISTS, don't set mobj Z. diff --git a/src/p_mobj.h b/src/p_mobj.h index 3a83a0f58..90394c70d 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -282,10 +282,8 @@ typedef struct mobj_s // The closest interval over all contacted sectors (or things). fixed_t floorz; // Nearest floor below. fixed_t ceilingz; // Nearest ceiling above. - size_t floor_sectornum; // FOF referred by floorz - size_t floor_rovernum; // FOF referred by floorz - size_t ceiling_sectornum; // FOF referred by ceilingz - size_t ceiling_rovernum; // FOF referred by ceilingz + struct ffloor_s *floorrover; // FOF referred by floorz + struct ffloor_s *ceilingrover; // FOF referred by ceilingz // For movement checking. fixed_t radius; diff --git a/src/p_saveg.c b/src/p_saveg.c index 33dfd1424..d0ca0a873 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1192,10 +1192,13 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->z); // Force this so 3dfloor problems don't arise. WRITEFIXED(save_p, mobj->floorz); WRITEFIXED(save_p, mobj->ceilingz); - WRITEUINT32(save_p, (UINT32)mobj->floor_sectornum); - WRITEUINT32(save_p, (UINT32)mobj->floor_rovernum); - WRITEUINT32(save_p, (UINT32)mobj->ceiling_sectornum); - WRITEUINT32(save_p, (UINT32)mobj->ceiling_rovernum); + + // \todo netsync for floorrover + + // WRITEUINT32(save_p, (UINT32)mobj->floor_sectornum); + // WRITEUINT32(save_p, (UINT32)mobj->floor_rovernum); + // WRITEUINT32(save_p, (UINT32)mobj->ceiling_sectornum); + // WRITEUINT32(save_p, (UINT32)mobj->ceiling_rovernum); if (diff & MD_SPAWNPOINT) { @@ -1993,7 +1996,7 @@ static void LoadMobjThinker(actionf_p1 thinker) UINT16 diff2; INT32 i; fixed_t z, floorz, ceilingz; - size_t floor_sectornum, floor_rovernum, ceiling_sectornum, ceiling_rovernum; + //size_t floor_sectornum, floor_rovernum, ceiling_sectornum, ceiling_rovernum; diff = READUINT32(save_p); if (diff & MD_MORE) @@ -2006,10 +2009,26 @@ static void LoadMobjThinker(actionf_p1 thinker) z = READFIXED(save_p); // Force this so 3dfloor problems don't arise. floorz = READFIXED(save_p); ceilingz = READFIXED(save_p); - floor_sectornum = (size_t)READUINT32(save_p); - floor_rovernum = (size_t)READUINT32(save_p); - ceiling_sectornum = (size_t)READUINT32(save_p); - ceiling_rovernum = (size_t)READUINT32(save_p); + + // \todo netsync for floorrover +#if 0 + // Find FOF referenced by floorz + if (old_sectornum) + { + size_t rovernum = 0; + for (rover = sectors[old_sectornum].ffloors; rover; rover = rover->next) + { + if (rovernum == old_rovernum) + break; + rovernum++; + } + } +#endif + + // floor_sectornum = (size_t)READUINT32(save_p); + // floor_rovernum = (size_t)READUINT32(save_p); + // ceiling_sectornum = (size_t)READUINT32(save_p); + // ceiling_rovernum = (size_t)READUINT32(save_p); if (diff & MD_SPAWNPOINT) { @@ -2035,10 +2054,13 @@ static void LoadMobjThinker(actionf_p1 thinker) mobj->z = z; mobj->floorz = floorz; mobj->ceilingz = ceilingz; - mobj->floor_sectornum = floor_sectornum; - mobj->floor_rovernum = floor_rovernum; - mobj->ceiling_sectornum = ceiling_sectornum; - mobj->ceiling_rovernum = ceiling_rovernum; + + // \todo netsync for floorrover + + // mobj->floor_sectornum = floor_sectornum; + // mobj->floor_rovernum = floor_rovernum; + // mobj->ceiling_sectornum = ceiling_sectornum; + // mobj->ceiling_rovernum = ceiling_rovernum; if (diff & MD_TYPE) mobj->type = READUINT32(save_p); From dd35871699cef6f77d05435c1aecdb2ae594f92f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 23:48:14 -0400 Subject: [PATCH 08/15] Savegame netsync for mobj->floorrover and ceilingrrover --- src/p_saveg.c | 100 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 27 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index d0ca0a873..4c9e17b4f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -972,11 +972,13 @@ typedef enum MD2_EXTVAL1 = 1<<5, MD2_EXTVAL2 = 1<<6, MD2_HNEXT = 1<<7, -#ifdef ESLOPE MD2_HPREV = 1<<8, - MD2_SLOPE = 1<<9 + MD2_FLOORROVER = 1<<9, +#ifdef ESLOPE + MD2_CEILINGROVER = 1<<10, + MD2_SLOPE = 1<<11 #else - MD2_HPREV = 1<<8 + MD2_CEILINGROVER = 1<<10 #endif } mobj_diff2_t; @@ -1170,6 +1172,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_HNEXT; if (mobj->hprev) diff2 |= MD2_HPREV; + if (mobj->floorrover) + diff2 |= MD2_FLOORROVER; + if (mobj->ceilingrover) + diff2 |= MD2_CEILINGROVER; #ifdef ESLOPE if (mobj->standingslope) diff2 |= MD2_SLOPE; @@ -1193,12 +1199,45 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->floorz); WRITEFIXED(save_p, mobj->ceilingz); - // \todo netsync for floorrover + if (diff & MD2_FLOORROVER) + { + ffloor_t *rover; + size_t i = 0; + INT32 roverindex = -1; - // WRITEUINT32(save_p, (UINT32)mobj->floor_sectornum); - // WRITEUINT32(save_p, (UINT32)mobj->floor_rovernum); - // WRITEUINT32(save_p, (UINT32)mobj->ceiling_sectornum); - // WRITEUINT32(save_p, (UINT32)mobj->ceiling_rovernum); + for (rover = mobj->floorrover->target->ffloors; rover; rover = rover->next) + { + if (rover == mobj->floorrover) + { + roverindex = i; + break; + } + i++; + } + + WRITEUINT32(save_p, (UINT32)(mobj->floorrover->target - sectors)); + WRITEUINT32(save_p, (UINT32)roverindex); + } + + if (diff & MD2_CEILINGROVER) + { + ffloor_t *rover; + size_t i = 0; + INT32 roverindex = -1; + + for (rover = mobj->ceilingrover->target->ffloors; rover; rover = rover->next) + { + if (rover == mobj->ceilingrover) + { + roverindex = i; + break; + } + i++; + } + + WRITEUINT32(save_p, mobj->ceilingrover->target - sectors); + WRITEUINT32(save_p, roverindex); + } if (diff & MD_SPAWNPOINT) { @@ -1996,7 +2035,7 @@ static void LoadMobjThinker(actionf_p1 thinker) UINT16 diff2; INT32 i; fixed_t z, floorz, ceilingz; - //size_t floor_sectornum, floor_rovernum, ceiling_sectornum, ceiling_rovernum; + ffloor_t *floorrover = NULL, *ceilingrover = NULL; diff = READUINT32(save_p); if (diff & MD_MORE) @@ -2010,25 +2049,37 @@ static void LoadMobjThinker(actionf_p1 thinker) floorz = READFIXED(save_p); ceilingz = READFIXED(save_p); - // \todo netsync for floorrover -#if 0 - // Find FOF referenced by floorz - if (old_sectornum) + if (diff2 & MD2_FLOORROVER) { + size_t floor_sectornum = (size_t)READUINT32(save_p); + size_t floor_rovernum = (size_t)READUINT32(save_p); + ffloor_t *rover = NULL; size_t rovernum = 0; - for (rover = sectors[old_sectornum].ffloors; rover; rover = rover->next) + + for (rover = sectors[floor_sectornum].ffloors; rover; rover = rover->next) { - if (rovernum == old_rovernum) + if (rovernum == floor_rovernum) break; rovernum++; } + floorrover = rover; } -#endif - // floor_sectornum = (size_t)READUINT32(save_p); - // floor_rovernum = (size_t)READUINT32(save_p); - // ceiling_sectornum = (size_t)READUINT32(save_p); - // ceiling_rovernum = (size_t)READUINT32(save_p); + if (diff2 & MD2_CEILINGROVER) + { + size_t ceiling_sectornum = (size_t)READUINT32(save_p); + size_t ceiling_rovernum = (size_t)READUINT32(save_p); + ffloor_t *rover = NULL; + size_t rovernum = 0; + + for (rover = sectors[ceiling_sectornum].ffloors; rover; rover = rover->next) + { + if (rovernum == ceiling_rovernum) + break; + rovernum++; + } + ceilingrover = rover; + } if (diff & MD_SPAWNPOINT) { @@ -2054,13 +2105,8 @@ static void LoadMobjThinker(actionf_p1 thinker) mobj->z = z; mobj->floorz = floorz; mobj->ceilingz = ceilingz; - - // \todo netsync for floorrover - - // mobj->floor_sectornum = floor_sectornum; - // mobj->floor_rovernum = floor_rovernum; - // mobj->ceiling_sectornum = ceiling_sectornum; - // mobj->ceiling_rovernum = ceiling_rovernum; + mobj->floorrover = floorrover; + mobj->ceilingrover = ceilingrover; if (diff & MD_TYPE) mobj->type = READUINT32(save_p); From 03d1baf422434b87f7e1c842f89f9fa3ab7236fa Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:07:22 -0400 Subject: [PATCH 09/15] Savegame floorrover fixes --- src/p_saveg.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 4c9e17b4f..c73df0cc9 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1199,11 +1199,11 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->floorz); WRITEFIXED(save_p, mobj->ceilingz); - if (diff & MD2_FLOORROVER) + if (diff2 & MD2_FLOORROVER) { ffloor_t *rover; size_t i = 0; - INT32 roverindex = -1; + UINT32 roverindex = 0; for (rover = mobj->floorrover->target->ffloors; rover; rover = rover->next) { @@ -1216,14 +1216,14 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) } WRITEUINT32(save_p, (UINT32)(mobj->floorrover->target - sectors)); - WRITEUINT32(save_p, (UINT32)roverindex); + WRITEUINT32(save_p, rover ? roverindex : i); // store max index to denote invalid ffloor ref } - if (diff & MD2_CEILINGROVER) + if (diff2 & MD2_CEILINGROVER) { ffloor_t *rover; size_t i = 0; - INT32 roverindex = -1; + UINT32 roverindex = 0; for (rover = mobj->ceilingrover->target->ffloors; rover; rover = rover->next) { @@ -1235,8 +1235,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) i++; } - WRITEUINT32(save_p, mobj->ceilingrover->target - sectors); - WRITEUINT32(save_p, roverindex); + WRITEUINT32(save_p, (UINT32)(mobj->ceilingrover->target - sectors)); + WRITEUINT32(save_p, rover ? roverindex : i); // store max index to denote invalid ffloor ref } if (diff & MD_SPAWNPOINT) From 832f891cbbacb5f8c1dbb96436753c7472cdce86 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:13:32 -0400 Subject: [PATCH 10/15] Remove rovernum increment from P_CheckPosition because unused --- src/p_map.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 4bf06fa4b..0726084d5 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1749,7 +1749,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) if (newsubsec->sector->ffloors) { ffloor_t *rover; - size_t rovernum = 0; fixed_t delta1, delta2; INT32 thingtop = thing->z + thing->height; @@ -1758,10 +1757,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) fixed_t topheight, bottomheight; if (!(rover->flags & FF_EXISTS)) - { - rovernum++; continue; - } topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL); bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL); @@ -1804,7 +1800,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) } } } - rovernum++; continue; } @@ -1815,10 +1810,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) else if (!((rover->flags & FF_BLOCKPLAYER && thing->player) || (rover->flags & FF_BLOCKOTHERS && !thing->player) || rover->flags & FF_QUICKSAND)) - { - rovernum++; continue; - } if (rover->flags & FF_QUICKSAND) { @@ -1833,7 +1825,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) } } // Quicksand blocks never change heights otherwise. - rovernum++; continue; } @@ -1861,7 +1852,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) tmceilingslope = *rover->b_slope; #endif } - rovernum++; } } From 943dc9412d3e3f39ceb906f379786ac285c533da Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:20:51 -0400 Subject: [PATCH 11/15] Initialize floorrover and ceilingrover on SpawnMobj --- src/p_mobj.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index 7b588645b..d433561ae 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8627,6 +8627,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) #endif mobj->subsector->sector->ceilingheight; + mobj->floorrover = NULL; + mobj->ceilingrover = NULL; + // Tells MobjCheckWater that the water height was not set. mobj->watertop = INT32_MAX; @@ -8890,6 +8893,9 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype #endif mobj->subsector->sector->ceilingheight; + mobj->floorrover = NULL; + mobj->ceilingrover = NULL; + mobj->z = z; mobj->momz = mobjinfo[type].speed; From 0d88f31bbd22b8893503f7d6719bc72923947970 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:23:23 -0400 Subject: [PATCH 12/15] Add floorrover and ceilingrover to precipmobj_t --- src/p_mobj.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_mobj.h b/src/p_mobj.h index 90394c70d..630600b54 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -400,6 +400,8 @@ typedef struct precipmobj_s // The closest interval over all contacted sectors (or things). fixed_t floorz; // Nearest floor below. fixed_t ceilingz; // Nearest ceiling above. + struct ffloor_s *floorrover; // FOF referred by floorz + struct ffloor_s *ceilingrover; // FOF referred by ceilingz // For movement checking. fixed_t radius; // Fixed at 2*FRACUNIT From a6f959ba21c9f599b4823d0adce9bc9d7c355b65 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:35:40 -0400 Subject: [PATCH 13/15] Set mobj->floorrover and ceilingrover in appropriate places --- src/lua_mobjlib.c | 6 ++++++ src/p_local.h | 1 + src/p_map.c | 10 ++++++++++ src/p_mobj.c | 4 ++++ src/p_polyobj.c | 2 ++ 5 files changed, 23 insertions(+) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 1583bd3c4..6efbeff8e 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -396,6 +396,8 @@ static int mobj_set(lua_State *L) P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; P_SetTarget(&tmthing, ptmthing); break; } @@ -439,6 +441,8 @@ static int mobj_set(lua_State *L) P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; P_SetTarget(&tmthing, ptmthing); break; } @@ -451,6 +455,8 @@ static int mobj_set(lua_State *L) P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; P_SetTarget(&tmthing, ptmthing); break; } diff --git a/src/p_local.h b/src/p_local.h index 2676fb030..b98eeae1c 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -326,6 +326,7 @@ void P_InternalFlickyHop(mobj_t *actor, fixed_t momz, fixed_t momh, angle_t angl extern boolean floatok; extern fixed_t tmfloorz; extern fixed_t tmceilingz; +extern ffloor_t *tmfloorrover, *tmceilingrover; extern mobj_t *tmfloorthing, *tmhitthing, *tmthing; extern camera_t *mapcampointer; extern fixed_t tmx; diff --git a/src/p_map.c b/src/p_map.c index 0726084d5..648bb2bcc 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -102,6 +102,8 @@ boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; return true; } @@ -2485,6 +2487,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep) { thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; + thing->ceilingrover = tmceilingrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #ifdef ESLOPE @@ -2492,6 +2495,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else if (tmceilingslope && tmceilingz < thingtop && thingtop - tmceilingz <= maxstep) { thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; + thing->ceilingrover = tmceilingrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #endif @@ -2499,6 +2503,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep) { thing->z = thing->floorz = tmfloorz; + thing->floorrover = tmfloorrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #ifdef ESLOPE @@ -2506,6 +2511,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else if (tmfloorslope && tmfloorz > thing->z && tmfloorz - thing->z <= maxstep) { thing->z = thing->floorz = tmfloorz; + thing->floorrover = tmfloorrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #endif @@ -2577,6 +2583,8 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; #ifdef ESLOPE if (!(thing->flags & MF_NOCLIPHEIGHT)) @@ -2657,6 +2665,8 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; thing->x = x; thing->y = y; diff --git a/src/p_mobj.c b/src/p_mobj.c index d433561ae..7c9baf0f1 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8027,6 +8027,8 @@ void P_MobjThinker(mobj_t *mobj) return; mobj->floorz = tmfloorz; mobj->ceilingz = tmceilingz; + mobj->floorrover = tmfloorrover; + mobj->ceilingrover = tmceilingrover; if ((mobj->eflags & MFE_UNDERWATER) && mobj->health > 0) { @@ -8545,6 +8547,8 @@ void P_SceneryThinker(mobj_t *mobj) return; mobj->floorz = tmfloorz; mobj->ceilingz = tmceilingz; + mobj->floorrover = tmfloorrover; + mobj->ceilingrover = tmceilingrover; } else { diff --git a/src/p_polyobj.c b/src/p_polyobj.c index fd3237c9d..23e799d06 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -985,6 +985,8 @@ static void Polyobj_pushThing(polyobj_t *po, line_t *line, mobj_t *mo) P_CheckPosition(mo, mo->x + momx, mo->y + momy); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; } } From f85d1da54f700cfc88b1a4bcc56260c8141584a5 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 21:42:52 -0400 Subject: [PATCH 14/15] Lua support for floorrover/ceilingrover --- src/lua_mobjlib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 6efbeff8e..da0e99ab2 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -40,6 +40,8 @@ enum mobj_e { mobj_subsector, mobj_floorz, mobj_ceilingz, + mobj_floorrover, + mobj_ceilingrover, mobj_radius, mobj_height, mobj_momx, @@ -100,6 +102,8 @@ static const char *const mobj_opt[] = { "subsector", "floorz", "ceilingz", + "floorrover", + "ceilingrover", "radius", "height", "momx", @@ -208,6 +212,12 @@ static int mobj_get(lua_State *L) case mobj_ceilingz: lua_pushfixed(L, mo->ceilingz); break; + case mobj_floorrover: + LUA_PushUserdata(L, mo->floorrover, META_FFLOOR); + break; + case mobj_ceilingrover: + LUA_PushUserdata(L, mo->ceilingrover, META_FFLOOR); + break; case mobj_radius: lua_pushfixed(L, mo->radius); break; @@ -432,6 +442,10 @@ static int mobj_set(lua_State *L) return NOSETPOS; case mobj_ceilingz: return NOSETPOS; + case mobj_floorrover: + return NOSET; + case mobj_ceilingrover: + return NOSET; case mobj_radius: { mobj_t *ptmthing = tmthing; From c45d523e8f2e1505283e614695bfe05d71b1ff82 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 06:27:30 -0400 Subject: [PATCH 15/15] 420: Don't interrupt existing light fade on duration timing except EFFECT5 (cherry picked from commit 3b957c32517a8f5148940c0067af7e88a51d1fee) --- src/lua_baselib.c | 3 ++- src/p_lights.c | 12 +++++++++++- src/p_spec.c | 3 ++- src/p_spec.h | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 840863eb0..ce017620c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1810,9 +1810,10 @@ static int lib_pFadeLight(lua_State *L) INT32 destvalue = (INT32)luaL_checkinteger(L, 2); INT32 speed = (INT32)luaL_checkinteger(L, 3); boolean ticbased = lua_optboolean(L, 4); + boolean force = lua_optboolean(L, 5); NOHUD INLEVEL - P_FadeLight(tag, destvalue, speed, ticbased); + P_FadeLight(tag, destvalue, speed, ticbased, force); return 0; } diff --git a/src/p_lights.c b/src/p_lights.c index 2ea93b796..12abc9e05 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -371,12 +371,22 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean } } -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force) { INT32 i; // search all sectors for ones with tag for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0 ;) + { + if (!force && ticbased // always let speed fader execute + && sectors[i].lightingdata + && ((lightlevel_t*)sectors[i].lightingdata)->thinker.function.acp1 == (actionf_p1)T_LightFade) + // && ((lightlevel_t*)sectors[i].lightingdata)->timer > 2) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 420 Executor: Fade light thinker already exists, timer: %d\n", ((lightlevel_t*)sectors[i].lightingdata)->timer); + continue; + } P_FadeLightBySector(§ors[i], destvalue, speed, ticbased); + } } /** Fades the light level in a sector to a new value. diff --git a/src/p_spec.c b/src/p_spec.c index b0a976a10..42cff1282 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2877,7 +2877,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) max(min(sides[line->sidenum[1]].rowoffset>>FRACBITS, 255), 0) : max(min(sides[line->sidenum[0]].rowoffset>>FRACBITS, 255), 0)) : abs(P_AproxDistance(line->dx, line->dy))>>FRACBITS, - (line->flags & ML_EFFECT4)); + (line->flags & ML_EFFECT4), + (line->flags & ML_EFFECT5)); break; case 421: // Stop lighting effect in tagged sectors diff --git a/src/p_spec.h b/src/p_spec.h index 56684b496..848b80ecf 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -162,7 +162,7 @@ void T_Glow(glow_t *g); glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length); void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased); -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased); +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force); void T_LightFade(lightlevel_t *ll); typedef enum