- split DObject::Destroy into the main method, a native OnDestroy and a scripted OnDestroy method and made the main method non-virtual

This was done to ensure it can be properly overridden in scripts without causing problems when called during engine shutdown for the type and symbol objects the VM needs to work and to have the scripted version always run first.
Since the scripted OnDestroy method never calls the native version - the native one is run after the scripted one - this can be simply skipped over during shutdown.
This commit is contained in:
Christoph Oelckers 2017-01-12 22:49:18 +01:00
commit 7b7623d2c4
58 changed files with 175 additions and 154 deletions

View file

@ -219,7 +219,7 @@ class DCorpsePointer : public DThinker
HAS_OBJECT_POINTERS
public:
DCorpsePointer (AActor *ptr);
void Destroy() override;
void OnDestroy() override;
void Serialize(FSerializer &arc);
TObjPtr<AActor> Corpse;
DWORD Count; // Only the first corpse pointer's count is valid.
@ -271,7 +271,7 @@ DCorpsePointer::DCorpsePointer (AActor *ptr)
++first->Count;
}
void DCorpsePointer::Destroy ()
void DCorpsePointer::OnDestroy ()
{
// Store the count of corpses in the first thinker in the list
TThinkerIterator<DCorpsePointer> iterator (STAT_CORPSEPOINTER);
@ -293,7 +293,7 @@ void DCorpsePointer::Destroy ()
{
Corpse->Destroy ();
}
Super::Destroy ();
Super::OnDestroy();
}
void DCorpsePointer::Serialize(FSerializer &arc)

View file

@ -8,12 +8,12 @@ class ACustomBridge : public AActor
{
DECLARE_CLASS (ACustomBridge, AActor)
public:
void Destroy() override;
void OnDestroy() override;
};
IMPLEMENT_CLASS(ACustomBridge, false, false)
void ACustomBridge::Destroy()
void ACustomBridge::OnDestroy()
{
// Hexen originally just set a flag to make the bridge balls remove themselves in A_BridgeOrbit.
// But this is not safe with custom bridge balls that do not necessarily call that function.
@ -29,5 +29,5 @@ void ACustomBridge::Destroy()
thing->Destroy();
}
}
Super::Destroy();
Super::OnDestroy();
}

View file

@ -111,10 +111,10 @@ DBaseDecal::DBaseDecal (const DBaseDecal *basis)
{
}
void DBaseDecal::Destroy ()
void DBaseDecal::OnDestroy ()
{
Remove ();
Super::Destroy ();
Super::OnDestroy();
}
void DBaseDecal::Remove ()
@ -670,10 +670,10 @@ DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, double ix, doubl
return decal;
}
void DImpactDecal::Destroy ()
void DImpactDecal::OnDestroy ()
{
ImpactCount--;
Super::Destroy ();
Super::OnDestroy();
}
CCMD (countdecals)

View file

@ -23,10 +23,10 @@ DFlashFader::DFlashFader (float r1, float g1, float b1, float a1,
Blends[1][0]=r2; Blends[1][1]=g2; Blends[1][2]=b2; Blends[1][3]=a2;
}
void DFlashFader::Destroy ()
void DFlashFader::OnDestroy ()
{
SetBlend (1.f);
Super::Destroy();
Super::OnDestroy();
}
void DFlashFader::Serialize(FSerializer &arc)

View file

@ -690,13 +690,13 @@ void AMorphedMonster::Serialize(FSerializer &arc)
("flagsave", FlagsSave);
}
void AMorphedMonster::Destroy ()
void AMorphedMonster::OnDestroy ()
{
if (UnmorphedMe != NULL)
{
UnmorphedMe->Destroy ();
}
Super::Destroy ();
Super::OnDestroy();
}
void AMorphedMonster::Die (AActor *source, AActor *inflictor, int dmgflags)

View file

@ -47,7 +47,7 @@ bool ASectorAction::IsActivatedByUse() const
return ActivatedByUse;
}
void ASectorAction::Destroy ()
void ASectorAction::OnDestroy ()
{
if (Sector != nullptr)
{
@ -72,7 +72,7 @@ void ASectorAction::Destroy ()
Sector = nullptr;
}
Super::Destroy ();
Super::OnDestroy();
}
void ASectorAction::BeginPlay ()

View file

