- initial work to save game state to XML. Current only saves when out of synch or game end occurs and saves to same folder as log files and file is called: megaglest-saved.xml

(Currently we store way too much info but this is a starting point)
This commit is contained in:
Mark Vejvoda 2012-03-10 03:27:25 +00:00
parent 623623d33f
commit c5331b7e8a
67 changed files with 2120 additions and 14 deletions

View File

@ -22,10 +22,16 @@ using namespace Shared::Util;
namespace Glest { namespace Game {
void Task::saveGame(XmlNode *rootNode) const {
std::map<string,string> mapTagReplacements;
XmlNode *taskNode = rootNode->addChild("Task");
taskNode->addAttribute("taskClass",intToStr(taskClass), mapTagReplacements);
}
// =====================================================
// class ProduceTask
// =====================================================
ProduceTask::ProduceTask(UnitClass unitClass){
taskClass= tcProduce;
this->unitClass= unitClass;
@ -53,6 +59,24 @@ string ProduceTask::toString() const{
return str;
}
void ProduceTask::saveGame(XmlNode *rootNode) const {
Task::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *produceTaskNode = rootNode->addChild("ProduceTask");
// UnitClass unitClass;
produceTaskNode->addAttribute("unitClass",intToStr(unitClass), mapTagReplacements);
// const UnitType *unitType;
if(unitType != NULL) {
produceTaskNode->addAttribute("unitType",unitType->getName(), mapTagReplacements);
}
// const ResourceType *resourceType;
if(resourceType != NULL) {
produceTaskNode->addAttribute("resourceType",resourceType->getName(), mapTagReplacements);
}
}
// =====================================================
// class BuildTask
// =====================================================
@ -87,6 +111,26 @@ string BuildTask::toString() const{
return str;
}
void BuildTask::saveGame(XmlNode *rootNode) const {
Task::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *buildTaskNode = rootNode->addChild("BuildTask");
// const UnitType *unitType;
if(unitType != NULL) {
buildTaskNode->addAttribute("unitType",unitType->getName(), mapTagReplacements);
}
// const ResourceType *resourceType;
if(resourceType != NULL) {
buildTaskNode->addAttribute("resourceType",resourceType->getName(), mapTagReplacements);
}
// bool forcePos;
buildTaskNode->addAttribute("forcePos",intToStr(forcePos), mapTagReplacements);
// Vec2i pos;
buildTaskNode->addAttribute("pos",pos.getString(), mapTagReplacements);
}
// =====================================================
// class UpgradeTask
// =====================================================
@ -104,6 +148,17 @@ string UpgradeTask::toString() const{
return str;
}
void UpgradeTask::saveGame(XmlNode *rootNode) const {
Task::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *upgradeTaskNode = rootNode->addChild("UpgradeTask");
if(upgradeType != NULL) {
upgradeType->saveGame(upgradeTaskNode);
}
}
// =====================================================
// class Ai
// =====================================================
@ -884,4 +939,29 @@ bool Ai::outputAIBehaviourToConsole() const {
return false;
}
void Ai::saveGame(XmlNode *rootNode) const {
std::map<string,string> mapTagReplacements;
XmlNode *aiNode = rootNode->addChild("Ai");
// AiInterface *aiInterface;
// AiRules aiRules;
// int startLoc;
aiNode->addAttribute("startLoc",intToStr(startLoc), mapTagReplacements);
// bool randomMinWarriorsReached;
aiNode->addAttribute("randomMinWarriorsReached",intToStr(randomMinWarriorsReached), mapTagReplacements);
// Tasks tasks;
for(Tasks::const_iterator it = tasks.begin(); it != tasks.end(); ++it) {
(*it)->saveGame(aiNode);
}
// Positions expansionPositions;
for(Positions::const_iterator it = expansionPositions.begin(); it != expansionPositions.end(); ++it) {
XmlNode *expansionPositionsNode = aiNode->addChild("expansionPositions");
expansionPositionsNode->addAttribute("pos",(*it).getString(), mapTagReplacements);
}
// RandomGen random;
aiNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements);
// std::map<int,int> factionSwitchTeamRequestCount;
}
}}//end namespace

View File

@ -51,6 +51,8 @@ public:
virtual ~Task(){}
TaskClass getClass() const {return taskClass;}
virtual string toString() const= 0;
virtual void saveGame(XmlNode *rootNode) const;
};
// ==================== ProduceTask ====================
@ -70,6 +72,8 @@ public:
const UnitType *getUnitType() const {return unitType;}
const ResourceType *getResourceType() const {return resourceType;}
virtual string toString() const;
virtual void saveGame(XmlNode *rootNode) const;
};
// ==================== BuildTask ====================
@ -91,6 +95,8 @@ public:
bool getForcePos() const {return forcePos;}
Vec2i getPos() const {return pos;}
virtual string toString() const;
virtual void saveGame(XmlNode *rootNode) const;
};
// ==================== UpgradeTask ====================
@ -103,6 +109,8 @@ public:
UpgradeTask(const UpgradeType *upgradeType= NULL);
const UpgradeType *getUpgradeType() const {return upgradeType;}
virtual string toString() const;
virtual void saveGame(XmlNode *rootNode) const;
};
// ===============================
@ -197,6 +205,8 @@ public:
void unblockUnits();
bool outputAIBehaviourToConsole() const;
void saveGame(XmlNode *rootNode) const;
};
}}//end namespace

View File

@ -667,4 +667,36 @@ bool AiInterface::factionUsesResourceType(const FactionType *factionType, const
return factionUsesResourceType;
}
void AiInterface::saveGame(XmlNode *rootNode) const {
std::map<string,string> mapTagReplacements;
XmlNode *aiInterfaceNode = rootNode->addChild("AiInterface");
// World *world;
// Commander *commander;
// Console *console;
// GameSettings *gameSettings;
//
// Ai ai;
ai.saveGame(aiInterfaceNode);
// int timer;
aiInterfaceNode->addAttribute("timer",intToStr(timer), mapTagReplacements);
// int factionIndex;
aiInterfaceNode->addAttribute("factionIndex",intToStr(factionIndex), mapTagReplacements);
// int teamIndex;
aiInterfaceNode->addAttribute("teamIndex",intToStr(teamIndex), mapTagReplacements);
// //config
// bool redir;
aiInterfaceNode->addAttribute("redir",intToStr(redir), mapTagReplacements);
// int logLevel;
aiInterfaceNode->addAttribute("logLevel",intToStr(logLevel), mapTagReplacements);
// std::map<const ResourceType *,int> cacheUnitHarvestResourceLookup;
for(std::map<const ResourceType *,int>::const_iterator iterMap = cacheUnitHarvestResourceLookup.begin();
iterMap != cacheUnitHarvestResourceLookup.end(); ++iterMap) {
XmlNode *cacheUnitHarvestResourceLookupNode = aiInterfaceNode->addChild("cacheUnitHarvestResourceLookup");
cacheUnitHarvestResourceLookupNode->addAttribute("key",iterMap->first->getName(), mapTagReplacements);
cacheUnitHarvestResourceLookupNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
}
}
}}//end namespace

View File

@ -103,6 +103,8 @@ public:
bool factionUsesResourceType(const FactionType *factionType, const ResourceType *rt);
void saveGame(XmlNode *rootNode) const;
private:
string getLogFilename() const {return "ai"+intToStr(factionIndex)+".log";}
bool executeCommandOverNetwork();

View File

@ -1483,4 +1483,136 @@ bool PathFinder::openPos(const Vec2i &sucPos, FactionState &faction) {
return true;
}
int PathFinder::findNodeIndex(Node *node, Nodes &nodeList) {
int index = -1;
if(node != NULL) {
for(unsigned int i = 0; i < nodeList.size(); ++i) {
Node *curnode = nodeList[i];
if(node == curnode) {
index = i;
break;
}
}
}
return index;
}
int PathFinder::findNodeIndex(Node *node, std::vector<Node> &nodeList) {
int index = -1;
if(node != NULL) {
for(unsigned int i = 0; i < nodeList.size(); ++i) {
Node &curnode = nodeList[i];
if(node == &curnode) {
index = i;
break;
}
}
}
return index;
}
void PathFinder::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *pathfinderNode = rootNode->addChild("PathFinder");
// static int pathFindNodesMax;
pathfinderNode->addAttribute("pathFindNodesMax",intToStr(pathFindNodesMax), mapTagReplacements);
// static int pathFindNodesAbsoluteMax;
pathfinderNode->addAttribute("pathFindNodesAbsoluteMax",intToStr(pathFindNodesAbsoluteMax), mapTagReplacements);
// FactionStateList factions;
for(unsigned int i = 0; i < factions.size(); ++i) {
FactionState &factionState = factions[i];
XmlNode *factionsNode = pathfinderNode->addChild("factions");
// std::map<Vec2i, bool> openPosList;
XmlNode *openPosListNode = factionsNode->addChild("openPosList");
for(std::map<Vec2i, bool>::iterator iterMap = factionState.openPosList.begin();
iterMap != factionState.openPosList.end(); ++iterMap) {
openPosListNode->addAttribute("key",iterMap->first.getString(), mapTagReplacements);
openPosListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
}
// std::map<float, Nodes> openNodesList;
XmlNode *openNodesListNode = factionsNode->addChild("openNodesList");
for(std::map<float, Nodes>::iterator iterMap = factionState.openNodesList.begin();
iterMap != factionState.openNodesList.end(); ++iterMap) {
Nodes &nodeList = iterMap->second;
for(unsigned int j = 0; j < nodeList.size(); ++j) {
Node *curNode = nodeList[j];
XmlNode *openNodesListNodeNode = factionsNode->addChild("openNodesListNode");
openNodesListNodeNode->addAttribute("key",floatToStr(iterMap->first), mapTagReplacements);
// Vec2i pos;
openNodesListNodeNode->addAttribute("pos",curNode->pos.getString(), mapTagReplacements);
// Node *next;
int nextIdx = findNodeIndex(curNode->next, nodeList);
openNodesListNodeNode->addAttribute("next",intToStr(nextIdx), mapTagReplacements);
// Node *prev;
int prevIdx = findNodeIndex(curNode->prev, nodeList);
openNodesListNodeNode->addAttribute("prev",intToStr(nextIdx), mapTagReplacements);
// float heuristic;
openNodesListNodeNode->addAttribute("heuristic",floatToStr(curNode->heuristic), mapTagReplacements);
// bool exploredCell;
openNodesListNodeNode->addAttribute("exploredCell",intToStr(curNode->exploredCell), mapTagReplacements);
}
}
// std::map<float, Nodes> closedNodesList;
XmlNode *closedNodesListNode = factionsNode->addChild("closedNodesList");
for(std::map<float, Nodes>::iterator iterMap = factionState.closedNodesList.begin();
iterMap != factionState.closedNodesList.end(); ++iterMap) {
Nodes &nodeList = iterMap->second;
for(unsigned int j = 0; j < nodeList.size(); ++j) {
Node *curNode = nodeList[j];
XmlNode *closedNodesListNodeNode = factionsNode->addChild("closedNodesListNode");
closedNodesListNodeNode->addAttribute("key",floatToStr(iterMap->first), mapTagReplacements);
// Vec2i pos;
closedNodesListNodeNode->addAttribute("pos",curNode->pos.getString(), mapTagReplacements);
// Node *next;
int nextIdx = findNodeIndex(curNode->next, nodeList);
closedNodesListNodeNode->addAttribute("next",intToStr(nextIdx), mapTagReplacements);
// Node *prev;
int prevIdx = findNodeIndex(curNode->prev, nodeList);
closedNodesListNodeNode->addAttribute("prev",intToStr(nextIdx), mapTagReplacements);
// float heuristic;
closedNodesListNodeNode->addAttribute("heuristic",floatToStr(curNode->heuristic), mapTagReplacements);
// bool exploredCell;
closedNodesListNodeNode->addAttribute("exploredCell",intToStr(curNode->exploredCell), mapTagReplacements);
}
}
// std::vector<Node> nodePool;
for(unsigned int j = 0; j < factionState.nodePool.size(); ++j) {
Node *curNode = &factionState.nodePool[j];
XmlNode *nodePoolNode = factionsNode->addChild("nodePool");
//closedNodesListNodeNode->addAttribute("key",iterMap->first.getString(), mapTagReplacements);
// Vec2i pos;
nodePoolNode->addAttribute("pos",curNode->pos.getString(), mapTagReplacements);
// Node *next;
int nextIdx = findNodeIndex(curNode->next, factionState.nodePool);
nodePoolNode->addAttribute("next",intToStr(nextIdx), mapTagReplacements);
// Node *prev;
int prevIdx = findNodeIndex(curNode->prev, factionState.nodePool);
nodePoolNode->addAttribute("prev",intToStr(nextIdx), mapTagReplacements);
// float heuristic;
nodePoolNode->addAttribute("heuristic",floatToStr(curNode->heuristic), mapTagReplacements);
// bool exploredCell;
nodePoolNode->addAttribute("exploredCell",intToStr(curNode->exploredCell), mapTagReplacements);
}
// int nodePoolCount;
// RandomGen random;
// int useMaxNodeCount;
//
// std::map<int,TravelState> precachedTravelState;
// std::map<int,std::vector<Vec2i> > precachedPath;
}
// const Map *map;
}
}} //end namespace

View File

@ -118,6 +118,11 @@ public:
void clearUnitPrecache(Unit *unit);
void removeUnitPrecache(Unit *unit);
int findNodeIndex(Node *node, Nodes &nodeList);
int findNodeIndex(Node *node, std::vector<Node> &nodeList);
void saveGame(XmlNode *rootNode);
private:
TravelState aStar(Unit *unit, const Vec2i &finalPos, bool inBailout, int frameIndex, int maxNodeCount=-1);
Node *newNode(FactionState &faction,int maxNodeCount);

View File

