Replace firsttic with timer increment

This commit is contained in:
mazmazz 2018-09-09 21:01:00 -04:00
parent 3f4656e57e
commit 573e1d0017
4 changed files with 11 additions and 17 deletions

View File

@ -2873,9 +2873,9 @@ void T_PolyObjFade(polyfade_t *th)
if (po->thinker == NULL) if (po->thinker == NULL)
po->thinker = &th->thinker; 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 po->translucency = th->destvalue; // set to dest translucency
@ -2884,7 +2884,7 @@ void T_PolyObjFade(polyfade_t *th)
po->thinker = NULL; po->thinker = NULL;
P_RemoveThinker(&th->thinker); P_RemoveThinker(&th->thinker);
} }
else if (!((gametic - th->firsttic) % th->interval)) else if (!(th->timer % th->interval))
{ {
if (th->speed <= 0) if (th->speed <= 0)
po->translucency = max(po->translucency + th->speed, th->destvalue); po->translucency = max(po->translucency + th->speed, th->destvalue);
@ -2968,10 +2968,9 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata)
th->destvalue = pfdata->destvalue; th->destvalue = pfdata->destvalue;
th->docollision = pfdata->docollision; th->docollision = pfdata->docollision;
th->doghostfade = pfdata->doghostfade; th->doghostfade = pfdata->doghostfade;
th->duration = pfdata->duration; th->timer = pfdata->timer;
th->speed = pfdata->speed; th->speed = pfdata->speed;
th->interval = pfdata->interval; th->interval = pfdata->interval;
th->firsttic = pfdata->firsttic;
oldpo = po; oldpo = po;

View File

@ -215,10 +215,9 @@ typedef struct polyfade_s
INT32 destvalue; INT32 destvalue;
boolean docollision; boolean docollision;
boolean doghostfade; boolean doghostfade;
UINT32 duration; INT32 timer;
INT32 speed; INT32 speed;
UINT32 interval; UINT32 interval;
tic_t firsttic;
} polyfade_t; } polyfade_t;
// //
@ -286,10 +285,9 @@ typedef struct polyfadedata_s
INT32 destvalue; INT32 destvalue;
boolean docollision; boolean docollision;
boolean doghostfade; boolean doghostfade;
UINT32 duration; INT32 timer;
INT32 speed; INT32 speed;
UINT32 interval; UINT32 interval;
tic_t firsttic;
} polyfadedata_t; } polyfadedata_t;
// //

View File

@ -1708,10 +1708,9 @@ static void SavePolyfadeThinker(const thinker_t *th, const UINT8 type)
WRITEINT32(save_p, ht->destvalue); WRITEINT32(save_p, ht->destvalue);
WRITEUINT8(save_p, (UINT8)ht->docollision); WRITEUINT8(save_p, (UINT8)ht->docollision);
WRITEUINT8(save_p, (UINT8)ht->doghostfade); WRITEUINT8(save_p, (UINT8)ht->doghostfade);
WRITEUINT32(save_p, ht->duration); WRITEINT32(save_p, ht->timer);
WRITEINT32(save_p, ht->speed); WRITEINT32(save_p, ht->speed);
WRITEUINT32(save_p, ht->interval); WRITEUINT32(save_p, ht->interval);
WRITEUINT32(save_p, (UINT32)ht->firsttic);
} }
#endif #endif
@ -2723,10 +2722,9 @@ static void LoadPolyfadeThinker(actionf_p1 thinker)
ht->destvalue = READINT32(save_p); ht->destvalue = READINT32(save_p);
ht->docollision = (boolean)READUINT8(save_p); ht->docollision = (boolean)READUINT8(save_p);
ht->doghostfade = (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->speed = READINT32(save_p);
ht->interval = READUINT32(save_p); ht->interval = READUINT32(save_p);
ht->firsttic = (tic_t)READUINT32(save_p);
P_AddThinker(&ht->thinker); P_AddThinker(&ht->thinker);
} }
#endif #endif

View File

@ -1276,12 +1276,11 @@ static boolean PolyFade(line_t *line)
pfd.docollision = !(line->flags & ML_BOUNCY), // do not handle collision flags 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.doghostfade = (line->flags & ML_EFFECT1), // do ghost fade (no collision flags during fade)
pfd.duration = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); pfd.timer = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS);
pfd.speed = FixedFloor(FixedDiv(pfd.destvalue - po->translucency, pfd.duration))/FRACUNIT; pfd.speed = FixedFloor(FixedDiv(pfd.destvalue - po->translucency, pfd.timer))/FRACUNIT;
if (!pfd.speed) if (!pfd.speed)
pfd.speed = (pfd.destvalue < po->translucency) ? -1 : 1; pfd.speed = (pfd.destvalue < po->translucency) ? -1 : 1;
pfd.interval = max(FixedFloor(FixedDiv(pfd.duration, abs(pfd.destvalue - po->translucency)))/FRACUNIT, 1); pfd.interval = max(FixedFloor(FixedDiv(pfd.timer, abs(pfd.destvalue - po->translucency)))/FRACUNIT, 1);
pfd.firsttic = gametic;
return EV_DoPolyObjFade(&pfd); return EV_DoPolyObjFade(&pfd);
} }