- saved games now go into saved folder
This commit is contained in:
parent
510ee7dfff
commit
01f8f518b3
|
@ -3606,7 +3606,7 @@ string Game::saveGame(string name) {
|
||||||
gameNode->addAttribute("lastMasterServerGameStatsDump",intToStr(lastMasterServerGameStatsDump), mapTagReplacements);
|
gameNode->addAttribute("lastMasterServerGameStatsDump",intToStr(lastMasterServerGameStatsDump), mapTagReplacements);
|
||||||
|
|
||||||
// Save the file now
|
// Save the file now
|
||||||
string saveGameFile = name;
|
string saveGameFile = "saved/" + name;
|
||||||
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
|
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
|
||||||
saveGameFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + saveGameFile;
|
saveGameFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + saveGameFile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2706,9 +2706,14 @@ int glestMain(int argc, char** argv) {
|
||||||
shutdownFadeSoundMilliseconds = config.getInt("ShutdownFadeSoundMilliseconds",intToStr(shutdownFadeSoundMilliseconds).c_str());
|
shutdownFadeSoundMilliseconds = config.getInt("ShutdownFadeSoundMilliseconds",intToStr(shutdownFadeSoundMilliseconds).c_str());
|
||||||
|
|
||||||
string userData = config.getString("UserData_Root","");
|
string userData = config.getString("UserData_Root","");
|
||||||
if(userData != "") {
|
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
|
||||||
endPathWithSlash(userData);
|
userData = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey);
|
||||||
|
}
|
||||||
|
if(userData != "") {
|
||||||
|
endPathWithSlash(userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(userData != "") {
|
||||||
if(isdir(userData.c_str()) == false) {
|
if(isdir(userData.c_str()) == false) {
|
||||||
createDirectoryPaths(userData);
|
createDirectoryPaths(userData);
|
||||||
}
|
}
|
||||||
|
@ -2719,6 +2724,12 @@ int glestMain(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
setCRCCacheFilePath(crcCachePath);
|
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/";
|
string tempDataPath = userData + "temp/";
|
||||||
if(isdir(tempDataPath.c_str()) == true) {
|
if(isdir(tempDataPath.c_str()) == true) {
|
||||||
removeFolder(tempDataPath);
|
removeFolder(tempDataPath);
|
||||||
|
|
|
@ -267,6 +267,7 @@ XmlNode *XmlIoRapid::load(const string &path, std::map<string,string> mapTagRepl
|
||||||
Chrono chrono;
|
Chrono chrono;
|
||||||
chrono.start();
|
chrono.start();
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using RapidXml to load file [%s]\n",path.c_str());
|
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;
|
XmlNode *rootNode = NULL;
|
||||||
try {
|
try {
|
||||||
|
@ -280,29 +281,25 @@ XmlNode *XmlIoRapid::load(const string &path, std::map<string,string> mapTagRepl
|
||||||
throw runtime_error("Can not open file: [" + path + "]");
|
throw runtime_error("Can not open file: [" + path + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
// read file into input_xml
|
xmlFile.unsetf(ios::skipws);
|
||||||
string inputXml = "";
|
|
||||||
const int bufsize = 32 * 1024;
|
|
||||||
char buff[bufsize]="";
|
|
||||||
while(xmlFile) {
|
|
||||||
xmlFile.read(buff,bufsize);
|
|
||||||
if(buff[0] != '\0') {
|
|
||||||
inputXml += buff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// make a safe-to-modify copy of input_xml
|
// Determine stream size
|
||||||
// (you should never modify the contents of an std::string directly)
|
xmlFile.seekg(0, ios::end);
|
||||||
vector<char> buffer(inputXml.begin(), inputXml.end());
|
size_t size = xmlFile.tellg();
|
||||||
buffer.push_back('\0');
|
xmlFile.seekg(0);
|
||||||
|
|
||||||
/* "Read file into vector<char>" See linked thread above*/
|
// Load data and add terminating 0
|
||||||
//vector<char> buffer((istreambuf_iterator<char>(xmlFile)), istreambuf_iterator<char>( ));
|
vector<char> buffer;
|
||||||
//buffer.push_back('\0');
|
buffer.resize(size + 1);
|
||||||
doc->parse<parse_no_data_nodes>(&buffer[0]);
|
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);
|
rootNode= new XmlNode(doc->first_node(),mapTagReplacementValues);
|
||||||
//parser->release();
|
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(__MINGW32__)
|
#if defined(WIN32) && !defined(__MINGW32__)
|
||||||
if(fp) {
|
if(fp) {
|
||||||
|
@ -310,15 +307,16 @@ XmlNode *XmlIoRapid::load(const string &path, std::map<string,string> mapTagRepl
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch(const DOMException &ex) {
|
catch(const exception &ex) {
|
||||||
char szBuf[8096]="";
|
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);
|
SystemFlags::OutputDebug(SystemFlags::debugError,"%s\n",szBuf);
|
||||||
|
|
||||||
throw runtime_error(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;
|
return rootNode;
|
||||||
}
|
}
|
||||||
|
@ -371,7 +369,7 @@ void XmlIoRapid::save(const string &path, const XmlNode *node){
|
||||||
}
|
}
|
||||||
|
|
||||||
//xmlFile << xml_no_indent;
|
//xmlFile << xml_no_indent;
|
||||||
// xmlFile << xml_as_string << '\0';
|
// xmlFile << xml_as_string;
|
||||||
xmlFile << doc;
|
xmlFile << doc;
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(__MINGW32__)
|
#if defined(WIN32) && !defined(__MINGW32__)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user