From b8cca9c48d6ea5a2372e10bbe2a75ae95917db42 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Mon, 8 Dec 2008 21:54:38 +0100 Subject: An attempt to fix the crashes related to particles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The player character is never deleted, and hence might have particles still active when the map changes. These particles are deleted on map change, but when the player character was moved, it was trying to mark these deleted particles for deletion, writing to unallocated memory. The marking for deletion by the player character now happens before the particles are deleted. Signed-off-by: Bjørn Lindeijer --- src/engine.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/engine.cpp b/src/engine.cpp index 2edc6550..709fcec4 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -67,10 +67,15 @@ Engine::~Engine() void Engine::changeMap(const std::string &mapPath) { - // Clean up floor items + // Clean up floor items, beings and particles floorItemManager->clear(); - beingManager->clear(); + + // Unset the map of the player so that its particles are cleared before + // being deleted in the next step + if (player_node) + player_node->setMap(0); + particleEngine->clear(); // Store full map path in global var -- cgit v1.2.3-70-g09d2