- 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
parent 0b94d4e0a3
commit 7b7623d2c4
58 changed files with 175 additions and 154 deletions

View file

@ -595,7 +595,7 @@ public:
AActor &operator= (const AActor &other);
~AActor ();
virtual void Destroy() override;
virtual void OnDestroy() override;
virtual void Serialize(FSerializer &arc) override;
virtual void PostSerialize() override;
virtual void PostBeginPlay() override; // Called immediately before the actor's first tick

View file

@ -3199,14 +3199,14 @@ void ADehackedPickup::DoPickupSpecial (AActor *toucher)
RealPickup = nullptr;
}
void ADehackedPickup::Destroy ()
void ADehackedPickup::OnDestroy ()
{
if (RealPickup != nullptr)
{
RealPickup->Destroy ();
RealPickup = nullptr;
}
Super::Destroy ();
Super::OnDestroy();
}
PClassActor *ADehackedPickup::DetermineType ()

View file

@ -41,7 +41,7 @@ class ADehackedPickup : public AInventory
DECLARE_CLASS (ADehackedPickup, AInventory)
HAS_OBJECT_POINTERS
public:
void Destroy() override;
void OnDestroy() override;
FString PickupMessage ();
bool ShouldRespawn ();
bool ShouldStay ();

View file

@ -2715,7 +2715,6 @@ void D_DoomMain (void)
*(afunc->VMPointer) = NULL;
}
ReleaseGlobalSymbols();
PClass::StaticShutdown();
GC::FullGC(); // perform one final garbage collection after shutdown
@ -2727,6 +2726,7 @@ void D_DoomMain (void)
restart++;
PClass::bShutdown = false;
PClass::bShuttingDown = false;
}
while (1);
}

View file

@ -351,8 +351,18 @@ DObject::~DObject ()
//
//==========================================================================
void DObject::Destroy ()
void DObject:: Destroy ()
{
// We cannot call the VM during shutdown because all the needed data has been or is in the process of being deleted.
if (!PClass::bShuttingDown)
{
IFVIRTUAL(DObject, OnDestroy)
{
VMValue params[1] = { (DObject*)this };
GlobalVMStack.Call(func, params, 1, nullptr, 0);
}
}
OnDestroy();
ObjectFlags = (ObjectFlags & ~OF_Fixed) | OF_EuthanizeMe;
}
@ -555,4 +565,4 @@ DEFINE_ACTION_FUNCTION(DObject, GetClassName)
{
PARAM_SELF_PROLOGUE(DObject);
ACTION_RETURN_INT(self->GetClass()->TypeName);
}
}

View file

@ -473,7 +473,8 @@ public:
// that don't call their base class.
void CheckIfSerialized () const;
virtual void Destroy();
virtual void OnDestroy() {}
void Destroy();
// If you need to replace one object with another and want to
// change any pointers from the old object to the new object,

View file

@ -72,6 +72,7 @@ FTypeTable TypeTable;
PSymbolTable GlobalSymbols;
TArray<PClass *> PClass::AllClasses;
bool PClass::bShutdown;
bool PClass::bShuttingDown;
PErrorType *TypeError;
PErrorType *TypeAuto;
@ -534,16 +535,9 @@ const char *PType::DescriptiveName() const
//
//==========================================================================
void ReleaseGlobalSymbols()
{
TypeTable.Clear();
GlobalSymbols.ReleaseSymbols();
}
void PType::StaticInit()
{
// Add types to the global symbol table.
atterm(ReleaseGlobalSymbols);
// Set up TypeTable hash keys.
RUNTIME_CLASS(PErrorType)->TypeTableType = RUNTIME_CLASS(PErrorType);
@ -2962,7 +2956,18 @@ void PClass::StaticShutdown ()
TArray<size_t *> uniqueFPs(64);
unsigned int i, j;
FS_Close(); // this must be done before the classes get deleted.
// Make a full garbage collection here so that all destroyed but uncollected higher level objects that still exist can be properly taken down.
GC::FullGC();
// From this point onward no scripts may be called anymore because the data needed by the VM is getting deleted now.
// This flags DObject::Destroy not to call any scripted OnDestroy methods anymore.
bShuttingDown = true;
// Unless something went wrong, anything left here should be class and type objects only, which do not own any scripts.
TypeTable.Clear();
GlobalSymbols.ReleaseSymbols();
for (i = 0; i < PClass::AllClasses.Size(); ++i)
{
PClass *type = PClass::AllClasses[i];
@ -2989,7 +2994,6 @@ void PClass::StaticShutdown ()
{
delete[] uniqueFPs[i];
}
TypeTable.Clear();
bShutdown = true;
AllClasses.Clear();
@ -3002,7 +3006,7 @@ void PClass::StaticShutdown ()
auto cr = ((ClassReg *)*probe);
cr->MyClass = nullptr;
}
}
//==========================================================================