@ -24,7 +24,7 @@ public:
DBaseDecal (const DBaseDecal *basis);
void Serialize(FSerializer &arc);
void Destroy() override;
void OnDestroy() override;
FTextureID StickToWall(side_t *wall, double x, double y, F3DFloor * ffloor);
double GetRealZ (const side_t *wall) const;
void SetShade (DWORD rgb);
@ -66,7 +66,7 @@ public:
static DImpactDecal *StaticCreate(const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0);
void BeginPlay ();
void Destroy() override;
void OnDestroy() override;
protected:
DBaseDecal *CloneSelf(const FDecalTemplate *tpl, double x, double y, double z, side_t *wall, F3DFloor * ffloor) const;
@ -88,7 +88,7 @@ class ASkyViewpoint : public AActor
DECLARE_CLASS (ASkyViewpoint, AActor)
public:
void BeginPlay ();
void Destroy() override;
void OnDestroy() override;
};
// For an EE compatible linedef based definition.
@ -116,7 +116,7 @@ public:
DFlashFader (float r1, float g1, float b1, float a1,
float r2, float g2, float b2, float a2,
float time, AActor *who);
void Destroy() override;
void OnDestroy() override;
void Serialize(FSerializer &arc);
void Tick ();
AActor *WhoFor() { return ForWho; }
@ -207,7 +207,7 @@ public:
void Serialize(FSerializer &arc);
void Die (AActor *source, AActor *inflictor, int dmgflags);
void Destroy() override;
void OnDestroy() override;
TObjPtr<AActor> UnmorphedMe;
int UnmorphTime, MorphStyle;

View file

@ -56,7 +56,7 @@ void ASkyViewpoint::BeginPlay ()
}
}
void ASkyViewpoint::Destroy ()
void ASkyViewpoint::OnDestroy ()
{
// remove all sector references to ourselves.
for (auto &s : sectorPortals)
@ -70,7 +70,7 @@ void ASkyViewpoint::Destroy ()
}
}
Super::Destroy();
Super::OnDestroy();
}
IMPLEMENT_CLASS(ASkyCamCompat, false, false)
@ -157,7 +157,7 @@ class ASectorSilencer : public AActor
DECLARE_CLASS (ASectorSilencer, AActor)
public:
void BeginPlay ();
void Destroy() override;
void OnDestroy() override;
};
IMPLEMENT_CLASS(ASectorSilencer, false, false)
@ -168,12 +168,12 @@ void ASectorSilencer::BeginPlay ()
Sector->Flags |= SECF_SILENT;
}
void ASectorSilencer::Destroy ()
void ASectorSilencer::OnDestroy ()
{
if (Sector != nullptr)
{
Sector->Flags &= ~SECF_SILENT;
}
Super::Destroy ();
Super::OnDestroy();
}

View file

@ -104,7 +104,7 @@ class ASoundSequence : public AActor
{
DECLARE_CLASS (ASoundSequence, AActor)
public:
void Destroy() override;
void OnDestroy() override;
void PostBeginPlay ();
void Activate (AActor *activator);
void Deactivate (AActor *activator);
@ -119,10 +119,10 @@ IMPLEMENT_CLASS(ASoundSequence, false, false)
//
//==========================================================================
void ASoundSequence::Destroy ()
void ASoundSequence::OnDestroy ()
{
SN_StopSequence (this);
Super::Destroy();
Super::OnDestroy();
}
//==========================================================================

View file

@ -220,13 +220,13 @@ DSpotState::DSpotState ()
//
//----------------------------------------------------------------------------
void DSpotState::Destroy ()
void DSpotState::OnDestroy ()
{
SpotLists.Clear();
SpotLists.ShrinkToFit();
SpotState = NULL;
Super::Destroy();
Super::OnDestroy();
}
//----------------------------------------------------------------------------
@ -389,11 +389,11 @@ void ASpecialSpot::BeginPlay()
//
//----------------------------------------------------------------------------
void ASpecialSpot::Destroy()
void ASpecialSpot::OnDestroy()
{
DSpotState *state = DSpotState::GetSpotState(false);
if (state != NULL) state->RemoveSpot(this);
Super::Destroy();
Super::OnDestroy();
}
// Mace spawn spot ----------------------------------------------------------

View file

@ -11,7 +11,7 @@ class ASpecialSpot : public AActor
public:
void BeginPlay();
void Destroy() override;
void OnDestroy() override;
};
@ -28,7 +28,7 @@ public:
DSpotState ();
void Destroy() override;
void OnDestroy() override;
void Tick ();
static DSpotState *GetSpotState(bool create = true);
FSpotList *FindSpotList(PClassActor *type);

View file

@ -341,7 +341,7 @@ public:
};
DBaseStatusBar (int reltop, int hres=320, int vres=200);
void Destroy() override;
void OnDestroy() override;
void SetScaled (bool scale, bool force=false);

View file

@ -258,7 +258,7 @@ DBaseStatusBar::DBaseStatusBar (int reltop, int hres, int vres)
//
//---------------------------------------------------------------------------
void DBaseStatusBar::Destroy ()
void DBaseStatusBar::OnDestroy ()
{
for (size_t i = 0; i < countof(Messages); ++i)
{
@ -271,7 +271,7 @@ void DBaseStatusBar::Destroy ()
}
Messages[i] = NULL;
}
Super::Destroy();
Super::OnDestroy();
}
//---------------------------------------------------------------------------