some fixes for config handling + save searchpaths

git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@155 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
albertzeyer
2009-07-24 18:07:25 +00:00
parent 6c0db530e2
commit 6af47445c3
4 changed files with 22 additions and 19 deletions

View File

@@ -65,7 +65,7 @@ bool CParser::saveParseFile() // open, write on the file and close
if((fp=OpenGameFile(m_configfile.c_str(),"wt")))
{
for(std::list<std::string>::iterator i=m_filebuffer.begin() ; i != m_filebuffer.end() ; ++i )
for(std::list<std::string>::iterator i = m_filebuffer.begin() ; i != m_filebuffer.end() ; ++i )
fprintf(fp,"%s\n",i->c_str());
fclose(fp);
@@ -97,8 +97,8 @@ std::string CParser::getValue(const std::string& keyword, const std::string& cat
if(subStrCaseEqual(*line, keyword + " =", keyword.size() + 2))
return line->substr(keyword.size() + 2);
}
break;
}
break;
}
}
return def;
@@ -163,7 +163,7 @@ int CParser::getIntValue(const std::string& keyword, const std::string& category
bool fail = false;
int v = from_string<int>(str, fail);
if(fail) return def;
return v;
}

View File

@@ -221,6 +221,8 @@ int main(int argc, char *argv[])
cleanupResources(&CKP);
Settings.saveDrvCfg();
printf("Thank you very much for playing this wonderful game!");
return 0;

View File

@@ -18,13 +18,11 @@ std::string CONFIGFILENAME = "genius.cfg";
CSettings::CSettings() {
// TODO Auto-generated constructor stub
notes << "Reading game options from " << GetFullFileName(CONFIGFILENAME) << endl;
notes << "Will write game options to " << GetWriteFullFileName(CONFIGFILENAME, true) << endl;
}
CSettings::~CSettings() {
// TODO Auto-generated destructor stub
}
CSettings::~CSettings() {}
short CSettings::saveDrvCfg(void)
@@ -32,7 +30,14 @@ short CSettings::saveDrvCfg(void)
short retval = 0;
CParser Parser;
Parser.loadParseFile();
{
int i = 1;
for(searchpathlist::const_iterator p = tSearchPaths.begin(); p != tSearchPaths.end(); p++, i++)
Parser.saveValue("SearchPath" + itoa(i), "FileHandling", *p);
}
Parser.saveIntValue("bpp","Video",g_pVideoDriver->getDepth());
Parser.saveIntValue("frameskip","Video",g_pVideoDriver->getFrameskip());
@@ -157,16 +162,13 @@ short CSettings::loadGameCfg(stOption *Option)
void CSettings::saveGameCfg(stOption *Option)
{
int i;
CParser Parser;
Parser.loadParseFile();
for (int i = 0; i < NUM_OPTIONS; i++)
Parser.saveIntValue(Option[i].name,"Game",Option[i].value);
if(Parser.loadParseFile())
{
for (i = 0; i < NUM_OPTIONS; i++)
Parser.saveIntValue(Option[i].name,"Game",Option[i].value);
Parser.saveParseFile();
}
Parser.saveParseFile();
return;
}

View File

@@ -275,15 +275,14 @@ bool CVideoDriver::applyMode(void)
// And Display can be setup.
screen = SDL_SetVideoMode(m_Resolution.width,m_Resolution.height,m_Resolution.depth,Mode);
m_Resolution.depth = screen->format->BitsPerPixel;
if( !screen )
{
g_pLogFile->textOut(RED,"VidDrv_Start(): Couldn't create a SDL surface: %s<br>", SDL_GetError());
return false;
}
m_Resolution.depth = screen->format->BitsPerPixel;
if(!Fullscreen)
SDL_ShowCursor(SDL_ENABLE);
else