From 16aeb84cd35996a6b41f10cbc48a677eeccc911c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 2 Jan 2021 13:50:34 +0000 Subject: Fix potential destruction crashes (#5095) * Fix potential destruction crashes * Fix destructors accessing destroyted objects * Fix cPlayer not destroying windows (Destroyed never called) * Tentatively fixes #4608, fixes #3236, fixes #3262 - Remove cEntity::Destroyed() and replace with cEntity::OnRemoveFromWorld() * Add missing call to OnRemoveFromWorld --- src/Entities/Entity.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/Entities/Entity.h') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 20712e7ea..85cf35661 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -169,7 +169,7 @@ public: cEntity(eEntityType a_EntityType, Vector3d a_Pos, double a_Width, double a_Height); - virtual ~cEntity(); + virtual ~cEntity() = default; /** Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed). Adds the entity to the world. */ @@ -296,7 +296,7 @@ public: // tolua_end /** Destroys the entity, schedules it for memory freeing and broadcasts the DestroyEntity packet */ - virtual void Destroy(); + void Destroy(); // tolua_begin /** Makes this pawn take damage from an attack by a_Attacker. Damage values are calculated automatically and DoTakeDamage() called */ @@ -594,9 +594,6 @@ public: /** Removes a mob from the leashed list of mobs. */ void RemoveLeashedMob(cMonster * a_Monster); - /** Removes all mobs from the leashed list of mobs. */ - void RemoveAllLeashedMobs(); - /** Returs whether the entity has any mob leashed to it. */ bool HasAnyMobLeashed() const { return m_LeashedMobs.size() > 0; } @@ -723,8 +720,6 @@ protected: Should handle degenerate cases such as moving to the same world. */ virtual void DoMoveToWorld(const sWorldChangeInfo & a_WorldChangeInfo); - virtual void Destroyed(void) {} // Called after the entity has been destroyed - /** Applies friction to an entity @param a_Speed The speed vector to apply changes to @param a_SlowdownMultiplier The factor to reduce the speed by */ -- cgit v1.2.3