From 00febf68ad8bc36546c02b0c0b926189fb3955a1 Mon Sep 17 00:00:00 2001 From: LogicParrot Date: Wed, 30 Aug 2017 00:13:25 +0300 Subject: Much safer raw pointers to entities --- src/Entities/Entity.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Entities') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 347c0ec91..ccba28d53 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -239,7 +239,9 @@ void cEntity::Destroy(bool a_ShouldBroadcast) } cChunk * ParentChunk = GetParentChunk(); - m_World->QueueTask([this, ParentChunk](cWorld & a_World) + // Destroy the entity after two seconds, to give time for all raw pointers such as m_Target + // to de-target this entity. This is a temporary solution. + m_World->ScheduleTask(40, [this, ParentChunk](cWorld & a_World) { LOGD("Destroying entity #%i (%s) from chunk (%d, %d)", this->GetUniqueID(), this->GetClass(), -- cgit v1.2.3