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

Convert Game::savetele() to TinyXML2

I just had to find-and-replace all `new TiXmlDocument` to
`doc.NewDocument` and `new TiXmlText` to `doc.NewText`, along some other
stuff.
This commit is contained in:
Misa 2020-06-03 11:39:33 -07:00 committed by Ethan Lee
parent 9348bf5b24
commit 6706197741

View file

@ -5636,19 +5636,18 @@ void Game::savetele()
return; return;
} }
TiXmlDocument doc; tinyxml2::XMLDocument doc;
TiXmlElement* msg; tinyxml2::XMLElement* msg;
TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" ); tinyxml2::XMLDeclaration* decl = doc.NewDeclaration();
doc.LinkEndChild( decl ); doc.LinkEndChild( decl );
TiXmlElement * root = new TiXmlElement( "Save" ); tinyxml2::XMLElement * root = doc.NewElement( "Save" );
doc.LinkEndChild( root ); doc.LinkEndChild( root );
TiXmlComment * comment = new TiXmlComment(); tinyxml2::XMLComment * comment = doc.NewComment(" Save file " );
comment->SetValue(" Save file " );
root->LinkEndChild( comment ); root->LinkEndChild( comment );
TiXmlElement * msgs = new TiXmlElement( "Data" ); tinyxml2::XMLElement * msgs = doc.NewElement( "Data" );
root->LinkEndChild( msgs ); root->LinkEndChild( msgs );
@ -5659,8 +5658,8 @@ void Game::savetele()
{ {
mapExplored += help.String(map.explored[i]) + ","; mapExplored += help.String(map.explored[i]) + ",";
} }
msg = new TiXmlElement( "worldmap" ); msg = doc.NewElement( "worldmap" );
msg->LinkEndChild( new TiXmlText( mapExplored.c_str() )); msg->LinkEndChild( doc.NewText( mapExplored.c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
std::string flags; std::string flags;
@ -5668,8 +5667,8 @@ void Game::savetele()
{ {
flags += help.String((int) obj.flags[i]) + ","; flags += help.String((int) obj.flags[i]) + ",";
} }
msg = new TiXmlElement( "flags" ); msg = doc.NewElement( "flags" );
msg->LinkEndChild( new TiXmlText( flags.c_str() )); msg->LinkEndChild( doc.NewText( flags.c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
std::string crewstatsString; std::string crewstatsString;
@ -5677,8 +5676,8 @@ void Game::savetele()
{ {
crewstatsString += help.String(crewstats[i]) + ","; crewstatsString += help.String(crewstats[i]) + ",";
} }
msg = new TiXmlElement( "crewstats" ); msg = doc.NewElement( "crewstats" );
msg->LinkEndChild( new TiXmlText( crewstatsString.c_str() )); msg->LinkEndChild( doc.NewText( crewstatsString.c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
std::string collect; std::string collect;
@ -5686,50 +5685,50 @@ void Game::savetele()
{ {
collect += help.String((int) obj.collect[i]) + ","; collect += help.String((int) obj.collect[i]) + ",";
} }
msg = new TiXmlElement( "collect" ); msg = doc.NewElement( "collect" );
msg->LinkEndChild( new TiXmlText( collect.c_str() )); msg->LinkEndChild( doc.NewText( collect.c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
//Position //Position
msg = new TiXmlElement( "finalx" ); msg = doc.NewElement( "finalx" );
msg->LinkEndChild( new TiXmlText( help.String(map.finalx).c_str() )); msg->LinkEndChild( doc.NewText( help.String(map.finalx).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "finaly" ); msg = doc.NewElement( "finaly" );
msg->LinkEndChild( new TiXmlText( help.String(map.finaly).c_str() )); msg->LinkEndChild( doc.NewText( help.String(map.finaly).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "savex" ); msg = doc.NewElement( "savex" );
msg->LinkEndChild( new TiXmlText( help.String(savex).c_str() )); msg->LinkEndChild( doc.NewText( help.String(savex).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "savey" ); msg = doc.NewElement( "savey" );
msg->LinkEndChild( new TiXmlText( help.String(savey).c_str() )); msg->LinkEndChild( doc.NewText( help.String(savey).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "saverx" ); msg = doc.NewElement( "saverx" );
msg->LinkEndChild( new TiXmlText( help.String(saverx).c_str() )); msg->LinkEndChild( doc.NewText( help.String(saverx).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "savery" ); msg = doc.NewElement( "savery" );
msg->LinkEndChild( new TiXmlText( help.String(savery).c_str() )); msg->LinkEndChild( doc.NewText( help.String(savery).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "savegc" ); msg = doc.NewElement( "savegc" );
msg->LinkEndChild( new TiXmlText( help.String(savegc).c_str() )); msg->LinkEndChild( doc.NewText( help.String(savegc).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "savedir" ); msg = doc.NewElement( "savedir" );
msg->LinkEndChild( new TiXmlText( help.String(savedir).c_str() )); msg->LinkEndChild( doc.NewText( help.String(savedir).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "savepoint" ); msg = doc.NewElement( "savepoint" );
msg->LinkEndChild( new TiXmlText( help.String(savepoint).c_str() )); msg->LinkEndChild( doc.NewText( help.String(savepoint).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "trinkets" ); msg = doc.NewElement( "trinkets" );
msg->LinkEndChild( new TiXmlText( help.String(trinkets()).c_str() )); msg->LinkEndChild( doc.NewText( help.String(trinkets()).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
@ -5737,83 +5736,83 @@ void Game::savetele()
if(music.nicefade==1) if(music.nicefade==1)
{ {
msg = new TiXmlElement( "currentsong" ); msg = doc.NewElement( "currentsong" );
msg->LinkEndChild( new TiXmlText( help.String(music.nicechange).c_str() )); msg->LinkEndChild( doc.NewText( help.String(music.nicechange).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
} }
else else
{ {
msg = new TiXmlElement( "currentsong" ); msg = doc.NewElement( "currentsong" );
msg->LinkEndChild( new TiXmlText( help.String(music.currentsong).c_str() )); msg->LinkEndChild( doc.NewText( help.String(music.currentsong).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
} }
msg = new TiXmlElement( "teleportscript" ); msg = doc.NewElement( "teleportscript" );
msg->LinkEndChild( new TiXmlText( teleportscript.c_str() )); msg->LinkEndChild( doc.NewText( teleportscript.c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "companion" ); msg = doc.NewElement( "companion" );
msg->LinkEndChild( new TiXmlText( help.String(companion).c_str() )); msg->LinkEndChild( doc.NewText( help.String(companion).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "lastsaved" ); msg = doc.NewElement( "lastsaved" );
msg->LinkEndChild( new TiXmlText( help.String(lastsaved).c_str() )); msg->LinkEndChild( doc.NewText( help.String(lastsaved).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "supercrewmate" ); msg = doc.NewElement( "supercrewmate" );
msg->LinkEndChild( new TiXmlText( BoolToString(supercrewmate) )); msg->LinkEndChild( doc.NewText( BoolToString(supercrewmate) ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "scmprogress" ); msg = doc.NewElement( "scmprogress" );
msg->LinkEndChild( new TiXmlText( help.String(scmprogress).c_str() )); msg->LinkEndChild( doc.NewText( help.String(scmprogress).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "scmmoveme" ); msg = doc.NewElement( "scmmoveme" );
msg->LinkEndChild( new TiXmlText( BoolToString(scmmoveme) )); msg->LinkEndChild( doc.NewText( BoolToString(scmmoveme) ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "frames" ); msg = doc.NewElement( "frames" );
msg->LinkEndChild( new TiXmlText( help.String(frames).c_str() )); msg->LinkEndChild( doc.NewText( help.String(frames).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "seconds" ); msg = doc.NewElement( "seconds" );
msg->LinkEndChild( new TiXmlText( help.String(seconds).c_str() )); msg->LinkEndChild( doc.NewText( help.String(seconds).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "minutes" ); msg = doc.NewElement( "minutes" );
msg->LinkEndChild( new TiXmlText( help.String(minutes).c_str()) ); msg->LinkEndChild( doc.NewText( help.String(minutes).c_str()) );
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "hours" ); msg = doc.NewElement( "hours" );
msg->LinkEndChild( new TiXmlText( help.String(hours).c_str()) ); msg->LinkEndChild( doc.NewText( help.String(hours).c_str()) );
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "deathcounts" ); msg = doc.NewElement( "deathcounts" );
msg->LinkEndChild( new TiXmlText( help.String(deathcounts).c_str() )); msg->LinkEndChild( doc.NewText( help.String(deathcounts).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "totalflips" ); msg = doc.NewElement( "totalflips" );
msg->LinkEndChild( new TiXmlText( help.String(totalflips).c_str() )); msg->LinkEndChild( doc.NewText( help.String(totalflips).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "hardestroom" ); msg = doc.NewElement( "hardestroom" );
msg->LinkEndChild( new TiXmlText( hardestroom.c_str() )); msg->LinkEndChild( doc.NewText( hardestroom.c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "hardestroomdeaths" ); msg = doc.NewElement( "hardestroomdeaths" );
msg->LinkEndChild( new TiXmlText( help.String(hardestroomdeaths).c_str() )); msg->LinkEndChild( doc.NewText( help.String(hardestroomdeaths).c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "finalmode" ); msg = doc.NewElement( "finalmode" );
msg->LinkEndChild( new TiXmlText( BoolToString(map.finalmode))); msg->LinkEndChild( doc.NewText( BoolToString(map.finalmode)));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "finalstretch" ); msg = doc.NewElement( "finalstretch" );
msg->LinkEndChild( new TiXmlText( BoolToString(map.finalstretch) )); msg->LinkEndChild( doc.NewText( BoolToString(map.finalstretch) ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
msg = new TiXmlElement( "summary" ); msg = doc.NewElement( "summary" );
std::string summary = savearea + ", " + timestring(); std::string summary = savearea + ", " + timestring();
msg->LinkEndChild( new TiXmlText( summary.c_str() )); msg->LinkEndChild( doc.NewText( summary.c_str() ));
msgs->LinkEndChild( msg ); msgs->LinkEndChild( msg );
telesummary = summary; telesummary = summary;
if(FILESYSTEM_saveTiXmlDocument("saves/tsave.vvv", &doc)) if(FILESYSTEM_saveTiXml2Document("saves/tsave.vvv", doc))
{ {
printf("Game saved\n"); printf("Game saved\n");
} }