1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-28 15:38:30 +02:00

Convert Game::Game() to TinyXML2

This commit is contained in:
Misa 2020-06-03 19:29:44 -07:00 committed by Ethan Lee
parent 45e864315e
commit 142241fd74

View File

@ -280,28 +280,28 @@ void Game::init(void)
saveFilePath = FILESYSTEM_getUserSaveDirectory(); saveFilePath = FILESYSTEM_getUserSaveDirectory();
TiXmlDocument doc; tinyxml2::XMLDocument doc;
if (!FILESYSTEM_loadTiXmlDocument("saves/qsave.vvv", &doc)) if (!FILESYSTEM_loadTiXml2Document("saves/qsave.vvv", doc))
{ {
quicksummary = ""; quicksummary = "";
printf("Quick Save Not Found\n"); printf("Quick Save Not Found\n");
} }
else else
{ {
TiXmlHandle hDoc(&doc); tinyxml2::XMLHandle hDoc(&doc);
TiXmlElement* pElem; tinyxml2::XMLElement* pElem;
TiXmlHandle hRoot(0); tinyxml2::XMLHandle hRoot(NULL);
pElem=hDoc.FirstChildElement().Element(); pElem=hDoc.FirstChildElement().ToElement();
if (!pElem) if (!pElem)
{ {
printf("Quick Save Appears Corrupted: No XML Root\n"); printf("Quick Save Appears Corrupted: No XML Root\n");
} }
// save this for later // save this for later
hRoot=TiXmlHandle(pElem); hRoot=tinyxml2::XMLHandle(pElem);
for( pElem = hRoot.FirstChild( "Data" ).FirstChild().Element(); pElem; pElem=pElem->NextSiblingElement()) for( pElem = hRoot.FirstChildElement( "Data" ).FirstChild().ToElement(); pElem; pElem=pElem->NextSiblingElement())
{ {
std::string pKey(pElem->Value()); std::string pKey(pElem->Value());
const char* pText = pElem->GetText() ; const char* pText = pElem->GetText() ;
@ -316,21 +316,21 @@ void Game::init(void)
} }
TiXmlDocument docTele; tinyxml2::XMLDocument docTele;
if (!FILESYSTEM_loadTiXmlDocument("saves/tsave.vvv", &docTele)) if (!FILESYSTEM_loadTiXml2Document("saves/tsave.vvv", docTele))
{ {
telesummary = ""; telesummary = "";
printf("Teleporter Save Not Found\n"); printf("Teleporter Save Not Found\n");
} }
else else
{ {
TiXmlHandle hDoc(&docTele); tinyxml2::XMLHandle hDoc(&docTele);
TiXmlElement* pElem; tinyxml2::XMLElement* pElem;
TiXmlHandle hRoot(0); tinyxml2::XMLHandle hRoot(NULL);
{ {
pElem=hDoc.FirstChildElement().Element(); pElem=hDoc.FirstChildElement().ToElement();
// should always have a valid root but handle gracefully if it does // should always have a valid root but handle gracefully if it does
if (!pElem) if (!pElem)
{ {
@ -338,10 +338,10 @@ void Game::init(void)
} }
// save this for later // save this for later
hRoot=TiXmlHandle(pElem); hRoot=tinyxml2::XMLHandle(pElem);
} }
for( pElem = hRoot.FirstChild( "Data" ).FirstChild().Element(); pElem; pElem=pElem->NextSiblingElement()) for( pElem = hRoot.FirstChildElement( "Data" ).FirstChild().ToElement(); pElem; pElem=pElem->NextSiblingElement())
{ {
std::string pKey(pElem->Value()); std::string pKey(pElem->Value());
const char* pText = pElem->GetText() ; const char* pText = pElem->GetText() ;