From 03178d9e758ec8bfa93d3a41cb230591dbdac609 Mon Sep 17 00:00:00 2001 From: auria Date: Thu, 1 Sep 2011 23:47:15 +0000 Subject: [PATCH] Kinda fixed crash I introduced in 3 strikes, but the current code leaks. Will need to ask Joerg how irrlicht memory management works... git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9704 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/modes/three_strikes_battle.cpp | 9 +++++++++ src/modes/three_strikes_battle.hpp | 2 ++ src/tracks/track_object_manager.cpp | 9 +++++++++ src/tracks/track_object_manager.hpp | 2 ++ 4 files changed, 22 insertions(+) diff --git a/src/modes/three_strikes_battle.cpp b/src/modes/three_strikes_battle.cpp index 8a3d7ec0c..045d5b412 100644 --- a/src/modes/three_strikes_battle.cpp +++ b/src/modes/three_strikes_battle.cpp @@ -76,6 +76,13 @@ void ThreeStrikesBattle::init() //----------------------------------------------------------------------------- ThreeStrikesBattle::~ThreeStrikesBattle() { + PhysicalObject* obj; + for_in(obj, m_tires) + { + m_track->getTrackObjectManager()->removeObject(obj); + } + m_tires.clearWithoutDeleting(); + delete[] m_kart_display_info; // TODO: need to drop the mesh? I got a crash when I added this line so // not sure this is right @@ -210,6 +217,8 @@ void ThreeStrikesBattle::update(float dt) // FIXME: orient the force relative to kart orientation obj->getBody()->applyCentralForce(btVector3(60.0f, 0.0f, 0.0f)); m_insert_tire = false; + + m_tires.push_back(obj); } } // update diff --git a/src/modes/three_strikes_battle.hpp b/src/modes/three_strikes_battle.hpp index 615974d33..d4e64b196 100644 --- a/src/modes/three_strikes_battle.hpp +++ b/src/modes/three_strikes_battle.hpp @@ -52,6 +52,8 @@ private: /** for tires that are blown away */ core::vector3df m_tire_position; + PtrVector m_tires; + public: /** Used to show a nice graph when battle is over */ diff --git a/src/tracks/track_object_manager.cpp b/src/tracks/track_object_manager.cpp index 0a06938a2..b76ac222c 100644 --- a/src/tracks/track_object_manager.cpp +++ b/src/tracks/track_object_manager.cpp @@ -204,4 +204,13 @@ PhysicalObject* TrackObjectManager::insertObject(const std::string& model, return object; } +// ---------------------------------------------------------------------------- + +void TrackObjectManager::removeObject(PhysicalObject* who) +{ + m_all_objects.remove(who); + + // FIXME: need to do memory management + //delete who; +} diff --git a/src/tracks/track_object_manager.hpp b/src/tracks/track_object_manager.hpp index 6ba520caa..673ae7e48 100644 --- a/src/tracks/track_object_manager.hpp +++ b/src/tracks/track_object_manager.hpp @@ -59,6 +59,8 @@ public: const core::vector3df& hpr, const core::vector3df& pos, const core::vector3df& scale); + + void removeObject(PhysicalObject* who); }; // class TrackObjectManager #endif