@ -2614,9 +2614,9 @@ void Game::keyPress(SDL_KeyboardEvent c) {
Stats Game::quitGame() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled == true) {
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled == true) {
world.DumpWorldToLog();
}
//}
//Stats stats = *(world.getStats());
Stats endStats;
@ -3417,4 +3417,161 @@ void Game::toggleTeamColorMarker() {
renderExtraTeamColor=renderExtraTeamColor%4;
}
void Game::saveGame(string name) {
XmlTree xmlTree;
xmlTree.init("megaglest-saved-game");
XmlNode *rootNode = xmlTree.getRootNode();
std::map<string,string> mapTagReplacements;
time_t now = time(NULL);
struct tm *loctime = localtime (&now);
char szBuf[4096]="";
strftime(szBuf,4095,"%Y-%m-%d %H:%M:%S",loctime);
rootNode->addAttribute("version",glestVersionString, mapTagReplacements);
rootNode->addAttribute("timestamp",szBuf, mapTagReplacements);
XmlNode *gameNode = rootNode->addChild("Game");
//World world;
world.saveGame(gameNode);
//AiInterfaces aiInterfaces;
for(unsigned int i = 0; i < aiInterfaces.size(); ++i) {
AiInterface *aiIntf = aiInterfaces[i];
if(aiIntf != NULL) {
aiIntf->saveGame(gameNode);
}
}
//Gui gui;
gui.saveGame(gameNode);
//GameCamera gameCamera;
gameCamera.saveGame(gameNode);
//Commander commander;
//Console console;
//ChatManager chatManager;
//ScriptManager scriptManager;
//misc
//Checksum checksum;
gameNode->addAttribute("checksum",intToStr(checksum.getSum()), mapTagReplacements);
//string loadingText;
// int mouse2d;
gameNode->addAttribute("mouse2d",intToStr(mouse2d), mapTagReplacements);
// int mouseX;
gameNode->addAttribute("mouseX",intToStr(mouseX), mapTagReplacements);
// int mouseY; //coords win32Api
gameNode->addAttribute("mouseY",intToStr(mouseY), mapTagReplacements);
// Vec2i mouseCellPos;
gameNode->addAttribute("mouseCellPos",mouseCellPos.getString(), mapTagReplacements);
// int updateFps, lastUpdateFps, avgUpdateFps;
// int totalRenderFps, renderFps, lastRenderFps, avgRenderFps,currentAvgRenderFpsTotal;
//Uint64 tickCount;
gameNode->addAttribute("tickCount",intToStr(tickCount), mapTagReplacements);
//bool paused;
gameNode->addAttribute("paused",intToStr(paused), mapTagReplacements);
//bool gameOver;
gameNode->addAttribute("gameOver",intToStr(gameOver), mapTagReplacements);
//bool renderNetworkStatus;
//bool showFullConsole;
//bool mouseMoved;
//float scrollSpeed;
gameNode->addAttribute("scrollSpeed",floatToStr(scrollSpeed), mapTagReplacements);
//bool camLeftButtonDown;
//bool camRightButtonDown;
//bool camUpButtonDown;
//bool camDownButtonDown;
//Speed speed;
gameNode->addAttribute("speed",intToStr(speed), mapTagReplacements);
//GraphicMessageBox mainMessageBox;
//GraphicMessageBox errorMessageBox;
//misc ptr
//ParticleSystem *weatherParticleSystem;
if(weatherParticleSystem != NULL) {
weatherParticleSystem->saveGame(gameNode);
}
//GameSettings gameSettings;
//Vec2i lastMousePos;
gameNode->addAttribute("lastMousePos",lastMousePos.getString(), mapTagReplacements);
//time_t lastRenderLog2d;
gameNode->addAttribute("lastRenderLog2d",intToStr(lastRenderLog2d), mapTagReplacements);
//DisplayMessageFunction originalDisplayMsgCallback;
//bool isFirstRender;
gameNode->addAttribute("isFirstRender",intToStr(isFirstRender), mapTagReplacements);
//bool quitTriggeredIndicator;
//int original_updateFps;
gameNode->addAttribute("original_updateFps",intToStr(original_updateFps), mapTagReplacements);
//int original_cameraFps;
gameNode->addAttribute("original_cameraFps",intToStr(original_cameraFps), mapTagReplacements);
//bool captureAvgTestStatus;
gameNode->addAttribute("captureAvgTestStatus",intToStr(captureAvgTestStatus), mapTagReplacements);
//int updateFpsAvgTest;
gameNode->addAttribute("updateFpsAvgTest",intToStr(updateFpsAvgTest), mapTagReplacements);
//int renderFpsAvgTest;
gameNode->addAttribute("renderFpsAvgTest",intToStr(renderFpsAvgTest), mapTagReplacements);
//int renderExtraTeamColor;
gameNode->addAttribute("renderExtraTeamColor",intToStr(renderExtraTeamColor), mapTagReplacements);
//static const int renderTeamColorCircleBit=1;
//static const int renderTeamColorPlaneBit=2;
//bool photoModeEnabled;
gameNode->addAttribute("photoModeEnabled",intToStr(photoModeEnabled), mapTagReplacements);
//bool visibleHUD;
gameNode->addAttribute("visibleHUD",intToStr(visibleHUD), mapTagReplacements);
//bool withRainEffect;
gameNode->addAttribute("withRainEffect",intToStr(withRainEffect), mapTagReplacements);
//Program *program;
//bool gameStarted;
gameNode->addAttribute("gameStarted",intToStr(gameStarted), mapTagReplacements);
//time_t lastMaxUnitCalcTime;
gameNode->addAttribute("lastMaxUnitCalcTime",intToStr(lastMaxUnitCalcTime), mapTagReplacements);
//PopupMenu popupMenu;
//PopupMenu popupMenuSwitchTeams;
//std::map<int,int> switchTeamIndexMap;
//GraphicMessageBox switchTeamConfirmMessageBox;
//int exitGamePopupMenuIndex;
//int joinTeamPopupMenuIndex;
//int pauseGamePopupMenuIndex;
//int keyboardSetupPopupMenuIndex;
//GLuint statelist3dMenu;
//ProgramState *currentUIState;
//bool masterserverMode;
//StrSound *currentAmbientSound;
//time_t lastNetworkPlayerConnectionCheck;
gameNode->addAttribute("lastNetworkPlayerConnectionCheck",intToStr(lastNetworkPlayerConnectionCheck), mapTagReplacements);
//time_t lastMasterServerGameStatsDump;
gameNode->addAttribute("lastMasterServerGameStatsDump",intToStr(lastMasterServerGameStatsDump), mapTagReplacements);
// Save the file now
string saveGameFile = name;
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
saveGameFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + saveGameFile;
}
else {
string userData = Config::getInstance().getString("UserData_Root","");
if(userData != "") {
endPathWithSlash(userData);
}
saveGameFile = userData + saveGameFile;
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Saving game to [%s]\n",saveGameFile.c_str());
xmlTree.save(saveGameFile);
}
}}//end namespace

View File

@ -225,6 +225,8 @@ public:
void endGame();
void saveGame(string name);
private:
//render
void render3d();

View File

@ -412,4 +412,58 @@ void GameCamera::moveUp(float d){
destPos.y += d;
}
void GameCamera::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *gamecameraNode = rootNode->addChild("GameCamera");
// Vec3f pos;
gamecameraNode->addAttribute("pos",pos.getString(), mapTagReplacements);
// Vec3f destPos;
gamecameraNode->addAttribute("destPos",destPos.getString(), mapTagReplacements);
//
// float hAng; //YZ plane positive -Z axis
gamecameraNode->addAttribute("hAng",floatToStr(hAng), mapTagReplacements);
// float vAng; //XZ plane positive +Z axis
gamecameraNode->addAttribute("vAng",floatToStr(vAng), mapTagReplacements);
// float lastHAng;
gamecameraNode->addAttribute("lastHAng",floatToStr(lastHAng), mapTagReplacements);
// float lastVAng;
gamecameraNode->addAttribute("lastVAng",floatToStr(lastVAng), mapTagReplacements);
// Vec2f destAng;
gamecameraNode->addAttribute("destAng",destAng.getString(), mapTagReplacements);
// float rotate;
gamecameraNode->addAttribute("rotate",floatToStr(rotate), mapTagReplacements);
// Vec3f move;
gamecameraNode->addAttribute("move",move.getString(), mapTagReplacements);
// State state;
gamecameraNode->addAttribute("state",intToStr(state), mapTagReplacements);
// int limitX;
gamecameraNode->addAttribute("limitX",intToStr(limitX), mapTagReplacements);
// int limitY;
gamecameraNode->addAttribute("limitY",intToStr(limitY), mapTagReplacements);
// //config
// float speed;
gamecameraNode->addAttribute("speed",floatToStr(speed), mapTagReplacements);
// bool clampBounds;
gamecameraNode->addAttribute("clampBounds",intToStr(clampBounds), mapTagReplacements);
// //float maxRenderDistance;
// float maxHeight;
gamecameraNode->addAttribute("maxHeight",floatToStr(maxHeight), mapTagReplacements);
// float minHeight;
gamecameraNode->addAttribute("minHeight",floatToStr(minHeight), mapTagReplacements);
// //float maxCameraDist;
// //float minCameraDist;
// float minVAng;
gamecameraNode->addAttribute("minVAng",floatToStr(minVAng), mapTagReplacements);
// float maxVAng;
gamecameraNode->addAttribute("maxVAng",floatToStr(maxVAng), mapTagReplacements);
// float fov;
gamecameraNode->addAttribute("fov",floatToStr(fov), mapTagReplacements);
// float calculatedDefault;
gamecameraNode->addAttribute("calculatedDefault",floatToStr(calculatedDefault), mapTagReplacements);
// std::map<float, std::map<float, std::map<Vec3f, Quad2i> > > cacheVisibleQuad;
// int MaxVisibleQuadItemCache;
gamecameraNode->addAttribute("MaxVisibleQuadItemCache",intToStr(MaxVisibleQuadItemCache), mapTagReplacements);
}
}}//end namespace

View File

@ -143,6 +143,8 @@ public:
void setMinVAng(float value) { minVAng = value; }
void setMaxVAng(float value) { maxVAng = value; }
void saveGame(XmlNode *rootNode);
private:
void clampPosXYZ(float x1, float x2, float y1, float y2, float z1, float z2);
void clampPosXZ(float x1, float x2, float z1, float z2);

View File

@ -125,6 +125,8 @@ public:
static const char *application_name;
static const char *saveGameFileDefault;
// VC++ Chokes on init of non integral static types
static const float normalMultiplier;
static const float easyMultiplier;

View File

@ -150,4 +150,63 @@ string Stats::getStats() const {
return result;
}
void Stats::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *statsNode = rootNode->addChild("Stats");
// PlayerStats playerStats[GameConstants::maxPlayers];
for(unsigned int i = 0; i < GameConstants::maxPlayers; ++i) {
PlayerStats &stat = playerStats[i];
XmlNode *statsNodePlayer = statsNode->addChild("Player");
// ControlType control;
statsNodePlayer->addAttribute("control",intToStr(stat.control), mapTagReplacements);
// float resourceMultiplier;
statsNodePlayer->addAttribute("resourceMultiplier",floatToStr(stat.resourceMultiplier), mapTagReplacements);
// string factionTypeName;
statsNodePlayer->addAttribute("factionTypeName",stat.factionTypeName, mapTagReplacements);
// FactionPersonalityType personalityType;
statsNodePlayer->addAttribute("personalityType",intToStr(stat.personalityType), mapTagReplacements);
// int teamIndex;
statsNodePlayer->addAttribute("teamIndex",intToStr(stat.teamIndex), mapTagReplacements);
// bool victory;
statsNodePlayer->addAttribute("victory",intToStr(stat.victory), mapTagReplacements);
// int kills;
statsNodePlayer->addAttribute("kills",intToStr(stat.kills), mapTagReplacements);
// int enemykills;
statsNodePlayer->addAttribute("enemykills",intToStr(stat.enemykills), mapTagReplacements);
// int deaths;
statsNodePlayer->addAttribute("deaths",intToStr(stat.deaths), mapTagReplacements);
// int unitsProduced;
statsNodePlayer->addAttribute("unitsProduced",intToStr(stat.unitsProduced), mapTagReplacements);
// int resourcesHarvested;
statsNodePlayer->addAttribute("resourcesHarvested",intToStr(stat.resourcesHarvested), mapTagReplacements);
// string playerName;
statsNodePlayer->addAttribute("playerName",stat.playerName, mapTagReplacements);
// Vec3f playerColor;
statsNodePlayer->addAttribute("playerColor",stat.playerColor.getString(), mapTagReplacements);
}
// string description;
statsNode->addAttribute("description",description, mapTagReplacements);
// int factionCount;
statsNode->addAttribute("factionCount",intToStr(factionCount), mapTagReplacements);
// int thisFactionIndex;
statsNode->addAttribute("thisFactionIndex",intToStr(thisFactionIndex), mapTagReplacements);
//
// float worldTimeElapsed;
statsNode->addAttribute("worldTimeElapsed",floatToStr(worldTimeElapsed), mapTagReplacements);
// int framesPlayed;
statsNode->addAttribute("framesPlayed",intToStr(framesPlayed), mapTagReplacements);
// int framesToCalculatePlaytime;
statsNode->addAttribute("framesToCalculatePlaytime",intToStr(framesToCalculatePlaytime), mapTagReplacements);
// time_t timePlayed;
statsNode->addAttribute("timePlayed",intToStr(timePlayed), mapTagReplacements);
// int maxConcurrentUnitCount;
statsNode->addAttribute("maxConcurrentUnitCount",intToStr(maxConcurrentUnitCount), mapTagReplacements);
// int totalEndGameConcurrentUnitCount;
statsNode->addAttribute("totalEndGameConcurrentUnitCount",intToStr(totalEndGameConcurrentUnitCount), mapTagReplacements);
// bool isMasterserverMode;
}
}}//end namespace

View File

@ -134,6 +134,8 @@ public:
void addFramesToCalculatePlaytime() {this->framesToCalculatePlaytime++; }
string getStats() const;
void saveGame(XmlNode *rootNode);
};
}}//end namespace

View File

@ -61,6 +61,8 @@ const char *GameConstants::path_data_CacheLookupKey = "data";
const char *GameConstants::path_ini_CacheLookupKey = "ini";
const char *GameConstants::path_logs_CacheLookupKey = "logs";
const char *GameConstants::saveGameFileDefault = "megaglest-saved.xml";
const char *Config::glest_ini_filename = "glest.ini";
const char *Config::glestuser_ini_filename = "glestuser.ini";

View File

