From 07b7fd4ad3fef714399009efd5d4a903a561a6f2 Mon Sep 17 00:00:00 2001 From: LogicParrot Date: Tue, 2 Feb 2016 17:37:21 +0200 Subject: Fixed cChunk::m_Entities corruption upon world travel --- src/Chunk.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Chunk.h') diff --git a/src/Chunk.h b/src/Chunk.h index d944af10a..41bc79746 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -260,6 +260,9 @@ public: void AddEntity(cEntity * a_Entity); void RemoveEntity(cEntity * a_Entity); + /** RemoveEntity is dangerous if the chunk is inside the tick() method because it invalidates the iterator. + This will safely remove an entity. */ + void SafeRemoveEntity(cEntity * a_Entity); bool HasEntity(UInt32 a_EntityID); /** Calls the callback for each entity; returns true if all entities processed, false if the callback aborted by returning true */ @@ -502,7 +505,7 @@ private: /** If the chunk fails to load, should it be queued in the generator or reset back to invalid? */ bool m_ShouldGenerateIfLoadFailed; - + bool m_IsInTick; // True if the chunk is executing the tick() method. bool m_IsLightValid; // True if the blocklight and skylight are calculated bool m_IsDirty; // True if the chunk has changed since it was last saved bool m_IsSaving; // True if the chunk is being saved -- cgit v1.2.3