View file

@ -883,6 +883,7 @@ public:
static TArray<PClass *> AllClasses;
static bool bShutdown;
static bool bShuttingDown;
};
class PClassType : public PClass
@ -1015,8 +1016,6 @@ public:
PSymbolConstString() {}
};
void ReleaseGlobalSymbols();
// Enumerations for serializing types in an archive -------------------------
enum ETypeVal : BYTE

View file

@ -39,7 +39,7 @@ DSectorEffect::DSectorEffect ()
m_Sector = NULL;
}
void DSectorEffect::Destroy()
void DSectorEffect::OnDestroy()
{
if (m_Sector)
{
@ -56,7 +56,7 @@ void DSectorEffect::Destroy()
m_Sector->lightingdata = NULL;
}
}
Super::Destroy();
Super::OnDestroy();
}
DSectorEffect::DSectorEffect (sector_t *sector)
@ -87,10 +87,10 @@ DMover::DMover (sector_t *sector)
interpolation = NULL;
}
void DMover::Destroy()
void DMover::OnDestroy()
{
StopInterpolation();
Super::Destroy();
Super::OnDestroy();
}
void DMover::Serialize(FSerializer &arc)

View file

@ -12,7 +12,7 @@ public:
void Serialize(FSerializer &arc);
void Destroy() override;
void OnDestroy() override;
sector_t *GetSector() const { return m_Sector; }
@ -35,7 +35,7 @@ protected:
DMover ();
void Serialize(FSerializer &arc);
void Destroy() override;
void OnDestroy() override;
};
class DMovingFloor : public DMover

View file

@ -253,7 +253,7 @@ DThinker::~DThinker ()
assert(NextThinker == NULL && PrevThinker == NULL);
}
void DThinker::Destroy ()
void DThinker::OnDestroy ()
{
assert((NextThinker != NULL && PrevThinker != NULL) ||
(NextThinker == NULL && PrevThinker == NULL));
@ -261,7 +261,7 @@ void DThinker::Destroy ()
{
Remove();
}
Super::Destroy();
Super::OnDestroy();
}
//==========================================================================

View file

@ -66,7 +66,7 @@ class DThinker : public DObject
DECLARE_CLASS (DThinker, DObject)
public:
DThinker (int statnum = STAT_DEFAULT) throw();
void Destroy () override;
void OnDestroy () override;
virtual ~DThinker ();
virtual void Tick ();
void CallTick();

View file

@ -1786,7 +1786,7 @@ public:
DLightLevel(sector_t * s,int destlevel,int speed);
void Serialize(FSerializer &arc);
void Tick ();
void Destroy() { Super::Destroy(); m_Sector->lightingdata=NULL; }
void OnDestroy() { Super::OnDestroy(); m_Sector->lightingdata = nullptr; }
};
IMPLEMENT_CLASS(DLightLevel, false, false)

View file

@ -184,7 +184,7 @@ DFsScript::~DFsScript()
//
//==========================================================================
void DFsScript::Destroy()
void DFsScript::OnDestroy()
{
ClearVariables(true);
ClearSections();
@ -194,7 +194,7 @@ void DFsScript::Destroy()
data = NULL;
parent = NULL;
trigger = NULL;
Super::Destroy();
Super::OnDestroy();
}
//==========================================================================
@ -334,7 +334,7 @@ DRunningScript::DRunningScript(AActor *trigger, DFsScript *owner, int index)
//
//==========================================================================
void DRunningScript::Destroy()
void DRunningScript::OnDestroy()
{
int i;
DFsVariable *current, *next;
@ -352,7 +352,7 @@ void DRunningScript::Destroy()
}
variables[i] = NULL;
}
Super::Destroy();
Super::OnDestroy();
}
//==========================================================================
@ -421,7 +421,7 @@ DFraggleThinker::DFraggleThinker()
//
//==========================================================================
void DFraggleThinker::Destroy()
void DFraggleThinker::OnDestroy()
{
DRunningScript *p = RunningScripts;
while (p)
@ -438,7 +438,7 @@ void DFraggleThinker::Destroy()
SpawnedThings.Clear();
ActiveThinker = NULL;
Super::Destroy();
Super::OnDestroy();
}
//==========================================================================