@ -20,6 +20,7 @@
#include "game_constants.h"
#include "util.h"
#include "platform_common.h"
#include "conversion.h"
#include "leak_dumper.h"
using namespace Shared::Xml;
@ -304,6 +305,63 @@ void ParticleSystemType::setValues(AttackParticleSystem *ats){
ats->setBlendMode(ParticleSystem::strToBlendMode(mode));
}
void ParticleSystemType::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *particleSystemTypeNode = rootNode->addChild("ParticleSystemType");
// string type;
particleSystemTypeNode->addAttribute("type",type, mapTagReplacements);
// Texture2D *texture;
// Model *model;
// float modelCycle;
particleSystemTypeNode->addAttribute("modelCycle",floatToStr(modelCycle), mapTagReplacements);
// string primitive;
particleSystemTypeNode->addAttribute("primitive",primitive, mapTagReplacements);
// Vec3f offset;
particleSystemTypeNode->addAttribute("offset",offset.getString(), mapTagReplacements);
// Vec4f color;
particleSystemTypeNode->addAttribute("color",color.getString(), mapTagReplacements);
// Vec4f colorNoEnergy;
particleSystemTypeNode->addAttribute("colorNoEnergy",colorNoEnergy.getString(), mapTagReplacements);
// float size;
particleSystemTypeNode->addAttribute("size",floatToStr(size), mapTagReplacements);
// float sizeNoEnergy;
particleSystemTypeNode->addAttribute("sizeNoEnergy",floatToStr(sizeNoEnergy), mapTagReplacements);
// float speed;
particleSystemTypeNode->addAttribute("speed",floatToStr(speed), mapTagReplacements);
// float gravity;
particleSystemTypeNode->addAttribute("gravity",floatToStr(gravity), mapTagReplacements);
// float emissionRate;
particleSystemTypeNode->addAttribute("emissionRate",floatToStr(emissionRate), mapTagReplacements);
// int energyMax;
particleSystemTypeNode->addAttribute("energyMax",intToStr(energyMax), mapTagReplacements);
// int energyVar;
particleSystemTypeNode->addAttribute("energyVar",intToStr(energyVar), mapTagReplacements);
// string mode;
particleSystemTypeNode->addAttribute("mode",mode, mapTagReplacements);
// bool teamcolorNoEnergy;
particleSystemTypeNode->addAttribute("teamcolorNoEnergy",intToStr(teamcolorNoEnergy), mapTagReplacements);
// bool teamcolorEnergy;
particleSystemTypeNode->addAttribute("teamcolorEnergy",intToStr(teamcolorEnergy), mapTagReplacements);
// int alternations;
particleSystemTypeNode->addAttribute("alternations",intToStr(alternations), mapTagReplacements);
// int particleSystemStartDelay;
particleSystemTypeNode->addAttribute("particleSystemStartDelay",intToStr(particleSystemStartDelay), mapTagReplacements);
// typedef std::list<UnitParticleSystemType*> Children;
// Children children;
for(Children::iterator it = children.begin(); it != children.end(); ++it) {
(*it)->saveGame(particleSystemTypeNode);
}
// bool minmaxEnabled;
particleSystemTypeNode->addAttribute("minmaxEnabled",intToStr(minmaxEnabled), mapTagReplacements);
// int minHp;
particleSystemTypeNode->addAttribute("minHp",intToStr(minHp), mapTagReplacements);
// int maxHp;
particleSystemTypeNode->addAttribute("maxHp",intToStr(maxHp), mapTagReplacements);
// bool minmaxIsPercent;
particleSystemTypeNode->addAttribute("minmaxIsPercent",intToStr(minmaxIsPercent), mapTagReplacements);
}
// ===========================================================
// class ParticleSystemTypeProjectile
// ===========================================================
@ -383,6 +441,22 @@ ProjectileParticleSystem *ParticleSystemTypeProjectile::create() {
return ps;
}
void ParticleSystemTypeProjectile::saveGame(XmlNode *rootNode) {
ParticleSystemType::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *particleSystemTypeProjectileNode = rootNode->addChild("ParticleSystemTypeProjectile");
// string trajectory;
particleSystemTypeProjectileNode->addAttribute("trajectory",trajectory, mapTagReplacements);
// float trajectorySpeed;
particleSystemTypeProjectileNode->addAttribute("trajectorySpeed",floatToStr(trajectorySpeed), mapTagReplacements);
// float trajectoryScale;
particleSystemTypeProjectileNode->addAttribute("trajectoryScale",floatToStr(trajectoryScale), mapTagReplacements);
// float trajectoryFrequency;
particleSystemTypeProjectileNode->addAttribute("trajectoryFrequency",floatToStr(trajectoryFrequency), mapTagReplacements);
}
// ===========================================================
// class ParticleSystemTypeSplash
// ===========================================================
@ -452,4 +526,22 @@ SplashParticleSystem *ParticleSystemTypeSplash::create(){
return ps;
}
void ParticleSystemTypeSplash::saveGame(XmlNode *rootNode) {
ParticleSystemType::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *particleSystemTypeSplashNode = rootNode->addChild("ParticleSystemTypeSplash");
// float emissionRateFade;
particleSystemTypeSplashNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade), mapTagReplacements);
// float verticalSpreadA;
particleSystemTypeSplashNode->addAttribute("verticalSpreadA",floatToStr(verticalSpreadA), mapTagReplacements);
// float verticalSpreadB;
particleSystemTypeSplashNode->addAttribute("verticalSpreadB",floatToStr(verticalSpreadB), mapTagReplacements);
// float horizontalSpreadA;
particleSystemTypeSplashNode->addAttribute("horizontalSpreadA",floatToStr(horizontalSpreadA), mapTagReplacements);
// float horizontalSpreadB;
particleSystemTypeSplashNode->addAttribute("horizontalSpreadB",floatToStr(horizontalSpreadB), mapTagReplacements);
}
}}//end mamespace

View File

@ -106,6 +106,8 @@ public:
string getType() const { return type; };
virtual void saveGame(XmlNode *rootNode);
protected:
};
@ -128,6 +130,7 @@ public:
string parentLoader, string techtreePath);
ProjectileParticleSystem *create();
virtual void saveGame(XmlNode *rootNode);
};
// ===========================================================
@ -143,6 +146,8 @@ public:
string parentLoader, string techtreePath);
SplashParticleSystem *create();
virtual void saveGame(XmlNode *rootNode);
private:
float emissionRateFade;
float verticalSpreadA;

View File

@ -17,7 +17,7 @@
#include "config.h"
#include "game_constants.h"
#include "platform_common.h"
#include "conversion.h"
#include "leak_dumper.h"
using namespace Shared::Xml;
@ -280,4 +280,48 @@ void UnitParticleSystemType::load(const XmlNode *particleFileNode, const string
}
}
void UnitParticleSystemType::saveGame(XmlNode *rootNode) {
ParticleSystemType::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *unitParticleSystemTypeNode = rootNode->addChild("UnitParticleSystemType");
// UnitParticleSystem::Shape shape;
unitParticleSystemTypeNode->addAttribute("shape",intToStr(shape), mapTagReplacements);
// float angle;
unitParticleSystemTypeNode->addAttribute("angle",floatToStr(angle), mapTagReplacements);
// float radius;
unitParticleSystemTypeNode->addAttribute("radius",floatToStr(radius), mapTagReplacements);
// float minRadius;
unitParticleSystemTypeNode->addAttribute("minRadius",floatToStr(minRadius), mapTagReplacements);
// float emissionRateFade;
unitParticleSystemTypeNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade), mapTagReplacements);
// Vec3f direction;
unitParticleSystemTypeNode->addAttribute("direction",direction.getString(), mapTagReplacements);
// bool relative;
unitParticleSystemTypeNode->addAttribute("relative",intToStr(relative), mapTagReplacements);
// bool relativeDirection;
unitParticleSystemTypeNode->addAttribute("relativeDirection",intToStr(relativeDirection), mapTagReplacements);
// bool fixed;
unitParticleSystemTypeNode->addAttribute("fixed",intToStr(fixed), mapTagReplacements);
// int staticParticleCount;
unitParticleSystemTypeNode->addAttribute("staticParticleCount",intToStr(staticParticleCount), mapTagReplacements);
// bool isVisibleAtNight;
unitParticleSystemTypeNode->addAttribute("isVisibleAtNight",intToStr(isVisibleAtNight), mapTagReplacements);
// bool isVisibleAtDay;
unitParticleSystemTypeNode->addAttribute("isVisibleAtDay",intToStr(isVisibleAtDay), mapTagReplacements);
// bool isDaylightAffected;
unitParticleSystemTypeNode->addAttribute("isDaylightAffected",intToStr(isDaylightAffected), mapTagReplacements);
// bool radiusBasedStartenergy;
unitParticleSystemTypeNode->addAttribute("radiusBasedStartenergy",intToStr(radiusBasedStartenergy), mapTagReplacements);
// int delay;
unitParticleSystemTypeNode->addAttribute("delay",intToStr(delay), mapTagReplacements);
// int lifetime;
unitParticleSystemTypeNode->addAttribute("lifetime",intToStr(lifetime), mapTagReplacements);
// float startTime;
unitParticleSystemTypeNode->addAttribute("startTime",floatToStr(startTime), mapTagReplacements);
// float endTime;
unitParticleSystemTypeNode->addAttribute("endTime",floatToStr(endTime), mapTagReplacements);
}
}}//end mamespace

View File

@ -82,6 +82,7 @@ public:
const void setValues (UnitParticleSystem *uts);
bool hasTexture() const { return(texture != NULL); }
virtual void saveGame(XmlNode *rootNode);
};
class ObjectParticleSystemType: public UnitParticleSystemType{

View File

@ -128,4 +128,31 @@ int Display::computeUpY(int index) const{
return Metrics::getInstance().getDisplayH() - (index/upCellSideCount)*upImageSize - upImageSize;
}
void Display::saveGame(XmlNode *rootNode) const {
std::map<string,string> mapTagReplacements;
XmlNode *displayNode = rootNode->addChild("Display");
// string title;
displayNode->addAttribute("title",title, mapTagReplacements);
// string text;
displayNode->addAttribute("text",text, mapTagReplacements);
// string infoText;
displayNode->addAttribute("infoText",infoText, mapTagReplacements);
// const Texture2D *upImages[upCellCount];
// const Texture2D *downImages[downCellCount];
// bool downLighted[downCellCount];
// const CommandType *commandTypes[downCellCount];
// CommandClass commandClasses[downCellCount];
// int progressBar;
displayNode->addAttribute("progressBar",intToStr(progressBar), mapTagReplacements);
// int downSelectedPos;
displayNode->addAttribute("downSelectedPos",intToStr(downSelectedPos), mapTagReplacements);
// Vec4f colors[colorCount];
// int currentColor;
displayNode->addAttribute("currentColor",intToStr(currentColor), mapTagReplacements);
// int upCellSideCount;
// int upImageSize;
// int maxUpIndex;
}
}}//end namespace

View File

@ -103,6 +103,8 @@ public:
int computeUpX(int index) const;
int computeUpY(int index) const;
void saveGame(XmlNode *rootNode) const;
private:
void calculateUpDimensions(int index);
};

View File

@ -1162,10 +1162,75 @@ Unit* Gui::getRelevantObjectFromSelection(Selection::UnitContainer *uc){
return resultUnit;
}
void Gui::removingObjectEvent(Object* o){
void Gui::removingObjectEvent(Object* o){
if(getSelectedResourceObject()==o){
selectedResourceObject=NULL;
}
}
void Gui::saveGame(XmlNode *rootNode) const {
std::map<string,string> mapTagReplacements;
XmlNode *guiNode = rootNode->addChild("Gui");
//External objects
// RandomGen random;
guiNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements);
// const Commander *commander;
// const World *world;
// const Game *game;
// GameCamera *gameCamera;
// Console *console;
//
// //Positions
// Vec2i posObjWorld; //world coords
guiNode->addAttribute("posObjWorld",posObjWorld.getString(), mapTagReplacements);
// bool validPosObjWorld;
guiNode->addAttribute("validPosObjWorld",intToStr(validPosObjWorld), mapTagReplacements);
// //display
// const UnitType *choosenBuildingType;
if(choosenBuildingType != NULL) {
guiNode->addAttribute("choosenBuildingType",choosenBuildingType->getName(), mapTagReplacements);
}
// const CommandType *activeCommandType;
if(activeCommandType != NULL) {
guiNode->addAttribute("activeCommandType",activeCommandType->getName(), mapTagReplacements);
}
// CommandClass activeCommandClass;
guiNode->addAttribute("activeCommandClass",intToStr(activeCommandClass), mapTagReplacements);
// int activePos;
guiNode->addAttribute("activePos",intToStr(activePos), mapTagReplacements);
// int lastPosDisplay;
guiNode->addAttribute("lastPosDisplay",intToStr(lastPosDisplay), mapTagReplacements);
// //composite
// Display display;
display.saveGame(guiNode);
// Mouse3d mouse3d;
// Selection selection;
selection.saveGame(guiNode);
// SelectionQuad selectionQuad;
// int lastQuadCalcFrame;
guiNode->addAttribute("lastQuadCalcFrame",intToStr(lastQuadCalcFrame), mapTagReplacements);
// int selectionCalculationFrameSkip;
guiNode->addAttribute("selectionCalculationFrameSkip",intToStr(selectionCalculationFrameSkip), mapTagReplacements);
// int minQuadSize;
guiNode->addAttribute("minQuadSize",intToStr(minQuadSize), mapTagReplacements);
// Chrono lastGroupRecallTime;
//guiNode->addAttribute("lastGroupRecallTime",intToStr(lastGroupRecallTime.getMillis()), mapTagReplacements);
// int lastGroupRecall;
guiNode->addAttribute("lastGroupRecall",intToStr(lastGroupRecall), mapTagReplacements);
// //states
// bool selectingBuilding;
guiNode->addAttribute("selectingBuilding",intToStr(selectingBuilding), mapTagReplacements);
// bool selectingPos;
guiNode->addAttribute("selectingPos",intToStr(selectingPos), mapTagReplacements);
// bool selectingMeetingPoint;
guiNode->addAttribute("selectingMeetingPoint",intToStr(selectingMeetingPoint), mapTagReplacements);
// CardinalDir selectedBuildingFacing;
guiNode->addAttribute("selectedBuildingFacing",intToStr(selectedBuildingFacing), mapTagReplacements);
// const Object *selectedResourceObject;
//
// Texture2D* hudTexture;
}
}}//end namespace

View File

@ -199,6 +199,8 @@ public:
void switchToNextDisplayColor();
void onSelectionChanged();
void saveGame(XmlNode *rootNode) const;
private:
//orders

View File

@ -216,4 +216,33 @@ void Selection::unitEvent(UnitObserver::Event event, const Unit *unit){
}
}
void Selection::saveGame(XmlNode *rootNode) const {
std::map<string,string> mapTagReplacements;
XmlNode *selectionNode = rootNode->addChild("Selection");
// int factionIndex;
selectionNode->addAttribute("factionIndex",intToStr(factionIndex), mapTagReplacements);
// int teamIndex;
selectionNode->addAttribute("teamIndex",intToStr(teamIndex), mapTagReplacements);
// UnitContainer selectedUnits;
for(unsigned int i = 0; i < selectedUnits.size(); i++) {
Unit *unit = selectedUnits[i];
XmlNode *selectedUnitsNode = selectionNode->addChild("selectedUnits");
selectedUnitsNode->addAttribute("id",intToStr(unit->getId()), mapTagReplacements);
}
// UnitContainer groups[maxGroups];
for(unsigned int x = 0; x < maxGroups; ++x) {
XmlNode *groupsNode = selectionNode->addChild("groups");
for(unsigned int i = 0; i < selectedUnits.size(); i++) {
Unit *unit = selectedUnits[i];
XmlNode *selectedUnitsNode = groupsNode->addChild("selectedUnits");
selectedUnitsNode->addAttribute("id",intToStr(unit->getId()), mapTagReplacements);
}
}
// Gui *gui;
}
}}//end namespace

View File

@ -79,6 +79,8 @@ public:
virtual void unitEvent(UnitObserver::Event event, const Unit *unit);
virtual void saveGame(XmlNode *rootNode) const;
};
}}//end namespace

View File

