XmlNodeRef CCheckpointSystem::ReadXML(const char *fileName) { IPlayerProfileManager *pPlayerProfMan = CCryAction::GetCryAction()->GetIPlayerProfileManager();; string path; if(!pPlayerProfMan) { //on consoles there is no profile manager path = CONSOLE_SAVEGAME_DIRECTORY; } else { const char* sharedSaveGameFolder = pPlayerProfMan->GetSharedSaveGameFolder(); path = sharedSaveGameFolder; } path = PathUtil::AddSlash(path); path.append(fileName); //read XML data from given checkpoint file _smart_ptr<IXmlParser> xmlParser; xmlParser.reset(GetISystem()->GetXmlUtils()->CreateXmlParser()); XmlNodeRef data = xmlParser->ParseFile(path.c_str(), true); if(!data) CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "Failed reading checkpoint at %s", path.c_str()); return data; }
void CCheckpointSystem::WriteXML(XmlNodeRef data, const char *fileName) { IPlayerProfileManager *pPlayerProfMan = CCryAction::GetCryAction()->GetIPlayerProfileManager();; string path; if(!pPlayerProfMan) { path = CONSOLE_SAVEGAME_DIRECTORY; } else { const char* sharedSaveGameFolder = pPlayerProfMan->GetSharedSaveGameFolder(); path = sharedSaveGameFolder; } path = PathUtil::AddSlash(path); path.append(fileName); if(data) { //write checkpoint data to xml file with given name const string xmlHeader("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); bool bSuccess = data->saveToFile(path.c_str(), 32767/2, NULL); if (bSuccess) { //remember last saved checkpoint for "quickload" g_lastSavedCheckpoint = fileName; } else CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "Failed writing checkpoint file at %s", path.c_str()); } }