From b492f93be72d59cdf065cf0e3904a4f2b9138ffc Mon Sep 17 00:00:00 2001 From: stephena Date: Fri, 15 Dec 2006 16:12:35 +0000 Subject: [PATCH] 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 --- stella/src/emucore/Settings.cxx | 38 +++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/stella/src/emucore/Settings.cxx b/stella/src/emucore/Settings.cxx index 538f22ac0..fc7deb0ad 100644 --- a/stella/src/emucore/Settings.cxx +++ b/stella/src/emucore/Settings.cxx @@ -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 @@ -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