@ -98,4 +98,37 @@ string NetworkCommand::toString() const {
return result;
}
void NetworkCommand::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *networkCommandNode = rootNode->addChild("NetworkCommand");
// int16 networkCommandType;
networkCommandNode->addAttribute("networkCommandType",intToStr(networkCommandType), mapTagReplacements);
// int32 unitId;
networkCommandNode->addAttribute("unitId",intToStr(unitId), mapTagReplacements);
// int16 unitTypeId;
networkCommandNode->addAttribute("unitTypeId",intToStr(unitTypeId), mapTagReplacements);
// int16 commandTypeId;
networkCommandNode->addAttribute("commandTypeId",intToStr(commandTypeId), mapTagReplacements);
// int16 positionX;
networkCommandNode->addAttribute("positionX",intToStr(positionX), mapTagReplacements);
// int16 positionY;
networkCommandNode->addAttribute("positionY",intToStr(positionY), mapTagReplacements);
// int32 targetId;
networkCommandNode->addAttribute("targetId",intToStr(targetId), mapTagReplacements);
// int8 wantQueue;
networkCommandNode->addAttribute("wantQueue",intToStr(wantQueue), mapTagReplacements);
// int8 fromFactionIndex;
networkCommandNode->addAttribute("fromFactionIndex",intToStr(fromFactionIndex), mapTagReplacements);
// uint16 unitFactionUnitCount;
networkCommandNode->addAttribute("unitFactionUnitCount",intToStr(unitFactionUnitCount), mapTagReplacements);
// int8 unitFactionIndex;
networkCommandNode->addAttribute("unitFactionIndex",intToStr(unitFactionIndex), mapTagReplacements);
// int8 commandStateType;
networkCommandNode->addAttribute("commandStateType",intToStr(commandStateType), mapTagReplacements);
// int32 commandStateValue;
networkCommandNode->addAttribute("commandStateValue",intToStr(commandStateValue), mapTagReplacements);
// int32 unitCommandGroupId;
networkCommandNode->addAttribute("unitCommandGroupId",intToStr(unitCommandGroupId), mapTagReplacements);
}
}}//end namespace

View File

@ -130,6 +130,9 @@ public:
void preprocessNetworkCommand(World *world);
string toString() const;
void saveGame(XmlNode *rootNode);
};
#pragma pack(pop)

View File

@ -140,4 +140,31 @@ std::string Command::toString() const {
return result;
}
void Command::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *commandNode = rootNode->addChild("Command");
// const CommandType *commandType;
if(commandType != NULL) {
commandNode->addAttribute("commandType",commandType->getName(), mapTagReplacements);
}
// Vec2i originalPos;
commandNode->addAttribute("originalPos",originalPos.getString(), mapTagReplacements);
// Vec2i pos;
commandNode->addAttribute("pos",pos.getString(), mapTagReplacements);
// UnitReference unitRef; //target unit, used to move and attack optionally
unitRef.saveGame(commandNode);
// CardinalDir facing; // facing, for build command
commandNode->addAttribute("facing",intToStr(facing), mapTagReplacements);
// const UnitType *unitType; //used for build
if(unitType != NULL) {
commandNode->addAttribute("unitType",unitType->getName(), mapTagReplacements);
}
// CommandStateType stateType;
commandNode->addAttribute("stateType",intToStr(stateType), mapTagReplacements);
// int stateValue;
commandNode->addAttribute("stateValue",intToStr(stateValue), mapTagReplacements);
// int unitCommandGroupId;
commandNode->addAttribute("unitCommandGroupId",intToStr(unitCommandGroupId), mapTagReplacements);
}
}}//end namespace

View File

@ -86,6 +86,8 @@ public:
int getUnitCommandGroupId() const { return unitCommandGroupId; }
std::string toString() const;
void saveGame(XmlNode *rootNode);
};
}}//end namespace

View File

@ -1761,4 +1761,77 @@ std::string Faction::toString() const {
return result;
}
void Faction::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *factionNode = rootNode->addChild("Faction");
// UpgradeManager upgradeManager;
upgradeManager.saveGame(factionNode);
// Resources resources;
for(unsigned int i = 0; i < resources.size(); ++i) {
Resource &resource = resources[i];
resource.saveGame(factionNode);
}
// Store store;
// Allies allies;
for(unsigned int i = 0; i < allies.size(); ++i) {
Faction *ally = allies[i];
XmlNode *allyNode = factionNode->addChild("Ally");
allyNode->addAttribute("startlocationindex",intToStr(ally->getStartLocationIndex()), mapTagReplacements);
}
// Mutex *unitsMutex;
// Units units;
for(unsigned int i = 0; i < units.size(); ++i) {
Unit *unit = units[i];
unit->saveGame(factionNode);
}
// UnitMap unitMap;
// World *world;
// ScriptManager *scriptManager;
//
// ControlType control;
factionNode->addAttribute("control",intToStr(control), mapTagReplacements);
// Texture2D *texture;
// FactionType *factionType;
factionNode->addAttribute("factiontype",factionType->getName(), mapTagReplacements);
// int index;
factionNode->addAttribute("index",intToStr(index), mapTagReplacements);
// int teamIndex;
factionNode->addAttribute("teamIndex",intToStr(teamIndex), mapTagReplacements);
// int startLocationIndex;
factionNode->addAttribute("startLocationIndex",intToStr(startLocationIndex), mapTagReplacements);
// bool thisFaction;
factionNode->addAttribute("thisFaction",intToStr(thisFaction), mapTagReplacements);
// bool factionDisconnectHandled;
//
// bool cachingDisabled;
// std::map<Vec2i,int> cacheResourceTargetList;
for(std::map<Vec2i,int>::iterator iterMap = cacheResourceTargetList.begin();
iterMap != cacheResourceTargetList.end(); ++iterMap) {
XmlNode *cacheResourceTargetListNode = factionNode->addChild("cacheResourceTargetList");
cacheResourceTargetListNode->addAttribute("key",iterMap->first.getString(), mapTagReplacements);
cacheResourceTargetListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
}
// std::map<Vec2i,bool> cachedCloseResourceTargetLookupList;
for(std::map<Vec2i,bool>::iterator iterMap = cachedCloseResourceTargetLookupList.begin();
iterMap != cachedCloseResourceTargetLookupList.end(); ++iterMap) {
XmlNode *cachedCloseResourceTargetLookupListNode = factionNode->addChild("cachedCloseResourceTargetLookupList");
cachedCloseResourceTargetLookupListNode->addAttribute("key",iterMap->first.getString(), mapTagReplacements);
cachedCloseResourceTargetLookupListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
}
// RandomGen random;
factionNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements);
// FactionThread *workerThread;
//
// std::map<int,SwitchTeamVote> switchTeamVotes;
// int currentSwitchTeamVoteFactionIndex;
factionNode->addAttribute("currentSwitchTeamVoteFactionIndex",intToStr(currentSwitchTeamVoteFactionIndex), mapTagReplacements);
// set<int> livingUnits;
// set<Unit*> livingUnitsp;
}
}}//end namespace

View File

@ -256,6 +256,8 @@ public:
std::string toString() const;
void saveGame(XmlNode *rootNode);
private:
void resetResourceAmount(const ResourceType *rt);
};

View File

@ -101,4 +101,18 @@ bool Resource::decAmount(int i) {
return true;
}
void Resource::saveGame(XmlNode *rootNode) const {
std::map<string,string> mapTagReplacements;
XmlNode *resourceNode = rootNode->addChild("Resource");
// int amount;
resourceNode->addAttribute("amount",intToStr(amount), mapTagReplacements);
// const ResourceType *type;
resourceNode->addAttribute("type",type->getName(), mapTagReplacements);
// Vec2i pos;
resourceNode->addAttribute("pos",pos.getString(), mapTagReplacements);
// int balance;
resourceNode->addAttribute("balance",intToStr(balance), mapTagReplacements);
}
}}//end namespace

View File

@ -14,10 +14,12 @@
#include <string>
#include "vec.h"
#include "platform_common.h"
#include "xml_parser.h"
#include "leak_dumper.h"
using std::string;
using std::map;
using Shared::Xml::XmlNode;
namespace Glest{ namespace Game{
@ -55,6 +57,8 @@ public:
void setBalance(int balance);
bool decAmount(int i);
void saveGame(XmlNode *rootNode) const;
};
}}// end namespace

View File

