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); }