Added logic to Settings class so that a settings file can be marked as

'too old'.  In this case, the file won't be parsed, and the internal
defaults will be used.  This should only be changed when absolutely
necessary, as is the case with this release, since there are a few
settings that can cause Stella to not work when used with a 2.2 settings file.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1215 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-12-15 16:12:35 +00:00
parent 945bd27cbd
commit b492f93be7
1 changed files with 31 additions and 7 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Settings.cxx,v 1.99 2006-12-13 17:09:10 stephena Exp $
// $Id: Settings.cxx,v 1.100 2006-12-15 16:12:35 stephena Exp $
//============================================================================
#include <cassert>
@ -25,6 +25,14 @@
#include "bspf.hxx"
#include "Settings.hxx"
// Specifies the minimum version of the settings file that's valid
// for this version of Stella. If the settings file is too old,
// the internal defaults are used.
// For each new release, this should only be bumped if there have been
// major changes in some settings; changes which could stop Stella from
// actually working.
#define MIN_SETTINGS_VERSION "2.3_alpha"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Settings::Settings(OSystem* osystem)
: myOSystem(osystem)
@ -42,13 +50,12 @@ Settings::Settings(OSystem* osystem)
setInternal("gl_lib", "");
setInternal("gl_vsync", "true");
setInternal("scale_ui", "zoom1x");
setInternal("scale_tia", "zoom1x");
setInternal("scale_ui", "zoom2x");
setInternal("scale_tia", "zoom2x");
setInternal("fullscreen", "false");
setInternal("center", "true");
setInternal("grabmouse", "false");
setInternal("palette", "standard");
setInternal("debugheight", "0");
setInternal("sound", "true");
setInternal("fragsize", "512");
@ -72,13 +79,14 @@ Settings::Settings(OSystem* osystem)
setInternal("showinfo", "false");
setInternal("ssdir", "");
setInternal("ssdir", string(".") + BSPF_PATH_SEPARATOR);
setInternal("sssingle", "false");
setInternal("romdir", "");
setInternal("rombrowse", "true");
setInternal("lastrom", "");
setInternal("modtime", ""); // romdir last modification time
setInternal("modtime", "");
setInternal("debugheight", "0");
setInternal("tiadefaults", "true");
setInternal("autoslot", "false");
@ -105,6 +113,21 @@ void Settings::loadConfig()
return;
}
// Get the first line, and parse the version string (if it exists)
// If we don't have the minimum settings version, then ignore
// this settings file.
if(getline(in, line))
{
string minVersion = "; Version ";
minVersion += MIN_SETTINGS_VERSION;
if(line.find("; Version") != 0 || line < minVersion)
{
cout << "Error: Settings file too old, using internal defaults\n";
in.close();
return;
}
}
while(getline(in, line))
{
// Strip all whitespace and tabs from the line
@ -396,7 +419,8 @@ void Settings::saveConfig()
return;
}
out << "; Stella configuration file" << endl
out << "; Version " << STELLA_VERSION << endl
<< "; Stella configuration file" << endl
<< ";" << endl
<< "; Lines starting with ';' are comments and are ignored." << endl
<< "; Spaces and tabs are ignored." << endl