@ -157,6 +157,29 @@ std::string UnitPathBasic::toString() const {
return result;
}
void UnitPathBasic::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *unitPathBasicNode = rootNode->addChild("UnitPathBasic");
// int blockCount;
unitPathBasicNode->addAttribute("blockCount",intToStr(blockCount), mapTagReplacements);
// vector<Vec2i> pathQueue;
for(unsigned int i = 0; i < pathQueue.size(); ++i) {
Vec2i &vec = pathQueue[i];
XmlNode *pathQueueNode = unitPathBasicNode->addChild("pathQueue");
pathQueueNode->addAttribute("vec",vec.getString(), mapTagReplacements);
}
// vector<Vec2i> lastPathCacheQueue;
for(unsigned int i = 0; i < lastPathCacheQueue.size(); ++i) {
Vec2i &vec = lastPathCacheQueue[i];
XmlNode *lastPathCacheQueueNode = unitPathBasicNode->addChild("lastPathCacheQueue");
lastPathCacheQueueNode->addAttribute("vec",vec.getString(), mapTagReplacements);
}
}
// =====================================================
// class UnitPath
// =====================================================
@ -217,6 +240,16 @@ Unit *UnitReference::getUnit() const{
return NULL;
}
void UnitReference::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *unitRefNode = rootNode->addChild("UnitReference");
unitRefNode->addAttribute("id",intToStr(id), mapTagReplacements);
if(faction != NULL) {
unitRefNode->addAttribute("faction",intToStr(faction->getIndex()), mapTagReplacements);
}
}
const bool checkMemory = false;
static map<void *,int> memoryObjectList;
@ -257,6 +290,29 @@ UnitAttackBoostEffect::~UnitAttackBoostEffect() {
upst = NULL;
}
void UnitAttackBoostEffect::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *unitAttackBoostEffectNode = rootNode->addChild("UnitAttackBoostEffect");
// const AttackBoost *boost;
if(boost != NULL) {
boost->saveGame(unitAttackBoostEffectNode);
}
// const Unit *source;
if(source != NULL) {
unitAttackBoostEffectNode->addAttribute("source",intToStr(source->getId()), mapTagReplacements);
}
// UnitParticleSystem *ups;
if(ups != NULL) {
ups->saveGame(unitAttackBoostEffectNode);
}
// UnitParticleSystemType *upst;
if(upst != NULL) {
upst->saveGame(unitAttackBoostEffectNode);
}
}
UnitAttackBoostEffectOriginator::UnitAttackBoostEffectOriginator() {
skillType = NULL;
currentAppliedEffect = NULL;
@ -267,6 +323,24 @@ UnitAttackBoostEffectOriginator::~UnitAttackBoostEffectOriginator() {
currentAppliedEffect = NULL;
}
void UnitAttackBoostEffectOriginator::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *unitAttackBoostEffectOriginatorNode = rootNode->addChild("UnitAttackBoostEffectOriginator");
// const SkillType *skillType;
if(skillType != NULL) {
unitAttackBoostEffectOriginatorNode->addAttribute("skillType",skillType->getName(), mapTagReplacements);
}
// std::vector<int> currentAttackBoostUnits;
for(unsigned int i = 0; i < currentAttackBoostUnits.size(); ++i) {
XmlNode *currentAttackBoostUnitsNode = unitAttackBoostEffectOriginatorNode->addChild("currentAttackBoostUnits");
currentAttackBoostUnitsNode->addAttribute("value",intToStr(currentAttackBoostUnits[i]), mapTagReplacements);
}
// UnitAttackBoostEffect *currentAppliedEffect;
if(currentAppliedEffect != NULL) {
currentAppliedEffect->saveGame(unitAttackBoostEffectOriginatorNode);
}
}
// =====================================================
// class Unit
@ -3353,4 +3427,228 @@ std::string Unit::toString() const {
return result;
}
void Unit::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *unitNode = rootNode->addChild("Unit");
// const int id;
unitNode->addAttribute("id",intToStr(id), mapTagReplacements);
// int hp;
unitNode->addAttribute("hp",intToStr(hp), mapTagReplacements);
// int ep;
unitNode->addAttribute("ep",intToStr(ep), mapTagReplacements);
// int loadCount;
unitNode->addAttribute("loadCount",intToStr(loadCount), mapTagReplacements);
// int deadCount;
unitNode->addAttribute("deadCount",intToStr(deadCount), mapTagReplacements);
// float progress; //between 0 and 1
unitNode->addAttribute("progress",floatToStr(progress), mapTagReplacements);
// float lastAnimProgress; //between 0 and 1
unitNode->addAttribute("lastAnimProgress",floatToStr(lastAnimProgress), mapTagReplacements);
// float animProgress; //between 0 and 1
unitNode->addAttribute("animProgress",floatToStr(animProgress), mapTagReplacements);
// float highlight;
unitNode->addAttribute("highlight",floatToStr(highlight), mapTagReplacements);
// int progress2;
unitNode->addAttribute("progress2",intToStr(progress2), mapTagReplacements);
// int kills;
unitNode->addAttribute("kills",intToStr(kills), mapTagReplacements);
// int enemyKills;
unitNode->addAttribute("enemyKills",intToStr(enemyKills), mapTagReplacements);
// UnitReference targetRef;
targetRef.saveGame(unitNode);
//
// Field currField;
unitNode->addAttribute("currField",intToStr(currField), mapTagReplacements);
// Field targetField;
unitNode->addAttribute("targetField",intToStr(targetField), mapTagReplacements);
// const Level *level;
if(level != NULL) {
level->saveGame(unitNode);
}
// Vec2i pos;
unitNode->addAttribute("pos",pos.getString(), mapTagReplacements);
// Vec2i lastPos;
unitNode->addAttribute("lastPos",lastPos.getString(), mapTagReplacements);
// Vec2i targetPos; //absolute target pos
unitNode->addAttribute("targetPos",targetPos.getString(), mapTagReplacements);
// Vec3f targetVec;
unitNode->addAttribute("targetVec",targetVec.getString(), mapTagReplacements);
// Vec2i meetingPos;
unitNode->addAttribute("meetingPos",meetingPos.getString(), mapTagReplacements);
//
// float lastRotation; //in degrees
unitNode->addAttribute("lastRotation",floatToStr(lastRotation), mapTagReplacements);
// float targetRotation;
unitNode->addAttribute("targetRotation",floatToStr(targetRotation), mapTagReplacements);
// float rotation;
unitNode->addAttribute("rotation",floatToStr(rotation), mapTagReplacements);
// float targetRotationZ;
unitNode->addAttribute("targetRotationZ",floatToStr(targetRotationZ), mapTagReplacements);
// float targetRotationX;
unitNode->addAttribute("targetRotationX",floatToStr(targetRotationX), mapTagReplacements);
// float rotationZ;
unitNode->addAttribute("rotationZ",floatToStr(rotationZ), mapTagReplacements);
// float rotationX;
unitNode->addAttribute("rotationX",floatToStr(rotationX), mapTagReplacements);
// const UnitType *type;
unitNode->addAttribute("type",type->getName(), mapTagReplacements);
// const ResourceType *loadType;
if(loadType != NULL) {
unitNode->addAttribute("loadType",loadType->getName(), mapTagReplacements);
}
// const SkillType *currSkill;
if(currSkill != NULL) {
unitNode->addAttribute("currSkill",currSkill->getName(), mapTagReplacements);
}
// int lastModelIndexForCurrSkillType;
unitNode->addAttribute("lastModelIndexForCurrSkillType",intToStr(lastModelIndexForCurrSkillType), mapTagReplacements);
// int animationRandomCycleCount;
unitNode->addAttribute("animationRandomCycleCount",intToStr(animationRandomCycleCount), mapTagReplacements);
//
// bool toBeUndertaken;
unitNode->addAttribute("toBeUndertaken",intToStr(toBeUndertaken), mapTagReplacements);
// bool alive;
unitNode->addAttribute("alive",intToStr(alive), mapTagReplacements);
// bool showUnitParticles;
unitNode->addAttribute("showUnitParticles",intToStr(showUnitParticles), mapTagReplacements);
// Faction *faction;
// ParticleSystem *fire;
if(fire != NULL) {
fire->saveGame(unitNode);
}
// TotalUpgrade totalUpgrade;
totalUpgrade.saveGame(unitNode);
// Map *map;
//
// UnitPathInterface *unitPath;
unitPath->saveGame(unitNode);
// WaypointPath waypointPath;
//
// Commands commands;
for(Commands::iterator it = commands.begin(); it != commands.end(); ++it) {
(*it)->saveGame(unitNode);
}
// Observers observers;
for(Observers::iterator it = observers.begin(); it != observers.end(); ++it) {
(*it)->saveGame(unitNode);
}
// vector<UnitParticleSystem*> unitParticleSystems;
for(unsigned int i = 0; i < unitParticleSystems.size(); ++i) {
UnitParticleSystem *ups= unitParticleSystems[i];
ups->saveGame(unitNode);
}
// vector<UnitParticleSystemType*> queuedUnitParticleSystemTypes;
for(unsigned int i = 0; i < queuedUnitParticleSystemTypes.size(); ++i) {
UnitParticleSystemType *upst= queuedUnitParticleSystemTypes[i];
upst->saveGame(unitNode);
}
// UnitParticleSystems damageParticleSystems;
for(unsigned int i = 0; i < damageParticleSystems.size(); ++i) {
UnitParticleSystem *ups= damageParticleSystems[i];
ups->saveGame(unitNode);
}
// std::map<int, UnitParticleSystem *> damageParticleSystemsInUse;
for(std::map<int, UnitParticleSystem *>::const_iterator iterMap = damageParticleSystemsInUse.begin();
iterMap != damageParticleSystemsInUse.end(); ++iterMap) {
XmlNode *damageParticleSystemsInUseNode = unitNode->addChild("damageParticleSystemsInUse");
damageParticleSystemsInUseNode->addAttribute("key",intToStr(iterMap->first), mapTagReplacements);
iterMap->second->saveGame(damageParticleSystemsInUseNode);
}
// vector<ParticleSystem*> fireParticleSystems;
for(unsigned int i = 0; i < fireParticleSystems.size(); ++i) {
ParticleSystem *ps= fireParticleSystems[i];
ps->saveGame(unitNode);
}
// vector<UnitParticleSystem*> smokeParticleSystems;
for(unsigned int i = 0; i < smokeParticleSystems.size(); ++i) {
UnitParticleSystem *ups= smokeParticleSystems[i];
ups->saveGame(unitNode);
}
// CardinalDir modelFacing;
unitNode->addAttribute("modelFacing",intToStr(modelFacing), mapTagReplacements);
// std::string lastSynchDataString;
unitNode->addAttribute("lastSynchDataString",lastSynchDataString, mapTagReplacements);
// std::string lastFile;
unitNode->addAttribute("lastFile",lastFile, mapTagReplacements);
// int lastLine;
unitNode->addAttribute("lastLine",intToStr(lastLine), mapTagReplacements);
// std::string lastSource;
unitNode->addAttribute("lastSource",lastSource, mapTagReplacements);
// int lastRenderFrame;
unitNode->addAttribute("lastRenderFrame",intToStr(lastRenderFrame), mapTagReplacements);
// bool visible;
unitNode->addAttribute("visible",intToStr(visible), mapTagReplacements);
// int retryCurrCommandCount;
unitNode->addAttribute("retryCurrCommandCount",intToStr(retryCurrCommandCount), mapTagReplacements);
// Vec3f screenPos;
unitNode->addAttribute("screenPos",screenPos.getString(), mapTagReplacements);
// string currentUnitTitle;
unitNode->addAttribute("currentUnitTitle",currentUnitTitle, mapTagReplacements);
//
// bool inBailOutAttempt;
unitNode->addAttribute("inBailOutAttempt",intToStr(inBailOutAttempt), mapTagReplacements);
// //std::vector<std::pair<Vec2i,Chrono> > badHarvestPosList;
// std::map<Vec2i,int> badHarvestPosList;
for(std::map<Vec2i,int>::const_iterator iterMap = badHarvestPosList.begin();
iterMap != badHarvestPosList.end(); ++iterMap) {
XmlNode *badHarvestPosListNode = unitNode->addChild("badHarvestPosList");
badHarvestPosListNode->addAttribute("key",iterMap->first.getString(), mapTagReplacements);
badHarvestPosListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
}
// //time_t lastBadHarvestListPurge;
// std::pair<Vec2i,int> lastHarvestResourceTarget;
XmlNode *lastHarvestResourceTargetNode = unitNode->addChild("lastHarvestResourceTarget");
lastHarvestResourceTargetNode->addAttribute("key",lastHarvestResourceTarget.first.getString(), mapTagReplacements);
lastHarvestResourceTargetNode->addAttribute("value",intToStr(lastHarvestResourceTarget.second), mapTagReplacements);
// //std::pair<Vec2i,std::vector<Vec2i> > currentTargetPathTaken;
// static Game *game;
//
// bool ignoreCheckCommand;
unitNode->addAttribute("ignoreCheckCommand",intToStr(ignoreCheckCommand), mapTagReplacements);
// uint32 lastStuckFrame;
unitNode->addAttribute("lastStuckFrame",intToStr(lastStuckFrame), mapTagReplacements);
// Vec2i lastStuckPos;
unitNode->addAttribute("lastStuckPos",lastStuckPos.getString(), mapTagReplacements);
// uint32 lastPathfindFailedFrame;
unitNode->addAttribute("lastPathfindFailedFrame",intToStr(lastPathfindFailedFrame), mapTagReplacements);
// Vec2i lastPathfindFailedPos;
unitNode->addAttribute("lastPathfindFailedPos",lastPathfindFailedPos.getString(), mapTagReplacements);
// bool usePathfinderExtendedMaxNodes;
unitNode->addAttribute("usePathfinderExtendedMaxNodes",intToStr(usePathfinderExtendedMaxNodes), mapTagReplacements);
// int maxQueuedCommandDisplayCount;
unitNode->addAttribute("maxQueuedCommandDisplayCount",intToStr(maxQueuedCommandDisplayCount), mapTagReplacements);
// UnitAttackBoostEffectOriginator currentAttackBoostOriginatorEffect;
currentAttackBoostOriginatorEffect.saveGame(unitNode);
// std::vector<UnitAttackBoostEffect *> currentAttackBoostEffects;
for(unsigned int i = 0; i < currentAttackBoostEffects.size(); ++i) {
UnitAttackBoostEffect *uabe= currentAttackBoostEffects[i];
uabe->saveGame(unitNode);
}
// Mutex *mutexCommands;
//
// //static Mutex mutexDeletedUnits;
// //static std::map<void *,bool> deletedUnits;
//
// bool changedActiveCommand;
unitNode->addAttribute("changedActiveCommand",intToStr(changedActiveCommand), mapTagReplacements);
// int lastAttackerUnitId;
unitNode->addAttribute("lastAttackerUnitId",intToStr(lastAttackerUnitId), mapTagReplacements);
// int lastAttackedUnitId;
unitNode->addAttribute("lastAttackedUnitId",intToStr(lastAttackedUnitId), mapTagReplacements);
// CauseOfDeathType causeOfDeath;
unitNode->addAttribute("causeOfDeath",intToStr(causeOfDeath), mapTagReplacements);
}
}}//end namespace

View File

@ -88,6 +88,8 @@ public:
public:
virtual ~UnitObserver() {}
virtual void unitEvent(Event event, const Unit *unit)=0;
virtual void saveGame(XmlNode *rootNode) const = 0;
};
// =====================================================
@ -107,6 +109,8 @@ public:
int getUnitId() const { return id; }
Faction *getUnitFaction() const { return faction; }
void saveGame(XmlNode *rootNode);
};
class UnitPathInterface {
@ -133,6 +137,8 @@ public:
virtual void setMap(Map *value) = 0;
virtual Map * getMap() = 0;
virtual void saveGame(XmlNode *rootNode) = 0;
};
class UnitPathBasic : public UnitPathInterface {
@ -179,6 +185,8 @@ public:
virtual Map * getMap() { return map; }
virtual std::string toString() const;
virtual void saveGame(XmlNode *rootNode);
};
// =====================================================
@ -235,6 +243,8 @@ public:
virtual Map * getMap() { return map; }
virtual std::string toString() const;
virtual void saveGame(XmlNode *rootNode) {};
};
class WaypointPath : public list<Vec2i> {
@ -264,6 +274,7 @@ public:
UnitParticleSystem *ups;
UnitParticleSystemType *upst;
virtual void saveGame(XmlNode *rootNode);
};
class UnitAttackBoostEffectOriginator {
@ -275,6 +286,8 @@ public:
const SkillType *skillType;
std::vector<int> currentAttackBoostUnits;
UnitAttackBoostEffect *currentAppliedEffect;
virtual void saveGame(XmlNode *rootNode);
};
class Unit : public BaseColorPickEntity, ValueCheckerVault {
@ -627,6 +640,8 @@ public:
void updateTimedParticles();
virtual string getUniquePickName() const;
void saveGame(XmlNode *rootNode);
private:
float computeHeight(const Vec2i &pos) const;
void calculateXZRotation();

View File

@ -65,6 +65,14 @@ std::string Upgrade::toString() const {
return result;
}
void Upgrade::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *upgradeNode = rootNode->addChild("Upgrade");
upgradeNode->addAttribute("state",intToStr(state), mapTagReplacements);
upgradeNode->addAttribute("factionIndex",intToStr(factionIndex), mapTagReplacements);
upgradeNode->addAttribute("type",type->getName(), mapTagReplacements);
}
// =====================================================
// class UpgradeManager
@ -226,4 +234,18 @@ std::string UpgradeManager::toString() const {
return result;
}
void UpgradeManager::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *upgrademanagerNode = rootNode->addChild("UpgradeManager");
for(unsigned int i = 0; i < upgrades.size(); ++i) {
upgrades[i]->saveGame(upgrademanagerNode);
}
// Upgrades upgrades;
// UgradesLookup upgradesLookup;
}
}}// end namespace

View File

@ -15,10 +15,12 @@
#include <vector>
#include <string>
#include <map>
#include "xml_parser.h"
#include "leak_dumper.h"
using std::vector;
using std::map;
using Shared::Xml::XmlNode;
namespace Glest { namespace Game {
@ -62,6 +64,8 @@ private:
void setState(UpgradeState state);
std::string toString() const;
void saveGame(XmlNode *rootNode);
};
@ -90,6 +94,7 @@ public:
void computeTotalUpgrade(const Unit *unit, TotalUpgrade *totalUpgrade) const;
std::string toString() const;
void saveGame(XmlNode *rootNode);
};
}}//end namespace

View File

@ -10,11 +10,33 @@
// ==============================================================
#include "damage_multiplier.h"
#include "conversion.h"
#include "leak_dumper.h"
using namespace Shared::Util;
namespace Glest{ namespace Game{
void AttackType::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *attackTypeNode = rootNode->addChild("AttackType");
// string name;
attackTypeNode->addAttribute("name",name, mapTagReplacements);
// int id;
attackTypeNode->addAttribute("id",intToStr(id), mapTagReplacements);
}
void ArmorType::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *armorTypeNode = rootNode->addChild("ArmorType");
// string name;
armorTypeNode->addAttribute("name",name, mapTagReplacements);
// int id;
armorTypeNode->addAttribute("id",intToStr(id), mapTagReplacements);
}
// =====================================================
// class DamageMultiplierTable
// =====================================================
@ -48,4 +70,21 @@ void DamageMultiplierTable::setDamageMultiplier(const AttackType *att, const Arm
values[attackTypeCount*art->getId()+att->getId()]= value;
}
void DamageMultiplierTable::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *damageMultiplierTableNode = rootNode->addChild("DamageMultiplierTable");
// float *values;
// int attackTypeCount;
// int armorTypeCount;
damageMultiplierTableNode->addAttribute("attackTypeCount",intToStr(attackTypeCount), mapTagReplacements);
damageMultiplierTableNode->addAttribute("armorTypeCount",intToStr(armorTypeCount), mapTagReplacements);
int valueCount= attackTypeCount * armorTypeCount;
for(unsigned int i=0; i < valueCount; ++i) {
XmlNode *valuesNode = damageMultiplierTableNode->addChild("values");
valuesNode->addAttribute("value",intToStr(values[i]), mapTagReplacements);
}
}
}}//end namespaces

View File

