From 1ac9aa6d3f1b10e67faba07ae794845cf0aa0fd7 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 17 Mar 2012 08:20:17 +0000 Subject: [PATCH] - 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 --- source/glest_game/facilities/auto_test.cpp | 53 ++++++++++++++----- source/glest_game/facilities/auto_test.h | 21 ++++++-- source/glest_game/game/game.cpp | 18 ++++++- source/glest_game/game/game_constants.h | 1 + source/glest_game/global/config.cpp | 1 + source/glest_game/global/core_data.cpp | 13 +++-- source/glest_game/global/core_data.h | 2 +- source/glest_game/main/battle_end.cpp | 1 + source/glest_game/main/intro.cpp | 1 + source/glest_game/main/main.cpp | 51 ++++++++++++++++-- .../glest_game/menu/menu_state_load_game.cpp | 1 + .../glest_game/menu/menu_state_new_game.cpp | 1 + source/glest_game/menu/menu_state_root.cpp | 12 +++-- .../glest_game/menu/menu_state_scenario.cpp | 1 + .../include/platform/common/platform_common.h | 2 + .../include/platform/sdl/platform_main.h | 10 ++++ .../platform/common/platform_common.cpp | 42 +++++++++++++++ source/shared_lib/sources/xml/xml_parser.cpp | 8 +-- 18 files changed, 204 insertions(+), 35 deletions(-) diff --git a/source/glest_game/facilities/auto_test.cpp b/source/glest_game/facilities/auto_test.cpp index 2cc10d3b..ea6f3a0f 100644 --- a/source/glest_game/facilities/auto_test.cpp +++ b/source/glest_game/facilities/auto_test.cpp @@ -15,7 +15,9 @@ #include "main_menu.h" #include "menu_state_new_game.h" #include "menu_state_scenario.h" +#include "menu_state_custom_game.h" #include "game.h" +#include "core_data.h" #include "config.h" #include "leak_dumper.h" @@ -28,33 +30,52 @@ namespace Glest{ namespace Game{ // ===================================================== const time_t AutoTest::invalidTime = -1; -const time_t AutoTest::gameTime = 60*20; +time_t AutoTest::gameTime = 60 * 20; +bool AutoTest::wantExitGame = false; + +GameSettings AutoTest::gameSettings; +string AutoTest::loadGameSettingsFile = ""; // ===================== PUBLIC ======================== -AutoTest::AutoTest(){ +AutoTest::AutoTest() { + exitGame = false; gameStartTime = invalidTime; random.init(time(NULL)); } -AutoTest & AutoTest::getInstance(){ +AutoTest & AutoTest::getInstance() { static AutoTest autoTest; return autoTest; } -void AutoTest::updateIntro(Program *program){ +void AutoTest::updateIntro(Program *program) { program->setState(new MainMenu(program)); } -void AutoTest::updateRoot(Program *program, MainMenu *mainMenu){ +void AutoTest::updateRoot(Program *program, MainMenu *mainMenu) { mainMenu->setState(new MenuStateNewGame(program, mainMenu)); } -void AutoTest::updateNewGame(Program *program, MainMenu *mainMenu){ - mainMenu->setState(new MenuStateScenario(program, mainMenu, Config::getInstance().getPathListForType(ptScenarios))); +void AutoTest::updateNewGame(Program *program, MainMenu *mainMenu) { + if(loadGameSettingsFile != "") { + gameStartTime = invalidTime; + bool fileFound = CoreData::getInstance().loadGameSettingsFromFile( + loadGameSettingsFile, &gameSettings); + + if(fileFound == false) { + throw runtime_error("Specified game settings file [" + loadGameSettingsFile + "] was NOT found!"); + } + //printf("Got settings:\n%s",gameSettings.toString().c_str()); + mainMenu->setState(new MenuStateCustomGame(program, mainMenu, false, pNewGame, true, &gameSettings)); + } + else { + mainMenu->setState(new MenuStateScenario(program, mainMenu, + Config::getInstance().getPathListForType(ptScenarios))); + } } -void AutoTest::updateScenario(MenuStateScenario *menuStateScenario){ +void AutoTest::updateScenario(MenuStateScenario *menuStateScenario) { gameStartTime = invalidTime; int scenarioIndex = random.randRange(0, menuStateScenario->getScenarioCount()-1); @@ -63,23 +84,27 @@ void AutoTest::updateScenario(MenuStateScenario *menuStateScenario){ menuStateScenario->launchGame(); } -void AutoTest::updateGame(Game *game){ - +bool AutoTest::updateGame(Game *game) { // record start time - if(gameStartTime==invalidTime) - { + if(gameStartTime == invalidTime) { gameStartTime = time(NULL); } // quit if we've espend enough time in the game - if(time(NULL)-gameStartTime>gameTime){ + if(difftime(time(NULL),gameStartTime) > gameTime) { Program *program = game->getProgram(); Stats endStats = game->quitGame(); + if(AutoTest::wantExitGame == true) { + exitGame = true; + } Game::exitGameState(program, endStats); + return true; } + + return false; } -void AutoTest::updateBattleEnd(Program *program){ +void AutoTest::updateBattleEnd(Program *program) { program->setState(new MainMenu(program)); } diff --git a/source/glest_game/facilities/auto_test.h b/source/glest_game/facilities/auto_test.h index 85e7e38c..4cbff4e9 100644 --- a/source/glest_game/facilities/auto_test.h +++ b/source/glest_game/facilities/auto_test.h @@ -13,10 +13,12 @@ #define _SHARED_UTIL_AUTO_TEST_H_ #include - #include "randomgen.h" +#include +#include "game_settings.h" #include "leak_dumper.h" +using namespace std; using Shared::Util::RandomGen; namespace Glest{ namespace Game{ @@ -36,20 +38,31 @@ class AutoTest{ private: int gameStartTime; RandomGen random; + bool exitGame; + static bool wantExitGame; + + static GameSettings gameSettings; + static string loadGameSettingsFile; -private: static const time_t invalidTime; - static const time_t gameTime; + static time_t gameTime; public: static AutoTest & getInstance(); AutoTest(); + static void setMaxGameTime(time_t value) { gameTime = value; } + static void setWantExitGameWhenDone(bool value) { wantExitGame = value; } + static string getLoadGameSettingsFile() { return loadGameSettingsFile; } + static void setLoadGameSettingsFile(string filename) { loadGameSettingsFile = filename; } + + bool mustExitGame() const { return exitGame; } + void updateIntro(Program *program); void updateRoot(Program *program, MainMenu *mainMenu); void updateNewGame(Program *program, MainMenu *mainMenu); void updateScenario(MenuStateScenario *menuStateScenario); - void updateGame(Game *game); + bool updateGame(Game *game); void updateBattleEnd(Program *program); }; diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index fb2de028..df858e61 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -1274,6 +1274,7 @@ void Game::update() { //update auto test if(Config::getInstance().getBool("AutoTest")){ AutoTest::getInstance().updateGame(this); + return; } if(world.getQueuedScenario() != "") { @@ -2651,7 +2652,9 @@ Stats Game::quitGame() { } //printf("Check savegame\n"); //printf("Saving...\n"); - this->saveGame(GameConstants::saveGameFileDefault); + if(Config::getInstance().getBool("AutoTest")){ + this->saveGame(GameConstants::saveGameFileAutoTestDefault); + } //Stats stats = *(world.getStats()); Stats endStats; @@ -2689,7 +2692,8 @@ void Game::exitGameState(Program *program, Stats &endStats) { game->endGame(); } - if(game->isMasterserverMode() == true) { + if(game->isMasterserverMode() == true || + Config::getInstance().getBool("AutoTest") == true) { printf("Game ending with stats:\n"); printf("-----------------------\n"); @@ -3464,6 +3468,16 @@ string Game::saveGame(string name) { sprintf(szBuf,name.c_str(),szBuf2); name = szBuf; } + else if(name == GameConstants::saveGameFileAutoTestDefault) { + time_t curTime = time(NULL); + struct tm *loctime = localtime (&curTime); + char szBuf2[100]=""; + strftime(szBuf2,100,"%Y%m%d_%H%M%S",loctime); + + char szBuf[8096]=""; + sprintf(szBuf,name.c_str(),szBuf2); + name = szBuf; + } //XmlTree xmlTree(XML_XERCES_ENGINE); XmlTree xmlTree; xmlTree.init("megaglest-saved-game"); diff --git a/source/glest_game/game/game_constants.h b/source/glest_game/game/game_constants.h index 8660d688..4f2d26ca 100644 --- a/source/glest_game/game/game_constants.h +++ b/source/glest_game/game/game_constants.h @@ -126,6 +126,7 @@ public: static const char *application_name; static const char *saveGameFileDefault; + static const char *saveGameFileAutoTestDefault; static const char *saveGameFilePattern; // VC++ Chokes on init of non integral static types diff --git a/source/glest_game/global/config.cpp b/source/glest_game/global/config.cpp index 0f98fe7b..d1a2519d 100644 --- a/source/glest_game/global/config.cpp +++ b/source/glest_game/global/config.cpp @@ -62,6 +62,7 @@ const char *GameConstants::path_ini_CacheLookupKey = "ini"; const char *GameConstants::path_logs_CacheLookupKey = "logs"; const char *GameConstants::saveGameFileDefault = "megaglest-saved.xml"; +const char *GameConstants::saveGameFileAutoTestDefault = "megaglest-auto-saved_%s.xml"; const char *GameConstants::saveGameFilePattern = "megaglest-saved_%s.xml"; const char *Config::glest_ini_filename = "glest.ini"; diff --git a/source/glest_game/global/core_data.cpp b/source/glest_game/global/core_data.cpp index 089efb11..83d0d6ae 100644 --- a/source/glest_game/global/core_data.cpp +++ b/source/glest_game/global/core_data.cpp @@ -687,22 +687,27 @@ void CoreData::saveGameSettingsToFile(std::string fileName, GameSettings *gameSe if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); } -void CoreData::loadGameSettingsFromFile(std::string fileName, GameSettings *gameSettings) { +bool CoreData::loadGameSettingsFromFile(std::string fileName, GameSettings *gameSettings) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); + bool fileWasFound = false; Config &config = Config::getInstance(); string userData = config.getString("UserData_Root",""); if(userData != "") { endPathWithSlash(userData); } - fileName = userData + fileName; + if(fileExists(userData + fileName) == true) { + fileName = userData + fileName; + fileWasFound = true; + } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str()); if(fileExists(fileName) == false) { - return; + return false; } + fileWasFound = true; if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str()); Properties properties; @@ -757,6 +762,8 @@ void CoreData::loadGameSettingsFromFile(std::string fileName, GameSettings *game } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); + + return fileWasFound; } // ================== PRIVATE ======================== diff --git a/source/glest_game/global/core_data.h b/source/glest_game/global/core_data.h index 33a7897d..2c27e615 100644 --- a/source/glest_game/global/core_data.h +++ b/source/glest_game/global/core_data.h @@ -142,7 +142,7 @@ public: Font3D *getConsoleFont3D() const {return consoleFont3D;} void saveGameSettingsToFile(std::string fileName, GameSettings *gameSettings,int advancedIndex=0); - void loadGameSettingsFromFile(std::string fileName, GameSettings *gameSettings); + bool loadGameSettingsFromFile(std::string fileName, GameSettings *gameSettings); private: CoreData(); diff --git a/source/glest_game/main/battle_end.cpp b/source/glest_game/main/battle_end.cpp index 8634b9ed..11bed200 100644 --- a/source/glest_game/main/battle_end.cpp +++ b/source/glest_game/main/battle_end.cpp @@ -93,6 +93,7 @@ BattleEnd::~BattleEnd() { void BattleEnd::update() { if(Config::getInstance().getBool("AutoTest")){ AutoTest::getInstance().updateBattleEnd(program); + return; } mouse2d= (mouse2d+1) % Renderer::maxMouse2dAnim; diff --git a/source/glest_game/main/intro.cpp b/source/glest_game/main/intro.cpp index 7e0fe33d..fbc0da27 100644 --- a/source/glest_game/main/intro.cpp +++ b/source/glest_game/main/intro.cpp @@ -518,6 +518,7 @@ void Intro::update() { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); AutoTest::getInstance().updateIntro(program); + return; SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index d0ace0b2..c3d1e3e5 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -39,12 +39,9 @@ #include #include "core_data.h" #include "font_text.h" -//#include "FileReader.h" -//#include "JPGReader.h" -//#include "sound.h" -//#include "unicode/uclean.h" #include #include "string_utils.h" +#include "auto_test.h" // For gcc backtrace on crash! #if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD) @@ -3068,6 +3065,52 @@ int glestMain(int argc, char** argv) { } } + if(hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_AUTO_TEST])) == true || + Config::getInstance().getBool("AutoTest","false") == true) { + printf("Running in auto test mode\n"); + } + if(hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_AUTO_TEST])) == true) { + Config::getInstance().setBool("AutoTest","true"); + + int foundParamIndIndex = -1; + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_AUTO_TEST]) + string("="),&foundParamIndIndex); + if(foundParamIndIndex < 0) { + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_AUTO_TEST]),&foundParamIndIndex); + } + string paramValue = argv[foundParamIndIndex]; + vector paramPartTokens; + Tokenize(paramValue,paramPartTokens,"="); + if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) { + vector paramPartTokens2; + Tokenize(paramPartTokens[1],paramPartTokens2,","); + if(paramPartTokens2.size() >= 1 && paramPartTokens2[0].length() > 0) { + string newMaxSeconds = paramPartTokens2[0]; + time_t newTimeMaxSeconds = strToInt(newMaxSeconds); + AutoTest::setMaxGameTime(newTimeMaxSeconds); + //printf("#1 Forcing font [%s] paramPartTokens.size() = %d, paramValue [%s]\n",newfont.c_str(),paramPartTokens.size(),paramValue.c_str()); + printf("Forcing maximum game time to [%ld] seconds (%.2f minutes)\n",newTimeMaxSeconds,((double)newTimeMaxSeconds / 60.0)); + } + if(paramPartTokens2.size() >= 3 && paramPartTokens2[2].length() > 0) { + string autoTestCmd = paramPartTokens2[2]; + if(autoTestCmd == "exit") { + printf("Detected auto test command [%s], will exit after game.\n",autoTestCmd.c_str()); + + AutoTest::setWantExitGameWhenDone(true); + } + else { + printf("WARNING: Detected and UNKNOWN auto test command [%s].\n",autoTestCmd.c_str()); + } + } + + if(paramPartTokens2.size() >= 2 && paramPartTokens2[1].length() > 0) { + string newGameSettingsFileToLoad = paramPartTokens2[1]; + + printf("About to auto test using game settings file [%s]\n",newGameSettingsFileToLoad.c_str()); + AutoTest::setLoadGameSettingsFile(newGameSettingsFileToLoad); + } + } + } + Renderer &renderer= Renderer::getInstance(); lang.loadStrings(language,false, true); diff --git a/source/glest_game/menu/menu_state_load_game.cpp b/source/glest_game/menu/menu_state_load_game.cpp index 44faab23..5b3a7e83 100644 --- a/source/glest_game/menu/menu_state_load_game.cpp +++ b/source/glest_game/menu/menu_state_load_game.cpp @@ -394,6 +394,7 @@ void MenuStateLoadGame::render(){ void MenuStateLoadGame::update(){ if(Config::getInstance().getBool("AutoTest")){ AutoTest::getInstance().updateNewGame(program, mainMenu); + return; } slotsScrollBar.arrangeComponents(slotsGB); console.update(); diff --git a/source/glest_game/menu/menu_state_new_game.cpp b/source/glest_game/menu/menu_state_new_game.cpp index f26b033a..e339b5da 100644 --- a/source/glest_game/menu/menu_state_new_game.cpp +++ b/source/glest_game/menu/menu_state_new_game.cpp @@ -142,6 +142,7 @@ void MenuStateNewGame::render(){ void MenuStateNewGame::update(){ if(Config::getInstance().getBool("AutoTest")){ AutoTest::getInstance().updateNewGame(program, mainMenu); + return; } console.update(); } diff --git a/source/glest_game/menu/menu_state_root.cpp b/source/glest_game/menu/menu_state_root.cpp index bf704efa..4eb65e50 100644 --- a/source/glest_game/menu/menu_state_root.cpp +++ b/source/glest_game/menu/menu_state_root.cpp @@ -293,9 +293,15 @@ void MenuStateRoot::render() { if(program != NULL) program->renderProgramMsgBox(); } -void MenuStateRoot::update(){ - if(Config::getInstance().getBool("AutoTest")){ - AutoTest::getInstance().updateRoot(program, mainMenu); +void MenuStateRoot::update() { + if(Config::getInstance().getBool("AutoTest")) { + if(AutoTest::getInstance().mustExitGame() == false) { + AutoTest::getInstance().updateRoot(program, mainMenu); + } + else { + program->exit(); + } + return; } console.update(); } diff --git a/source/glest_game/menu/menu_state_scenario.cpp b/source/glest_game/menu/menu_state_scenario.cpp index 07c5c76f..ddadc94f 100644 --- a/source/glest_game/menu/menu_state_scenario.cpp +++ b/source/glest_game/menu/menu_state_scenario.cpp @@ -228,6 +228,7 @@ void MenuStateScenario::render(){ void MenuStateScenario::update() { if(Config::getInstance().getBool("AutoTest")) { AutoTest::getInstance().updateScenario(this); + return; } if(this->autoloadScenarioName != "") { listBoxScenario.setSelectedItem(formatString(this->autoloadScenarioName),false); diff --git a/source/shared_lib/include/platform/common/platform_common.h b/source/shared_lib/include/platform/common/platform_common.h index 98b53d29..c29a317c 100644 --- a/source/shared_lib/include/platform/common/platform_common.h +++ b/source/shared_lib/include/platform/common/platform_common.h @@ -214,6 +214,8 @@ void updatePathClimbingParts(string &path); string formatPath(string path); string replaceAll(string& context, const string& from, const string& to); +vector replaceAllBetweenTokens(vector& 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); diff --git a/source/shared_lib/include/platform/sdl/platform_main.h b/source/shared_lib/include/platform/sdl/platform_main.h index e513b0da..ebdb3ab5 100644 --- a/source/shared_lib/include/platform/sdl/platform_main.h +++ b/source/shared_lib/include/platform/sdl/platform_main.h @@ -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]); diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index d71ae35c..f07353d0 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -1743,6 +1743,48 @@ string replaceAll(string& context, const string& from, const string& to) { return context; } +vector replaceAllBetweenTokens(vector& 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(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; diff --git a/source/shared_lib/sources/xml/xml_parser.cpp b/source/shared_lib/sources/xml/xml_parser.cpp index 22b5763e..79cf38e3 100644 --- a/source/shared_lib/sources/xml/xml_parser.cpp +++ b/source/shared_lib/sources/xml/xml_parser.cpp @@ -294,9 +294,9 @@ XmlNode *XmlIoRapid::load(const string &path, std::map mapTagRepl xmlFile.read(&buffer.front(), static_cast(size)); buffer[size] = 0; - //doc->parse(&buffer[0]); - //doc->parse(&buffer.front()); - //doc->parse(&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(&buffer.front()); rootNode= new XmlNode(doc->first_node(),mapTagReplacementValues); @@ -518,7 +518,7 @@ XmlNode::XmlNode(xml_node<> *node, std::map 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();