Merge branch 'master' of https://github.com/leyyin/stk-code into leyyin-master

This commit is contained in:
hiker 2014-04-22 14:14:49 +10:00
commit 1bff514c27
6 changed files with 59 additions and 24 deletions

View File

@ -39,6 +39,7 @@ float STKConfig::UNDEFINED = -99.9f;
STKConfig::STKConfig() STKConfig::STKConfig()
{ {
m_has_been_loaded = false; m_has_been_loaded = false;
m_title_music = NULL;
m_default_kart_properties = new KartProperties(); m_default_kart_properties = new KartProperties();
} // STKConfig } // STKConfig
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -46,7 +47,9 @@ STKConfig::~STKConfig()
{ {
if(m_title_music) if(m_title_music)
delete m_title_music; delete m_title_music;
delete m_default_kart_properties;
if(m_default_kart_properties)
delete m_default_kart_properties;
} // ~STKConfig } // ~STKConfig
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -137,8 +137,7 @@ public:
std::vector<int> m_score_increase; std::vector<int> m_score_increase;
/** Filename of the title music to play.*/ /** Filename of the title music to play.*/
MusicInformation MusicInformation *m_title_music;
*m_title_music;
/** Minimum time between consecutive saved tranform events. */ /** Minimum time between consecutive saved tranform events. */
float m_replay_dt; float m_replay_dt;

View File

@ -106,6 +106,7 @@ IrrDriver::IrrDriver()
m_request_screenshot = false; m_request_screenshot = false;
m_shaders = NULL; m_shaders = NULL;
m_rtts = NULL; m_rtts = NULL;
m_post_processing = NULL;
m_wind = new Wind(); m_wind = new Wind();
m_mipviz = m_wireframe = m_normals = m_ssaoviz = \ m_mipviz = m_wireframe = m_normals = m_ssaoviz = \
m_lightviz = m_shadowviz = m_distortviz = 0; m_lightviz = m_shadowviz = m_distortviz = 0;
@ -124,7 +125,11 @@ IrrDriver::~IrrDriver()
// instead we just decrease the ref count here. When the material // instead we just decrease the ref count here. When the material
// is deleted, it will trigger the actual deletion of // is deleted, it will trigger the actual deletion of
// PostProcessing when decreasing the refcount of its callback object. // PostProcessing when decreasing the refcount of its callback object.
m_post_processing->drop(); if(m_post_processing)
{
// check if we createad the OpenGL device by calling initDevice()
m_post_processing->drop();
}
assert(m_device != NULL); assert(m_device != NULL);
m_device->drop(); m_device->drop();

View File

@ -490,9 +490,12 @@ void FileManager::pushTextureSearchPath(const std::string& path)
*/ */
void FileManager::popTextureSearchPath() void FileManager::popTextureSearchPath()
{ {
std::string dir = m_texture_search_path.back(); if(!m_texture_search_path.empty())
m_texture_search_path.pop_back(); {
m_file_system->removeFileArchive(createAbsoluteFilename(dir)); std::string dir = m_texture_search_path.back();
m_texture_search_path.pop_back();
m_file_system->removeFileArchive(createAbsoluteFilename(dir));
}
} // popTextureSearchPath } // popTextureSearchPath
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -500,11 +503,25 @@ void FileManager::popTextureSearchPath()
*/ */
void FileManager::popModelSearchPath() void FileManager::popModelSearchPath()
{ {
std::string dir = m_model_search_path.back(); if(!m_model_search_path.empty())
m_model_search_path.pop_back(); {
m_file_system->removeFileArchive(createAbsoluteFilename(dir)); std::string dir = m_model_search_path.back();
m_model_search_path.pop_back();
m_file_system->removeFileArchive(createAbsoluteFilename(dir));
}
} // popModelSearchPath } // popModelSearchPath
// ------------------------------------------------------------------------
/** Removes the last added directory from the music search path.
*/
void FileManager::popMusicSearchPath()
{
if(!m_music_search_path.empty())
{
m_music_search_path.pop_back();
}
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Tries to find the specified file in any of the given search paths. /** Tries to find the specified file in any of the given search paths.
* \param full_path On return contains the full path of the file, or * \param full_path On return contains the full path of the file, or

View File

@ -132,9 +132,10 @@ public:
void pushTextureSearchPath(const std::string& path); void pushTextureSearchPath(const std::string& path);
void pushModelSearchPath (const std::string& path); void pushModelSearchPath(const std::string& path);
void popTextureSearchPath (); void popTextureSearchPath();
void popModelSearchPath (); void popModelSearchPath();
void popMusicSearchPath();
void redirectOutput(); void redirectOutput();
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Adds a directory to the music search path (or stack). /** Adds a directory to the music search path (or stack).
@ -143,10 +144,7 @@ public:
{ {
m_music_search_path.push_back(path); m_music_search_path.push_back(path);
} // pushMusicSearchPath } // pushMusicSearchPath
// ------------------------------------------------------------------------
/** Removes the last added directory from the music search path.
*/
void popMusicSearchPath() {m_music_search_path.pop_back(); }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns true if the specified file exists. /** Returns true if the specified file exists.
*/ */

View File

@ -201,6 +201,7 @@
#include "utils/translation.hpp" #include "utils/translation.hpp"
static void cleanSuperTuxKart(); static void cleanSuperTuxKart();
static void cleanUserConfig();
// ============================================================================ // ============================================================================
// gamepad visualisation screen // gamepad visualisation screen
@ -462,10 +463,10 @@ void cmdLineHelp()
*/ */
int handleCmdLinePreliminary() int handleCmdLinePreliminary()
{ {
if(CommandLine::has("--help") || CommandLine::has("--help") || if(CommandLine::has("--help") || CommandLine::has("-h"))
CommandLine::has("-h"))
{ {
cmdLineHelp(); cmdLineHelp();
cleanUserConfig();
exit(0); exit(0);
} }
@ -478,6 +479,7 @@ int handleCmdLinePreliminary()
IRRLICHT_VERSION_MAJOR , IRRLICHT_VERSION_MINOR, IRRLICHT_VERSION_MAJOR , IRRLICHT_VERSION_MINOR,
IRRLICHT_VERSION_REVISION, IRRLICHT_SDK_VERSION ); IRRLICHT_VERSION_REVISION, IRRLICHT_SDK_VERSION );
Log::info("main", "=============================="); Log::info("main", "==============================");
cleanUserConfig();
exit(0); exit(0);
} }
@ -1213,8 +1215,10 @@ int main(int argc, char *argv[] )
// If the server has been created (--server option), this will do nothing (just a warning): // If the server has been created (--server option), this will do nothing (just a warning):
NetworkManager::getInstance<ClientNetworkManager>(); NetworkManager::getInstance<ClientNetworkManager>();
if (NetworkManager::getInstance()->isServer()) if (NetworkManager::getInstance()->isServer())
{
ServerNetworkManager::getInstance()->setMaxPlayers( ServerNetworkManager::getInstance()->setMaxPlayers(
UserConfigParams::m_server_max_players); UserConfigParams::m_server_max_players);
}
NetworkManager::getInstance()->run(); NetworkManager::getInstance()->run();
if (NetworkManager::getInstance()->isServer()) if (NetworkManager::getInstance()->isServer())
{ {
@ -1443,15 +1447,24 @@ static void cleanSuperTuxKart()
if(sfx_manager) delete sfx_manager; if(sfx_manager) delete sfx_manager;
if(music_manager) delete music_manager; if(music_manager) delete music_manager;
delete ParticleKindManager::get(); delete ParticleKindManager::get();
if(stk_config) delete stk_config;
if(user_config) delete user_config;
PlayerManager::destroy(); PlayerManager::destroy();
if(unlock_manager) delete unlock_manager; if(unlock_manager) delete unlock_manager;
if(translations) delete translations;
if(file_manager) delete file_manager; cleanUserConfig();
if(irr_driver) delete irr_driver;
StateManager::deallocate(); StateManager::deallocate();
GUIEngine::EventHandler::deallocate(); GUIEngine::EventHandler::deallocate();
} // cleanSuperTuxKart } // cleanSuperTuxKart
//=============================================================================
/**
* Frees all the memory of initUserConfig()
*/
static void cleanUserConfig()
{
if(stk_config) delete stk_config;
if(translations) delete translations;
if(user_config) delete user_config;
if(file_manager) delete file_manager;
if(irr_driver) delete irr_driver;
}