Mercurial > sumwars
changeset 2010:27f65797b817
Using std::string instead of char pointers with temporary storage: we were getting garbage file names for config files since my recent commit
author | mafm |
---|---|
date | Sun, 30 Oct 2011 23:30:48 +0000 |
parents | a483225a5948 |
children | f5673ed5d8cb |
files | src/gui/application.cpp |
diffstat | 1 files changed, 15 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gui/application.cpp Sun Oct 30 23:28:16 2011 +0000 +++ b/src/gui/application.cpp Sun Oct 30 23:30:48 2011 +0000 @@ -193,12 +193,12 @@ // creating local {ogre,plugins}.cfg files, if system-wide ones not // found - const char* ogreCfgSystem = (SumwarsHelper::gameDataPath() + "/ogre.cfg").c_str(); - const char* ogreCfgUser = (SumwarsHelper::userPath() + "/ogre.cfg").c_str(); - const char* pluginsCfgSystem = (SumwarsHelper::gameDataPath() + "/plugins.cfg").c_str(); - const char* pluginsCfgUser = (SumwarsHelper::userPath() + "/plugins.cfg").c_str(); + std::string ogreCfgSystem = (SumwarsHelper::gameDataPath() + "/ogre.cfg").c_str(); + std::string ogreCfgUser = (SumwarsHelper::userPath() + "/ogre.cfg").c_str(); + std::string pluginsCfgSystem = (SumwarsHelper::gameDataPath() + "/plugins.cfg").c_str(); + std::string pluginsCfgUser = (SumwarsHelper::userPath() + "/plugins.cfg").c_str(); - if (! PHYSFS_exists(ogreCfgSystem)) { + if (! PHYSFS_exists(ogreCfgSystem.c_str())) { std::string str = "Render System=OpenGL Rendering Subsystem\ \ [OpenGL Rendering Subsystem]\ @@ -207,19 +207,20 @@ RTT Preferred Mode=PBuffer\ Video Mode=940 x 705\ "; - int count = PHYSFS_write(PHYSFS_openWrite(ogreCfgUser), + PHYSFS_file* ogreFile = PHYSFS_openWrite(ogreCfgUser.c_str()); + int count = PHYSFS_write(ogreFile, str.c_str(), sizeof(char), str.size()); if (count < str.size()) { ERRORMSG("A global '%s' file could not be found, and attempting to write a local one failed: PHYSFS_write('%s') failed: %s\n", - ogreCfgSystem, - ogreCfgUser, + ogreCfgSystem.c_str(), + ogreCfgUser.c_str(), PHYSFS_getLastError()); return false; } } - if (! PHYSFS_exists(pluginsCfgSystem)) { + if (! PHYSFS_exists(pluginsCfgSystem.c_str())) { std::string str = "# Defines plugins to load\ \ # Define plugin folder\ @@ -231,13 +232,14 @@ Plugin=Plugin_BSPSceneManager.so\ Plugin=Plugin_OctreeSceneManager.so\ "; - int count = PHYSFS_write(PHYSFS_openWrite(pluginsCfgUser), + PHYSFS_file* pluginsFile = PHYSFS_openWrite(pluginsCfgUser.c_str()); + int count = PHYSFS_write(pluginsFile, str.c_str(), sizeof(char), str.size()); if (count < str.size()) { ERRORMSG("A global '%s' file could not be found, and attempting to write a local one failed: PHYSFS_write('%s') failed: %s\n", - pluginsCfgSystem, - pluginsCfgUser, + pluginsCfgSystem.c_str(), + pluginsCfgUser.c_str(), PHYSFS_getLastError()); return false; } @@ -268,7 +270,7 @@ #elif defined (__unix__) // ogreCfgSystem, ogreCfgUser, pluginsCfgSystem and pluginsCfgUser // declared above - if (PHYSFS_exists(pluginsCfgSystem) && PHYSFS_exists(pluginsCfgSystem)) { + if (PHYSFS_exists(pluginsCfgSystem.c_str()) && PHYSFS_exists(pluginsCfgSystem.c_str())) { m_ogre_root = new Ogre::Root(pluginsCfgSystem, ogreCfgSystem, SumwarsHelper::userPath() + "/Ogre.log");