mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-11-17 07:48:27 +01:00
Saved games: increase the XML format version, to indicate incompatibilities
This commit is contained in:
parent
76d761ad8d
commit
c423da2425
2 changed files with 25 additions and 2 deletions
|
@ -53,6 +53,10 @@
|
|||
#include "navigation.h"
|
||||
#include "header.h"
|
||||
|
||||
// Current version of our save game format. Bump it when it becomes
|
||||
// incompatible (and keep it in sync with xml_writer.cpp)
|
||||
#define CURRENT_XML_VERSION "2"
|
||||
|
||||
using namespace std;
|
||||
|
||||
INIT_LOGGER(game, XmlReader);
|
||||
|
@ -165,7 +169,22 @@ void XmlReader::startElement(const string& namespaceURI,
|
|||
|
||||
m_data.clear();
|
||||
const string &tag = localName;
|
||||
if (tag == "Dictionary")
|
||||
if (tag == "EliotGame")
|
||||
{
|
||||
// Make sure that we are loading the correct XML format
|
||||
for (int i = 0; i < atts.getLength(); ++i)
|
||||
{
|
||||
if (atts.getLocalName(i) == "format" &&
|
||||
atts.getValue(i) != CURRENT_XML_VERSION)
|
||||
{
|
||||
LOG_ERROR("Incompatible save game format: current="
|
||||
<< CURRENT_XML_VERSION
|
||||
<< " savegame=" << atts.getValue(i));
|
||||
throw LoadGameException("This saved game is not compatible with the current version of Eliot.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tag == "Dictionary")
|
||||
{
|
||||
m_context = "Dictionary";
|
||||
}
|
||||
|
|
|
@ -42,6 +42,10 @@
|
|||
#include "dic.h"
|
||||
#include "header.h"
|
||||
|
||||
// Current version of our save game format. Bump it when it becomes
|
||||
// incompatible (and keep it in sync with xml_reader.cpp)
|
||||
#define CURRENT_XML_VERSION "2"
|
||||
|
||||
using namespace std;
|
||||
|
||||
INIT_LOGGER(game, XmlWriter);
|
||||
|
@ -101,7 +105,7 @@ void XmlWriter::write(const Game &iGame, const string &iFileName)
|
|||
out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
|
||||
|
||||
string indent = "";
|
||||
out << indent << "<EliotGame format=\"1\">" << endl;
|
||||
out << indent << "<EliotGame format=\"" << CURRENT_XML_VERSION << "\">" << endl;
|
||||
addIndent(indent);
|
||||
|
||||
// ------------------------
|
||||
|
|
Loading…
Reference in a new issue