diff --git a/src/FindFile.cpp b/src/FindFile.cpp index f6c29a2ae..50d320282 100644 --- a/src/FindFile.cpp +++ b/src/FindFile.cpp @@ -18,7 +18,6 @@ - #ifdef _MSC_VER #pragma warning(disable: 4786) // WARNING: identifier XXX was truncated to 255 characters in the debug info #pragma warning(disable: 4503) // WARNING: decorated name length exceeded, name was truncated @@ -423,19 +422,19 @@ bool GetExactFileName(const std::string& abs_searchname, std::string& filename) searchpathlist basesearchpaths; void InitBaseSearchPaths() { basesearchpaths.clear(); -#if defined(MACOSX) - AddToFileList(&basesearchpaths, "${HOME}/Library/Application Support/OpenLieroX"); +#if defined(__APPLE__) + AddToFileList(&basesearchpaths, "${HOME}/Library/Application Support/Commander Genius"); AddToFileList(&basesearchpaths, "."); - AddToFileList(&basesearchpaths, "${BIN}/../Resources/gamedir"); - AddToFileList(&basesearchpaths, SYSTEM_DATA_DIR"/OpenLieroX"); + AddToFileList(&basesearchpaths, "${BIN}/../Resources/data"); + AddToFileList(&basesearchpaths, SYSTEM_DATA_DIR"/commandergenius"); #elif defined(WIN32) - AddToFileList(&basesearchpaths, "${HOME}/OpenLieroX"); + AddToFileList(&basesearchpaths, "${HOME}/Commander Genius"); AddToFileList(&basesearchpaths, "."); AddToFileList(&basesearchpaths, "${BIN}"); #else // all other systems (Linux, *BSD, OS/2, ...) - AddToFileList(&basesearchpaths, "${HOME}/.OpenLieroX"); + AddToFileList(&basesearchpaths, "${HOME}/.CommanderGenius"); AddToFileList(&basesearchpaths, "."); - AddToFileList(&basesearchpaths, SYSTEM_DATA_DIR"/OpenLieroX"); // no use of ${SYSTEM_DATA}, because it is uncommon and could cause confusion to the user + AddToFileList(&basesearchpaths, SYSTEM_DATA_DIR"/commandergenius"); // no use of ${SYSTEM_DATA}, because it is uncommon and could cause confusion to the user #endif } diff --git a/src/fileio/CParser.cpp b/src/fileio/CParser.cpp index e92b48852..8983e4973 100644 --- a/src/fileio/CParser.cpp +++ b/src/fileio/CParser.cpp @@ -11,7 +11,7 @@ #include #include -#define CONFIGFILENAME "genius.cfg" +std::string CONFIGFILENAME = "genius.cfg"; CParser::CParser() { @@ -41,7 +41,7 @@ bool CParser::loadParseFile() // Open, read the list and close the file { FILE *fp; - if((fp=fopen(CONFIGFILENAME,"rt"))) + if((fp=fopen(CONFIGFILENAME.c_str(),"rt"))) { while(!feof(fp)) { @@ -52,12 +52,9 @@ bool CParser::loadParseFile() // Open, read the list and close the file fclose(fp); return true; } - else - { - g_pLogFile->ftextOut(GREEN,"Parser : The file has not been found. When CKP is trying to save the file it will create a new one."); - return false; - } + g_pLogFile->ftextOut(GREEN,"Parser : The file has not been found. When CKP is trying to save the file it will create a new one."); + return false; } // Close the text which was parsed. This will also copy all stuff of the memory to the file. @@ -65,7 +62,7 @@ bool CParser::saveParseFile() // open, write on the file and close { FILE *fp; - if((fp=fopen(CONFIGFILENAME,"wt"))) + if((fp=fopen(CONFIGFILENAME.c_str(),"wt"))) { for(std::list::iterator i=m_filebuffer.begin() ; i != m_filebuffer.end() ; ++i ) fprintf(fp,"%s\n",i->c_str()); @@ -73,11 +70,9 @@ bool CParser::saveParseFile() // open, write on the file and close fclose(fp); return true; } - else - { - g_pLogFile->ftextOut(RED,"Parser : Error opening the file for write operations. Check your permissions or if the disk is full"); - return false; - } + + g_pLogFile->ftextOut(RED,"Parser : Error opening the file for write operations. Check your permissions or if the disk is full"); + return false; } // read the value of the to be seeked keyword and returns it as an int. diff --git a/src/fileio/CParser.h b/src/fileio/CParser.h index 959118630..0864385b0 100644 --- a/src/fileio/CParser.h +++ b/src/fileio/CParser.h @@ -13,6 +13,8 @@ #include #include +extern std::string CONFIGFILENAME; + class CParser { public: CParser(); diff --git a/src/sdl/CSettings.cpp b/src/sdl/CSettings.cpp index a89d6b710..25994f3c6 100644 --- a/src/sdl/CSettings.cpp +++ b/src/sdl/CSettings.cpp @@ -10,6 +10,40 @@ #include "CSettings.h" #include "CVideoDriver.h" #include "sound/CSound.h" +#include "../FindFile.h" +#include "../ConfigHandler.h" + + +void InitSearchPaths() { + // have to set to find the config at some of the default places + InitBaseSearchPaths(); + + std::string value; + int i = 1; + while(true) { + if(!ReadString(CONFIGFILENAME, "FileHandling", "SearchPath" + itoa(i,10), value, "")) + break; + + AddToFileList(&tSearchPaths, value); + i++; + } + + // add the basesearchpaths to the searchpathlist as they should be saved in the end + for(searchpathlist::const_iterator p1 = basesearchpaths.begin(); p1 != basesearchpaths.end(); i++,p1++) { + AddToFileList(&tSearchPaths, *p1); + } + + // print the searchpaths, this may be very usefull for the user + notes << "I have now the following searchpaths (in this order):\n"; + for(searchpathlist::const_iterator p2 = tSearchPaths.begin(); p2 != tSearchPaths.end(); p2++) { + std::string path = *p2; + ReplaceFileVariables(path); + notes << " " << path << "\n"; + } + notes << " And that's all." << endl; +} + + CSettings::CSettings() { // TODO Auto-generated constructor stub