mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 14:11:15 +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:
@@ -214,6 +214,8 @@ void updatePathClimbingParts(string &path);
|
||||
string formatPath(string path);
|
||||
|
||||
string replaceAll(string& context, const string& from, const string& to);
|
||||
vector<char> replaceAllBetweenTokens(vector<char>& context, const string startToken, const string endToken, const string newText, bool removeTokens=true);
|
||||
string replaceAllBetweenTokens(string& context, const string startToken, const string endToken, const string newText, bool removeTokens=true);
|
||||
bool removeFile(string file);
|
||||
bool renameFile(string oldFile, string newFile);
|
||||
void removeFolder(const string path);
|
||||
|
@@ -27,6 +27,7 @@ const char *GAME_ARGS[] = {
|
||||
|
||||
"--autostart-lastgame",
|
||||
"--load-saved-game",
|
||||
"--auto-test",
|
||||
"--connecthost",
|
||||
"--starthost",
|
||||
"--headless-server-mode",
|
||||
@@ -79,6 +80,7 @@ enum GAME_ARG_TYPE {
|
||||
|
||||
GAME_ARG_AUTOSTART_LASTGAME,
|
||||
GAME_ARG_AUTOSTART_LAST_SAVED_GAME,
|
||||
GAME_ARG_AUTO_TEST,
|
||||
GAME_ARG_CLIENT,
|
||||
GAME_ARG_SERVER,
|
||||
GAME_ARG_MASTERSERVER_MODE,
|
||||
@@ -147,6 +149,14 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
|
||||
printf("\n \t\tWhere x is an optional name of the saved game file to load.");
|
||||
printf("\n \t\tIf x is not specified we load the last game that was saved.");
|
||||
|
||||
printf("\n%s=x,y,z\t\t\tRun in auto test mode.",GAME_ARGS[GAME_ARG_AUTO_TEST]);
|
||||
printf("\n \t\tWhere x is an optional maximum # seconds to play.");
|
||||
printf("\n \t\tIf x is not specified the default is 1200 seconds (20 minutes).");
|
||||
printf("\n \t\tWhere y is an optional game settings file to play.");
|
||||
printf("\n \t\tIf y is not specified (or is empty) then auto test cycles through playing scenarios.");
|
||||
printf("\n \t\tWhere z is the word exit indicating the game should exit after the game is finished or the time runs out.");
|
||||
printf("\n \t\tIf z is not specified (or is empty) then auto test continues to cycle.");
|
||||
|
||||
printf("\n%s=x\t\t\tAuto connect to host server at IP or hostname x",GAME_ARGS[GAME_ARG_CLIENT]);
|
||||
printf("\n%s\t\t\tAuto create a host server.",GAME_ARGS[GAME_ARG_SERVER]);
|
||||
|
||||
|
@@ -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