@ -13,9 +13,11 @@
#define _GLEST_GAME_DAMAGEMULTIPLIER_H_
#include <string>
#include "xml_parser.h"
#include "leak_dumper.h"
using std::string;
using Shared::Xml::XmlNode;
namespace Glest{ namespace Game{
@ -23,7 +25,7 @@ namespace Glest{ namespace Game{
// class AttackType
// ===============================
class AttackType{
class AttackType {
private:
string name;
int id;
@ -37,6 +39,8 @@ public:
void setName(const string &name) {this->name= name;}
void setId(int id) {this->id= id;}
void saveGame(XmlNode *rootNode);
};
// ===============================
@ -57,6 +61,8 @@ public:
void setName(const string &name) {this->name= name;}
void setId(int id) {this->id= id;}
void saveGame(XmlNode *rootNode);
};
// =====================================================
@ -66,7 +72,7 @@ public:
/// armor types and vice-versa
// =====================================================
class DamageMultiplierTable{
class DamageMultiplierTable {
private:
float *values;
int attackTypeCount;
@ -79,6 +85,8 @@ public:
void init(int attackTypeCount, int armorTypeCount);
float getDamageMultiplier(const AttackType *att, const ArmorType *art) const;
void setDamageMultiplier(const AttackType *att, const ArmorType *art, float value);
void saveGame(XmlNode *rootNode);
};
}}//end namespace

View File

@ -35,6 +35,13 @@ DisplayableType::DisplayableType(){
image= NULL;
}
void DisplayableType::saveGame(XmlNode *rootNode) const {
std::map<string,string> mapTagReplacements;
XmlNode *displayableTypeNode = rootNode->addChild("DisplayableType");
displayableTypeNode->addAttribute("name",name, mapTagReplacements);
}
// =====================================================
// class RequirableType
// =====================================================
@ -71,6 +78,28 @@ string RequirableType::getReqDesc() const{
}
}
void RequirableType::saveGame(XmlNode *rootNode) const {
DisplayableType::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *requirableTypeNode = rootNode->addChild("RequirableType");
// UnitReqs unitReqs; //needed units
for(unsigned int i = 0; i < unitReqs.size(); ++i) {
const UnitType *ut = unitReqs[i];
XmlNode *unitReqsNode = requirableTypeNode->addChild("unitReqs");
unitReqsNode->addAttribute("name",ut->getName(), mapTagReplacements);
}
// UpgradeReqs upgradeReqs; //needed upgrades
for(unsigned int i = 0; i < upgradeReqs.size(); ++i) {
const UpgradeType* ut = upgradeReqs[i];
ut->saveGame(requirableTypeNode);
}
}
// =====================================================
// class ProducibleType
// =====================================================
@ -115,4 +144,20 @@ string ProducibleType::getReqDesc() const{
return str;
}
void ProducibleType::saveGame(XmlNode *rootNode) const {
RequirableType::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *producibleTypeNode = rootNode->addChild("ProducibleType");
// Costs costs;
for(unsigned int i = 0; i < costs.size(); ++i) {
const Resource &res = costs[i];
res.saveGame(producibleTypeNode);
}
// Texture2D *cancelImage;
// int productionTime;
producibleTypeNode->addAttribute("productionTime",intToStr(productionTime), mapTagReplacements);
}
}}//end namespace

View File

@ -39,7 +39,7 @@ class ResourceType;
/// Base class for anything that has a name and a portrait
// =====================================================
class DisplayableType{
class DisplayableType {
protected:
string name; //name
Texture2D *image; //portrait
@ -51,6 +51,8 @@ public:
//get
string getName() const {return name;}
const Texture2D *getImage() const {return image;}
virtual void saveGame(XmlNode *rootNode) const;
};
@ -78,6 +80,8 @@ public:
//other
virtual string getReqDesc() const;
virtual void saveGame(XmlNode *rootNode) const;
};
@ -87,7 +91,7 @@ public:
/// Base class for anything that can be produced
// =====================================================
class ProducibleType: public RequirableType{
class ProducibleType: public RequirableType {
private:
typedef vector<Resource> Costs;
@ -111,6 +115,8 @@ public:
void checkCostStrings(TechTree *techTree);
virtual string getReqDesc() const;
virtual void saveGame(XmlNode *rootNode) const;
};
}}//end namespace

View File

@ -799,4 +799,56 @@ std::string FactionType::toString() const {
return result;
}
void FactionType::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *factionTypeNode = rootNode->addChild("FactionType");
// string name;
factionTypeNode->addAttribute("name",name, mapTagReplacements);
// UnitTypes unitTypes;
for(unsigned int i = 0; i < unitTypes.size(); ++i) {
XmlNode *unitTypesNode = factionTypeNode->addChild("unitTypes");
unitTypesNode->addAttribute("name",unitTypes[i].getName(), mapTagReplacements);
}
// UpgradeTypes upgradeTypes;
for(unsigned int i = 0; i < upgradeTypes.size(); ++i) {
XmlNode *upgradeTypesNode = factionTypeNode->addChild("upgradeTypes");
upgradeTypesNode->addAttribute("name",upgradeTypes[i].getName(), mapTagReplacements);
}
// StartingUnits startingUnits;
for(unsigned int i = 0; i < startingUnits.size(); ++i) {
XmlNode *startingUnitsNode = factionTypeNode->addChild("startingUnits");
startingUnitsNode->addAttribute("name",startingUnits[i].first->getName(), mapTagReplacements);
startingUnitsNode->addAttribute("count",intToStr(startingUnits[i].second), mapTagReplacements);
}
// Resources startingResources;
for(unsigned int i = 0; i < startingResources.size(); ++i) {
startingResources[i].saveGame(factionTypeNode);
}
// StrSound *music;
// FactionPersonalityType personalityType;
factionTypeNode->addAttribute("personalityType",intToStr(personalityType), mapTagReplacements);
// std::map<AIBehaviorUnitCategory, std::vector<PairPUnitTypeInt> > mapAIBehaviorUnitCategories;
for(std::map<AIBehaviorUnitCategory, std::vector<PairPUnitTypeInt> >::iterator iterMap = mapAIBehaviorUnitCategories.begin();
iterMap != mapAIBehaviorUnitCategories.end(); ++iterMap) {
std::vector<PairPUnitTypeInt> &vct = iterMap->second;
for(unsigned int i = 0; i < vct.size(); ++i) {
PairPUnitTypeInt &item = vct[i];
XmlNode *mapAIBehaviorUnitCategoriesNode = factionTypeNode->addChild("mapAIBehaviorUnitCategories");
mapAIBehaviorUnitCategoriesNode->addAttribute("key",intToStr(iterMap->first), mapTagReplacements);
mapAIBehaviorUnitCategoriesNode->addAttribute("unitType",item.first->getName(), mapTagReplacements);
mapAIBehaviorUnitCategoriesNode->addAttribute("count",intToStr(item.second), mapTagReplacements);
}
}
// std::vector<const UpgradeType*> vctAIBehaviorUpgrades;
for(unsigned int i = 0; i < vctAIBehaviorUpgrades.size(); ++i) {
vctAIBehaviorUpgrades[i]->saveGame(factionTypeNode);
}
}
}}//end namespace

View File

@ -90,6 +90,8 @@ public:
void deletePixels();
bool factionUsesResourceType(const ResourceType *rt) const;
void saveGame(XmlNode *rootNode);
};
}}//end namespace

View File

@ -199,4 +199,34 @@ void ResourceType::deletePixels() {
}
}
void ResourceType::saveGame(XmlNode *rootNode) {
DisplayableType::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *resourceTypeNode = rootNode->addChild("ResourceType");
// ResourceClass resourceClass;
resourceTypeNode->addAttribute("resourceClass",intToStr(resourceClass), mapTagReplacements);
// int tilesetObject; //used only if class==rcTileset
resourceTypeNode->addAttribute("tilesetObject",intToStr(tilesetObject), mapTagReplacements);
// int resourceNumber; //used only if class==rcTech, resource number in the map
resourceTypeNode->addAttribute("resourceNumber",intToStr(resourceNumber), mapTagReplacements);
// int interval; //used only if class==rcConsumable
resourceTypeNode->addAttribute("interval",intToStr(interval), mapTagReplacements);
// int defResPerPatch; //used only if class==rcTileset || class==rcTech
resourceTypeNode->addAttribute("defResPerPatch",intToStr(defResPerPatch), mapTagReplacements);
// bool recoup_cost;
resourceTypeNode->addAttribute("recoup_cost",intToStr(recoup_cost), mapTagReplacements);
//
// Model *model;
if(model != NULL) {
resourceTypeNode->addAttribute("model",model->getFileName(), mapTagReplacements);
}
// ObjectParticleSystemTypes particleTypes;
for(unsigned int i = 0; i < particleTypes.size(); ++i) {
ObjectParticleSystemType *opst = particleTypes[i];
opst->saveGame(resourceTypeNode);
}
}
}}//end namespace

View File

@ -72,6 +72,8 @@ public:
static ResourceClass strToRc(const string &s);
void deletePixels();
void saveGame(XmlNode *rootNode);
};
}} //end namespace

View File

@ -205,6 +205,41 @@ string AttackBoost::getDesc() const{
return "";
}
void AttackBoost::saveGame(XmlNode *rootNode) const {
std::map<string,string> mapTagReplacements;
XmlNode *attackBoostNode = rootNode->addChild("AttackBoost");
// bool enabled;
attackBoostNode->addAttribute("enabled",intToStr(enabled), mapTagReplacements);
// bool allowMultipleBoosts;
attackBoostNode->addAttribute("allowMultipleBoosts",intToStr(allowMultipleBoosts), mapTagReplacements);
// int radius;
attackBoostNode->addAttribute("radius",intToStr(radius), mapTagReplacements);
// AttackBoostTargetType targetType;
attackBoostNode->addAttribute("targetType",intToStr(targetType), mapTagReplacements);
// vector<const UnitType *> boostUnitList;
for(unsigned int i = 0; i < boostUnitList.size(); ++i) {
const UnitType *ut = boostUnitList[i];
XmlNode *unitTypeNode = attackBoostNode->addChild("UnitType");
unitTypeNode->addAttribute("name",ut->getName(), mapTagReplacements);
}
// UpgradeTypeBase boostUpgrade;
boostUpgrade.saveGame(attackBoostNode);
// UnitParticleSystemType *unitParticleSystemTypeForSourceUnit;
if(unitParticleSystemTypeForSourceUnit != NULL) {
unitParticleSystemTypeForSourceUnit->saveGame(attackBoostNode);
}
// UnitParticleSystemType *unitParticleSystemTypeForAffectedUnit;
if(unitParticleSystemTypeForAffectedUnit != NULL) {
unitParticleSystemTypeForAffectedUnit->saveGame(attackBoostNode);
}
// bool includeSelf;
attackBoostNode->addAttribute("includeSelf",intToStr(includeSelf), mapTagReplacements);
// string name;
attackBoostNode->addAttribute("name",name, mapTagReplacements);
}
// =====================================================
// class SkillType
// =====================================================
@ -546,6 +581,41 @@ string SkillType::fieldToStr(Field field){
};
}
void SkillType::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *skillTypeNode = rootNode->addChild("SkillType");
// SkillClass skillClass;
skillTypeNode->addAttribute("skillClass",intToStr(skillClass), mapTagReplacements);
// string name;
skillTypeNode->addAttribute("name",name, mapTagReplacements);
// int mpCost;
skillTypeNode->addAttribute("mpCost",intToStr(mpCost), mapTagReplacements);
// int hpCost;
skillTypeNode->addAttribute("hpCost",intToStr(hpCost), mapTagReplacements);
// int speed;
skillTypeNode->addAttribute("speed",intToStr(speed), mapTagReplacements);
// int animSpeed;
skillTypeNode->addAttribute("animSpeed",intToStr(animSpeed), mapTagReplacements);
// int animationRandomCycleMaxcount;
skillTypeNode->addAttribute("animationRandomCycleMaxcount",intToStr(animationRandomCycleMaxcount), mapTagReplacements);
// vector<Model *> animations;
// vector<AnimationAttributes> animationAttributes;
//
// SoundContainer sounds;
// float soundStartTime;
skillTypeNode->addAttribute("soundStartTime",floatToStr(soundStartTime), mapTagReplacements);
// RandomGen random;
skillTypeNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements);
// AttackBoost attackBoost;
attackBoost.saveGame(skillTypeNode);
// static int nextAttackBoostId;
skillTypeNode->addAttribute("nextAttackBoostId",intToStr(nextAttackBoostId), mapTagReplacements);
// UnitParticleSystemTypes unitParticleSystemTypes;
for(UnitParticleSystemTypes::iterator it = unitParticleSystemTypes.begin(); it != unitParticleSystemTypes.end(); ++it) {
(*it)->saveGame(skillTypeNode);
}
}
// =====================================================
// class StopSkillType
@ -732,6 +802,52 @@ int AttackSkillType::getTotalAttackRange(const TotalUpgrade *totalUpgrade) const
return result;
}
void AttackSkillType::saveGame(XmlNode *rootNode) {
SkillType::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *attackSkillTypeNode = rootNode->addChild("AttackSkillType");
// int attackStrength;
attackSkillTypeNode->addAttribute("attackStrength",intToStr(attackStrength), mapTagReplacements);
// int attackVar;
attackSkillTypeNode->addAttribute("attackVar",intToStr(attackVar), mapTagReplacements);
// int attackRange;
attackSkillTypeNode->addAttribute("attackRange",intToStr(attackRange), mapTagReplacements);
// const AttackType *attackType;
if(attackType != NULL) {
attackSkillTypeNode->addAttribute("attackType",attackType->getName(), mapTagReplacements);
}
// bool attackFields[fieldCount];
for(unsigned int i = 0; i < fieldCount; ++i) {
XmlNode *attackFieldsNode = attackSkillTypeNode->addChild("attackFields");
attackFieldsNode->addAttribute("key",intToStr(i), mapTagReplacements);
attackFieldsNode->addAttribute("value",intToStr(attackFields[i]), mapTagReplacements);
}
// float attackStartTime;
attackSkillTypeNode->addAttribute("attackStartTime",floatToStr(attackStartTime), mapTagReplacements);
// string spawnUnit;
attackSkillTypeNode->addAttribute("spawnUnit",spawnUnit, mapTagReplacements);
// int spawnUnitcount;
attackSkillTypeNode->addAttribute("spawnUnitcount",intToStr(spawnUnitcount), mapTagReplacements);
// bool projectile;
attackSkillTypeNode->addAttribute("projectile",intToStr(projectile), mapTagReplacements);
// ParticleSystemTypeProjectile* projectileParticleSystemType;
if(projectileParticleSystemType != NULL) {
projectileParticleSystemType->saveGame(attackSkillTypeNode);
}
// SoundContainer projSounds;
//
// bool splash;
attackSkillTypeNode->addAttribute("splash",intToStr(splash), mapTagReplacements);
// int splashRadius;
attackSkillTypeNode->addAttribute("splashRadius",intToStr(splashRadius), mapTagReplacements);
// bool splashDamageAll;
attackSkillTypeNode->addAttribute("splashDamageAll",intToStr(splashDamageAll), mapTagReplacements);
// ParticleSystemTypeSplash* splashParticleSystemType;
if(splashParticleSystemType != NULL) {
splashParticleSystemType->saveGame(attackSkillTypeNode);
}
}
// =====================================================
// class BuildSkillType
// =====================================================
@ -802,6 +918,13 @@ int ProduceSkillType::getTotalSpeed(const TotalUpgrade *totalUpgrade) const{
return result;
}
void ProduceSkillType::saveGame(XmlNode *rootNode) {
SkillType::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *produceSkillTypeNode = rootNode->addChild("ProduceSkillType");
produceSkillTypeNode->addAttribute("animProgressBound",intToStr(animProgressBound), mapTagReplacements);
}
// =====================================================
// class UpgradeSkillType
// =====================================================
@ -835,6 +958,14 @@ int UpgradeSkillType::getTotalSpeed(const TotalUpgrade *totalUpgrade) const{
return result;
}
void UpgradeSkillType::saveGame(XmlNode *rootNode) {
SkillType::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *upgradeSkillTypeNode = rootNode->addChild("UpgradeSkillType");
upgradeSkillTypeNode->addAttribute("animProgressBound",intToStr(animProgressBound), mapTagReplacements);
}
// =====================================================
// class BeBuiltSkillType
// =====================================================
@ -866,6 +997,14 @@ string BeBuiltSkillType::toString() const{
return "Be built";
}
void BeBuiltSkillType::saveGame(XmlNode *rootNode) {
SkillType::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *beBuiltSkillTypeNode = rootNode->addChild("BeBuiltSkillType");
beBuiltSkillTypeNode->addAttribute("animProgressBound",intToStr(animProgressBound), mapTagReplacements);
}
// =====================================================
// class MorphSkillType
// =====================================================
@ -899,6 +1038,14 @@ int MorphSkillType::getTotalSpeed(const TotalUpgrade *totalUpgrade) const{
return result;
}
void MorphSkillType::saveGame(XmlNode *rootNode) {
SkillType::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *morphSkillTypeNode = rootNode->addChild("MorphSkillType");
morphSkillTypeNode->addAttribute("animProgressBound",intToStr(animProgressBound), mapTagReplacements);
}
// =====================================================
// class DieSkillType
// =====================================================
@ -921,6 +1068,14 @@ string DieSkillType::toString() const{
return "Die";
}
void DieSkillType::saveGame(XmlNode *rootNode) {
SkillType::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *dieSkillTypeNode = rootNode->addChild("DieSkillType");
dieSkillTypeNode->addAttribute("fade",intToStr(fade), mapTagReplacements);
}
// =====================================================
// class SkillTypeFactory
// =====================================================

