From 9055c587836f159d6cfd3faf377c3db6949d2d5a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 7 Sep 2018 15:27:18 -0400 Subject: [PATCH 01/11] Initial polyobj fade skeleton --- src/p_polyobj.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ src/p_polyobj.h | 17 +++++++++++++ src/p_saveg.c | 24 ++++++++++++++++++ src/p_spec.c | 32 ++++++++++++++++++++++++ 4 files changed, 138 insertions(+) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index fd3237c9d..d943a0bfe 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2853,6 +2853,71 @@ INT32 EV_DoPolyObjFlag(line_t *pfdata) return 1; } +void T_PolyObjFade(polyfade_t *th) +{ + polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); + size_t i; + + if (!po) +#ifdef RANGECHECK + I_Error("T_PolyObjFade: thinker has invalid id %d\n", th->polyObjNum); +#else + { + CONS_Debug(DBG_POLYOBJ, "T_PolyObjFade: thinker with invalid id %d removed.\n", th->polyObjNum); + P_RemoveThinkerDelayed(&th->thinker); + return; + } +#endif + + // check for displacement due to override and reattach when possible + if (po->thinker == NULL) + po->thinker = &th->thinker; + + // \todo logic +} + +INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) +{ + polyobj_t *po; + polyobj_t *oldpo; + polyfade_t *th; + INT32 start; + + if (!(po = Polyobj_GetForNum(prdata->polyObjNum))) + { + CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjRotate: bad polyobj %d\n", prdata->polyObjNum); + return 0; + } + + // don't allow line actions to affect bad polyobjects + if (po->isBad) + return 0; + + // create a new thinker + th = Z_Malloc(sizeof(polyfade_t), PU_LEVSPEC, NULL); + th->thinker.function.acp1 = (actionf_p1)T_PolyObjFade; + PolyObj_AddThinker(&th->thinker); + po->thinker = &th->thinker; + + // set fields + th->polyObjNum = pfdata->tag; + + // \todo polyfade fields + + oldpo = po; + + // apply action to mirroring polyobjects as well + start = 0; + while ((po = Polyobj_GetChild(oldpo, &start))) + { + pfdata->tag = po->id; + EV_DoPolyObjFade(pfdata); + } + + // action was successful + return 1; +} + #endif // ifdef POLYOBJECTS // EOF diff --git a/src/p_polyobj.h b/src/p_polyobj.h index c9838a922..0bd94a636 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -207,6 +207,15 @@ typedef struct polydisplace_s fixed_t oldHeights; } polydisplace_t; +typedef struct polyfade_s +{ + thinker_t thinker; // must be first + + INT32 polyObjNum; + + // \todo polyfade fields +} polyfade_t; + // // Line Activation Data Structures // @@ -266,6 +275,12 @@ typedef struct polydisplacedata_s fixed_t dy; } polydisplacedata_t; +typedef struct polyfadedata_s +{ + INT32 polyObjNum; + // \todo polyfadedata fields +} polyfadedata_t; + // // Functions // @@ -287,6 +302,7 @@ void T_PolyDoorSlide(polyslidedoor_t *); void T_PolyDoorSwing(polyswingdoor_t *); void T_PolyObjDisplace (polydisplace_t *); void T_PolyObjFlag (polymove_t *); +void T_PolyObjFade (polyfade_t *); INT32 EV_DoPolyDoor(polydoordata_t *); INT32 EV_DoPolyObjMove(polymovedata_t *); @@ -294,6 +310,7 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *); INT32 EV_DoPolyObjRotate(polyrotdata_t *); INT32 EV_DoPolyObjDisplace(polydisplacedata_t *); INT32 EV_DoPolyObjFlag(struct line_s *); +INT32 EV_DoPolyObjFade(polyfadedata_t *); // diff --git a/src/p_saveg.c b/src/p_saveg.c index 22d43f358..3cc061ebb 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1019,6 +1019,7 @@ typedef enum tc_polyswingdoor, tc_polyflag, tc_polydisplace, + tc_polyfade, #endif tc_end } specials_e; @@ -1918,6 +1919,11 @@ static void P_NetArchiveThinkers(void) SavePolydisplaceThinker(th, tc_polydisplace); continue; } + else if (th->function.acp1 == (actionf_p1)T_PolyObjFade) + { + SavePolyfadeThinker(th, tc_polyfade); + continue; + } #endif #ifdef PARANOIA else if (th->function.acv != P_RemoveThinkerDelayed) // wait garbage collection @@ -2689,6 +2695,20 @@ static inline void LoadPolydisplaceThinker(actionf_p1 thinker) ht->oldHeights = READFIXED(save_p); P_AddThinker(&ht->thinker); } + +// +// LoadPolyfadeThinker +// +// Loads a polyfadet_t thinker +// +static void LoadPolyfadeThinker(actionf_p1 thinker) +{ + polyfade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); + ht->thinker.function.acp1 = thinker; + ht->polyObjNum = READINT32(save_p); + // \todo polyfade thinker fields + P_AddThinker(&ht->thinker); +} #endif /* @@ -2886,6 +2906,10 @@ static void P_NetUnArchiveThinkers(void) case tc_polydisplace: LoadPolydisplaceThinker((actionf_p1)T_PolyObjDisplace); break; + + case tc_polyfade: + LoadPolyfadeThinker((actionf_p1)T_PolyObjFade); + break; #endif case tc_scroll: LoadScrollThinker((actionf_p1)T_Scroll); diff --git a/src/p_spec.c b/src/p_spec.c index 6c359c9cc..fd2c312fb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1245,6 +1245,35 @@ static void PolyTranslucency(line_t *line) po->translucency = (line->frontsector->floorheight >> FRACBITS) / 100; } +// +// PolyFade +// +// Makes a polyobject translucency fade and applies tangibility +// +static void PolyFade(line_t *line) +{ + INT32 polyObjNum = line->tag; + polyobj_t *po; + + if (!(po = Polyobj_GetForNum(polyObjNum))) + { + CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjWaypoint: bad polyobj %d\n", polyObjNum); + return; + } + + // don't allow line actions to affect bad polyobjects + if (po->isBad) + return; + + polyfadedata_t pfd; + + pfd.polyObjNum = line->tag; + + // \todo polyfadedata fields + + return EV_DoPolyObjFade(&pfd); +} + // // PolyWaypoint // @@ -3337,6 +3366,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 491: PolyTranslucency(line); break; + case 492: + PolyFade(line); + break; #endif default: From b0fca6b7b491f7690edf55758d80547791ab1252 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 01:08:02 -0400 Subject: [PATCH 02/11] Polyobject Fade logic --- src/p_polyobj.c | 85 ++++++++++++++++++++++++++++++++++++++++++++----- src/p_polyobj.h | 17 ++++++++-- src/p_saveg.c | 22 ++++++++++++- src/p_spec.c | 22 ++++++++++--- 4 files changed, 129 insertions(+), 17 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index d943a0bfe..9e5cdf90e 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2855,8 +2855,8 @@ INT32 EV_DoPolyObjFlag(line_t *pfdata) void T_PolyObjFade(polyfade_t *th) { + boolean stillfading = false; polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); - size_t i; if (!po) #ifdef RANGECHECK @@ -2873,7 +2873,67 @@ void T_PolyObjFade(polyfade_t *th) if (po->thinker == NULL) po->thinker = &th->thinker; - // \todo logic + stillfading = !(gametic - th->firsttic >= th->duration); + + if (gametic - th->firsttic >= th->duration) + { + po->translucency = th->destvalue; // set to dest translucency + + // remove thinker + if (po->thinker == &th->thinker) + po->thinker = NULL; + P_RemoveThinker(&th->thinker); + } + else if (!((gametic - th->firsttic) % th->interval)) + { + if (th->speed <= 0) + po->translucency = max(po->translucency + th->speed, th->destvalue); + else + po->translucency = min(po->translucency + th->speed, th->destvalue); + } + + if (!stillfading) + { + // set render flags + if (po->translucency >= NUMTRANSMAPS) // invisible + po->flags &= ~POF_RENDERALL; + else + po->flags |= POF_RENDERALL; + + // set collision + if (th->docollision && th->speed) + { + if (th->speed > 0) // faded out + { + po->flags &= ~POF_SOLID; + po->flags |= POF_NOSPECIALS; + } + else + { + po->flags |= POF_SOLID; + po->flags &= ~POF_NOSPECIALS; + } + } + } + else + { + po->flags |= POF_RENDERALL; + + // set collision + if (th->docollision && th->speed) + { + if (th->doghostfade) + { + po->flags &= ~POF_SOLID; + po->flags |= POF_NOSPECIALS; + } + else + { + po->flags |= POF_SOLID; + po->flags &= ~POF_NOSPECIALS; + } + } + } } INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) @@ -2883,9 +2943,9 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) polyfade_t *th; INT32 start; - if (!(po = Polyobj_GetForNum(prdata->polyObjNum))) + if (!(po = Polyobj_GetForNum(pfdata->polyObjNum))) { - CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjRotate: bad polyobj %d\n", prdata->polyObjNum); + CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjFade: bad polyobj %d\n", pfdata->polyObjNum); return 0; } @@ -2893,6 +2953,10 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) if (po->isBad) return 0; + // already equal, nothing to do + if (po->translucency == pfdata->destvalue) + return 1; + // create a new thinker th = Z_Malloc(sizeof(polyfade_t), PU_LEVSPEC, NULL); th->thinker.function.acp1 = (actionf_p1)T_PolyObjFade; @@ -2900,9 +2964,14 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) po->thinker = &th->thinker; // set fields - th->polyObjNum = pfdata->tag; - - // \todo polyfade fields + th->polyObjNum = pfdata->polyObjNum; + th->destvalue = pfdata->destvalue; + th->docollision = pfdata->docollision; + th->doghostfade = pfdata->doghostfade; + th->duration = pfdata->duration; + th->speed = pfdata->speed; + th->interval = pfdata->interval; + th->firsttic = pfdata->firsttic; oldpo = po; @@ -2910,7 +2979,7 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) start = 0; while ((po = Polyobj_GetChild(oldpo, &start))) { - pfdata->tag = po->id; + pfdata->polyObjNum = po->id; EV_DoPolyObjFade(pfdata); } diff --git a/src/p_polyobj.h b/src/p_polyobj.h index 0bd94a636..cf00d64ba 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -212,8 +212,13 @@ typedef struct polyfade_s thinker_t thinker; // must be first INT32 polyObjNum; - - // \todo polyfade fields + INT32 destvalue; + boolean docollision; + boolean doghostfade; + UINT32 duration; + INT32 speed; + UINT32 interval; + tic_t firsttic; } polyfade_t; // @@ -278,7 +283,13 @@ typedef struct polydisplacedata_s typedef struct polyfadedata_s { INT32 polyObjNum; - // \todo polyfadedata fields + INT32 destvalue; + boolean docollision; + boolean doghostfade; + UINT32 duration; + INT32 speed; + UINT32 interval; + tic_t firsttic; } polyfadedata_t; // diff --git a/src/p_saveg.c b/src/p_saveg.c index 3cc061ebb..fc9382233 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1700,6 +1700,20 @@ static void SavePolydisplaceThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, ht->oldHeights); } +static void SavePolyfadeThinker(const thinker_t *th, const UINT8 type) +{ + const polyfade_t *ht = (const void *)th; + WRITEUINT8(save_p, type); + WRITEINT32(save_p, ht->polyObjNum); + WRITEINT32(save_p, ht->destvalue); + WRITEUINT8(save_p, (UINT8)ht->docollision); + WRITEUINT8(save_p, (UINT8)ht->doghostfade); + WRITEUINT32(save_p, ht->duration); + WRITEINT32(save_p, ht->speed); + WRITEUINT32(save_p, ht->interval); + WRITEUINT32(save_p, (UINT32)ht->firsttic); +} + #endif /* // @@ -2706,7 +2720,13 @@ static void LoadPolyfadeThinker(actionf_p1 thinker) polyfade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->polyObjNum = READINT32(save_p); - // \todo polyfade thinker fields + ht->destvalue = READINT32(save_p); + ht->docollision = (boolean)READUINT8(save_p); + ht->doghostfade = (boolean)READUINT8(save_p); + ht->duration = READUINT32(save_p); + ht->speed = READINT32(save_p); + ht->interval = READUINT32(save_p); + ht->firsttic = (tic_t)READUINT32(save_p); P_AddThinker(&ht->thinker); } #endif diff --git a/src/p_spec.c b/src/p_spec.c index fd2c312fb..6d746f670 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1250,7 +1250,7 @@ static void PolyTranslucency(line_t *line) // // Makes a polyobject translucency fade and applies tangibility // -static void PolyFade(line_t *line) +static boolean PolyFade(line_t *line) { INT32 polyObjNum = line->tag; polyobj_t *po; @@ -1258,18 +1258,30 @@ static void PolyFade(line_t *line) if (!(po = Polyobj_GetForNum(polyObjNum))) { CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjWaypoint: bad polyobj %d\n", polyObjNum); - return; + return 0; } // don't allow line actions to affect bad polyobjects if (po->isBad) - return; + return 0; + + // already equal, nothing to do + if (po->translucency == max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0)) + return 1; polyfadedata_t pfd; - pfd.polyObjNum = line->tag; + pfd.polyObjNum = polyObjNum; + pfd.destvalue = max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0); + pfd.docollision = !(line->flags & ML_BOUNCY), // do not handle collision flags + pfd.doghostfade = (line->flags & ML_EFFECT1), // do ghost fade (no collision flags during fade) - // \todo polyfadedata fields + pfd.duration = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + pfd.speed = FixedFloor(FixedDiv(pfd.destvalue - po->translucency, pfd.duration))/FRACUNIT; + if (!pfd.speed) + pfd.speed = (pfd.destvalue < po->translucency) ? -1 : 1; + pfd.interval = max(FixedFloor(FixedDiv(pfd.duration, abs(pfd.destvalue - po->translucency)))/FRACUNIT, 1); + pfd.firsttic = gametic; return EV_DoPolyObjFade(&pfd); } From 4a6ddbd496e3de265633b7d0a95a683690d6d20b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 21:01:00 -0400 Subject: [PATCH 03/11] Replace firsttic with timer increment --- src/p_polyobj.c | 9 ++++----- src/p_polyobj.h | 6 ++---- src/p_saveg.c | 6 ++---- src/p_spec.c | 7 +++---- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 9e5cdf90e..a8616dba1 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2873,9 +2873,9 @@ void T_PolyObjFade(polyfade_t *th) if (po->thinker == NULL) po->thinker = &th->thinker; - stillfading = !(gametic - th->firsttic >= th->duration); + stillfading = !(--(th->timer) <= 0); - if (gametic - th->firsttic >= th->duration) + if (th->timer <= 0) { po->translucency = th->destvalue; // set to dest translucency @@ -2884,7 +2884,7 @@ void T_PolyObjFade(polyfade_t *th) po->thinker = NULL; P_RemoveThinker(&th->thinker); } - else if (!((gametic - th->firsttic) % th->interval)) + else if (!(th->timer % th->interval)) { if (th->speed <= 0) po->translucency = max(po->translucency + th->speed, th->destvalue); @@ -2968,10 +2968,9 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) th->destvalue = pfdata->destvalue; th->docollision = pfdata->docollision; th->doghostfade = pfdata->doghostfade; - th->duration = pfdata->duration; + th->timer = pfdata->timer; th->speed = pfdata->speed; th->interval = pfdata->interval; - th->firsttic = pfdata->firsttic; oldpo = po; diff --git a/src/p_polyobj.h b/src/p_polyobj.h index cf00d64ba..d5c07cb5b 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -215,10 +215,9 @@ typedef struct polyfade_s INT32 destvalue; boolean docollision; boolean doghostfade; - UINT32 duration; + INT32 timer; INT32 speed; UINT32 interval; - tic_t firsttic; } polyfade_t; // @@ -286,10 +285,9 @@ typedef struct polyfadedata_s INT32 destvalue; boolean docollision; boolean doghostfade; - UINT32 duration; + INT32 timer; INT32 speed; UINT32 interval; - tic_t firsttic; } polyfadedata_t; // diff --git a/src/p_saveg.c b/src/p_saveg.c index fc9382233..403f05b00 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1708,10 +1708,9 @@ static void SavePolyfadeThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->destvalue); WRITEUINT8(save_p, (UINT8)ht->docollision); WRITEUINT8(save_p, (UINT8)ht->doghostfade); - WRITEUINT32(save_p, ht->duration); + WRITEINT32(save_p, ht->timer); WRITEINT32(save_p, ht->speed); WRITEUINT32(save_p, ht->interval); - WRITEUINT32(save_p, (UINT32)ht->firsttic); } #endif @@ -2723,10 +2722,9 @@ static void LoadPolyfadeThinker(actionf_p1 thinker) ht->destvalue = READINT32(save_p); ht->docollision = (boolean)READUINT8(save_p); ht->doghostfade = (boolean)READUINT8(save_p); - ht->duration = READUINT32(save_p); + ht->timer = READINT32(save_p); ht->speed = READINT32(save_p); ht->interval = READUINT32(save_p); - ht->firsttic = (tic_t)READUINT32(save_p); P_AddThinker(&ht->thinker); } #endif diff --git a/src/p_spec.c b/src/p_spec.c index 6d746f670..a20a339ed 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1276,12 +1276,11 @@ static boolean PolyFade(line_t *line) pfd.docollision = !(line->flags & ML_BOUNCY), // do not handle collision flags pfd.doghostfade = (line->flags & ML_EFFECT1), // do ghost fade (no collision flags during fade) - pfd.duration = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); - pfd.speed = FixedFloor(FixedDiv(pfd.destvalue - po->translucency, pfd.duration))/FRACUNIT; + pfd.timer = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + pfd.speed = FixedFloor(FixedDiv(pfd.destvalue - po->translucency, pfd.timer))/FRACUNIT; if (!pfd.speed) pfd.speed = (pfd.destvalue < po->translucency) ? -1 : 1; - pfd.interval = max(FixedFloor(FixedDiv(pfd.duration, abs(pfd.destvalue - po->translucency)))/FRACUNIT, 1); - pfd.firsttic = gametic; + pfd.interval = max(FixedFloor(FixedDiv(pfd.timer, abs(pfd.destvalue - po->translucency)))/FRACUNIT, 1); return EV_DoPolyObjFade(&pfd); } From d0b2728ce1919cd65807e616493177193a862608 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 21:58:20 -0400 Subject: [PATCH 04/11] 490 PolyVisible: Set proper spawn render flags instead of RENDERALL --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index a20a339ed..65f7fcd67 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1218,7 +1218,7 @@ static void PolyVisible(line_t *line) po->flags |= POF_SOLID; po->flags &= ~POF_NOSPECIALS; - po->flags |= POF_RENDERALL; + po->flags |= (po->spawnflags & POF_RENDERALL); } // From 33c1109993cc8ed581dd80d0c10836a346b0c103 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 22:08:07 -0400 Subject: [PATCH 05/11] PolyObjFade: Apply RENDER, SOLID, and NOSPECIALS flags according to spawnflags --- src/p_polyobj.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index a8616dba1..b47afed27 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2898,7 +2898,7 @@ void T_PolyObjFade(polyfade_t *th) if (po->translucency >= NUMTRANSMAPS) // invisible po->flags &= ~POF_RENDERALL; else - po->flags |= POF_RENDERALL; + po->flags |= (po->spawnflags & POF_RENDERALL); // set collision if (th->docollision && th->speed) @@ -2910,14 +2910,15 @@ void T_PolyObjFade(polyfade_t *th) } else { - po->flags |= POF_SOLID; - po->flags &= ~POF_NOSPECIALS; + po->flags |= (po->spawnflags & POF_SOLID); + if (!(po->spawnflags & POF_NOSPECIALS)) + po->flags &= ~POF_NOSPECIALS; } } } else { - po->flags |= POF_RENDERALL; + po->flags |= (po->spawnflags & POF_RENDERALL); // set collision if (th->docollision && th->speed) @@ -2929,8 +2930,9 @@ void T_PolyObjFade(polyfade_t *th) } else { - po->flags |= POF_SOLID; - po->flags &= ~POF_NOSPECIALS; + po->flags |= (po->spawnflags & POF_SOLID); + if (!(po->spawnflags & POF_NOSPECIALS)) + po->flags &= ~POF_NOSPECIALS; } } } From 509965d2c080757e563ab00a55d8ee9af74e769d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 00:04:50 -0400 Subject: [PATCH 06/11] 492 PolyObj Fade, 491 PolyObj Translucency, 490 PolyObj changes * 490: Set proper render flags according to spawnflags * 491: Add relative calc (EFFECT3) and Front X alpha param (DONTPEGTOP) * 492: * Tic-based (EFFECT4) and speed timing * Add relative calc (EFFECT3) and Front X alpha param (DONTPEGTOP) * Set proper render flags according to spawnflags * Fix OpenGL >= NUMTRANSMAPS render bug --- src/p_polyobj.c | 85 +++++++++++++++++++++++++++++++++++++------------ src/p_polyobj.h | 6 ++-- src/p_saveg.c | 6 ++-- src/p_spec.c | 57 +++++++++++++++++++++++++-------- 4 files changed, 116 insertions(+), 38 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index b47afed27..f7545e5bd 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2873,23 +2873,54 @@ void T_PolyObjFade(polyfade_t *th) if (po->thinker == NULL) po->thinker = &th->thinker; - stillfading = !(--(th->timer) <= 0); - - if (th->timer <= 0) + if (th->ticbased) { - po->translucency = th->destvalue; // set to dest translucency + stillfading = !(--(th->timer) <= 0); - // remove thinker - if (po->thinker == &th->thinker) - po->thinker = NULL; - P_RemoveThinker(&th->thinker); - } - else if (!(th->timer % th->interval)) - { - if (th->speed <= 0) - po->translucency = max(po->translucency + th->speed, th->destvalue); + if (th->timer <= 0) + { + po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); + + // remove thinker + if (po->thinker == &th->thinker) + po->thinker = NULL; + P_RemoveThinker(&th->thinker); + } else - po->translucency = min(po->translucency + th->speed, th->destvalue); + { + INT16 delta = abs(th->destvalue - th->sourcevalue); + fixed_t factor = min(FixedDiv(th->speed - th->timer, th->speed), 1*FRACUNIT); + if (th->destvalue < th->sourcevalue) + po->translucency = max(min(po->translucency, th->sourcevalue - (INT16)FixedMul(delta, factor)), th->destvalue); + else if (th->destvalue > th->sourcevalue) + po->translucency = min(max(po->translucency, th->sourcevalue + (INT16)FixedMul(delta, factor)), th->destvalue); + } + } + else + { + fixed_t timerdest = FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS-th->destvalue); + + if (th->destvalue > th->sourcevalue) // fading out, destvalue is higher + { + // for timer, lower is transparent, higher is opaque + stillfading = (th->timer > timerdest); + th->timer = max(timerdest, th->timer - th->speed); + } + else if (th->destvalue < th->sourcevalue) // fading in, destvalue is lower + { stillfading = (th->timer < timerdest); + th->timer = min(timerdest, th->timer + th->speed); + } + + if (!stillfading) + { + po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); + // remove thinker + if (po->thinker == &th->thinker) + po->thinker = NULL; + P_RemoveThinker(&th->thinker); + } + else + po->translucency = FixedDiv(256-th->timer, FixedDiv(256, NUMTRANSMAPS)); } if (!stillfading) @@ -2901,9 +2932,9 @@ void T_PolyObjFade(polyfade_t *th) po->flags |= (po->spawnflags & POF_RENDERALL); // set collision - if (th->docollision && th->speed) + if (th->docollision) { - if (th->speed > 0) // faded out + if (th->destvalue > th->sourcevalue) // faded out { po->flags &= ~POF_SOLID; po->flags |= POF_NOSPECIALS; @@ -2918,10 +2949,14 @@ void T_PolyObjFade(polyfade_t *th) } else { + if (po->translucency >= NUMTRANSMAPS) + // HACK: OpenGL renders fully opaque when >= NUMTRANSMAPS + po->translucency = NUMTRANSMAPS-1; + po->flags |= (po->spawnflags & POF_RENDERALL); // set collision - if (th->docollision && th->speed) + if (th->docollision) { if (th->doghostfade) { @@ -2967,12 +3002,22 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) // set fields th->polyObjNum = pfdata->polyObjNum; + th->sourcevalue = po->translucency; th->destvalue = pfdata->destvalue; th->docollision = pfdata->docollision; th->doghostfade = pfdata->doghostfade; - th->timer = pfdata->timer; - th->speed = pfdata->speed; - th->interval = pfdata->interval; + + if (pfdata->ticbased) + { + th->ticbased = true; + th->timer = th->speed = abs(pfdata->speed); // use th->speed for total duration + } + else + { + th->ticbased = false; + th->timer = FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - po->translucency); // use as internal counter + th->speed = pfdata->speed; + } oldpo = po; diff --git a/src/p_polyobj.h b/src/p_polyobj.h index d5c07cb5b..61404112c 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -212,12 +212,13 @@ typedef struct polyfade_s thinker_t thinker; // must be first INT32 polyObjNum; + INT32 sourcevalue; INT32 destvalue; boolean docollision; boolean doghostfade; + boolean ticbased; INT32 timer; INT32 speed; - UINT32 interval; } polyfade_t; // @@ -285,9 +286,8 @@ typedef struct polyfadedata_s INT32 destvalue; boolean docollision; boolean doghostfade; - INT32 timer; + boolean ticbased; INT32 speed; - UINT32 interval; } polyfadedata_t; // diff --git a/src/p_saveg.c b/src/p_saveg.c index 403f05b00..2bfc5859a 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1705,12 +1705,13 @@ static void SavePolyfadeThinker(const thinker_t *th, const UINT8 type) const polyfade_t *ht = (const void *)th; WRITEUINT8(save_p, type); WRITEINT32(save_p, ht->polyObjNum); + WRITEINT32(save_p, ht->sourcevalue); WRITEINT32(save_p, ht->destvalue); WRITEUINT8(save_p, (UINT8)ht->docollision); WRITEUINT8(save_p, (UINT8)ht->doghostfade); + WRITEUINT8(save_p, (UINT8)ht->ticbased); WRITEINT32(save_p, ht->timer); WRITEINT32(save_p, ht->speed); - WRITEUINT32(save_p, ht->interval); } #endif @@ -2719,12 +2720,13 @@ static void LoadPolyfadeThinker(actionf_p1 thinker) polyfade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->polyObjNum = READINT32(save_p); + ht->sourcevalue = READINT32(save_p); ht->destvalue = READINT32(save_p); ht->docollision = (boolean)READUINT8(save_p); ht->doghostfade = (boolean)READUINT8(save_p); + ht->ticbased = (boolean)READUINT8(save_p); ht->timer = READINT32(save_p); ht->speed = READINT32(save_p); - ht->interval = READUINT32(save_p); P_AddThinker(&ht->thinker); } #endif diff --git a/src/p_spec.c b/src/p_spec.c index 65f7fcd67..49d266f99 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1242,7 +1242,21 @@ static void PolyTranslucency(line_t *line) if (po->isBad) return; - po->translucency = (line->frontsector->floorheight >> FRACBITS) / 100; + // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset + // else, take it out of 1000. If Front X Offset is specified, use that. Else, use floorheight. + if (line->flags & ML_EFFECT3) // relative calc + po->translucency = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)), + NUMTRANSMAPS), 0); + else + po->translucency = (line->flags & ML_DONTPEGBOTTOM) ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100); } // @@ -1265,22 +1279,39 @@ static boolean PolyFade(line_t *line) if (po->isBad) return 0; - // already equal, nothing to do - if (po->translucency == max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0)) - return 1; - polyfadedata_t pfd; pfd.polyObjNum = polyObjNum; - pfd.destvalue = max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0); - pfd.docollision = !(line->flags & ML_BOUNCY), // do not handle collision flags - pfd.doghostfade = (line->flags & ML_EFFECT1), // do ghost fade (no collision flags during fade) - pfd.timer = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); - pfd.speed = FixedFloor(FixedDiv(pfd.destvalue - po->translucency, pfd.timer))/FRACUNIT; - if (!pfd.speed) - pfd.speed = (pfd.destvalue < po->translucency) ? -1 : 1; - pfd.interval = max(FixedFloor(FixedDiv(pfd.timer, abs(pfd.destvalue - po->translucency)))/FRACUNIT, 1); + // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset + // else, take it out of 1000 like type 491. If Front X Offset is specified, use that. Else, use floorheight. + if (line->flags & ML_EFFECT3) + pfd.destvalue = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)), + NUMTRANSMAPS), 0); + else + pfd.destvalue = (line->flags & ML_DONTPEGBOTTOM) ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100); + + // already equal, nothing to do + if (po->translucency == pfd.destvalue) + return 1; + + pfd.docollision = !(line->flags & ML_BOUNCY); // do not handle collision flags + pfd.doghostfade = (line->flags & ML_EFFECT1); // do ghost fade (no collision flags during fade) + pfd.ticbased = (line->flags & ML_EFFECT4); // Speed = Tic Duration + + // allow Back Y Offset to be consistent with other fade specials + pfd.speed = (line->sidenum[1] != 0xFFFF && !sides[line->sidenum[0]].rowoffset) ? + abs(sides[line->sidenum[1]].rowoffset>>FRACBITS) + : abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + return EV_DoPolyObjFade(&pfd); } From c9f6c362ff53844aa75ae9f6a56dd52570a87132 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 00:26:24 -0400 Subject: [PATCH 07/11] 491, 492: Allow BLOCKMONSTERS raw translucency value in floorheight --- src/p_spec.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 49d266f99..0502b5638 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1246,14 +1246,18 @@ static void PolyTranslucency(line_t *line) // else, take it out of 1000. If Front X Offset is specified, use that. Else, use floorheight. if (line->flags & ML_EFFECT3) // relative calc po->translucency = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? - max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS)) : (sides[line->sidenum[0]].textureoffset ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100 : max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)), NUMTRANSMAPS), 0); else po->translucency = (line->flags & ML_DONTPEGBOTTOM) ? - max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), 0)) : (sides[line->sidenum[0]].textureoffset ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100 : max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100); @@ -1284,17 +1288,21 @@ static boolean PolyFade(line_t *line) pfd.polyObjNum = polyObjNum; // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset - // else, take it out of 1000 like type 491. If Front X Offset is specified, use that. Else, use floorheight. - if (line->flags & ML_EFFECT3) + // else, take it out of 1000. If Front X Offset is specified, use that. Else, use floorheight. + if (line->flags & ML_EFFECT3) // relative calc pfd.destvalue = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? - max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS)) : (sides[line->sidenum[0]].textureoffset ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100 : max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)), NUMTRANSMAPS), 0); else pfd.destvalue = (line->flags & ML_DONTPEGBOTTOM) ? - max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), 0)) : (sides[line->sidenum[0]].textureoffset ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100 : max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100); From 413f25f3232fda068524dee50a6c03e42b0ccae5 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 00:56:27 -0400 Subject: [PATCH 08/11] 492: Mixed D+C fix --- src/p_spec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 0502b5638..2583c24f3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1272,6 +1272,7 @@ static boolean PolyFade(line_t *line) { INT32 polyObjNum = line->tag; polyobj_t *po; + polyfadedata_t pfd; if (!(po = Polyobj_GetForNum(polyObjNum))) { @@ -1283,8 +1284,6 @@ static boolean PolyFade(line_t *line) if (po->isBad) return 0; - polyfadedata_t pfd; - pfd.polyObjNum = polyObjNum; // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset From d8b57f32e71f5ad9f732b00ff1c89b4f1dee30d3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 20:00:04 -0400 Subject: [PATCH 09/11] 492: Merge speed and duration logic for fade polyobject --- src/p_polyobj.c | 68 ++++++++++++++++--------------------------------- src/p_polyobj.h | 2 +- src/p_saveg.c | 4 +-- 3 files changed, 25 insertions(+), 49 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index f7545e5bd..bbcf4f42a 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2873,54 +2873,29 @@ void T_PolyObjFade(polyfade_t *th) if (po->thinker == NULL) po->thinker = &th->thinker; - if (th->ticbased) + stillfading = th->ticbased ? !(--(th->timer) <= 0) + : !((th->timer -= th->duration) <= 0); + + if (th->timer <= 0) { - stillfading = !(--(th->timer) <= 0); + po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); - if (th->timer <= 0) - { - po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); - - // remove thinker - if (po->thinker == &th->thinker) - po->thinker = NULL; - P_RemoveThinker(&th->thinker); - } - else - { - INT16 delta = abs(th->destvalue - th->sourcevalue); - fixed_t factor = min(FixedDiv(th->speed - th->timer, th->speed), 1*FRACUNIT); - if (th->destvalue < th->sourcevalue) - po->translucency = max(min(po->translucency, th->sourcevalue - (INT16)FixedMul(delta, factor)), th->destvalue); - else if (th->destvalue > th->sourcevalue) - po->translucency = min(max(po->translucency, th->sourcevalue + (INT16)FixedMul(delta, factor)), th->destvalue); - } + // remove thinker + if (po->thinker == &th->thinker) + po->thinker = NULL; + P_RemoveThinker(&th->thinker); } else { - fixed_t timerdest = FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS-th->destvalue); - - if (th->destvalue > th->sourcevalue) // fading out, destvalue is higher - { - // for timer, lower is transparent, higher is opaque - stillfading = (th->timer > timerdest); - th->timer = max(timerdest, th->timer - th->speed); - } - else if (th->destvalue < th->sourcevalue) // fading in, destvalue is lower - { stillfading = (th->timer < timerdest); - th->timer = min(timerdest, th->timer + th->speed); - } - - if (!stillfading) - { - po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); - // remove thinker - if (po->thinker == &th->thinker) - po->thinker = NULL; - P_RemoveThinker(&th->thinker); - } - else - po->translucency = FixedDiv(256-th->timer, FixedDiv(256, NUMTRANSMAPS)); + INT16 delta = abs(th->destvalue - th->sourcevalue); + INT32 duration = th->ticbased ? th->duration + : abs(FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->destvalue) + - FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->sourcevalue)); // speed-based internal counter duration: delta in 256 scale + fixed_t factor = min(FixedDiv(duration - th->timer, duration), 1*FRACUNIT); + if (th->destvalue < th->sourcevalue) + po->translucency = max(min(po->translucency, th->sourcevalue - (INT16)FixedMul(delta, factor)), th->destvalue); + else if (th->destvalue > th->sourcevalue) + po->translucency = min(max(po->translucency, th->sourcevalue + (INT16)FixedMul(delta, factor)), th->destvalue); } if (!stillfading) @@ -3010,13 +2985,14 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) if (pfdata->ticbased) { th->ticbased = true; - th->timer = th->speed = abs(pfdata->speed); // use th->speed for total duration + th->timer = th->duration = abs(pfdata->speed); // pfdata->speed is duration } else { th->ticbased = false; - th->timer = FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - po->translucency); // use as internal counter - th->speed = pfdata->speed; + th->timer = abs(FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->destvalue) + - FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->sourcevalue)); // delta converted to 256 scale, use as internal counter + th->duration = abs(pfdata->speed); // use th->duration as speed decrement } oldpo = po; diff --git a/src/p_polyobj.h b/src/p_polyobj.h index 61404112c..524518f2a 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -217,8 +217,8 @@ typedef struct polyfade_s boolean docollision; boolean doghostfade; boolean ticbased; + INT32 duration; INT32 timer; - INT32 speed; } polyfade_t; // diff --git a/src/p_saveg.c b/src/p_saveg.c index 2bfc5859a..11c481be8 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1710,8 +1710,8 @@ static void SavePolyfadeThinker(const thinker_t *th, const UINT8 type) WRITEUINT8(save_p, (UINT8)ht->docollision); WRITEUINT8(save_p, (UINT8)ht->doghostfade); WRITEUINT8(save_p, (UINT8)ht->ticbased); + WRITEINT32(save_p, ht->duration); WRITEINT32(save_p, ht->timer); - WRITEINT32(save_p, ht->speed); } #endif @@ -2725,8 +2725,8 @@ static void LoadPolyfadeThinker(actionf_p1 thinker) ht->docollision = (boolean)READUINT8(save_p); ht->doghostfade = (boolean)READUINT8(save_p); ht->ticbased = (boolean)READUINT8(save_p); + ht->duration = READINT32(save_p); ht->timer = READINT32(save_p); - ht->speed = READINT32(save_p); P_AddThinker(&ht->thinker); } #endif From ae5b02bccd8cbc05cd1880c776823ec0d9e1ee84 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 07:06:59 -0400 Subject: [PATCH 10/11] 492: Don't interrupt existing polyobj fader unless EFFECT5 --- src/p_spec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 2583c24f3..481580b79 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1276,7 +1276,7 @@ static boolean PolyFade(line_t *line) if (!(po = Polyobj_GetForNum(polyObjNum))) { - CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjWaypoint: bad polyobj %d\n", polyObjNum); + CONS_Debug(DBG_POLYOBJ, "PolyFade: bad polyobj %d\n", polyObjNum); return 0; } @@ -1284,6 +1284,15 @@ static boolean PolyFade(line_t *line) if (po->isBad) return 0; + // Prevent continuous execs from interfering on an existing fade + if (!(line->flags & ML_EFFECT5) + && po->thinker + && po->thinker->function.acp1 == (actionf_p1)T_PolyObjFade) + { + CONS_Debug(DBG_POLYOBJ, "Line type 492 Executor: Fade PolyObject thinker already exists\n"); + return 0; + } + pfd.polyObjNum = polyObjNum; // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset From f3f8575dfcf94cfc37a3a4a425cba50db807f9ee Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 07:11:31 -0400 Subject: [PATCH 11/11] 492: Remove pre-existing thinker when setting up new fade --- src/p_polyobj.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index bbcf4f42a..c2b3ba399 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2969,6 +2969,9 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) if (po->translucency == pfdata->destvalue) return 1; + if (po->thinker && po->thinker->function.acp1 == (actionf_p1)T_PolyObjFade) + P_RemoveThinker(po->thinker); + // create a new thinker th = Z_Malloc(sizeof(polyfade_t), PU_LEVSPEC, NULL); th->thinker.function.acp1 = (actionf_p1)T_PolyObjFade;