change ReplayPlayer -allocation/deallocation in worls, world crashed in dtor, if replay-file was not found
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1249 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
bf7cda5179
commit
76dc339f38
@ -1,4 +1,4 @@
|
|||||||
// $Id$
|
// $Id: $
|
||||||
//
|
//
|
||||||
// SuperTuxKart - a fun racing game with go-kart
|
// SuperTuxKart - a fun racing game with go-kart
|
||||||
// Copyright (C) 2007 Damien Morel <divdams@free.fr>
|
// Copyright (C) 2007 Damien Morel <divdams@free.fr>
|
||||||
@ -25,14 +25,16 @@
|
|||||||
#include "replay_base.hpp"
|
#include "replay_base.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include "replay_base.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
// class managing:
|
// class managing:
|
||||||
// - the loading of replay-file
|
// - the loading of replay-file
|
||||||
// - the rendering of the replay (interpolation if needed)
|
// - the rendering of the replay (interpolation if needed)
|
||||||
class ReplayPlayer : public ReplayBase
|
class ReplayPlayer : public ReplayBase
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
ReplayPlayer() : ReplayBase() {}
|
||||||
|
virtual ~ReplayPlayer() { destroy(); }
|
||||||
|
|
||||||
|
void destroy() { ReplayBase::destroy(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,7 +208,12 @@ World::World(const RaceSetup& raceSetup_) : m_race_setup(raceSetup_)
|
|||||||
|
|
||||||
#ifdef HAVE_GHOST_REPLAY
|
#ifdef HAVE_GHOST_REPLAY
|
||||||
m_replay_recorder.initRecorder( m_race_setup.getNumKarts() );
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,8 +248,12 @@ World::~World()
|
|||||||
|
|
||||||
#ifdef HAVE_GHOST_REPLAY
|
#ifdef HAVE_GHOST_REPLAY
|
||||||
m_replay_recorder.destroy();
|
m_replay_recorder.destroy();
|
||||||
m_p_replay_player->destroy();
|
if( m_p_replay_player )
|
||||||
delete m_p_replay_player;
|
{
|
||||||
|
m_p_replay_player->destroy();
|
||||||
|
delete m_p_replay_player;
|
||||||
|
m_p_replay_player = NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,8 +478,8 @@ bool World::saveReplayHumanReadable( std::string const &filename ) const
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool World::loadReplayHumanReadable( std::string const &filename )
|
bool World::loadReplayHumanReadable( std::string const &filename )
|
||||||
{
|
{
|
||||||
delete m_p_replay_player;
|
assert( m_p_replay_player );
|
||||||
m_p_replay_player = new ReplayPlayer();
|
m_p_replay_player->destroy();
|
||||||
|
|
||||||
std::string path = ReplayBase::REPLAY_FOLDER + DIR_SEPARATOR;
|
std::string path = ReplayBase::REPLAY_FOLDER + DIR_SEPARATOR;
|
||||||
path += filename + ".";
|
path += filename + ".";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user