diff --git a/src/replay_player.hpp b/src/replay_player.hpp index ffb7d7f18..88b54ae4b 100644 --- a/src/replay_player.hpp +++ b/src/replay_player.hpp @@ -1,4 +1,4 @@ -// $Id$ +// $Id: $ // // SuperTuxKart - a fun racing game with go-kart // Copyright (C) 2007 Damien Morel @@ -25,14 +25,16 @@ #include "replay_base.hpp" -#include "replay_base.hpp" - - // class managing: // - the loading of replay-file // - the rendering of the replay (interpolation if needed) class ReplayPlayer : public ReplayBase { +public: + ReplayPlayer() : ReplayBase() {} + virtual ~ReplayPlayer() { destroy(); } + + void destroy() { ReplayBase::destroy(); } }; diff --git a/src/world.cpp b/src/world.cpp index c7672ca41..9477f9257 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -208,7 +208,12 @@ World::World(const RaceSetup& raceSetup_) : m_race_setup(raceSetup_) #ifdef HAVE_GHOST_REPLAY m_replay_recorder.initRecorder( m_race_setup.getNumKarts() ); - if( !loadReplayHumanReadable( "test1" ) ) delete m_p_replay_player; + m_p_replay_player = new ReplayPlayer; + if( !loadReplayHumanReadable( "test1" ) ) + { + delete m_p_replay_player; + m_p_replay_player = NULL; + } #endif } @@ -243,8 +248,12 @@ World::~World() #ifdef HAVE_GHOST_REPLAY m_replay_recorder.destroy(); - m_p_replay_player->destroy(); - delete m_p_replay_player; + if( m_p_replay_player ) + { + m_p_replay_player->destroy(); + delete m_p_replay_player; + m_p_replay_player = NULL; + } #endif } @@ -469,8 +478,8 @@ bool World::saveReplayHumanReadable( std::string const &filename ) const //----------------------------------------------------------------------------- bool World::loadReplayHumanReadable( std::string const &filename ) { - delete m_p_replay_player; - m_p_replay_player = new ReplayPlayer(); + assert( m_p_replay_player ); + m_p_replay_player->destroy(); std::string path = ReplayBase::REPLAY_FOLDER + DIR_SEPARATOR; path += filename + ".";