summaryrefslogtreecommitdiff
path: root/src/engine.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-08 21:54:38 +0100
committerIra Rice <irarice@gmail.com>2008-12-08 15:44:18 -0700
commit208d5a6c0523079ea1b2a2e69fd3e76804ada037 (patch)
tree50ca154ab191b66b44bbabcbf206f85afa36a5ba /src/engine.cpp
parent48c3263aa2540cd895b72edb0337e0717e136e3a (diff)
downloadMana-208d5a6c0523079ea1b2a2e69fd3e76804ada037.tar.gz
Mana-208d5a6c0523079ea1b2a2e69fd3e76804ada037.tar.bz2
Mana-208d5a6c0523079ea1b2a2e69fd3e76804ada037.tar.xz
Mana-208d5a6c0523079ea1b2a2e69fd3e76804ada037.zip
An attempt to fix the crashes related to particles
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 <bjorn@lindeijer.nl>
Diffstat (limited to 'src/engine.cpp')
-rw-r--r--src/engine.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 8382f775..04e5f287 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -66,10 +66,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