mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 06:01:17 +02:00
- fixed xml loading via rapidxml for some scenarios that had embeddex xml comments in lua
- added automation abilities for automated testing with automated saved games
This commit is contained in:
@@ -1743,6 +1743,48 @@ string replaceAll(string& context, const string& from, const string& to) {
|
||||
return context;
|
||||
}
|
||||
|
||||
vector<char> replaceAllBetweenTokens(vector<char>& context,
|
||||
const string startToken, const string endToken, const string newText,
|
||||
bool removeTokens) {
|
||||
string newValue(context.begin(),context.end());
|
||||
replaceAllBetweenTokens(newValue,startToken,endToken,newText,removeTokens);
|
||||
context = vector<char>(newValue.begin(),newValue.end());
|
||||
return context;
|
||||
}
|
||||
|
||||
string replaceAllBetweenTokens(string& context, const string startToken,
|
||||
const string endToken, const string newText, bool removeTokens) {
|
||||
size_t lookHere = 0;
|
||||
size_t foundHere = 0;
|
||||
size_t foundHereEnd = 0;
|
||||
if((foundHere = context.find(startToken, lookHere)) != string::npos) {
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Replacing context [%s] from [%s] to [%s]\n",context.c_str(),from.c_str(),to.c_str());
|
||||
|
||||
while((foundHere = context.find(startToken, lookHere)) != string::npos) {
|
||||
size_t foundHereEnd = context.find(endToken, foundHere+1);
|
||||
if(foundHereEnd == string::npos) {
|
||||
break;
|
||||
}
|
||||
if(removeTokens == true) {
|
||||
foundHereEnd += endToken.size();
|
||||
|
||||
context.replace(foundHere, foundHereEnd-foundHere+1, newText);
|
||||
lookHere = foundHere + newText.size();
|
||||
}
|
||||
else {
|
||||
foundHere += startToken.size();
|
||||
foundHereEnd -= 1;
|
||||
|
||||
context.replace(foundHere, foundHereEnd-foundHere+1, newText);
|
||||
lookHere = foundHere + newText.size();
|
||||
}
|
||||
}
|
||||
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("New context [%s]\n",context.c_str());
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
string getFullFileArchiveExtractCommand(string fileArchiveExtractCommand,
|
||||
string fileArchiveExtractCommandParameters, string outputpath, string archivename) {
|
||||
string parsedOutputpath = outputpath;
|
||||
|
@@ -294,9 +294,9 @@ XmlNode *XmlIoRapid::load(const string &path, std::map<string,string> mapTagRepl
|
||||
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]);
|
||||
// This is required because rapidxml seems to choke when we load lua
|
||||
// scenarios that have lua + xml style comments
|
||||
replaceAllBetweenTokens(buffer, "<!--","-->", "", true);
|
||||
doc->parse<parse_no_data_nodes>(&buffer.front());
|
||||
|
||||
rootNode= new XmlNode(doc->first_node(),mapTagReplacementValues);
|
||||
@@ -518,7 +518,7 @@ XmlNode::XmlNode(xml_node<> *node, std::map<string,string> mapTagReplacementValu
|
||||
name="document";
|
||||
}
|
||||
|
||||
//printf("Found XML Node [%s]\n",name.c_str());
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Found XML Node\nName [%s]\nValue [%s]\n",name.c_str(),node->value());
|
||||
|
||||
//check children
|
||||
for(xml_node<> *currentNode = node->first_node();
|
||||
|
Reference in New Issue
Block a user