View file

@ -347,7 +347,7 @@ public:
DFsScript();
~DFsScript();
void Destroy() override;
void OnDestroy() override;
void Serialize(FSerializer &ar);
DFsVariable *NewVariable(const char *name, int vtype);
@ -662,7 +662,7 @@ class DRunningScript : public DObject
public:
DRunningScript(AActor *trigger=NULL, DFsScript *owner = NULL, int index = 0) ;
void Destroy() override;
void OnDestroy() override;
void Serialize(FSerializer &arc);
TObjPtr<DFsScript> script;
@ -697,7 +697,7 @@ public:
bool nocheckposition;
DFraggleThinker();
void Destroy() override;
void OnDestroy() override;
void Serialize(FSerializer & arc);

View file

@ -292,10 +292,10 @@ void APowerup::CallEndEffect()
//
//===========================================================================
void APowerup::Destroy ()
void APowerup::OnDestroy ()
{
CallEndEffect ();
Super::Destroy ();
Super::OnDestroy();
}
//===========================================================================

View file

@ -12,7 +12,7 @@ class APowerup : public AInventory
DECLARE_CLASS (APowerup, AInventory)
public:
virtual void Tick () override;
virtual void Destroy () override;
virtual void OnDestroy() override;
virtual bool HandlePickup (AInventory *item) override;
virtual AInventory *CreateCopy (AActor *other) override;
virtual AInventory *CreateTossable () override;

View file

@ -1137,14 +1137,14 @@ bool AInventory::CallShouldStay()
//
//===========================================================================
void AInventory::Destroy ()
void AInventory::OnDestroy ()
{
if (Owner != NULL)
{
Owner->RemoveInventory (this);
}
Inventory = NULL;
Super::Destroy ();
Super::OnDestroy();
// Although contrived it can theoretically happen that these variables still got a pointer to this item
if (SendItemUse == this) SendItemUse = NULL;

View file

@ -76,7 +76,7 @@ public:
virtual void Serialize(FSerializer &arc) override;
virtual void MarkPrecacheSounds() const override;
virtual void BeginPlay () override;
virtual void Destroy () override;
virtual void OnDestroy() override;
virtual void Tick() override;
virtual bool Grind(bool items) override;

View file

@ -329,7 +329,7 @@ bool AWeapon::Use (bool pickup)
//
//===========================================================================
void AWeapon::Destroy()
void AWeapon::OnDestroy()
{
AWeapon *sister = SisterWeapon;
@ -342,7 +342,7 @@ void AWeapon::Destroy()
sister->Destroy();
}
}
Super::Destroy();
Super::OnDestroy();
}
//===========================================================================

View file

@ -145,7 +145,7 @@ public:
virtual bool TryPickup (AActor *&toucher) override;
virtual bool TryPickupRestricted (AActor *&toucher) override;
virtual bool Use (bool pickup) override;
virtual void Destroy() override;
virtual void OnDestroy() override;
bool PickupForAmmo(AWeapon *ownedWeapon);
void PostMorphWeapon();

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();
}
//---------------------------------------------------------------------------

View file

@ -805,10 +805,10 @@ void ADynamicLight::UnlinkLight ()
while (touching_sector) touching_sector = DeleteLightNode(touching_sector);
}
void ADynamicLight::Destroy()
void ADynamicLight::OnDestroy()
{
UnlinkLight();
Super::Destroy();
Super::OnDestroy();
}

View file

@ -108,7 +108,7 @@ public:
void BeginPlay();
void SetOrigin (double x, double y, double z, bool moving = false);
void PostBeginPlay();
void Destroy();
void OnDestroy() override;
void Activate(AActor *activator);
void Deactivate(AActor *activator);
void SetOffset(const DVector3 &pos);

