gzdoom/src/r_data/r_interpolate.h
Christoph Oelckers 5a2d6de296 - split up the OnDestroy method of interpolations.
It seems there can be rare conditions where an interpolation is 'lost' and later garbage collected. If that happens after the owning map is gone, all pointers in the interpolation object will be invalid and Destroy would crash while trying to unlink it. So anything that explicitly deletes an interpolation now has to manually unlink it from the map first so that OnDestroy can be kept clean of map references.
2019-02-05 18:34:02 +01:00

66 lines
1.4 KiB
C++

#ifndef R_INTERPOLATE_H
#define R_INTERPOLATE_H
#include "dobject.h"
struct FLevelLocals;
//==========================================================================
//
//
//
//==========================================================================
class DInterpolation : public DObject
{
friend struct FInterpolator;
DECLARE_ABSTRACT_CLASS(DInterpolation, DObject)
HAS_OBJECT_POINTERS
TObjPtr<DInterpolation*> Next = nullptr;
TObjPtr<DInterpolation*> Prev = nullptr;
protected:
FLevelLocals *Level;
int refcount = 0;
DInterpolation(FLevelLocals *l = nullptr) : Level(l) {}
public:
int AddRef();
int DelRef(bool force = false);
virtual void UnlinkFromMap();
virtual void UpdateInterpolation() = 0;
virtual void Restore() = 0;
virtual void Interpolate(double smoothratio) = 0;
virtual void Serialize(FSerializer &arc);
};
//==========================================================================
//
//
//
//==========================================================================
struct FInterpolator
{
TObjPtr<DInterpolation*> Head = nullptr;
bool didInterp = false;
int count = 0;
int CountInterpolations ();
public:
void UpdateInterpolations();
void AddInterpolation(DInterpolation *);
void RemoveInterpolation(DInterpolation *);
void DoInterpolations(double smoothratio);
void RestoreInterpolations();
void ClearInterpolations();
};
#endif