From c898371d6cfe0f77dee6648ad0027a1cf5b76069 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 17 Oct 2012 22:57:04 +0000 Subject: [PATCH] - added a few new items to the save/load game logic --- source/glest_game/game/game.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 0b90e9ac..fa6322c7 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -5019,6 +5019,20 @@ string Game::saveGame(string name) { //time_t lastMasterServerGameStatsDump; gameNode->addAttribute("lastMasterServerGameStatsDump",intToStr(lastMasterServerGameStatsDump), mapTagReplacements); + XmlNode *unitHighlightListNode = gameNode->addChild("unitHighlightList"); + //for(unsigned int i = 0; i < unitHighlightList.size(); ++i) { + for(std::map::iterator iterMap = unitHighlightList.begin(); + iterMap != unitHighlightList.end(); ++iterMap) { + HighlightSpecialUnitInfo &info = iterMap->second; + XmlNode *infoNode = unitHighlightListNode->addChild("info"); + infoNode->addAttribute("unitid",intToStr(iterMap->first), mapTagReplacements); + infoNode->addAttribute("radius",floatToStr(info.radius), mapTagReplacements); + infoNode->addAttribute("thickness",floatToStr(info.thickness), mapTagReplacements); + infoNode->addAttribute("color",info.color.getString(), mapTagReplacements); + } + + gameNode->addAttribute("timeDisplay",intToStr(timeDisplay), mapTagReplacements); + xmlTree.save(saveGameFile); if(masterserverMode == false) { @@ -5216,6 +5230,24 @@ void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode) { newGame->withRainEffect = gameNode->getAttribute("withRainEffect")->getIntValue() != 0; //Program *program; + if(gameNode->hasChild("unitHighlightList") == true) { + XmlNode *unitHighlightListNode = gameNode->getChild("unitHighlightList"); + vector infoNodeList = unitHighlightListNode->getChildList("info"); + for(unsigned int i = 0; i < infoNodeList.size(); ++i) { + XmlNode *infoNode = infoNodeList[i]; + + int unitId = infoNode->getAttribute("radius")->getIntValue(); + HighlightSpecialUnitInfo info; + info.radius = infoNode->getAttribute("radius")->getFloatValue(); + info.thickness = infoNode->getAttribute("thickness")->getFloatValue(); + info.color = Vec4f::strToVec4(infoNode->getAttribute("color")->getValue()); + + newGame->unitHighlightList[unitId] = info; + } + } + + newGame->timeDisplay = gameNode->getAttribute("timeDisplay")->getIntValue() != 0; + //bool gameStarted; //gameNode->addAttribute("gameStarted",intToStr(gameStarted), mapTagReplacements); // newGame->gameStarted = gameNode->getAttribute("gameStarted")->getIntValue();