- saved games now go into saved folder

This commit is contained in:
Mark Vejvoda 2012-03-15 22:09:11 +00:00
parent 510ee7dfff
commit 01f8f518b3
3 changed files with 35 additions and 26 deletions

View File

@ -3606,7 +3606,7 @@ string Game::saveGame(string name) {
gameNode->addAttribute("lastMasterServerGameStatsDump",intToStr(lastMasterServerGameStatsDump), mapTagReplacements);
// Save the file now
string saveGameFile = name;
string saveGameFile = "saved/" + name;
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
saveGameFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + saveGameFile;
}

View File

@ -2706,9 +2706,14 @@ int glestMain(int argc, char** argv) {
shutdownFadeSoundMilliseconds = config.getInt("ShutdownFadeSoundMilliseconds",intToStr(shutdownFadeSoundMilliseconds).c_str());
string userData = config.getString("UserData_Root","");
if(userData != "") {
endPathWithSlash(userData);
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
userData = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey);
}
if(userData != "") {
endPathWithSlash(userData);
}
if(userData != "") {
if(isdir(userData.c_str()) == false) {
createDirectoryPaths(userData);
}
@ -2719,6 +2724,12 @@ int glestMain(int argc, char** argv) {
}
setCRCCacheFilePath(crcCachePath);
string savedGamePath = userData + "saved/";
if(isdir(savedGamePath.c_str()) == false) {
createDirectoryPaths(savedGamePath);
//printf("savedGamePath = [%s]\n",savedGamePath.c_str());
}
string tempDataPath = userData + "temp/";
if(isdir(tempDataPath.c_str()) == true) {
removeFolder(tempDataPath);

View File

@ -267,6 +267,7 @@ XmlNode *XmlIoRapid::load(const string &path, std::map<string,string> mapTagRepl
Chrono chrono;
chrono.start();
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using RapidXml to load file [%s]\n",path.c_str());
//printf("Using RapidXml to load file [%s]\n",path.c_str());
XmlNode *rootNode = NULL;
try {
@ -280,29 +281,25 @@ XmlNode *XmlIoRapid::load(const string &path, std::map<string,string> mapTagRepl
throw runtime_error("Can not open file: [" + path + "]");
}
// read file into input_xml
string inputXml = "";
const int bufsize = 32 * 1024;
char buff[bufsize]="";
while(xmlFile) {
xmlFile.read(buff,bufsize);
if(buff[0] != '\0') {
inputXml += buff;
}
}
xmlFile.unsetf(ios::skipws);
// make a safe-to-modify copy of input_xml
// (you should never modify the contents of an std::string directly)
vector<char> buffer(inputXml.begin(), inputXml.end());
buffer.push_back('\0');
// Determine stream size
xmlFile.seekg(0, ios::end);
size_t size = xmlFile.tellg();
xmlFile.seekg(0);
/* "Read file into vector<char>" See linked thread above*/
//vector<char> buffer((istreambuf_iterator<char>(xmlFile)), istreambuf_iterator<char>( ));
//buffer.push_back('\0');
doc->parse<parse_no_data_nodes>(&buffer[0]);
// Load data and add terminating 0
vector<char> buffer;
buffer.resize(size + 1);
xmlFile.read(&buffer.front(), static_cast<streamsize>(size));
buffer[size] = 0;
//doc->parse<parse_no_utf8 | parse_validate_closing_tags>(&buffer[0]);
//doc->parse<parse_full>(&buffer.front());
//doc->parse<parse_declaration_node | parse_doctype_node | parse_pi_nodes | parse_validate_closing_tags>(&buffer[0]);
doc->parse<parse_no_data_nodes>(&buffer.front());
rootNode= new XmlNode(doc->first_node(),mapTagReplacementValues);
//parser->release();
#if defined(WIN32) && !defined(__MINGW32__)
if(fp) {
@ -310,15 +307,16 @@ XmlNode *XmlIoRapid::load(const string &path, std::map<string,string> mapTagRepl
}
#endif
}
catch(const DOMException &ex) {
catch(const exception &ex) {
char szBuf[8096]="";
sprintf(szBuf,"In [%s::%s Line: %d] Exception while loading: [%s], msg:\n%s",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(ex.msg));
sprintf(szBuf,"In [%s::%s Line: %d] Exception while loading: [%s], msg:\n%s",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,"%s\n",szBuf);
throw runtime_error(szBuf);
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] took msecs: %ld\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] took msecs: %ld for file [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis(),path.c_str());
printf("In [%s::%s Line: %d] took msecs: %ld for file [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis(),path.c_str());
return rootNode;
}
@ -371,7 +369,7 @@ void XmlIoRapid::save(const string &path, const XmlNode *node){
}
//xmlFile << xml_no_indent;
// xmlFile << xml_as_string << '\0';
// xmlFile << xml_as_string;
xmlFile << doc;
#if defined(WIN32) && !defined(__MINGW32__)