View file

@ -204,7 +204,7 @@ void DIntermissionScreen::Drawer ()
if (!mFlatfill) screen->FillBorder (NULL);
}
void DIntermissionScreen::Destroy()
void DIntermissionScreen::OnDestroy()
{
if (mPaletteChanged)
{
@ -222,7 +222,7 @@ void DIntermissionScreen::Destroy()
M_EnableMenu(true);
}
S_StopSound(CHAN_VOICE);
Super::Destroy();
Super::OnDestroy();
}
//==========================================================================
@ -874,9 +874,9 @@ void DIntermissionController::Drawer ()
}
}
void DIntermissionController::Destroy ()
void DIntermissionController::OnDestroy ()
{
Super::Destroy();
Super::OnDestroy();
if (mScreen != NULL) mScreen->Destroy();
if (mDeleteDesc) delete mDesc;
mDesc = NULL;

View file

@ -176,7 +176,7 @@ public:
virtual int Responder (event_t *ev);
virtual int Ticker ();
virtual void Drawer ();
void Destroy() override;
void OnDestroy() override;
FTextureID GetBackground(bool *fill)
{
*fill = mFlatfill;
@ -301,7 +301,7 @@ public:
bool Responder (event_t *ev);
void Ticker ();
void Drawer ();
void Destroy() override;
void OnDestroy() override;
friend void F_AdvanceIntermission();
};

View file

@ -95,7 +95,7 @@ public:
desc->CalcIndent();
}
void Destroy() override
void OnDestroy() override
{
if (mStartItem >= 0)
{

View file

@ -103,7 +103,7 @@ protected:
char savegamestring[SAVESTRINGSIZE];
DLoadSaveMenu(DMenu *parent = NULL, FListMenuDescriptor *desc = NULL);
void Destroy() override;
void OnDestroy() override;
int RemoveSaveSlot (int index);
void UnloadSaveData ();
@ -461,12 +461,12 @@ DLoadSaveMenu::DLoadSaveMenu(DMenu *parent, FListMenuDescriptor *desc)
commentBottom = commentTop + commentHeight;
}
void DLoadSaveMenu::Destroy()
void DLoadSaveMenu::OnDestroy()
{
if (currentSavePic != nullptr) delete currentSavePic;
currentSavePic = nullptr;
ClearSaveStuff ();
Super::Destroy();
Super::OnDestroy();
}
//=============================================================================
@ -928,7 +928,7 @@ class DSaveMenu : public DLoadSaveMenu
public:
DSaveMenu(DMenu *parent = NULL, FListMenuDescriptor *desc = NULL);
void Destroy() override;
void OnDestroy() override;
void DoSave (FSaveGameNode *node);
bool Responder (event_t *ev);
bool MenuEvent (int mkey, bool fromcontroller);
@ -968,7 +968,7 @@ DSaveMenu::DSaveMenu(DMenu *parent, FListMenuDescriptor *desc)
//
//=============================================================================
void DSaveMenu::Destroy()
void DSaveMenu::OnDestroy()
{
if (SaveGames[0] == &NewSaveNode)
{
@ -976,7 +976,7 @@ void DSaveMenu::Destroy()
if (Selected == 0) Selected = -1;
else Selected--;
}
Super::Destroy();
Super::OnDestroy();
}
//=============================================================================

View file

@ -63,7 +63,7 @@ class DMessageBoxMenu : public DMenu
public:
DMessageBoxMenu(DMenu *parent = NULL, const char *message = NULL, int messagemode = 0, bool playsound = false, FName action = NAME_None);
void Destroy() override;
void OnDestroy() override;
void Init(DMenu *parent, const char *message, int messagemode, bool playsound = false);
void Drawer();
bool Responder(event_t *ev);
@ -124,11 +124,11 @@ void DMessageBoxMenu::Init(DMenu *parent, const char *message, int messagemode,
//
//=============================================================================
void DMessageBoxMenu::Destroy()
void DMessageBoxMenu::OnDestroy()
{
if (mMessage != NULL) V_FreeBrokenLines(mMessage);
mMessage = NULL;
Super::Destroy();
Super::OnDestroy();
}
//=============================================================================

View file

@ -829,12 +829,12 @@ public:
//
//=============================================================================
void Destroy()
void OnDestroy() override
{
V_FreeBrokenLines(mDialogueLines);
mDialogueLines = NULL;
I_SetMusicVolume (1.f);
Super::Destroy();
Super::OnDestroy();
}
bool DimAllowed()

View file

@ -869,7 +869,7 @@ void DElevator::Serialize(FSerializer &arc)
//
//==========================================================================
void DElevator::Destroy()
void DElevator::OnDestroy()
{
if (m_Interp_Ceiling != NULL)
{
@ -881,7 +881,7 @@ void DElevator::Destroy()
m_Interp_Floor->DelRef();
m_Interp_Floor = NULL;
}
Super::Destroy();
Super::OnDestroy();
}
//==========================================================================

View file

@ -1770,7 +1770,7 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target)
}
}
// play the sound before changing the state, so that AActor::Destroy can call S_RelinkSounds on it and the death state can override it.
// play the sound before changing the state, so that AActor::OnDestroy can call S_RelinkSounds on it and the death state can override it.
if (mo->DeathSound)
{
S_Sound (mo, CHAN_VOICE, mo->DeathSound, 1,
@ -4920,7 +4920,7 @@ void AActor::CallDeactivate(AActor *activator)
//
//===========================================================================
void AActor::Destroy ()
void AActor::OnDestroy ()
{
ClearRenderSectorList();
ClearRenderLineList();
@ -4938,7 +4938,7 @@ void AActor::Destroy ()
// Transform any playing sound into positioned, non-actor sounds.
S_RelinkSound (this, NULL);
Super::Destroy ();
Super::OnDestroy();
}
//===========================================================================

View file

@ -52,7 +52,7 @@ DPillar::DPillar ()
{
}
void DPillar::Destroy()
void DPillar::OnDestroy()
{
if (m_Interp_Ceiling != NULL)
{
@ -64,7 +64,7 @@ void DPillar::Destroy()
m_Interp_Floor->DelRef();
m_Interp_Floor = NULL;
}
Super::Destroy();
Super::OnDestroy();
}
void DPillar::Serialize(FSerializer &arc)

View file

@ -1665,7 +1665,7 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, SetSafeFlash)
//
//------------------------------------------------------------------------
void DPSprite::Destroy()
void DPSprite::OnDestroy()
{
// Do not crash if this gets called on partially initialized objects.
if (Owner != nullptr && Owner->psprites != nullptr)
@ -1688,7 +1688,7 @@ void DPSprite::Destroy()
GC::WriteBarrier(Next);
}
}
Super::Destroy();
Super::OnDestroy();
}
//------------------------------------------------------------------------

