From 0fedd2e566553143d202fc1bbbece55fa6d85be9 Mon Sep 17 00:00:00 2001 From: Marco Z Date: Fri, 30 Mar 2018 15:27:37 -0400 Subject: [PATCH] Define fader thinker names --- src/p_saveg.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/p_spec.c | 33 +++++++++++++++++++++++++++++++++ src/p_spec.h | 16 ++++++++++++++++ 3 files changed, 98 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index 029df08f4..5542b3cda 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -988,6 +988,7 @@ typedef enum tc_noenemies, tc_eachtime, tc_disappear, + tc_fade, tc_planedisplace, #ifdef POLYOBJECTS tc_polyrotate, // haleyjd 03/26/06: polyobjects @@ -1552,6 +1553,25 @@ static void SaveDisappearThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->exists); } +// +// SaveFadeThinker +// +// Saves a fade_t thinker +// +static void SaveFadeThinker(const thinker_t *th, const UINT8 type) +{ + const fade_t *ht = (const void *)th; + // \todo fields + WRITEUINT8(save_p, type); + WRITEUINT32(save_p, ht->appeartime); + WRITEUINT32(save_p, ht->disappeartime); + WRITEUINT32(save_p, ht->offset); + WRITEUINT32(save_p, ht->timer); + WRITEINT32(save_p, ht->affectee); + WRITEINT32(save_p, ht->sourceline); + WRITEINT32(save_p, ht->exists); +} + // // SavePlaneDisplaceThinker // @@ -1854,6 +1874,11 @@ static void P_NetArchiveThinkers(void) SaveDisappearThinker(th, tc_disappear); continue; } + else if (th->function.acp1 == (actionf_p1)T_Fade) + { + SaveFadeThinker(th, tc_fade); + continue; + } else if (th->function.acp1 == (actionf_p1)T_PlaneDisplace) { @@ -2530,6 +2555,26 @@ static inline void LoadDisappearThinker(actionf_p1 thinker) P_AddThinker(&ht->thinker); } +// +// LoadFadeThinker +// +// Loads a fade_t thinker +// +static inline void LoadFadeThinker(actionf_p1 thinker) +{ + fade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); + ht->thinker.function.acp1 = thinker; + // \todo fields + ht->appeartime = READUINT32(save_p); + ht->disappeartime = READUINT32(save_p); + ht->offset = READUINT32(save_p); + ht->timer = READUINT32(save_p); + ht->affectee = READINT32(save_p); + ht->sourceline = READINT32(save_p); + ht->exists = READINT32(save_p); + P_AddThinker(&ht->thinker); +} + // // LoadPlaneDisplaceThinker // @@ -2833,6 +2878,10 @@ static void P_NetUnArchiveThinkers(void) LoadDisappearThinker((actionf_p1)T_Disappear); break; + case tc_fade: + LoadFadeThinker((actionf_p1)T_Fade); + break; + case tc_planedisplace: LoadPlaneDisplaceThinker((actionf_p1)T_PlaneDisplace); break; diff --git a/src/p_spec.c b/src/p_spec.c index 0b005baff..b1ede46d8 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7056,6 +7056,39 @@ void T_Disappear(disappear_t *d) } } +/** Adds master fader thinker. + * + * \param appeartime tics to be existent + * \param disappeartime tics to be nonexistent + * \param sector pointer to control sector + */ +static void P_AddMasterFader(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline) +{ + fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); + + // \todo fields + d->thinker.function.acp1 = (actionf_p1)T_Disappear; + d->appeartime = appeartime; + d->disappeartime = disappeartime; + d->offset = offset; + d->affectee = line; + d->sourceline = sourceline; + d->exists = true; + d->timer = 1; + + P_AddThinker(&d->thinker); +} + +/** Makes a FOF fade + * + * \param d Fade thinker. + * \sa P_AddMasterFader + */ +void T_Fade(fade_t *d) +{ + // \todo everything +} + /* SoM: 3/8/2000: Friction functions start. Add_Friction, diff --git a/src/p_spec.h b/src/p_spec.h index c4e05e072..3ed66f149 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -449,6 +449,22 @@ typedef struct void T_Disappear(disappear_t *d); +// Model for fading FOFs +typedef struct +{ + // \todo fields + thinker_t thinker; ///< Thinker structure for effect. + tic_t appeartime; ///< Tics to be appeared for + tic_t disappeartime;///< Tics to be disappeared for + tic_t offset; ///< Time to wait until thinker starts + tic_t timer; ///< Timer between states + INT32 affectee; ///< Number of affected line + INT32 sourceline; ///< Number of source line + INT32 exists; ///< Exists toggle +} fade_t; + +void T_Fade(fade_t *d); + // Prototype functions for pushers void T_Pusher(pusher_t *p); mobj_t *P_GetPushThing(UINT32 s);