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

Add XML forwards compatibility to tsave.vvv and qsave.vvv

These files are probably not of much consequence. The main game isn't
going to have things to be added to it anytime soon.
This commit is contained in:
Misa 2020-09-25 09:10:48 -07:00 committed by Ethan Lee
parent 17b8d0308e
commit 0eb39644c1

View file

@ -5720,6 +5720,11 @@ void Game::savetele()
}
tinyxml2::XMLDocument doc;
bool already_exists = FILESYSTEM_loadTiXml2Document("saves/tsave.vvv", doc);
if (!already_exists)
{
puts("No tsave.vvv found. Creating new file");
}
telesummary = writemaingamesave(doc);
if(FILESYSTEM_saveTiXml2Document("saves/tsave.vvv", doc))
@ -5743,6 +5748,11 @@ void Game::savequick()
}
tinyxml2::XMLDocument doc;
bool already_exists = FILESYSTEM_loadTiXml2Document("saves/qsave.vvv", doc);
if (!already_exists)
{
puts("No qsave.vvv found. Creating new file");
}
quicksummary = writemaingamesave(doc);
if(FILESYSTEM_saveTiXml2Document("saves/qsave.vvv", doc))
@ -5768,18 +5778,13 @@ std::string Game::writemaingamesave(tinyxml2::XMLDocument& doc)
return "";
}
tinyxml2::XMLElement* msg;
tinyxml2::XMLDeclaration* decl = doc.NewDeclaration();
doc.LinkEndChild( decl );
xml::update_declaration(doc);
tinyxml2::XMLElement * root = doc.NewElement( "Save" );
doc.LinkEndChild( root );
tinyxml2::XMLElement * root = xml::update_element(doc, "Save");
tinyxml2::XMLComment * comment = doc.NewComment(" Save file " );
root->LinkEndChild( comment );
xml::update_comment(root, " Save file " );
tinyxml2::XMLElement * msgs = doc.NewElement( "Data" );
root->LinkEndChild( msgs );
tinyxml2::XMLElement * msgs = xml::update_element(root, "Data");
//Flags, map and stats
@ -5789,157 +5794,91 @@ std::string Game::writemaingamesave(tinyxml2::XMLDocument& doc)
{
mapExplored += help.String(map.explored[i]) + ",";
}
msg = doc.NewElement( "worldmap" );
msg->LinkEndChild( doc.NewText( mapExplored.c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "worldmap", mapExplored.c_str());
std::string flags;
for(size_t i = 0; i < SDL_arraysize(obj.flags); i++ )
{
flags += help.String((int) obj.flags[i]) + ",";
}
msg = doc.NewElement( "flags" );
msg->LinkEndChild( doc.NewText( flags.c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "flags", flags.c_str());
std::string crewstatsString;
for(size_t i = 0; i < SDL_arraysize(crewstats); i++ )
{
crewstatsString += help.String(crewstats[i]) + ",";
}
msg = doc.NewElement( "crewstats" );
msg->LinkEndChild( doc.NewText( crewstatsString.c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "crewstats", crewstatsString.c_str());
std::string collect;
for(size_t i = 0; i < SDL_arraysize(obj.collect); i++ )
{
collect += help.String((int) obj.collect[i]) + ",";
}
msg = doc.NewElement( "collect" );
msg->LinkEndChild( doc.NewText( collect.c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "collect", collect.c_str());
//Position
msg = doc.NewElement( "finalx" );
msg->LinkEndChild( doc.NewText( help.String(map.finalx).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "finalx", map.finalx);
msg = doc.NewElement( "finaly" );
msg->LinkEndChild( doc.NewText( help.String(map.finaly).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "finaly", map.finaly);
msg = doc.NewElement( "savex" );
msg->LinkEndChild( doc.NewText( help.String(savex).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "savex", savex);
msg = doc.NewElement( "savey" );
msg->LinkEndChild( doc.NewText( help.String(savey).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "savey", savey);
msg = doc.NewElement( "saverx" );
msg->LinkEndChild( doc.NewText( help.String(saverx).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "saverx", saverx);
msg = doc.NewElement( "savery" );
msg->LinkEndChild( doc.NewText( help.String(savery).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "savery", savery);
msg = doc.NewElement( "savegc" );
msg->LinkEndChild( doc.NewText( help.String(savegc).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "savegc", savegc);
msg = doc.NewElement( "savedir" );
msg->LinkEndChild( doc.NewText( help.String(savedir).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "savedir", savedir);
msg = doc.NewElement( "savepoint" );
msg->LinkEndChild( doc.NewText( help.String(savepoint).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "savepoint", savepoint);
msg = doc.NewElement( "trinkets" );
msg->LinkEndChild( doc.NewText( help.String(trinkets()).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "trinkets", trinkets());
//Special stats
if(music.nicefade==1)
{
msg = doc.NewElement( "currentsong" );
msg->LinkEndChild( doc.NewText( help.String(music.nicechange).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "currentsong", music.nicechange);
}
else
{
msg = doc.NewElement( "currentsong" );
msg->LinkEndChild( doc.NewText( help.String(music.currentsong).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "currentsong", music.currentsong);
}
msg = doc.NewElement( "teleportscript" );
msg->LinkEndChild( doc.NewText( teleportscript.c_str() ));
msgs->LinkEndChild( msg );
msg = doc.NewElement( "companion" );
msg->LinkEndChild( doc.NewText( help.String(companion).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "teleportscript", teleportscript.c_str());
xml::update_tag(msgs, "companion", companion);
msg = doc.NewElement( "lastsaved" );
msg->LinkEndChild( doc.NewText( help.String(lastsaved).c_str() ));
msgs->LinkEndChild( msg );
msg = doc.NewElement( "supercrewmate" );
msg->LinkEndChild( doc.NewText( BoolToString(supercrewmate) ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "lastsaved", lastsaved);
xml::update_tag(msgs, "supercrewmate", BoolToString(supercrewmate));
msg = doc.NewElement( "scmprogress" );
msg->LinkEndChild( doc.NewText( help.String(scmprogress).c_str() ));
msgs->LinkEndChild( msg );
msg = doc.NewElement( "scmmoveme" );
msg->LinkEndChild( doc.NewText( BoolToString(scmmoveme) ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "scmprogress", scmprogress);
xml::update_tag(msgs, "scmmoveme", BoolToString(scmmoveme));
msg = doc.NewElement( "frames" );
msg->LinkEndChild( doc.NewText( help.String(frames).c_str() ));
msgs->LinkEndChild( msg );
msg = doc.NewElement( "seconds" );
msg->LinkEndChild( doc.NewText( help.String(seconds).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "frames", frames);
xml::update_tag(msgs, "seconds", seconds);
msg = doc.NewElement( "minutes" );
msg->LinkEndChild( doc.NewText( help.String(minutes).c_str()) );
msgs->LinkEndChild( msg );
msg = doc.NewElement( "hours" );
msg->LinkEndChild( doc.NewText( help.String(hours).c_str()) );
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "minutes", minutes);
xml::update_tag(msgs, "hours", hours);
msg = doc.NewElement( "deathcounts" );
msg->LinkEndChild( doc.NewText( help.String(deathcounts).c_str() ));
msgs->LinkEndChild( msg );
msg = doc.NewElement( "totalflips" );
msg->LinkEndChild( doc.NewText( help.String(totalflips).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "deathcounts", deathcounts);
xml::update_tag(msgs, "totalflips", totalflips);
msg = doc.NewElement( "hardestroom" );
msg->LinkEndChild( doc.NewText( hardestroom.c_str() ));
msgs->LinkEndChild( msg );
msg = doc.NewElement( "hardestroomdeaths" );
msg->LinkEndChild( doc.NewText( help.String(hardestroomdeaths).c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "hardestroom", hardestroom.c_str());
xml::update_tag(msgs, "hardestroomdeaths", hardestroomdeaths);
msg = doc.NewElement( "finalmode" );
msg->LinkEndChild( doc.NewText( BoolToString(map.finalmode)));
msgs->LinkEndChild( msg );
msg = doc.NewElement( "finalstretch" );
msg->LinkEndChild( doc.NewText( BoolToString(map.finalstretch) ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "finalmode", BoolToString(map.finalmode));
xml::update_tag(msgs, "finalstretch", BoolToString(map.finalstretch));
msg = doc.NewElement( "summary" );
std::string summary = savearea + ", " + timestring();
msg->LinkEndChild( doc.NewText( summary.c_str() ));
msgs->LinkEndChild( msg );
xml::update_tag(msgs, "summary", summary.c_str());
return summary;
}