View File

@ -101,6 +101,8 @@ public:
bool isAffected(const Unit *source, const Unit *dest) const;
virtual string getDesc() const;
virtual void saveGame(XmlNode *rootNode) const;
};
class AnimationAttributes {
@ -178,6 +180,8 @@ public:
static string skillClassToStr(SkillClass skillClass);
static string fieldToStr(Field field);
virtual string getBoostDesc() const {return attackBoost.getDesc();}
virtual void saveGame(XmlNode *rootNode);
};
// ===============================
@ -258,6 +262,8 @@ public:
//misc
int getTotalAttackStrength(const TotalUpgrade *totalUpgrade) const;
int getTotalAttackRange(const TotalUpgrade *totalUpgrade) const;
virtual void saveGame(XmlNode *rootNode);
};
@ -308,6 +314,8 @@ public:
virtual string toString() const;
virtual int getTotalSpeed(const TotalUpgrade *totalUpgrade) const;
virtual void saveGame(XmlNode *rootNode);
};
// ===============================
@ -327,6 +335,8 @@ public:
virtual string toString() const;
virtual int getTotalSpeed(const TotalUpgrade *totalUpgrade) const;
virtual void saveGame(XmlNode *rootNode);
};
@ -346,6 +356,8 @@ public:
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
virtual string toString() const;
virtual void saveGame(XmlNode *rootNode);
};
// ===============================
@ -366,6 +378,8 @@ public:
virtual string toString() const;
virtual int getTotalSpeed(const TotalUpgrade *totalUpgrade) const;
virtual void saveGame(XmlNode *rootNode);
};
// ===============================
@ -384,6 +398,8 @@ public:
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
virtual string toString() const;
virtual void saveGame(XmlNode *rootNode);
};
// ===============================

View File

@ -370,4 +370,48 @@ float TechTree::getDamageMultiplier(const AttackType *att, const ArmorType *art)
return damageMultiplierTable.getDamageMultiplier(att, art);
}
void TechTree::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *techTreeNode = rootNode->addChild("TechTree");
// string name;
techTreeNode->addAttribute("name",name, mapTagReplacements);
// //string desc;
// string treePath;
techTreeNode->addAttribute("treePath",treePath, mapTagReplacements);
// vector<string> pathList;
for(unsigned int i = 0; i < pathList.size(); ++i) {
XmlNode *pathListNode = techTreeNode->addChild("pathList");
pathListNode->addAttribute("value",pathList[i], mapTagReplacements);
}
// ResourceTypes resourceTypes;
for(unsigned int i = 0; i < resourceTypes.size(); ++i) {
ResourceType &rt = resourceTypes[i];
rt.saveGame(techTreeNode);
}
// FactionTypes factionTypes;
for(unsigned int i = 0; i < factionTypes.size(); ++i) {
FactionType &ft = factionTypes[i];
ft.saveGame(techTreeNode);
}
// ArmorTypes armorTypes;
for(unsigned int i = 0; i < armorTypes.size(); ++i) {
ArmorType &at = armorTypes[i];
at.saveGame(techTreeNode);
}
// AttackTypes attackTypes;
for(unsigned int i = 0; i < attackTypes.size(); ++i) {
AttackType &at = attackTypes[i];
at.saveGame(techTreeNode);
}
// DamageMultiplierTable damageMultiplierTable;
damageMultiplierTable.saveGame(techTreeNode);
// Checksum checksumValue;
techTreeNode->addAttribute("checksumValue",intToStr(checksumValue.getSum()), mapTagReplacements);
}
}}//end namespace

View File

@ -81,6 +81,9 @@ public:
float getDamageMultiplier(const AttackType *att, const ArmorType *art) const;
std::vector<std::string> validateFactionTypes();
std::vector<std::string> validateResourceTypes();
void saveGame(XmlNode *rootNode);
};
}} //end namespace

View File

@ -42,6 +42,13 @@ void Level::init(string name, int kills){
this->kills= kills;
}
void Level::saveGame(XmlNode *rootNode) const {
std::map<string,string> mapTagReplacements;
XmlNode *levelNode = rootNode->addChild("Level");
levelNode->addAttribute("name",name, mapTagReplacements);
levelNode->addAttribute("kills",intToStr(kills), mapTagReplacements);
}
// =====================================================
// class UnitType
// =====================================================

View File

@ -53,6 +53,8 @@ public:
const string &getName() const {return name;}
int getKills() const {return kills;}
void saveGame(XmlNode *rootNode) const ;
};
// ===============================

View File

@ -274,6 +274,102 @@ string UpgradeTypeBase::getDesc() const{
return str;
}
void UpgradeTypeBase::saveGame(XmlNode *rootNode) const {
std::map<string,string> mapTagReplacements;
XmlNode *upgradeTypeBaseNode = rootNode->addChild("UpgradeTypeBase");
// int maxHp;
upgradeTypeBaseNode->addAttribute("maxHp",intToStr(maxHp), mapTagReplacements);
// bool maxHpIsMultiplier;
upgradeTypeBaseNode->addAttribute("maxHpIsMultiplier",intToStr(maxHpIsMultiplier), mapTagReplacements);
// int maxHpRegeneration;
upgradeTypeBaseNode->addAttribute("maxHpRegeneration",intToStr(maxHpRegeneration), mapTagReplacements);
// //bool maxHpRegenerationIsMultiplier;
//
// int sight;
upgradeTypeBaseNode->addAttribute("sight",intToStr(sight), mapTagReplacements);
// bool sightIsMultiplier;
upgradeTypeBaseNode->addAttribute("sightIsMultiplier",intToStr(sightIsMultiplier), mapTagReplacements);
// int maxEp;
upgradeTypeBaseNode->addAttribute("maxEp",intToStr(maxEp), mapTagReplacements);
// bool maxEpIsMultiplier;
upgradeTypeBaseNode->addAttribute("maxEpIsMultiplier",intToStr(maxEpIsMultiplier), mapTagReplacements);
// int maxEpRegeneration;
upgradeTypeBaseNode->addAttribute("maxEpRegeneration",intToStr(maxEpRegeneration), mapTagReplacements);
// //bool maxEpRegenerationIsMultiplier;
// int armor;
upgradeTypeBaseNode->addAttribute("armor",intToStr(armor), mapTagReplacements);
// bool armorIsMultiplier;
upgradeTypeBaseNode->addAttribute("armorIsMultiplier",intToStr(armorIsMultiplier), mapTagReplacements);
// int attackStrength;
upgradeTypeBaseNode->addAttribute("attackStrength",intToStr(attackStrength), mapTagReplacements);
// bool attackStrengthIsMultiplier;
upgradeTypeBaseNode->addAttribute("attackStrengthIsMultiplier",intToStr(attackStrengthIsMultiplier), mapTagReplacements);
// std::map<string,int> attackStrengthMultiplierValueList;
for(std::map<string,int>::const_iterator iterMap = attackStrengthMultiplierValueList.begin();
iterMap != attackStrengthMultiplierValueList.end(); ++iterMap) {
XmlNode *attackStrengthMultiplierValueListNode = upgradeTypeBaseNode->addChild("attackStrengthMultiplierValueList");
attackStrengthMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
attackStrengthMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
}
// int attackRange;
upgradeTypeBaseNode->addAttribute("attackRange",intToStr(attackRange), mapTagReplacements);
// bool attackRangeIsMultiplier;
upgradeTypeBaseNode->addAttribute("attackRangeIsMultiplier",intToStr(attackRangeIsMultiplier), mapTagReplacements);
// std::map<string,int> attackRangeMultiplierValueList;
for(std::map<string,int>::const_iterator iterMap = attackRangeMultiplierValueList.begin();
iterMap != attackRangeMultiplierValueList.end(); ++iterMap) {
XmlNode *attackRangeMultiplierValueListNode = upgradeTypeBaseNode->addChild("attackRangeMultiplierValueList");
attackRangeMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
attackRangeMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
}
// int moveSpeed;
upgradeTypeBaseNode->addAttribute("moveSpeed",intToStr(moveSpeed), mapTagReplacements);
// bool moveSpeedIsMultiplier;
upgradeTypeBaseNode->addAttribute("moveSpeedIsMultiplier",intToStr(moveSpeedIsMultiplier), mapTagReplacements);
// std::map<string,int> moveSpeedIsMultiplierValueList;
for(std::map<string,int>::const_iterator iterMap = moveSpeedIsMultiplierValueList.begin();
iterMap != moveSpeedIsMultiplierValueList.end(); ++iterMap) {
XmlNode *moveSpeedIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("moveSpeedIsMultiplierValueList");
moveSpeedIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
moveSpeedIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
}
// int prodSpeed;
upgradeTypeBaseNode->addAttribute("prodSpeed",intToStr(prodSpeed), mapTagReplacements);
// bool prodSpeedIsMultiplier;
upgradeTypeBaseNode->addAttribute("prodSpeedIsMultiplier",intToStr(prodSpeedIsMultiplier), mapTagReplacements);
// std::map<string,int> prodSpeedProduceIsMultiplierValueList;
for(std::map<string,int>::const_iterator iterMap = prodSpeedProduceIsMultiplierValueList.begin();
iterMap != prodSpeedProduceIsMultiplierValueList.end(); ++iterMap) {
XmlNode *prodSpeedProduceIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("prodSpeedProduceIsMultiplierValueList");
prodSpeedProduceIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
prodSpeedProduceIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
}
// std::map<string,int> prodSpeedUpgradeIsMultiplierValueList;
for(std::map<string,int>::const_iterator iterMap = prodSpeedUpgradeIsMultiplierValueList.begin();
iterMap != prodSpeedUpgradeIsMultiplierValueList.end(); ++iterMap) {
XmlNode *prodSpeedUpgradeIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("prodSpeedUpgradeIsMultiplierValueList");
prodSpeedUpgradeIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
prodSpeedUpgradeIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
}
// std::map<string,int> prodSpeedMorphIsMultiplierValueList;
for(std::map<string,int>::const_iterator iterMap = prodSpeedMorphIsMultiplierValueList.begin();
iterMap != prodSpeedMorphIsMultiplierValueList.end(); ++iterMap) {
XmlNode *prodSpeedMorphIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("prodSpeedMorphIsMultiplierValueList");
prodSpeedMorphIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
prodSpeedMorphIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
}
}
// ==================== misc ====================
@ -476,6 +572,22 @@ bool UpgradeType::isAffected(const UnitType *unitType) const{
return find(effects.begin(), effects.end(), unitType)!=effects.end();
}
void UpgradeType::saveGame(XmlNode *rootNode) const {
UpgradeTypeBase::saveGame(rootNode);
ProducibleType::saveGame(rootNode);
std::map<string,string> mapTagReplacements;
XmlNode *upgradeTypeNode = rootNode->addChild("UpgradeType");
//upgradeTypeNode->addAttribute("maxHp",intToStr(maxHp), mapTagReplacements);
//vector<const UnitType*> effects;
for(unsigned int i = 0; i < effects.size(); ++i) {
XmlNode *unitTypeNode = rootNode->addChild("UnitType");
const UnitType *ut = effects[i];
unitTypeNode->addAttribute("name",ut->getName(), mapTagReplacements);
}
}
// ===============================
// class TotalUpgrade
@ -759,4 +871,5 @@ void TotalUpgrade::incLevel(const UnitType *ut) {
armor += ut->getArmor()*50/100;
}
}}//end namespace

View File

@ -131,6 +131,8 @@ public:
return result;
}
virtual void saveGame(XmlNode *rootNode) const;
};
// ===============================
@ -154,6 +156,8 @@ public:
//other methods
virtual string getReqDesc() const;
virtual void saveGame(XmlNode *rootNode) const;
};
// ===============================

View File

@ -243,6 +243,8 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
FILE *f = fopen(path.c_str(), "rb");
#endif
if(f != NULL) {
mapFile = path;
mapChecksum.addFile(path);
checksumValue.addFile(path);
//read header

View File

@ -171,6 +171,7 @@ private:
Vec2i *startLocations;
Checksum checksumValue;
float maxMapHeight;
string mapFile;
private:
Map(Map&);
@ -263,6 +264,8 @@ public:
bool isAproxFreeCellOrMightBeFreeSoon(Vec2i originPos,const Vec2i &pos, Field field, int teamIndex) const;
bool aproxCanMoveSoon(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2) const;
string getMapFile() const { return mapFile; }
private:
//compute
void smoothSurface(Tileset *tileset);

View File

@ -143,6 +143,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
string name= lastDir(dir);
tileset_name = name;
string currentPath = dir;
endPathWithSlash(currentPath);
string path= currentPath + name + ".xml";

View File

@ -141,6 +141,8 @@ private:
AmbientSounds ambientSounds;
Checksum checksumValue;
string tileset_name;
public:
Tileset() {
waterTex = NULL;
@ -178,6 +180,8 @@ public:
//sounds
AmbientSounds *getAmbientSounds() {return &ambientSounds;}
string getName() const { return tileset_name; }
};
}} //end namespace

View File

