1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09:43 +01:00

Fix loading levels saved with 2.2 or earlier

2.2 and earlier had this god-awful thing where it put the closing tag of
an edentity onto the next line, and then kept the indentation the same.
This requires parsing the XML in an extremely specific way (i.e.
ignoring the whitespace) so the newline and indentation isn't taken as
part of the actual contents of the tag.

2.3 removed this awful whitespace entirely to make it easier on parsers.
When I tested #270, I tested against a 2.3 re-save of Dimension Open and
diffed the two, because I thought testing against the original version
of the level would result in a bunch of noise I didn't want due to the
whitespace change. Well, I did exactly what I intended, and ended up
ignoring the whitespace change so much that levels saved in this stupid
format ended up getting broken.

Luckily, we can just tell TinyXML-2 to parse a document exactly like how
TinyXML-1 would've parsed it, by supplying the COLLAPSE_WHITESPACE enum
to it (by default it's on PRESERVE_WHITESPACE).
This commit is contained in:
Misa 2020-06-12 12:55:02 -07:00 committed by Ethan Lee
parent 3f4df82583
commit c2c0644453

View file

@ -1643,7 +1643,7 @@ bool editorclass::load(std::string& _path)
printf("Custom asset directory does not exist\n");
}
tinyxml2::XMLDocument doc;
tinyxml2::XMLDocument doc(true, tinyxml2::COLLAPSE_WHITESPACE);
if (!FILESYSTEM_loadTiXml2Document(_path.c_str(), doc))
{
printf("No level %s to load :(\n", _path.c_str());