View file

@ -75,6 +75,7 @@ public:
AActor* GetCaller() { return Caller; }
void SetCaller(AActor *newcaller) { Caller = newcaller; }
void ResetInterpolation() { oldx = x; oldy = y; }
void OnDestroy() override;
double x, y;
double oldx, oldy;
@ -87,7 +88,6 @@ private:
void Serialize(FSerializer &arc);
void Tick();
void Destroy() override;
public: // must be public to be able to generate the field export tables. Grrr...
TObjPtr<AActor> Caller;

View file

@ -45,7 +45,7 @@ public:
DScroller (EScroll type, double dx, double dy, int control, int affectee, int accel, EScrollPos scrollpos = EScrollPos::scw_all);
DScroller (double dx, double dy, const line_t *l, int control, int accel, EScrollPos scrollpos = EScrollPos::scw_all);
void Destroy() override;
void OnDestroy() override;
void Serialize(FSerializer &arc);
void Tick ();
@ -306,7 +306,7 @@ DScroller::DScroller (EScroll type, double dx, double dy,
}
}
void DScroller::Destroy ()
void DScroller::OnDestroy ()
{
for(int i=0;i<3;i++)
{
@ -316,7 +316,7 @@ void DScroller::Destroy ()
m_Interpolations[i] = NULL;
}
}
Super::Destroy();
Super::OnDestroy();
}
//-----------------------------------------------------------------------------

View file

@ -4188,6 +4188,11 @@ static void P_Shutdown ()
P_FreeLevelData ();
P_FreeExtraLevelData ();
ST_Clear();
FS_Close();
for (auto &p : players)
{
if (p.psprites != nullptr) p.psprites->Destroy();
}
}
#if 0

