From 711c35970c0c467c3a78c87aa8a7c851c16e9614 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Mon, 13 Apr 2020 14:31:19 +0200 Subject: [PATCH 1/5] Refactor an unholy piece of code. --- src/p_floor.c | 132 ++++++++++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 58 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index b8b40df3c..2923eeda0 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -48,13 +48,7 @@ result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crus boolean flag; fixed_t lastpos; fixed_t destheight; // used to keep floors/ceilings from moving through each other - // Stuff used for mobj hacks. - INT32 secnum = -1; mobj_t *mo = NULL; - sector_t *sec = NULL; - ffloor_t *rover = NULL; - boolean sectorisffloor = false; - boolean sectorisquicksand = false; sector->moved = true; @@ -193,41 +187,37 @@ result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crus break; } - // Hack for buggy mobjs to move by gravity with moving planes. + // If this is an FOF being checked, check all the affected sectors for moving mobjs. if (sector->tagline) - sectorisffloor = true; - - // Optimization condition. If the sector is not an FOF, declare sec as the main sector outside of the loop. - if (!sectorisffloor) - sec = sector; - - // Optimization condition. Only run the logic if there is any Things in the sector. - if (sectorisffloor || sec->thinglist) { - // If this is an FOF being checked, check all the affected sectors for moving mobjs. - while ((sectorisffloor ? (secnum = P_FindSectorFromLineTag(sector->tagline, secnum)) : (secnum = 1)) >= 0) - { - if (sectorisffloor) - { - // Get actual sector from the list of sectors. - sec = §ors[secnum]; + boolean sectorisquicksand = false; + sector_t *sec; + ffloor_t *rover; + INT32 secnum; - // Can't use P_InQuicksand because it will return the incorrect result - // because of checking for heights. - for (rover = sec->ffloors; rover; rover = rover->next) + while (secnum = P_FindSectorFromLineTag(sector->tagline, secnum) >= 0) + { + // Get actual sector from the list of sectors. + sec = §ors[secnum]; + + if (!sec->thinglist) + continue; + + // Can't use P_InQuicksand because it will return the incorrect result + // because of checking for heights. + for (rover = sec->ffloors; rover; rover = rover->next) + { + if (rover->target == sec && (rover->flags & FF_QUICKSAND)) { - if (rover->target == sec && (rover->flags & FF_QUICKSAND)) - { - sectorisquicksand = true; - break; - } + sectorisquicksand = true; + break; } } for (mo = sec->thinglist; mo; mo = mo->snext) { // The object should be ready to move as defined by this function. - if (!P_MobjReadyToMove(mo, sec, sectorisffloor, sectorisquicksand)) + if (!P_MobjReadyToMove(mo, sec, true, sectorisquicksand)) continue; // The object should not be moving at all. @@ -237,39 +227,65 @@ result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crus // These objects will be affected by this condition. switch (mo->type) { - case MT_GOOP: // Egg Slimer's goop objects - case MT_SPINFIRE: // Elemental Shield flame balls - case MT_SPIKE: // Floor Spike - // Is the object hang from the ceiling? - // In that case, swap the planes used. - // verticalflip inverts - if (!!(mo->flags & MF_SPAWNCEILING) ^ !!(mo->eflags & MFE_VERTICALFLIP)) - { - if (sectorisffloor && !sectorisquicksand) - mo->z = mo->ceilingz - mo->height; - else - mo->z = mo->ceilingz = mo->subsector->sector->ceilingheight - mo->height; - } + case MT_GOOP: // Egg Slimer's goop objects + case MT_SPINFIRE: // Elemental Shield flame balls + case MT_SPIKE: // Floor Spike + // Is the object hang from the ceiling? + // In that case, swap the planes used. + // verticalflip inverts + if (!!(mo->flags & MF_SPAWNCEILING) ^ !!(mo->eflags & MFE_VERTICALFLIP)) + { + if (!sectorisquicksand) + mo->z = mo->ceilingz - mo->height; else - { - if (sectorisffloor && !sectorisquicksand) - mo->z = mo->floorz; - else - mo->z = mo->floorz = mo->subsector->sector->floorheight; - } - break; - // Kill warnings... - default: - break; + mo->z = mo->ceilingz = mo->subsector->sector->ceilingheight - mo->height; + } + else + { + if (!sectorisquicksand) + mo->z = mo->floorz; + else + mo->z = mo->floorz = mo->subsector->sector->floorheight; + } + break; + default: + break; } } - - // Break from loop if there is no FOFs to check. - if (!sectorisffloor) - break; } } + // Only run the logic if there is any mobjs in the sector. + if (sector->thinglist) + for (mo = sector->thinglist; mo; mo = mo->snext) + { + // The object should be ready to move as defined by this function. + if (!P_MobjReadyToMove(mo, sector, false, false)) + continue; + + // The object should not be moving at all. + if (mo->momx || mo->momy || mo->momz) + continue; + + // These objects will be affected by this condition. + switch (mo->type) + { + case MT_GOOP: // Egg Slimer's goop objects + case MT_SPINFIRE: // Elemental Shield flame balls + case MT_SPIKE: // Floor Spike + // Is the object hang from the ceiling? + // In that case, swap the planes used. + // verticalflip inverts + if (!!(mo->flags & MF_SPAWNCEILING) ^ !!(mo->eflags & MFE_VERTICALFLIP)) + mo->z = mo->ceilingz = mo->subsector->sector->ceilingheight - mo->height; + else + mo->z = mo->floorz = mo->subsector->sector->floorheight; + break; + default: + break; + } + } + return ok; } From 74bd23c275f5c57fc5a5f31659fb752e79acddcf Mon Sep 17 00:00:00 2001 From: Nev3r Date: Mon, 13 Apr 2020 15:17:53 +0200 Subject: [PATCH 2/5] Actually remove the entire code block in T_MovePlane(), and remove line_t.tagline as it served no other purpose. --- src/p_floor.c | 101 -------------------------------------------------- src/p_setup.c | 1 - src/p_spec.c | 2 - src/r_defs.h | 5 --- 4 files changed, 109 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index 2923eeda0..078ee187b 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -48,8 +48,6 @@ result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crus boolean flag; fixed_t lastpos; fixed_t destheight; // used to keep floors/ceilings from moving through each other - mobj_t *mo = NULL; - sector->moved = true; switch (floorOrCeiling) @@ -187,105 +185,6 @@ result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crus break; } - // If this is an FOF being checked, check all the affected sectors for moving mobjs. - if (sector->tagline) - { - boolean sectorisquicksand = false; - sector_t *sec; - ffloor_t *rover; - INT32 secnum; - - while (secnum = P_FindSectorFromLineTag(sector->tagline, secnum) >= 0) - { - // Get actual sector from the list of sectors. - sec = §ors[secnum]; - - if (!sec->thinglist) - continue; - - // Can't use P_InQuicksand because it will return the incorrect result - // because of checking for heights. - for (rover = sec->ffloors; rover; rover = rover->next) - { - if (rover->target == sec && (rover->flags & FF_QUICKSAND)) - { - sectorisquicksand = true; - break; - } - } - - for (mo = sec->thinglist; mo; mo = mo->snext) - { - // The object should be ready to move as defined by this function. - if (!P_MobjReadyToMove(mo, sec, true, sectorisquicksand)) - continue; - - // The object should not be moving at all. - if (mo->momx || mo->momy || mo->momz) - continue; - - // These objects will be affected by this condition. - switch (mo->type) - { - case MT_GOOP: // Egg Slimer's goop objects - case MT_SPINFIRE: // Elemental Shield flame balls - case MT_SPIKE: // Floor Spike - // Is the object hang from the ceiling? - // In that case, swap the planes used. - // verticalflip inverts - if (!!(mo->flags & MF_SPAWNCEILING) ^ !!(mo->eflags & MFE_VERTICALFLIP)) - { - if (!sectorisquicksand) - mo->z = mo->ceilingz - mo->height; - else - mo->z = mo->ceilingz = mo->subsector->sector->ceilingheight - mo->height; - } - else - { - if (!sectorisquicksand) - mo->z = mo->floorz; - else - mo->z = mo->floorz = mo->subsector->sector->floorheight; - } - break; - default: - break; - } - } - } - } - - // Only run the logic if there is any mobjs in the sector. - if (sector->thinglist) - for (mo = sector->thinglist; mo; mo = mo->snext) - { - // The object should be ready to move as defined by this function. - if (!P_MobjReadyToMove(mo, sector, false, false)) - continue; - - // The object should not be moving at all. - if (mo->momx || mo->momy || mo->momz) - continue; - - // These objects will be affected by this condition. - switch (mo->type) - { - case MT_GOOP: // Egg Slimer's goop objects - case MT_SPINFIRE: // Elemental Shield flame balls - case MT_SPIKE: // Floor Spike - // Is the object hang from the ceiling? - // In that case, swap the planes used. - // verticalflip inverts - if (!!(mo->flags & MF_SPAWNCEILING) ^ !!(mo->eflags & MFE_VERTICALFLIP)) - mo->z = mo->ceilingz = mo->subsector->sector->ceilingheight - mo->height; - else - mo->z = mo->floorz = mo->subsector->sector->floorheight; - break; - default: - break; - } - } - return ok; } diff --git a/src/p_setup.c b/src/p_setup.c index 6c6ecbc5d..700113d85 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -872,7 +872,6 @@ static void P_InitializeSector(sector_t *ss) ss->linecount = 0; ss->lines = NULL; - ss->tagline = NULL; ss->ffloors = NULL; ss->attached = NULL; diff --git a/src/p_spec.c b/src/p_spec.c index 50b767535..ad22d1a54 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5772,8 +5772,6 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f sec2->floorheight = tempceiling; } - sec2->tagline = master; - if (sec2->numattached == 0) { sec2->attached = Z_Malloc(sizeof (*sec2->attached) * sec2->maxattached, PU_STATIC, NULL); diff --git a/src/r_defs.h b/src/r_defs.h index 5f62ec058..10c0721ac 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -328,11 +328,6 @@ typedef struct sector_s size_t linecount; struct line_s **lines; // [linecount] size - // Hack: store special line tagging to some sectors - // to efficiently help work around bugs by directly - // referencing the specific line that the problem happens in. - // (used in T_MovePlane mobj physics) - struct line_s *tagline; // Improved fake floor hack ffloor_t *ffloors; From 01c0797ba6965c110b37c385c02c3718d962bb90 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Mon, 13 Apr 2020 16:00:58 +0200 Subject: [PATCH 3/5] Remove now unused P_MobjReadyToMove(). --- src/p_floor.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index 078ee187b..aa05c6af2 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -26,19 +26,6 @@ // FLOORS // ========================================================================== -// -// Mini-P_IsObjectOnGroundIn for T_MovePlane hack -// -static inline boolean P_MobjReadyToMove(mobj_t *mo, sector_t *sec, boolean sectorisffloor, boolean sectorisquicksand) -{ - if (sectorisquicksand) - return (mo->z > sec->floorheight && mo->z < sec->ceilingheight); - else if (!!(mo->flags & MF_SPAWNCEILING) ^ !!(mo->eflags & MFE_VERTICALFLIP)) - return ((sectorisffloor) ? (mo->z+mo->height != sec->floorheight) : (mo->z+mo->height != sec->ceilingheight)); - else - return ((sectorisffloor) ? (mo->z != sec->ceilingheight) : (mo->z != sec->floorheight)); -} - // // Move a plane (floor or ceiling) and check for crushing // From 778ef86fee107d820701ba16eabaaa9b0687321f Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 14 Apr 2020 10:31:07 +0200 Subject: [PATCH 4/5] Remove the bridge thinker code. --- src/p_floor.c | 472 -------------------------------------------------- src/p_saveg.c | 10 -- src/p_spec.c | 52 +----- src/p_spec.h | 1 - 4 files changed, 6 insertions(+), 529 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index b8b40df3c..b916014b2 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1275,478 +1275,6 @@ void T_FloatSector(levelspecthink_t *floater) } } -// -// T_BridgeThinker -// -// Kind of like T_RaiseSector, -// but spreads out across -// multiple FOFs at varying -// intensity. -// -void T_BridgeThinker(levelspecthink_t *bridge) -{ - msecnode_t *node; - mobj_t *thing; - sector_t *sector; - sector_t *controlsec = NULL; - INT32 i, k; - - INT16 j; - boolean playeronme = false; - fixed_t ceilingdestination = 0, floordestination = 0; - result_e res = 0; - -#define ORIGFLOORHEIGHT (bridge->vars[0]) -#define ORIGCEILINGHEIGHT (bridge->vars[1]) -#define BASESPEED (bridge->vars[2]) -#define CURSPEED (bridge->vars[3]) -#define STARTTAG ((INT16)bridge->vars[4]) -#define ENDTAG ((INT16)bridge->vars[5]) -#define DIRECTION (bridge->vars[8]) -#define SAGAMT (8*FRACUNIT) - fixed_t lowceilheight = ORIGCEILINGHEIGHT - SAGAMT; - fixed_t lowfloorheight = ORIGFLOORHEIGHT - SAGAMT; -#define LOWCEILINGHEIGHT (lowceilheight) -#define LOWFLOORHEIGHT (lowfloorheight) -#define STARTCONTROLTAG (ENDTAG + 1) -#define ENDCONTROLTAG (ENDTAG + (ENDTAG - STARTTAG) + 1) - - // Is someone standing on it? - for (j = STARTTAG; j <= ENDTAG; j++) - { - for (i = -1; (i = P_FindSectorFromTag(j, i)) >= 0 ;) - { - sector = §ors[i]; - - // Nab the control sector that this sector belongs to. - k = P_FindSectorFromTag((INT16)(j + (ENDTAG-STARTTAG) + 1), -1); - - if (k == -1) - break; - - controlsec = §ors[k]; - - // Is a player standing on me? - for (node = sector->touching_thinglist; node; node = node->m_thinglist_next) - { - thing = node->m_thing; - - if (!thing->player) - continue; - - if (!(thing->z == controlsec->ceilingheight)) - continue; - - playeronme = true; - goto wegotit; // Just take the first one? - } - } - } -wegotit: - if (playeronme) - { - // Lower controlsec like a regular T_RaiseSector - // Set the heights of all the other control sectors to - // be a gradient of this height toward the edges - } - else - { - // Raise controlsec like a regular T_RaiseSector - // Set the heights of all the other control sectors to - // be a gradient of this height toward the edges. - } - - if (playeronme && controlsec) - { - INT32 dist; - - bridge->sector = controlsec; - CURSPEED = BASESPEED; - - { - // Translate tags to - 0 + range - /*so you have a number in [min, max]. - let range = max - min, subtract min - from your number to get [0, range]. - subtract range/2 to get [-range/2, range/2]. - take absolute value and get [0, range/2] where - lower number = closer to midpoint. divide by - range/2 to get [0, 1]. subtract that number - from 1 to get [0, 1] with higher number = closer - to midpoint. multiply this by max sag amount*/ - - INT32 midpoint = STARTCONTROLTAG + ((ENDCONTROLTAG-STARTCONTROLTAG) + 1)/2; -// INT32 tagstart = STARTTAG - midpoint; -// INT32 tagend = ENDTAG - midpoint; - -// CONS_Debug(DBG_GAMELOGIC, "tagstart is %d, tagend is %d\n", tagstart, tagend); - - // Sag is adjusted by how close you are to the center - dist = ((ENDCONTROLTAG - STARTCONTROLTAG))/2 - abs(bridge->sector->tag - midpoint); - -// CONS_Debug(DBG_GAMELOGIC, "Dist is %d\n", dist); - LOWCEILINGHEIGHT -= (SAGAMT) * dist; - LOWFLOORHEIGHT -= (SAGAMT) * dist; - } - - // go down - if (bridge->sector->ceilingheight <= LOWCEILINGHEIGHT) - { - bridge->sector->floorheight = LOWCEILINGHEIGHT - (bridge->sector->ceilingheight - bridge->sector->floorheight); - bridge->sector->ceilingheight = LOWCEILINGHEIGHT; - bridge->sector->ceilspeed = 0; - bridge->sector->floorspeed = 0; - goto dorest; - } - - DIRECTION = -1; - ceilingdestination = LOWCEILINGHEIGHT; - floordestination = LOWFLOORHEIGHT; - - if ((bridge->sector->ceilingheight - LOWCEILINGHEIGHT) - < (ORIGCEILINGHEIGHT - bridge->sector->ceilingheight)) - { - fixed_t origspeed = CURSPEED; - - // Slow down as you get closer to the bottom - CURSPEED = FixedMul(CURSPEED,FixedDiv(bridge->sector->ceilingheight - LOWCEILINGHEIGHT, (ORIGCEILINGHEIGHT - LOWCEILINGHEIGHT)>>5)); - - if (CURSPEED <= origspeed/16) - CURSPEED = origspeed/16; - else if (CURSPEED > origspeed) - CURSPEED = origspeed; - } - else - { - fixed_t origspeed = CURSPEED; - // Slow down as you get closer to the top - CURSPEED = FixedMul(CURSPEED,FixedDiv(ORIGCEILINGHEIGHT - bridge->sector->ceilingheight, (ORIGCEILINGHEIGHT - LOWCEILINGHEIGHT)>>5)); - - if (CURSPEED <= origspeed/16) - CURSPEED = origspeed/16; - else if (CURSPEED > origspeed) - CURSPEED = origspeed; - } - -// CONS_Debug(DBG_GAMELOGIC, "Curspeed is %d\n", CURSPEED>>FRACBITS); - - res = T_MovePlane - ( - bridge->sector, // sector - CURSPEED, // speed - ceilingdestination, // dest - 0, // crush - 1, // floor or ceiling (1 for ceiling) - DIRECTION // direction - ); - - if (res == ok || res == pastdest) - T_MovePlane - ( - bridge->sector, // sector - CURSPEED, // speed - floordestination, // dest - 0, // crush - 0, // floor or ceiling (0 for floor) - DIRECTION // direction - ); - - bridge->sector->ceilspeed = 42; - bridge->sector->floorspeed = CURSPEED*DIRECTION; - - dorest: - // Adjust joined sector heights - { - sector_t *sourcesec = bridge->sector; - - INT32 divisor = sourcesec->tag - ENDTAG + 1; - fixed_t heightdiff = ORIGCEILINGHEIGHT - sourcesec->ceilingheight; - fixed_t interval; - INT32 plusplusme = 0; - - if (divisor > 0) - { - interval = heightdiff/divisor; - -// CONS_Debug(DBG_GAMELOGIC, "interval is %d\n", interval>>FRACBITS); - - // TODO: Use T_MovePlane - - for (j = (INT16)(ENDTAG+1); j <= sourcesec->tag; j++, plusplusme++) - { - for (i = -1; (i = P_FindSectorFromTag(j, i)) >= 0 ;) - { - if (sectors[i].ceilingheight >= sourcesec->ceilingheight) - { - sectors[i].ceilingheight = ORIGCEILINGHEIGHT - (interval*plusplusme); - sectors[i].floorheight = ORIGFLOORHEIGHT - (interval*plusplusme); - } - else // Do the regular rise - { - bridge->sector = §ors[i]; - - CURSPEED = BASESPEED/2; - - // rise back up - if (bridge->sector->ceilingheight >= ORIGCEILINGHEIGHT) - { - bridge->sector->floorheight = ORIGCEILINGHEIGHT - (bridge->sector->ceilingheight - bridge->sector->floorheight); - bridge->sector->ceilingheight = ORIGCEILINGHEIGHT; - bridge->sector->ceilspeed = 0; - bridge->sector->floorspeed = 0; - continue; - } - - DIRECTION = 1; - ceilingdestination = ORIGCEILINGHEIGHT; - floordestination = ORIGFLOORHEIGHT; - -// CONS_Debug(DBG_GAMELOGIC, "ceildest: %d, floordest: %d\n", ceilingdestination>>FRACBITS, floordestination>>FRACBITS); - - if ((bridge->sector->ceilingheight - LOWCEILINGHEIGHT) - < (ORIGCEILINGHEIGHT - bridge->sector->ceilingheight)) - { - fixed_t origspeed = CURSPEED; - - // Slow down as you get closer to the bottom - CURSPEED = FixedMul(CURSPEED,FixedDiv(bridge->sector->ceilingheight - LOWCEILINGHEIGHT, (ORIGCEILINGHEIGHT - LOWCEILINGHEIGHT)>>5)); - - if (CURSPEED <= origspeed/16) - CURSPEED = origspeed/16; - else if (CURSPEED > origspeed) - CURSPEED = origspeed; - } - else - { - fixed_t origspeed = CURSPEED; - // Slow down as you get closer to the top - CURSPEED = FixedMul(CURSPEED,FixedDiv(ORIGCEILINGHEIGHT - bridge->sector->ceilingheight, (ORIGCEILINGHEIGHT - LOWCEILINGHEIGHT)>>5)); - - if (CURSPEED <= origspeed/16) - CURSPEED = origspeed/16; - else if (CURSPEED > origspeed) - CURSPEED = origspeed; - } - - res = T_MovePlane - ( - bridge->sector, // sector - CURSPEED, // speed - ceilingdestination, // dest - 0, // crush - 1, // floor or ceiling (1 for ceiling) - DIRECTION // direction - ); - - if (res == ok || res == pastdest) - T_MovePlane - ( - bridge->sector, // sector - CURSPEED, // speed - floordestination, // dest - 0, // crush - 0, // floor or ceiling (0 for floor) - DIRECTION // direction - ); - - bridge->sector->ceilspeed = 42; - bridge->sector->floorspeed = CURSPEED*DIRECTION; - } - } - } - } - - // Now the other side - divisor = ENDTAG + (ENDTAG-STARTTAG) + 1; - divisor -= sourcesec->tag; - - if (divisor > 0) - { - interval = heightdiff/divisor; - plusplusme = 0; - -// CONS_Debug(DBG_GAMELOGIC, "interval2 is %d\n", interval>>FRACBITS); - - for (j = (INT16)(sourcesec->tag+1); j <= ENDTAG + (ENDTAG-STARTTAG) + 1; j++, plusplusme++) - { - for (i = -1; (i = P_FindSectorFromTag(j, i)) >= 0 ;) - { - if (sectors[i].ceilingheight >= sourcesec->ceilingheight) - { - sectors[i].ceilingheight = sourcesec->ceilingheight + (interval*plusplusme); - sectors[i].floorheight = sourcesec->floorheight + (interval*plusplusme); - } - else // Do the regular rise - { - bridge->sector = §ors[i]; - - CURSPEED = BASESPEED/2; - - // rise back up - if (bridge->sector->ceilingheight >= ORIGCEILINGHEIGHT) - { - bridge->sector->floorheight = ORIGCEILINGHEIGHT - (bridge->sector->ceilingheight - bridge->sector->floorheight); - bridge->sector->ceilingheight = ORIGCEILINGHEIGHT; - bridge->sector->ceilspeed = 0; - bridge->sector->floorspeed = 0; - continue; - } - - DIRECTION = 1; - ceilingdestination = ORIGCEILINGHEIGHT; - floordestination = ORIGFLOORHEIGHT; - -// CONS_Debug(DBG_GAMELOGIC, "ceildest: %d, floordest: %d\n", ceilingdestination>>FRACBITS, floordestination>>FRACBITS); - - if ((bridge->sector->ceilingheight - LOWCEILINGHEIGHT) - < (ORIGCEILINGHEIGHT - bridge->sector->ceilingheight)) - { - fixed_t origspeed = CURSPEED; - - // Slow down as you get closer to the bottom - CURSPEED = FixedMul(CURSPEED,FixedDiv(bridge->sector->ceilingheight - LOWCEILINGHEIGHT, (ORIGCEILINGHEIGHT - LOWCEILINGHEIGHT)>>5)); - - if (CURSPEED <= origspeed/16) - CURSPEED = origspeed/16; - else if (CURSPEED > origspeed) - CURSPEED = origspeed; - } - else - { - fixed_t origspeed = CURSPEED; - // Slow down as you get closer to the top - CURSPEED = FixedMul(CURSPEED,FixedDiv(ORIGCEILINGHEIGHT - bridge->sector->ceilingheight, (ORIGCEILINGHEIGHT - LOWCEILINGHEIGHT)>>5)); - - if (CURSPEED <= origspeed/16) - CURSPEED = origspeed/16; - else if (CURSPEED > origspeed) - CURSPEED = origspeed; - } - - res = T_MovePlane - ( - bridge->sector, // sector - CURSPEED, // speed - ceilingdestination, // dest - 0, // crush - 1, // floor or ceiling (1 for ceiling) - DIRECTION // direction - ); - - if (res == ok || res == pastdest) - T_MovePlane - ( - bridge->sector, // sector - CURSPEED, // speed - floordestination, // dest - 0, // crush - 0, // floor or ceiling (0 for floor) - DIRECTION // direction - ); - - bridge->sector->ceilspeed = 42; - bridge->sector->floorspeed = CURSPEED*DIRECTION; - } - } - } - } - } - - // for (i = -1; (i = P_FindSectorFromTag(bridge->sourceline->tag, i)) >= 0 ;) - // P_RecalcPrecipInSector(§ors[i]); - } - else - { - // Iterate control sectors - for (j = (INT16)(ENDTAG+1); j <= (ENDTAG+(ENDTAG-STARTTAG)+1); j++) - { - for (i = -1; (i = P_FindSectorFromTag(j, i)) >= 0 ;) - { - bridge->sector = §ors[i]; - - CURSPEED = BASESPEED/2; - - // rise back up - if (bridge->sector->ceilingheight >= ORIGCEILINGHEIGHT) - { - bridge->sector->floorheight = ORIGCEILINGHEIGHT - (bridge->sector->ceilingheight - bridge->sector->floorheight); - bridge->sector->ceilingheight = ORIGCEILINGHEIGHT; - bridge->sector->ceilspeed = 0; - bridge->sector->floorspeed = 0; - continue; - } - - DIRECTION = 1; - ceilingdestination = ORIGCEILINGHEIGHT; - floordestination = ORIGFLOORHEIGHT; - -// CONS_Debug(DBG_GAMELOGIC, "ceildest: %d, floordest: %d\n", ceilingdestination>>FRACBITS, floordestination>>FRACBITS); - - if ((bridge->sector->ceilingheight - LOWCEILINGHEIGHT) - < (ORIGCEILINGHEIGHT - bridge->sector->ceilingheight)) - { - fixed_t origspeed = CURSPEED; - - // Slow down as you get closer to the bottom - CURSPEED = FixedMul(CURSPEED,FixedDiv(bridge->sector->ceilingheight - LOWCEILINGHEIGHT, (ORIGCEILINGHEIGHT - LOWCEILINGHEIGHT)>>5)); - - if (CURSPEED <= origspeed/16) - CURSPEED = origspeed/16; - else if (CURSPEED > origspeed) - CURSPEED = origspeed; - } - else - { - fixed_t origspeed = CURSPEED; - // Slow down as you get closer to the top - CURSPEED = FixedMul(CURSPEED,FixedDiv(ORIGCEILINGHEIGHT - bridge->sector->ceilingheight, (ORIGCEILINGHEIGHT - LOWCEILINGHEIGHT)>>5)); - - if (CURSPEED <= origspeed/16) - CURSPEED = origspeed/16; - else if (CURSPEED > origspeed) - CURSPEED = origspeed; - } - - res = T_MovePlane - ( - bridge->sector, // sector - CURSPEED, // speed - ceilingdestination, // dest - 0, // crush - 1, // floor or ceiling (1 for ceiling) - DIRECTION // direction - ); - - if (res == ok || res == pastdest) - T_MovePlane - ( - bridge->sector, // sector - CURSPEED, // speed - floordestination, // dest - 0, // crush - 0, // floor or ceiling (0 for floor) - DIRECTION // direction - ); - - bridge->sector->ceilspeed = 42; - bridge->sector->floorspeed = CURSPEED*DIRECTION; - } - } - // Update precip - } - -#undef SAGAMT -#undef LOWFLOORHEIGHT -#undef LOWCEILINGHEIGHT -#undef ORIGFLOORHEIGHT -#undef ORIGCEILINGHEIGHT -#undef BASESPEED -#undef CURSPEED -#undef STARTTAG -#undef ENDTAG -#undef DIRECTION -} - static mobj_t *SearchMarioNode(msecnode_t *node) { mobj_t *thing = NULL; diff --git a/src/p_saveg.c b/src/p_saveg.c index 716904432..259e58168 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1275,7 +1275,6 @@ typedef enum tc_marioblockchecker, tc_spikesector, tc_floatsector, - tc_bridgethinker, tc_crushceiling, tc_scroll, tc_friction, @@ -2291,11 +2290,6 @@ static void P_NetArchiveThinkers(void) SaveSpecialLevelThinker(th, tc_floatsector); continue; } - else if (th->function.acp1 == (actionf_p1)T_BridgeThinker) - { - SaveSpecialLevelThinker(th, tc_bridgethinker); - continue; - } else if (th->function.acp1 == (actionf_p1)T_LaserFlash) { SaveLaserThinker(th, tc_laserflash); @@ -3487,10 +3481,6 @@ static void P_NetUnArchiveThinkers(void) th = LoadSpecialLevelThinker((actionf_p1)T_FloatSector, 0); break; - case tc_bridgethinker: - th = LoadSpecialLevelThinker((actionf_p1)T_BridgeThinker, 3); - break; - case tc_laserflash: th = LoadLaserThinker((actionf_p1)T_LaserFlash); break; diff --git a/src/p_spec.c b/src/p_spec.c index 50b767535..8e56f2efe 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2041,7 +2041,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller INT32 triggercolor = (INT32)sides[triggerline->sidenum[0]].toptexture; UINT8 color = (actor->player ? actor->player->powers[pw_dye] : actor->color); boolean invert = (triggerline->flags & ML_NOCLIMB ? true : false); - + if (invert ^ (triggercolor != color)) return false; } @@ -4050,23 +4050,23 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } } break; - + case 463: // Dye object { INT32 color = sides[line->sidenum[0]].toptexture; - + if (mo) { if (color < 0 || color >= MAXTRANSLATIONS) return; - + var1 = 0; var2 = color; A_Dye(mo); } } break; - + #ifdef POLYOBJECTS case 480: // Polyobj_DoorSlide case 481: // Polyobj_DoorSwing @@ -5975,39 +5975,6 @@ static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline) floater->sourceline = sourceline; } -/** Adds a bridge thinker. - * Bridge thinkers cause a group of FOFs to behave like - * a bridge made up of pieces, that bows under weight. - * - * \param sec Control sector. - * \sa P_SpawnSpecials, T_BridgeThinker - * \author SSNTails - */ -/* -static inline void P_AddBridgeThinker(line_t *sourceline, sector_t *sec) -{ - levelspecthink_t *bridge; - - // create an initialize new thinker - bridge = Z_Calloc(sizeof (*bridge), PU_LEVSPEC, NULL); - P_AddThinker(THINK_MAIN, &bridge->thinker); - - bridge->thinker.function.acp1 = (actionf_p1)T_BridgeThinker; - - bridge->sector = sec; - bridge->vars[0] = sourceline->frontsector->floorheight; - bridge->vars[1] = sourceline->frontsector->ceilingheight; - bridge->vars[2] = P_AproxDistance(sourceline->dx, sourceline->dy); // Speed - bridge->vars[2] = FixedDiv(bridge->vars[2], 16*FRACUNIT); - bridge->vars[3] = bridge->vars[2]; - - // Start tag and end tag are TARGET SECTORS, not CONTROL SECTORS - // Control sector tags should be End_Tag + (End_Tag - Start_Tag) - bridge->vars[4] = sourceline->tag; // Start tag - bridge->vars[5] = (sides[sourceline->sidenum[0]].textureoffset>>FRACBITS); // End tag -} -*/ - /** * Adds a plane displacement thinker. * Whenever the "control" sector moves, @@ -6753,13 +6720,6 @@ void P_SpawnSpecials(boolean fromnetsave) } break; - case 65: // Bridge Thinker - /* - // Disable this until it's working right! - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - P_AddBridgeThinker(&lines[i], §ors[s]);*/ - break; - case 66: // Displace floor by front sector for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) P_AddPlaneDisplaceThinker(pd_floor, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); @@ -7287,7 +7247,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 331: case 333: break; - + // Object dye executors case 334: case 336: diff --git a/src/p_spec.h b/src/p_spec.h index 6377059b6..d756f1942 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -354,7 +354,6 @@ void T_StartCrumble(elevator_t *elevator); void T_MarioBlock(levelspecthink_t *block); void T_SpikeSector(levelspecthink_t *spikes); void T_FloatSector(levelspecthink_t *floater); -void T_BridgeThinker(levelspecthink_t *bridge); void T_MarioBlockChecker(levelspecthink_t *block); void T_ThwompSector(levelspecthink_t *thwomp); void T_NoEnemiesSector(levelspecthink_t *nobaddies); From 98481dc10b24f43d77b146dfcd42b87496c60827 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 14 Apr 2020 10:31:26 +0200 Subject: [PATCH 5/5] Remove the bridge thinker entry from the ZB configuration. --- extras/conf/SRB2-22.cfg | 6 ------ 1 file changed, 6 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index ec030b32f..b918cdb26 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -738,12 +738,6 @@ linedeftypes flags2text = "[1] Use control sector tag"; flags64text = "[6] No sound effect"; } - - 65 - { - title = "Bridge Thinker "; - prefix = "(65)"; - } } polyobject