diff --git a/game/xml_reader.cpp b/game/xml_reader.cpp index c7980c0..1d7748f 100644 --- a/game/xml_reader.cpp +++ b/game/xml_reader.cpp @@ -19,6 +19,7 @@ *****************************************************************************/ #include +#include #include #include @@ -202,7 +203,13 @@ void XmlReader::endElement(const string& namespaceURI, { if (tag == "Letters") { - if (m_dic.getHeader().getLetters() != fromUtf8(m_data)) + const wdstring & displayLetters = m_dic.convertToDisplay(m_dic.getHeader().getLetters()); + // Remove spaces + string::iterator it; + it = remove(m_data.begin(), m_data.end(), L' '); + m_data.erase(it, m_data.end()); + // Compare + if (displayLetters != fromUtf8(m_data)) throw LoadGameException("The current dictionary is different from the one used in the saved game"); } else if (tag == "WordNb") diff --git a/game/xml_writer.cpp b/game/xml_writer.cpp index 5cc2b27..e5597ea 100644 --- a/game/xml_writer.cpp +++ b/game/xml_writer.cpp @@ -116,7 +116,14 @@ void XmlWriter::write(const Game &iGame, const string &iFileName) else throw SaveGameException("Invalid dictionary type"); out << "" << endl; - out << indent << "" << toUtf8(header.getLetters()) << "" << endl; + // Retrieve the dictionary letters, ans separate them with spaces + wstring lettersWithSpaces = header.getLetters(); + for (size_t i = lettersWithSpaces.size() - 1; i > 0; --i) + lettersWithSpaces.insert(i, 1, L' '); + // Convert to a display string + const wstring &displayLetters = + iGame.getDic().convertToDisplay(lettersWithSpaces); + out << indent << "" << toUtf8(displayLetters) << "" << endl; out << indent << "" << header.getNbWords() << "" << endl; removeIndent(indent); out << indent << "" << endl;