From dd292e5da5ad50677b5112b46547b93a4f909701 Mon Sep 17 00:00:00 2001 From: doitux Date: Sat, 27 Jan 2007 16:34:16 +0000 Subject: [PATCH] Config File has a new item: ConfigRev. It will be incremented for every new config item. Constructor of ConfigFile check the Revision Number in the local Config File. If it is to old config file will be deleted and a new one with default values will be created. --- src/config/configfile.cpp | 13 +++++++++++++ src/config/configfile.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/config/configfile.cpp b/src/config/configfile.cpp index 01e35628..befd375e 100644 --- a/src/config/configfile.cpp +++ b/src/config/configfile.cpp @@ -30,6 +30,8 @@ using namespace std; ConfigFile::ConfigFile() { + // !!!! Revisionsnummer der Configdefaults !!!!! + configRev = 1; // Pfad und Dateinamen setzen #ifdef _WIN32 @@ -51,6 +53,14 @@ ConfigFile::ConfigFile() //Prüfen ob Configfile existiert --> sonst anlegen TiXmlDocument doc(configFileName); if(!doc.LoadFile()){ createDefaultConfig(); } + else { + //Prüfen ob die Revision stimmt ansonsten löschen und neue anlegen + int temp = 0; + TiXmlHandle docHandle( &doc ); + TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement(); + if ( conf ) { conf->QueryIntAttribute("value", &temp ); } + if (temp < configRev) { /*löschen()*/ createDefaultConfig() ;} + } } @@ -73,6 +83,9 @@ void ConfigFile::createDefaultConfig() { config = new TiXmlElement( "Configuration" ); root->LinkEndChild( config ); + TiXmlElement * confElement0 = new TiXmlElement( "ConfigRevision" ); + config->LinkEndChild( confElement0 ); + confElement0->SetAttribute("value", configRev); TiXmlElement * confElement1 = new TiXmlElement( "NumberOfPlayers" ); config->LinkEndChild( confElement1 ); confElement1->SetAttribute("value", 5); diff --git a/src/config/configfile.h b/src/config/configfile.h index 1fbe96e1..966e135b 100644 --- a/src/config/configfile.h +++ b/src/config/configfile.h @@ -40,6 +40,7 @@ public: private: std::string configFileName; + int configRev; };