Fixing #419: on restart of a 3SB tires previously thrown
on the track are now removed. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9850 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
9811148d12
commit
6b19b7c49e
@ -38,6 +38,7 @@ ThreeStrikesBattle::ThreeStrikesBattle() : WorldWithRank()
|
||||
m_insert_tire = 0;
|
||||
|
||||
m_tire = irr_driver->getMesh( file_manager->getModelFile("tire.b3d") );
|
||||
irr_driver->grabAllTextures(m_tire);
|
||||
} // ThreeStrikesBattle
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -88,6 +89,7 @@ ThreeStrikesBattle::~ThreeStrikesBattle()
|
||||
|
||||
delete[] m_kart_display_info;
|
||||
|
||||
irr_driver->grabAllTextures(m_tire);
|
||||
// Remove the mesh from the cache so that the mesh is properly
|
||||
// freed once all refernces to it (which will happen once all
|
||||
// karts are being freed, which would have a pointer to this mesh)
|
||||
@ -236,8 +238,6 @@ void ThreeStrikesBattle::update(float dt)
|
||||
// insert blown away tire(s) now if was requested
|
||||
while (m_insert_tire > 0)
|
||||
{
|
||||
TrackObjectManager* tom = m_track->getTrackObjectManager();
|
||||
|
||||
if(m_insert_tire == 1)
|
||||
{
|
||||
tire_offset = core::vector3df(0.0f, 0.0f, 0.0f);
|
||||
@ -258,6 +258,7 @@ void ThreeStrikesBattle::update(float dt)
|
||||
else if(m_insert_tire == 5) tire = m_tire_dir+"/wheel-rear-right.b3d";
|
||||
}
|
||||
|
||||
TrackObjectManager* tom = m_track->getTrackObjectManager();
|
||||
PhysicalObject* obj =
|
||||
tom->insertObject(tire,
|
||||
tire_model,
|
||||
@ -399,6 +400,12 @@ void ThreeStrikesBattle::restartRace()
|
||||
evt.m_kart_info = m_kart_info;
|
||||
m_battle_events.push_back(evt);
|
||||
|
||||
PhysicalObject *obj;
|
||||
for_in(obj, m_tires)
|
||||
{
|
||||
m_track->getTrackObjectManager()->removeObject(obj);
|
||||
}
|
||||
m_tires.clearWithoutDeleting();
|
||||
} // restartRace
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -207,12 +207,13 @@ PhysicalObject* TrackObjectManager::insertObject(const std::string& model,
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void TrackObjectManager::removeObject(PhysicalObject* who)
|
||||
/** Removes the object from the scene graph, bullet, and the list of
|
||||
* track objects, and then frees the object.
|
||||
* \param obj The physical object to remove.
|
||||
*/
|
||||
void TrackObjectManager::removeObject(PhysicalObject* obj)
|
||||
{
|
||||
m_all_objects.remove(who);
|
||||
|
||||
// FIXME: need to do memory management
|
||||
//delete who;
|
||||
}
|
||||
m_all_objects.remove(obj);
|
||||
delete obj;
|
||||
} // removeObject
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user