@ -15,6 +15,7 @@
#include "config.h"
#include "game_constants.h"
#include "util.h"
#include "conversion.h"
#include "leak_dumper.h"
using namespace Shared::Util;
@ -125,5 +126,19 @@ Vec3f TimeFlow::computeLightColor() const {
return color;
}
void TimeFlow::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *timeflowNode = rootNode->addChild("TimeFlow");
timeflowNode->addAttribute("firstTime",intToStr(firstTime), mapTagReplacements);
// bool firstTime;
// Tileset *tileset;
// float time;
timeflowNode->addAttribute("time",intToStr(time), mapTagReplacements);
// float lastTime;
timeflowNode->addAttribute("lastTime",intToStr(lastTime), mapTagReplacements);
// float timeInc;
timeflowNode->addAttribute("timeInc",intToStr(timeInc), mapTagReplacements);
}
}}//end namespace

View File

@ -59,6 +59,9 @@ public:
Vec3f computeLightColor() const;
void update();
void saveGame(XmlNode *rootNode);
private:
//bool isAproxTime(float time) const;
};

View File

@ -2575,6 +2575,31 @@ string UnitUpdater::getUnitRangeCellsLookupItemCacheStats() {
result = szBuf;
return result;
}
void UnitUpdater::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *unitupdaterNode = rootNode->addChild("UnitUpdater");
// const GameCamera *gameCamera;
// Gui *gui;
// Map *map;
// World *world;
// Console *console;
// ScriptManager *scriptManager;
// PathFinder *pathFinder;
pathFinder->saveGame(unitupdaterNode);
// RoutePlanner *routePlanner;
// Game *game;
// RandomGen random;
unitupdaterNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements);
// float attackWarnRange;
unitupdaterNode->addAttribute("attackWarnRange",floatToStr(attackWarnRange), mapTagReplacements);
// AttackWarnings attackWarnings;
//
// Mutex mutexUnitRangeCellsLookupItemCache;
// std::map<Vec2i, std::map<int, std::map<int, UnitRangeCellsLookupItem > > > UnitRangeCellsLookupItemCache;
}
// =====================================================
// class ParticleDamager
// =====================================================
@ -2604,4 +2629,20 @@ void ParticleDamager::update(ParticleSystem *particleSystem) {
delete this;
}
void ParticleDamager::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *particleDamagerNode = rootNode->addChild("ParticleDamager");
// UnitReference attackerRef;
attackerRef.saveGame(particleDamagerNode);
// const AttackSkillType* ast;
// UnitUpdater *unitUpdater;
// const GameCamera *gameCamera;
// Vec2i targetPos;
particleDamagerNode->addAttribute("targetPos",targetPos.getString(), mapTagReplacements);
// Field targetField;
particleDamagerNode->addAttribute("targetField",intToStr(targetField), mapTagReplacements);
}
}}//end namespace

View File

@ -128,6 +128,8 @@ public:
string getUnitRangeCellsLookupItemCacheStats();
void saveGame(XmlNode *rootNode);
private:
//attack
void hit(Unit *attacker);
@ -166,6 +168,7 @@ public:
public:
ParticleDamager(Unit *attacker, UnitUpdater *unitUpdater, const GameCamera *gameCamera);
virtual void update(ParticleSystem *particleSystem);
virtual void saveGame(XmlNode *rootNode);
};
}}//end namespace

View File

@ -1984,7 +1984,94 @@ std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const {
}
#endif
}
//printf("Check savegame\n");
if(this->game != NULL) {
//printf("Saving...\n");
this->game->saveGame(GameConstants::saveGameFileDefault);
}
return debugWorldLogFile;
}
void World::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *worldNode = rootNode->addChild("World");
// Map map;
worldNode->addAttribute("map",extractFileFromDirectoryPath(map.getMapFile()), mapTagReplacements);
// Tileset tileset;
worldNode->addAttribute("tileset",tileset.getName(), mapTagReplacements);
// //TechTree techTree;
// TechTree *techTree;
if(techTree != NULL) {
techTree->saveGame(worldNode);
}
worldNode->addAttribute("techTree",techTree->getName(), mapTagReplacements);
// TimeFlow timeFlow;
timeFlow.saveGame(worldNode);
// Scenario scenario;
//
// UnitUpdater unitUpdater;
unitUpdater.saveGame(worldNode);
// WaterEffects waterEffects;
// WaterEffects attackEffects; // onMiniMap
// Minimap minimap;
// Stats stats; //BattleEnd will delete this object
stats.saveGame(worldNode);
//
// Factions factions;
for(unsigned int i = 0; i < factions.size(); ++i) {
factions[i]->saveGame(worldNode);
}
// RandomGen random;
worldNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements);
// ScriptManager* scriptManager;
// Cartographer *cartographer;
// RoutePlanner *routePlanner;
//
// int thisFactionIndex;
worldNode->addAttribute("thisFactionIndex",intToStr(thisFactionIndex), mapTagReplacements);
// int thisTeamIndex;
worldNode->addAttribute("thisTeamIndex",intToStr(thisTeamIndex), mapTagReplacements);
// int frameCount;
worldNode->addAttribute("frameCount",intToStr(frameCount), mapTagReplacements);
// //int nextUnitId;
// Mutex mutexFactionNextUnitId;
// std::map<int,int> mapFactionNextUnitId;
for(std::map<int,int>::iterator iterMap = mapFactionNextUnitId.begin();
iterMap != mapFactionNextUnitId.end(); ++iterMap) {
XmlNode *factionNextUnitIdNode = worldNode->addChild("FactionNextUnitId");
factionNextUnitIdNode->addAttribute("key",intToStr(iterMap->first), mapTagReplacements);
factionNextUnitIdNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
}
// //config
// bool fogOfWarOverride;
worldNode->addAttribute("fogOfWarOverride",intToStr(fogOfWarOverride), mapTagReplacements);
// bool fogOfWar;
worldNode->addAttribute("fogOfWar",intToStr(fogOfWar), mapTagReplacements);
// int fogOfWarSmoothingFrameSkip;
worldNode->addAttribute("fogOfWarSmoothingFrameSkip",intToStr(fogOfWarSmoothingFrameSkip), mapTagReplacements);
// bool fogOfWarSmoothing;
worldNode->addAttribute("fogOfWarSmoothing",intToStr(fogOfWarSmoothing), mapTagReplacements);
// Game *game;
// Chrono chronoPerfTimer;
// bool perfTimerEnabled;
//
// bool unitParticlesEnabled;
worldNode->addAttribute("unitParticlesEnabled",intToStr(unitParticlesEnabled), mapTagReplacements);
// bool staggeredFactionUpdates;
worldNode->addAttribute("staggeredFactionUpdates",intToStr(staggeredFactionUpdates), mapTagReplacements);
// std::map<string,StaticSound *> staticSoundList;
// std::map<string,StrSound *> streamSoundList;
//
// uint32 nextCommandGroupId;
worldNode->addAttribute("nextCommandGroupId",intToStr(nextCommandGroupId), mapTagReplacements);
// string queuedScenarioName;
worldNode->addAttribute("queuedScenarioName",queuedScenarioName, mapTagReplacements);
// bool queuedScenarioKeepFactions;
worldNode->addAttribute("queuedScenarioKeepFactions",intToStr(queuedScenarioKeepFactions), mapTagReplacements);
}
}}//end namespace

View File

@ -267,6 +267,8 @@ public:
string getFowAlphaCellsLookupItemCacheStats();
string getAllFactionsCacheStats();
void saveGame(XmlNode *rootNode);
private:
void initCells(bool fogOfWar);

View File

@ -18,10 +18,12 @@
#include "pixmap.h"
#include "texture_manager.h"
#include "randomgen.h"
#include "xml_parser.h"
#include "leak_dumper.h"
using std::list;
using Shared::Util::RandomGen;
using Shared::Xml::XmlNode;
namespace Shared{ namespace Graphics{
@ -64,6 +66,8 @@ public:
Vec4f getColor() const {return color;}
float getSize() const {return size;}
int getEnergy() const {return energy;}
void saveGame(XmlNode *rootNode);
};
// =====================================================
@ -74,6 +78,7 @@ class ParticleObserver{
public:
virtual ~ParticleObserver(){};
virtual void update(ParticleSystem *particleSystem)= 0;
virtual void saveGame(XmlNode *rootNode) = 0;
};
// =====================================================
@ -186,6 +191,8 @@ public:
virtual int getChildCount() { return 0; }
virtual ParticleSystem* getChild(int i);
void saveGame(XmlNode *rootNode);
protected:
//protected
Particle *createParticle();

View File

@ -39,6 +39,9 @@ public:
int rand();
int randRange(int min, int max);
float randRange(float min, float max);
int getLastNumber() const { return lastNumber; }
void setLastNumber(int value) { lastNumber = value; }
};
}}//end namespace

View File

@ -1915,12 +1915,20 @@ void Md5Object::render () const {
//glRotatef( -90.0, 1.0, 0.0, 0.0 );
//glRotatef( -90.0, 0.0, 0.0, 1.0 );
//glTranslatef( 0.0f, -60.0f, 0.0f );
glRotatef( -20.0, 1.0, 0.0, 0.0 );
glRotatef( -20.0, 0.0, 1.0, 0.0 );
//!glRotatef( -20.0, 1.0, 0.0, 0.0 );
//!glRotatef( -20.0, 0.0, 1.0, 0.0 );
//glRotatef( 50.0, 1.0, 0.0, 0.0 );
//glTranslatef( 5.0f, -2.0f, -3.0f );
glTranslatef(-1.4f, -1.4f, -7.5f);
glScalef(1/4.0f, 1/4.0f, 1);
//!glTranslatef(-1.4f, -1.4f, -7.5f);
//glRotatef( 90.0, 0.0, 0.0, 1.0 );
//glRotatef( -25.0, 0.0, 1.0, 0.0 );
//glRotatef( -20.0, 1.0, 0.0, 0.0 );
//glScalef(1.0/20.0f, 1.0/20.0f, 1.0f);
if (!_softwareTransformation) {
glMultMatrixf (_modelView._m);

View File

@ -20,6 +20,7 @@
#include "particle_renderer.h"
#include "math_util.h"
#include "platform_common.h"
#include "conversion.h"
#include "leak_dumper.h"
using namespace std;
@ -36,6 +37,27 @@ namespace Graphics {
const bool checkMemory = false;
static map<void *,int> memoryObjectList;
void Particle::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *particleNode = rootNode->addChild("Particle");
// Vec3f pos;
particleNode->addAttribute("pos",pos.getString(), mapTagReplacements);
// Vec3f lastPos;
particleNode->addAttribute("lastPos",lastPos.getString(), mapTagReplacements);
// Vec3f speed;
particleNode->addAttribute("speed",speed.getString(), mapTagReplacements);
// Vec3f accel;
particleNode->addAttribute("accel",accel.getString(), mapTagReplacements);
// Vec4f color;
particleNode->addAttribute("color",color.getString(), mapTagReplacements);
// float size;
particleNode->addAttribute("size",floatToStr(size), mapTagReplacements);
// int energy;
particleNode->addAttribute("energy",intToStr(energy), mapTagReplacements);
}
ParticleSystem::ParticleSystem(int particleCount) {
if(checkMemory) {
printf("++ Create ParticleSystem [%p]\n",this);
@ -213,6 +235,65 @@ void ParticleSystem::setVisible(bool visible){
getChild(i)->setVisible(visible);
}
void ParticleSystem::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *particleSystemNode = rootNode->addChild("ParticleSystem");
// std::vector<Particle> particles;
for(unsigned int i = 0; i < particles.size(); ++i) {
Particle &particle = particles[i];
particle.saveGame(particleSystemNode);
}
// RandomGen random;
particleSystemNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements);
// BlendMode blendMode;
particleSystemNode->addAttribute("blendMode",intToStr(blendMode), mapTagReplacements);
// State state;
particleSystemNode->addAttribute("state",intToStr(state), mapTagReplacements);
// bool active;
particleSystemNode->addAttribute("active",intToStr(active), mapTagReplacements);
// bool visible;
particleSystemNode->addAttribute("visible",intToStr(visible), mapTagReplacements);
// int aliveParticleCount;
particleSystemNode->addAttribute("aliveParticleCount",intToStr(aliveParticleCount), mapTagReplacements);
// int particleCount;
particleSystemNode->addAttribute("particleCount",intToStr(particleCount), mapTagReplacements);
//
// Texture *texture;
// Vec3f pos;
particleSystemNode->addAttribute("pos",pos.getString(), mapTagReplacements);
// Vec4f color;
particleSystemNode->addAttribute("color",color.getString(), mapTagReplacements);
// Vec4f colorNoEnergy;
particleSystemNode->addAttribute("colorNoEnergy",colorNoEnergy.getString(), mapTagReplacements);
// float emissionRate;
particleSystemNode->addAttribute("emissionRate",floatToStr(emissionRate), mapTagReplacements);
// float emissionState;
particleSystemNode->addAttribute("emissionState",floatToStr(emissionState), mapTagReplacements);
// int maxParticleEnergy;
particleSystemNode->addAttribute("maxParticleEnergy",intToStr(maxParticleEnergy), mapTagReplacements);
// int varParticleEnergy;
particleSystemNode->addAttribute("varParticleEnergy",intToStr(varParticleEnergy), mapTagReplacements);
// float particleSize;
particleSystemNode->addAttribute("particleSize",floatToStr(particleSize), mapTagReplacements);
// float speed;
particleSystemNode->addAttribute("speed",floatToStr(speed), mapTagReplacements);
// Vec3f factionColor;
particleSystemNode->addAttribute("factionColor",factionColor.getString(), mapTagReplacements);
// bool teamcolorNoEnergy;
particleSystemNode->addAttribute("teamcolorNoEnergy",intToStr(teamcolorNoEnergy), mapTagReplacements);
// bool teamcolorEnergy;
particleSystemNode->addAttribute("teamcolorEnergy",intToStr(teamcolorEnergy), mapTagReplacements);
// int alternations;
particleSystemNode->addAttribute("alternations",intToStr(alternations), mapTagReplacements);
// int particleSystemStartDelay;
particleSystemNode->addAttribute("particleSystemStartDelay",intToStr(particleSystemStartDelay), mapTagReplacements);
// ParticleObserver *particleObserver;
if(particleObserver != NULL) {
particleObserver->saveGame(particleSystemNode);
}
}
// =============== MISC =========================
void ParticleSystem::fade(){
if(particleObserver != NULL){

View File

@ -147,6 +147,16 @@ void XmlIo::save(const string &path, const XmlNode *node){
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *document= implementation->createDocument(0, str, 0);
DOMElement *documentElement= document->getDocumentElement();
for(unsigned int i = 0; i < node->getAttributeCount() ; ++i){
XmlAttribute *attr = node->getAttribute(i);
XMLCh strName[strSize];
XMLString::transcode(attr->getName().c_str(), strName, strSize-1);
XMLCh strValue[strSize];
XMLString::transcode(attr->getValue("",false).c_str(), strValue, strSize-1);
documentElement->setAttribute(strName,strValue);
}
for(unsigned int i=0; i<node->getChildCount(); ++i){
documentElement->appendChild(node->getChild(i)->buildElement(document));