vkdoom_m/src/dsectoreffect.h
Christoph Oelckers e7aa10b5c8 - changed thinker initialization to occur in a Construct function instead of the constructor itself.
This was done to ensure that this code only runs when the thinker itself is fully set up.
With a constructor there is no control about such things, if some common initialization needs to be done it has to be in the base constructor, but that makes the entire approach chosen here to ensure proper linking into the thinker chains impossible.
ZDoom originally did it that way, which resulted in a very inflexible system and required some awful hacks to let the serializer work with it - the corresponding bSerialOverride flag is now gone.

The only thinker class still having a constructor is DFraggleThinker, because it contains non-serializable data that needs to be initialized in a piece of code that always runs, regardless of whether the object is created explicitly or from a savegame.
2019-01-27 13:08:54 +01:00

54 lines
1 KiB
C++

#ifndef __DSECTOREFFECT_H__
#define __DSECTOREFFECT_H__
#include "dthinker.h"
#include "r_defs.h"
class DSectorEffect : public DThinker
{
DECLARE_CLASS (DSectorEffect, DThinker)
public:
static const int DEFAULT_STAT = STAT_SECTOREFFECT;
void Construct(sector_t *sector);
void Serialize(FSerializer &arc);
void OnDestroy() override;
sector_t *GetSector() const { return m_Sector; }
sector_t *m_Sector;
};
class DMover : public DSectorEffect
{
DECLARE_ABSTRACT_CLASS (DMover, DSectorEffect)
HAS_OBJECT_POINTERS
protected:
void Construct(sector_t *sector);
TObjPtr<DInterpolation*> interpolation;
public:
void StopInterpolation(bool force = false);
protected:
void Serialize(FSerializer &arc);
void OnDestroy() override;
};
class DMovingFloor : public DMover
{
DECLARE_ABSTRACT_CLASS (DMovingFloor, DMover)
protected:
void Construct(sector_t *sector);
};
class DMovingCeiling : public DMover
{
DECLARE_ABSTRACT_CLASS (DMovingCeiling, DMover)
protected:
void Construct(sector_t *sector, bool interpolate = true);
};
#endif //__DSECTOREFFECT_H__