View file

@ -243,7 +243,7 @@ public:
void Serialize(FSerializer &arc);
void Tick ();
void Destroy() override;
void OnDestroy() override;
protected:
EPillar m_Type;
@ -574,7 +574,7 @@ public:
DElevator (sector_t *sec);
void Destroy() override;
void OnDestroy() override;
void Serialize(FSerializer &arc);
void Tick ();

View file

@ -187,7 +187,7 @@ DPolyAction::DPolyAction (int polyNum)
SetInterpolation ();
}
void DPolyAction::Destroy()
void DPolyAction::OnDestroy()
{
FPolyObj *poly = PO_GetPolyobj (m_PolyObj);
@ -197,7 +197,7 @@ void DPolyAction::Destroy()
}
StopInterpolation();
Super::Destroy();
Super::OnDestroy();
}
void DPolyAction::Stop()

View file

@ -12,7 +12,7 @@ class DPolyAction : public DThinker
public:
DPolyAction(int polyNum);
void Serialize(FSerializer &arc);
void Destroy() override;
void OnDestroy() override;
void Stop();
double GetSpeed() const { return m_Speed; }

View file

@ -62,7 +62,7 @@ public:
DSectorPlaneInterpolation() {}
DSectorPlaneInterpolation(sector_t *sector, bool plane, bool attach);
void Destroy() override;
void OnDestroy() override;
void UpdateInterpolation();
void Restore();
void Interpolate(double smoothratio);
@ -91,7 +91,7 @@ public:
DSectorScrollInterpolation() {}
DSectorScrollInterpolation(sector_t *sector, bool plane);
void Destroy() override;
void OnDestroy() override;
void UpdateInterpolation();
void Restore();
void Interpolate(double smoothratio);
@ -119,7 +119,7 @@ public:
DWallScrollInterpolation() {}
DWallScrollInterpolation(side_t *side, int part);
void Destroy() override;
void OnDestroy() override;
void UpdateInterpolation();
void Restore();
void Interpolate(double smoothratio);
@ -146,7 +146,7 @@ public:
DPolyobjInterpolation() {}
DPolyobjInterpolation(FPolyObj *poly);
void Destroy() override;
void OnDestroy() override;
void UpdateInterpolation();
void Restore();
void Interpolate(double smoothratio);
@ -364,11 +364,11 @@ int DInterpolation::DelRef(bool force)
//
//==========================================================================
void DInterpolation::Destroy()
void DInterpolation::OnDestroy()
{
interpolator.RemoveInterpolation(this);
refcount = 0;
Super::Destroy();
Super::OnDestroy();
}
//==========================================================================
@ -419,7 +419,7 @@ DSectorPlaneInterpolation::DSectorPlaneInterpolation(sector_t *_sector, bool _pl
//
//==========================================================================
void DSectorPlaneInterpolation::Destroy()
void DSectorPlaneInterpolation::OnDestroy()
{
if (sector != nullptr)
{
@ -437,7 +437,7 @@ void DSectorPlaneInterpolation::Destroy()
{
attached[i]->DelRef();
}
Super::Destroy();
Super::OnDestroy();
}
//==========================================================================
@ -597,7 +597,7 @@ DSectorScrollInterpolation::DSectorScrollInterpolation(sector_t *_sector, bool _
//
//==========================================================================
void DSectorScrollInterpolation::Destroy()
void DSectorScrollInterpolation::OnDestroy()
{
if (sector != nullptr)
{
@ -611,7 +611,7 @@ void DSectorScrollInterpolation::Destroy()
}
sector = nullptr;
}
Super::Destroy();
Super::OnDestroy();
}
//==========================================================================
@ -702,14 +702,14 @@ DWallScrollInterpolation::DWallScrollInterpolation(side_t *_side, int _part)
//
//==========================================================================
void DWallScrollInterpolation::Destroy()
void DWallScrollInterpolation::OnDestroy()
{
if (side != nullptr)
{
side->textures[part].interpolation = nullptr;
side = nullptr;
}
Super::Destroy();
Super::OnDestroy();
}
//==========================================================================
@ -800,13 +800,13 @@ DPolyobjInterpolation::DPolyobjInterpolation(FPolyObj *po)
//
//==========================================================================
void DPolyobjInterpolation::Destroy()
void DPolyobjInterpolation::OnDestroy()
{
if (poly != nullptr)
{
poly->interpolation = nullptr;
}
Super::Destroy();
Super::OnDestroy();
}
//==========================================================================

View file

@ -27,7 +27,7 @@ public:
int AddRef();
int DelRef(bool force = false);
void Destroy() override;
void OnDestroy() override;
virtual void UpdateInterpolation() = 0;
virtual void Restore() = 0;
virtual void Interpolate(double smoothratio) = 0;

View file

@ -283,7 +283,7 @@ class ASectorAction : public AActor
DECLARE_CLASS (ASectorAction, AActor)
public:
ASectorAction (bool activatedByUse = false);
void Destroy () override;
void OnDestroy() override;
void BeginPlay ();
void Activate (AActor *source);
void Deactivate (AActor *source);

View file

@ -106,7 +106,7 @@ class DSeqActorNode : public DSeqNode
HAS_OBJECT_POINTERS
public:
DSeqActorNode(AActor *actor, int sequence, int modenum);
void Destroy() override;
void OnDestroy() override;
void Serialize(FSerializer &arc);
void MakeSound(int loop, FSoundID id)
{
@ -134,7 +134,7 @@ class DSeqPolyNode : public DSeqNode
DECLARE_CLASS(DSeqPolyNode, DSeqNode)
public:
DSeqPolyNode(FPolyObj *poly, int sequence, int modenum);
void Destroy() override;
void OnDestroy() override;
void Serialize(FSerializer &arc);
void MakeSound(int loop, FSoundID id)
{
@ -162,7 +162,7 @@ class DSeqSectorNode : public DSeqNode
DECLARE_CLASS(DSeqSectorNode, DSeqNode)
public:
DSeqSectorNode(sector_t *sec, int chan, int sequence, int modenum);
void Destroy() override;
void OnDestroy() override;
void Serialize(FSerializer &arc);
void MakeSound(int loop, FSoundID id)
{
@ -379,7 +379,7 @@ void DSeqNode::Serialize(FSerializer &arc)
}
}
void DSeqNode::Destroy()
void DSeqNode::OnDestroy()
{
// If this sequence was launched by a parent sequence, advance that
// sequence now.
@ -405,7 +405,7 @@ void DSeqNode::Destroy()
GC::WriteBarrier(m_Next, m_Prev);
}
ActiveSequences--;
Super::Destroy();
Super::OnDestroy();
}
void DSeqNode::StopAndDestroy ()
@ -1041,31 +1041,31 @@ void SN_DoStop (void *source)
}
}
void DSeqActorNode::Destroy ()
void DSeqActorNode::OnDestroy ()
{
if (m_StopSound >= 0)
S_StopSound (m_Actor, CHAN_BODY);
if (m_StopSound >= 1)
MakeSound (0, m_StopSound);
Super::Destroy();
Super::OnDestroy();
}
void DSeqSectorNode::Destroy ()
void DSeqSectorNode::OnDestroy ()
{
if (m_StopSound >= 0)
S_StopSound (m_Sector, Channel & 7);
if (m_StopSound >= 1)
MakeSound (0, m_StopSound);
Super::Destroy();
Super::OnDestroy();
}
void DSeqPolyNode::Destroy ()
void DSeqPolyNode::OnDestroy ()
{
if (m_StopSound >= 0)
S_StopSound (m_Poly, CHAN_BODY);
if (m_StopSound >= 1)
MakeSound (0, m_StopSound);
Super::Destroy();
Super::OnDestroy();
}
//==========================================================================

View file

@ -22,7 +22,7 @@ class DSeqNode : public DObject
public:
void Serialize(FSerializer &arc);
void StopAndDestroy ();
void Destroy() override;
void OnDestroy() override;
void Tick ();
void ChangeData (int seqOffset, int delayTics, float volume, FSoundID currentSoundID);
void AddChoice (int seqnum, seqtype_t type);

View file

@ -17,8 +17,10 @@ class Object native
native static void SetMusicVolume(float vol);
native Name GetClassName();
native void Destroy();
/*virtual*/ native void Destroy();
// This does not call into the native method of the same name to avoid problems with objects that get garbage collected late on shutdown.
virtual void OnDestroy() {}
}
class Thinker : Object native