From 8916a86b8c278b4632a331c2c113c02f2558be92 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 19 Feb 2013 06:41:56 +0000 Subject: [PATCH] - bugfixes for load / save game for in progress joining --- source/glest_game/ai/path_finder.cpp | 2 +- source/glest_game/game/game.cpp | 9 ++- source/glest_game/game/game_camera.cpp | 24 +++---- source/glest_game/game/stats.cpp | 4 +- source/glest_game/graphics/particle_type.cpp | 28 ++++---- .../graphics/unit_particle_type.cpp | 12 ++-- source/glest_game/type_instances/object.cpp | 2 +- source/glest_game/type_instances/unit.cpp | 36 +++++------ source/glest_game/types/skill_type.cpp | 6 +- source/glest_game/types/unit_type.cpp | 2 +- source/glest_game/world/map.cpp | 10 +-- source/glest_game/world/minimap.cpp | 12 ++-- source/glest_game/world/time_flow.cpp | 22 ++++++- source/glest_game/world/time_flow.h | 8 +-- source/glest_game/world/unit_updater.cpp | 2 +- source/shared_lib/include/xml/xml_parser.h | 1 + .../sources/graphics/interpolation.cpp | 4 +- .../shared_lib/sources/graphics/particle.cpp | 64 +++++++++---------- source/shared_lib/sources/util/properties.cpp | 4 +- source/shared_lib/sources/xml/xml_parser.cpp | 12 ++++ 20 files changed, 146 insertions(+), 118 deletions(-) diff --git a/source/glest_game/ai/path_finder.cpp b/source/glest_game/ai/path_finder.cpp index 27bd4a27..99cf6b66 100644 --- a/source/glest_game/ai/path_finder.cpp +++ b/source/glest_game/ai/path_finder.cpp @@ -1505,7 +1505,7 @@ void PathFinder::saveGame(XmlNode *rootNode) { int prevIdx = findNodeIndex(curNode->prev, factionState.nodePool); nodePoolNode->addAttribute("prev",intToStr(prevIdx), mapTagReplacements); // float heuristic; - nodePoolNode->addAttribute("heuristic",floatToStr(curNode->heuristic), mapTagReplacements); + nodePoolNode->addAttribute("heuristic",floatToStr(curNode->heuristic,16), mapTagReplacements); // bool exploredCell; nodePoolNode->addAttribute("exploredCell",intToStr(curNode->exploredCell), mapTagReplacements); } diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index c35ec3c8..0a2ce1a8 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -5633,7 +5633,7 @@ string Game::saveGame(string name, string path) { //bool showFullConsole; //bool mouseMoved; //float scrollSpeed; - gameNode->addAttribute("scrollSpeed",floatToStr(scrollSpeed), mapTagReplacements); + gameNode->addAttribute("scrollSpeed",floatToStr(scrollSpeed,16), mapTagReplacements); //bool camLeftButtonDown; //bool camRightButtonDown; //bool camUpButtonDown; @@ -5727,8 +5727,8 @@ string Game::saveGame(string name, string path) { HighlightSpecialUnitInfo &info = iterMap->second; XmlNode *infoNode = unitHighlightListNode->addChild("info"); infoNode->addAttribute("unitid",intToStr(iterMap->first), mapTagReplacements); - infoNode->addAttribute("radius",floatToStr(info.radius), mapTagReplacements); - infoNode->addAttribute("thickness",floatToStr(info.thickness), mapTagReplacements); + infoNode->addAttribute("radius",floatToStr(info.radius,16), mapTagReplacements); + infoNode->addAttribute("thickness",floatToStr(info.thickness,16), mapTagReplacements); infoNode->addAttribute("color",info.color.getString(), mapTagReplacements); } @@ -5843,6 +5843,9 @@ void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode,cons XmlNode *guiNode = gameNode->getChild("Gui"); XmlNode *selectionNode = guiNode->getChild("Selection"); XmlNode *statsNode = worldNode->getChild("Stats"); + XmlNode *minimapNode = worldNode->getChild("Minimap"); + // This is explored fog of war for the host player, clear it + minimapNode->clearChild("fowPixmap1"); NetworkManager &networkManager= NetworkManager::getInstance(); NetworkRole role = networkManager.getNetworkRole(); diff --git a/source/glest_game/game/game_camera.cpp b/source/glest_game/game/game_camera.cpp index 66d24b26..2fa1904c 100644 --- a/source/glest_game/game/game_camera.cpp +++ b/source/glest_game/game/game_camera.cpp @@ -457,18 +457,18 @@ void GameCamera::saveGame(XmlNode *rootNode) { gamecameraNode->addAttribute("destPos",destPos.getString(), mapTagReplacements); // // float hAng; //YZ plane positive -Z axis - gamecameraNode->addAttribute("hAng",floatToStr(hAng), mapTagReplacements); + gamecameraNode->addAttribute("hAng",floatToStr(hAng,16), mapTagReplacements); // float vAng; //XZ plane positive +Z axis - gamecameraNode->addAttribute("vAng",floatToStr(vAng), mapTagReplacements); + gamecameraNode->addAttribute("vAng",floatToStr(vAng,16), mapTagReplacements); // float lastHAng; - gamecameraNode->addAttribute("lastHAng",floatToStr(lastHAng), mapTagReplacements); + gamecameraNode->addAttribute("lastHAng",floatToStr(lastHAng,16), mapTagReplacements); // float lastVAng; - gamecameraNode->addAttribute("lastVAng",floatToStr(lastVAng), mapTagReplacements); + gamecameraNode->addAttribute("lastVAng",floatToStr(lastVAng,16), mapTagReplacements); // Vec2f destAng; gamecameraNode->addAttribute("destAng",destAng.getString(), mapTagReplacements); // float rotate; - gamecameraNode->addAttribute("rotate",floatToStr(rotate), mapTagReplacements); + gamecameraNode->addAttribute("rotate",floatToStr(rotate,16), mapTagReplacements); // Vec3f move; gamecameraNode->addAttribute("move",move.getString(), mapTagReplacements); // State state; @@ -479,24 +479,24 @@ void GameCamera::saveGame(XmlNode *rootNode) { gamecameraNode->addAttribute("limitY",intToStr(limitY), mapTagReplacements); // //config // float speed; - gamecameraNode->addAttribute("speed",floatToStr(speed), mapTagReplacements); + gamecameraNode->addAttribute("speed",floatToStr(speed,16), mapTagReplacements); // bool clampBounds; gamecameraNode->addAttribute("clampBounds",intToStr(clampBounds), mapTagReplacements); // //float maxRenderDistance; // float maxHeight; - gamecameraNode->addAttribute("maxHeight",floatToStr(maxHeight), mapTagReplacements); + gamecameraNode->addAttribute("maxHeight",floatToStr(maxHeight,16), mapTagReplacements); // float minHeight; - gamecameraNode->addAttribute("minHeight",floatToStr(minHeight), mapTagReplacements); + gamecameraNode->addAttribute("minHeight",floatToStr(minHeight,16), mapTagReplacements); // //float maxCameraDist; // //float minCameraDist; // float minVAng; - gamecameraNode->addAttribute("minVAng",floatToStr(minVAng), mapTagReplacements); + gamecameraNode->addAttribute("minVAng",floatToStr(minVAng,16), mapTagReplacements); // float maxVAng; - gamecameraNode->addAttribute("maxVAng",floatToStr(maxVAng), mapTagReplacements); + gamecameraNode->addAttribute("maxVAng",floatToStr(maxVAng,16), mapTagReplacements); // float fov; - gamecameraNode->addAttribute("fov",floatToStr(fov), mapTagReplacements); + gamecameraNode->addAttribute("fov",floatToStr(fov,16), mapTagReplacements); // float calculatedDefault; - gamecameraNode->addAttribute("calculatedDefault",floatToStr(calculatedDefault), mapTagReplacements); + gamecameraNode->addAttribute("calculatedDefault",floatToStr(calculatedDefault,16), mapTagReplacements); // std::map > > cacheVisibleQuad; // int MaxVisibleQuadItemCache; gamecameraNode->addAttribute("MaxVisibleQuadItemCache",intToStr(MaxVisibleQuadItemCache), mapTagReplacements); diff --git a/source/glest_game/game/stats.cpp b/source/glest_game/game/stats.cpp index 1c6d9612..8a277710 100644 --- a/source/glest_game/game/stats.cpp +++ b/source/glest_game/game/stats.cpp @@ -179,7 +179,7 @@ void Stats::saveGame(XmlNode *rootNode) { // ControlType control; statsNodePlayer->addAttribute("control",intToStr(stat.control), mapTagReplacements); // float resourceMultiplier; - statsNodePlayer->addAttribute("resourceMultiplier",floatToStr(stat.resourceMultiplier), mapTagReplacements); + statsNodePlayer->addAttribute("resourceMultiplier",floatToStr(stat.resourceMultiplier,16), mapTagReplacements); // string factionTypeName; statsNodePlayer->addAttribute("factionTypeName",stat.factionTypeName, mapTagReplacements); // FactionPersonalityType personalityType; @@ -211,7 +211,7 @@ void Stats::saveGame(XmlNode *rootNode) { statsNode->addAttribute("thisFactionIndex",intToStr(thisFactionIndex), mapTagReplacements); // // float worldTimeElapsed; - statsNode->addAttribute("worldTimeElapsed",floatToStr(worldTimeElapsed), mapTagReplacements); + statsNode->addAttribute("worldTimeElapsed",floatToStr(worldTimeElapsed,16), mapTagReplacements); // int framesPlayed; statsNode->addAttribute("framesPlayed",intToStr(framesPlayed), mapTagReplacements); // int framesToCalculatePlaytime; diff --git a/source/glest_game/graphics/particle_type.cpp b/source/glest_game/graphics/particle_type.cpp index 63c820a7..e0fcd1aa 100644 --- a/source/glest_game/graphics/particle_type.cpp +++ b/source/glest_game/graphics/particle_type.cpp @@ -316,7 +316,7 @@ void ParticleSystemType::saveGame(XmlNode *rootNode) { // Texture2D *texture; // Model *model; // float modelCycle; - particleSystemTypeNode->addAttribute("modelCycle",floatToStr(modelCycle), mapTagReplacements); + particleSystemTypeNode->addAttribute("modelCycle",floatToStr(modelCycle,16), mapTagReplacements); // string primitive; particleSystemTypeNode->addAttribute("primitive",primitive, mapTagReplacements); // Vec3f offset; @@ -326,15 +326,15 @@ void ParticleSystemType::saveGame(XmlNode *rootNode) { // Vec4f colorNoEnergy; particleSystemTypeNode->addAttribute("colorNoEnergy",colorNoEnergy.getString(), mapTagReplacements); // float size; - particleSystemTypeNode->addAttribute("size",floatToStr(size), mapTagReplacements); + particleSystemTypeNode->addAttribute("size",floatToStr(size,16), mapTagReplacements); // float sizeNoEnergy; - particleSystemTypeNode->addAttribute("sizeNoEnergy",floatToStr(sizeNoEnergy), mapTagReplacements); + particleSystemTypeNode->addAttribute("sizeNoEnergy",floatToStr(sizeNoEnergy,16), mapTagReplacements); // float speed; - particleSystemTypeNode->addAttribute("speed",floatToStr(speed), mapTagReplacements); + particleSystemTypeNode->addAttribute("speed",floatToStr(speed,16), mapTagReplacements); // float gravity; - particleSystemTypeNode->addAttribute("gravity",floatToStr(gravity), mapTagReplacements); + particleSystemTypeNode->addAttribute("gravity",floatToStr(gravity,16), mapTagReplacements); // float emissionRate; - particleSystemTypeNode->addAttribute("emissionRate",floatToStr(emissionRate), mapTagReplacements); + particleSystemTypeNode->addAttribute("emissionRate",floatToStr(emissionRate,16), mapTagReplacements); // int energyMax; particleSystemTypeNode->addAttribute("energyMax",intToStr(energyMax), mapTagReplacements); // int energyVar; @@ -455,11 +455,11 @@ void ParticleSystemTypeProjectile::saveGame(XmlNode *rootNode) { // string trajectory; particleSystemTypeProjectileNode->addAttribute("trajectory",trajectory, mapTagReplacements); // float trajectorySpeed; - particleSystemTypeProjectileNode->addAttribute("trajectorySpeed",floatToStr(trajectorySpeed), mapTagReplacements); + particleSystemTypeProjectileNode->addAttribute("trajectorySpeed",floatToStr(trajectorySpeed,16), mapTagReplacements); // float trajectoryScale; - particleSystemTypeProjectileNode->addAttribute("trajectoryScale",floatToStr(trajectoryScale), mapTagReplacements); + particleSystemTypeProjectileNode->addAttribute("trajectoryScale",floatToStr(trajectoryScale,16), mapTagReplacements); // float trajectoryFrequency; - particleSystemTypeProjectileNode->addAttribute("trajectoryFrequency",floatToStr(trajectoryFrequency), mapTagReplacements); + particleSystemTypeProjectileNode->addAttribute("trajectoryFrequency",floatToStr(trajectoryFrequency,16), mapTagReplacements); } // =========================================================== @@ -538,15 +538,15 @@ void ParticleSystemTypeSplash::saveGame(XmlNode *rootNode) { XmlNode *particleSystemTypeSplashNode = rootNode->addChild("ParticleSystemTypeSplash"); // float emissionRateFade; - particleSystemTypeSplashNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade), mapTagReplacements); + particleSystemTypeSplashNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade,16), mapTagReplacements); // float verticalSpreadA; - particleSystemTypeSplashNode->addAttribute("verticalSpreadA",floatToStr(verticalSpreadA), mapTagReplacements); + particleSystemTypeSplashNode->addAttribute("verticalSpreadA",floatToStr(verticalSpreadA,16), mapTagReplacements); // float verticalSpreadB; - particleSystemTypeSplashNode->addAttribute("verticalSpreadB",floatToStr(verticalSpreadB), mapTagReplacements); + particleSystemTypeSplashNode->addAttribute("verticalSpreadB",floatToStr(verticalSpreadB,16), mapTagReplacements); // float horizontalSpreadA; - particleSystemTypeSplashNode->addAttribute("horizontalSpreadA",floatToStr(horizontalSpreadA), mapTagReplacements); + particleSystemTypeSplashNode->addAttribute("horizontalSpreadA",floatToStr(horizontalSpreadA,16), mapTagReplacements); // float horizontalSpreadB; - particleSystemTypeSplashNode->addAttribute("horizontalSpreadB",floatToStr(horizontalSpreadB), mapTagReplacements); + particleSystemTypeSplashNode->addAttribute("horizontalSpreadB",floatToStr(horizontalSpreadB,16), mapTagReplacements); } }}//end mamespace diff --git a/source/glest_game/graphics/unit_particle_type.cpp b/source/glest_game/graphics/unit_particle_type.cpp index 7bdc0fd3..5810766b 100644 --- a/source/glest_game/graphics/unit_particle_type.cpp +++ b/source/glest_game/graphics/unit_particle_type.cpp @@ -299,13 +299,13 @@ void UnitParticleSystemType::saveGame(XmlNode *rootNode) { // UnitParticleSystem::Shape shape; unitParticleSystemTypeNode->addAttribute("shape",intToStr(shape), mapTagReplacements); // float angle; - unitParticleSystemTypeNode->addAttribute("angle",floatToStr(angle), mapTagReplacements); + unitParticleSystemTypeNode->addAttribute("angle",floatToStr(angle,16), mapTagReplacements); // float radius; - unitParticleSystemTypeNode->addAttribute("radius",floatToStr(radius), mapTagReplacements); + unitParticleSystemTypeNode->addAttribute("radius",floatToStr(radius,16), mapTagReplacements); // float minRadius; - unitParticleSystemTypeNode->addAttribute("minRadius",floatToStr(minRadius), mapTagReplacements); + unitParticleSystemTypeNode->addAttribute("minRadius",floatToStr(minRadius,16), mapTagReplacements); // float emissionRateFade; - unitParticleSystemTypeNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade), mapTagReplacements); + unitParticleSystemTypeNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade,16), mapTagReplacements); // Vec3f direction; unitParticleSystemTypeNode->addAttribute("direction",direction.getString(), mapTagReplacements); // bool relative; @@ -329,9 +329,9 @@ void UnitParticleSystemType::saveGame(XmlNode *rootNode) { // int lifetime; unitParticleSystemTypeNode->addAttribute("lifetime",intToStr(lifetime), mapTagReplacements); // float startTime; - unitParticleSystemTypeNode->addAttribute("startTime",floatToStr(startTime), mapTagReplacements); + unitParticleSystemTypeNode->addAttribute("startTime",floatToStr(startTime,16), mapTagReplacements); // float endTime; - unitParticleSystemTypeNode->addAttribute("endTime",floatToStr(endTime), mapTagReplacements); + unitParticleSystemTypeNode->addAttribute("endTime",floatToStr(endTime,16), mapTagReplacements); } }}//end mamespace diff --git a/source/glest_game/type_instances/object.cpp b/source/glest_game/type_instances/object.cpp index 5e6952a6..2babac22 100644 --- a/source/glest_game/type_instances/object.cpp +++ b/source/glest_game/type_instances/object.cpp @@ -241,7 +241,7 @@ void Object::saveGame(XmlNode *rootNode) { // Vec3f pos; objectNode->addAttribute("pos",pos.getString(), mapTagReplacements); // float rotation; - objectNode->addAttribute("rotation",floatToStr(rotation), mapTagReplacements); + objectNode->addAttribute("rotation",floatToStr(rotation,16), mapTagReplacements); // int variation; objectNode->addAttribute("variation",intToStr(variation), mapTagReplacements); // int lastRenderFrame; diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index c4e71f90..3ffa1958 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -3733,11 +3733,11 @@ std::string Unit::toString() const { result += " ep = " + intToStr(this->ep); result += " loadCount = " + intToStr(this->loadCount); result += " deadCount = " + intToStr(this->deadCount); - result += " progress = " + floatToStr(this->progress); + result += " progress = " + floatToStr(this->progress,16); result += "\n"; - result += " lastAnimProgress = " + floatToStr(this->lastAnimProgress); - result += " animProgress = " + floatToStr(this->animProgress); - result += " highlight = " + floatToStr(this->highlight); + result += " lastAnimProgress = " + floatToStr(this->lastAnimProgress,16); + result += " animProgress = " + floatToStr(this->animProgress,16); + result += " highlight = " + floatToStr(this->highlight,16); result += " progress2 = " + intToStr(this->progress2); result += " kills = " + intToStr(this->kills); result += " enemyKills = " + intToStr(this->enemyKills); @@ -3764,9 +3764,9 @@ std::string Unit::toString() const { result += " meetingPos = " + meetingPos.getString(); result += "\n"; - result += " lastRotation = " + floatToStr(this->lastRotation); - result += " targetRotation = " + floatToStr(this->targetRotation); - result += " rotation = " + floatToStr(this->rotation); + result += " lastRotation = " + floatToStr(this->lastRotation,16); + result += " targetRotation = " + floatToStr(this->targetRotation,16); + result += " rotation = " + floatToStr(this->rotation,16); if(loadType != NULL) { result += " loadType = " + loadType->getName(); @@ -3831,13 +3831,13 @@ void Unit::saveGame(XmlNode *rootNode) { // int deadCount; unitNode->addAttribute("deadCount",intToStr(deadCount), mapTagReplacements); // float progress; //between 0 and 1 - unitNode->addAttribute("progress",floatToStr(progress), mapTagReplacements); + unitNode->addAttribute("progress",floatToStr(progress,16), mapTagReplacements); // float lastAnimProgress; //between 0 and 1 - unitNode->addAttribute("lastAnimProgress",floatToStr(lastAnimProgress), mapTagReplacements); + unitNode->addAttribute("lastAnimProgress",floatToStr(lastAnimProgress,16), mapTagReplacements); // float animProgress; //between 0 and 1 - unitNode->addAttribute("animProgress",floatToStr(animProgress), mapTagReplacements); + unitNode->addAttribute("animProgress",floatToStr(animProgress,16), mapTagReplacements); // float highlight; - unitNode->addAttribute("highlight",floatToStr(highlight), mapTagReplacements); + unitNode->addAttribute("highlight",floatToStr(highlight,16), mapTagReplacements); // int progress2; unitNode->addAttribute("progress2",intToStr(progress2), mapTagReplacements); // int kills; @@ -3867,19 +3867,19 @@ void Unit::saveGame(XmlNode *rootNode) { unitNode->addAttribute("meetingPos",meetingPos.getString(), mapTagReplacements); // // float lastRotation; //in degrees - unitNode->addAttribute("lastRotation",floatToStr(lastRotation), mapTagReplacements); + unitNode->addAttribute("lastRotation",floatToStr(lastRotation,16), mapTagReplacements); // float targetRotation; - unitNode->addAttribute("targetRotation",floatToStr(targetRotation), mapTagReplacements); + unitNode->addAttribute("targetRotation",floatToStr(targetRotation,16), mapTagReplacements); // float rotation; - unitNode->addAttribute("rotation",floatToStr(rotation), mapTagReplacements); + unitNode->addAttribute("rotation",floatToStr(rotation,16), mapTagReplacements); // float targetRotationZ; - unitNode->addAttribute("targetRotationZ",floatToStr(targetRotationZ), mapTagReplacements); + unitNode->addAttribute("targetRotationZ",floatToStr(targetRotationZ,16), mapTagReplacements); // float targetRotationX; - unitNode->addAttribute("targetRotationX",floatToStr(targetRotationX), mapTagReplacements); + unitNode->addAttribute("targetRotationX",floatToStr(targetRotationX,16), mapTagReplacements); // float rotationZ; - unitNode->addAttribute("rotationZ",floatToStr(rotationZ), mapTagReplacements); + unitNode->addAttribute("rotationZ",floatToStr(rotationZ,16), mapTagReplacements); // float rotationX; - unitNode->addAttribute("rotationX",floatToStr(rotationX), mapTagReplacements); + unitNode->addAttribute("rotationX",floatToStr(rotationX,16), mapTagReplacements); // const UnitType *type; unitNode->addAttribute("type",type->getName(), mapTagReplacements); // const ResourceType *loadType; diff --git a/source/glest_game/types/skill_type.cpp b/source/glest_game/types/skill_type.cpp index 136123f2..4722be31 100644 --- a/source/glest_game/types/skill_type.cpp +++ b/source/glest_game/types/skill_type.cpp @@ -665,7 +665,7 @@ void SkillType::saveGame(XmlNode *rootNode) { // // SoundContainer sounds; // float soundStartTime; - skillTypeNode->addAttribute("soundStartTime",floatToStr(soundStartTime), mapTagReplacements); + skillTypeNode->addAttribute("soundStartTime",floatToStr(soundStartTime,16), mapTagReplacements); // RandomGen random; skillTypeNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements); // AttackBoost attackBoost; @@ -886,7 +886,7 @@ void AttackSkillType::saveGame(XmlNode *rootNode) { attackFieldsNode->addAttribute("value",intToStr(attackFields[i]), mapTagReplacements); } // float attackStartTime; - attackSkillTypeNode->addAttribute("attackStartTime",floatToStr(attackStartTime), mapTagReplacements); + attackSkillTypeNode->addAttribute("attackStartTime",floatToStr(attackStartTime,16), mapTagReplacements); // string spawnUnit; attackSkillTypeNode->addAttribute("spawnUnit",spawnUnit, mapTagReplacements); // int spawnUnitcount; @@ -1173,7 +1173,7 @@ void FogOfWarSkillType::saveGame(XmlNode *rootNode) { fogSkillTypeNode->addAttribute("enable-fog",intToStr(fowEnable), mapTagReplacements); fogSkillTypeNode->addAttribute("apply-team",intToStr(applyToTeam), mapTagReplacements); - fogSkillTypeNode->addAttribute("duration",floatToStr(durationTime), mapTagReplacements); + fogSkillTypeNode->addAttribute("duration",floatToStr(durationTime,16), mapTagReplacements); } // ===================================================== diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index 67c01521..eb610409 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -1080,7 +1080,7 @@ std::string UnitType::toString() const { result += " sight = " + intToStr(sight); result += " size = " + intToStr(size); result += " height = " + intToStr(height); - result += " rotatedBuildPos = " + floatToStr(rotatedBuildPos); + result += " rotatedBuildPos = " + floatToStr(rotatedBuildPos,16); result += " rotationAllowed = " + intToStr(rotationAllowed); if(cellMap != NULL) { diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index 8cdf821c..b9635c1a 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -93,7 +93,7 @@ void Cell::saveGame(XmlNode *rootNode, int index) const { } // float height; - cellNode->addAttribute("height",floatToStr(height), mapTagReplacements); + cellNode->addAttribute("height",floatToStr(height,16), mapTagReplacements); } } @@ -1716,11 +1716,11 @@ void Map::saveGame(XmlNode *rootNode) const { // string title; mapNode->addAttribute("title",title, mapTagReplacements); // float waterLevel; - mapNode->addAttribute("waterLevel",floatToStr(waterLevel), mapTagReplacements); + mapNode->addAttribute("waterLevel",floatToStr(waterLevel,16), mapTagReplacements); // float heightFactor; - mapNode->addAttribute("heightFactor",floatToStr(heightFactor), mapTagReplacements); + mapNode->addAttribute("heightFactor",floatToStr(heightFactor,16), mapTagReplacements); // float cliffLevel; - mapNode->addAttribute("cliffLevel",floatToStr(cliffLevel), mapTagReplacements); + mapNode->addAttribute("cliffLevel",floatToStr(cliffLevel,16), mapTagReplacements); // int cameraHeight; mapNode->addAttribute("cameraHeight",intToStr(cameraHeight), mapTagReplacements); // int w; @@ -1800,7 +1800,7 @@ void Map::saveGame(XmlNode *rootNode) const { // Checksum checksumValue; // mapNode->addAttribute("checksumValue",intToStr(checksumValue.getSum()), mapTagReplacements); // float maxMapHeight; - mapNode->addAttribute("maxMapHeight",floatToStr(maxMapHeight), mapTagReplacements); + mapNode->addAttribute("maxMapHeight",floatToStr(maxMapHeight,16), mapTagReplacements); // string mapFile; mapNode->addAttribute("mapFile",mapFile, mapTagReplacements); } diff --git a/source/glest_game/world/minimap.cpp b/source/glest_game/world/minimap.cpp index 2db19cd6..60b7856a 100644 --- a/source/glest_game/world/minimap.cpp +++ b/source/glest_game/world/minimap.cpp @@ -267,12 +267,14 @@ void Minimap::saveGame(XmlNode *rootNode) { void Minimap::loadGame(const XmlNode *rootNode) { const XmlNode *minimapNode = rootNode->getChild("Minimap"); - vector fowPixmap1NodeList = minimapNode->getChildList("fowPixmap1"); - for(unsigned int i = 0; i < fowPixmap1NodeList.size(); ++i) { - XmlNode *fowPixmap1Node = fowPixmap1NodeList[i]; + if(minimapNode->hasChild("fowPixmap1") == true) { + vector fowPixmap1NodeList = minimapNode->getChildList("fowPixmap1"); + for(unsigned int i = 0; i < fowPixmap1NodeList.size(); ++i) { + XmlNode *fowPixmap1Node = fowPixmap1NodeList[i]; - int pixelIndex = fowPixmap1Node->getAttribute("index")->getIntValue(); - fowPixmap1->getPixels()[pixelIndex] = fowPixmap1Node->getAttribute("pixel")->getIntValue(); + int pixelIndex = fowPixmap1Node->getAttribute("index")->getIntValue(); + fowPixmap1->getPixels()[pixelIndex] = fowPixmap1Node->getAttribute("pixel")->getIntValue(); + } } } diff --git a/source/glest_game/world/time_flow.cpp b/source/glest_game/world/time_flow.cpp index c45597b0..d5faedd3 100644 --- a/source/glest_game/world/time_flow.cpp +++ b/source/glest_game/world/time_flow.cpp @@ -29,6 +29,15 @@ namespace Glest{ namespace Game{ const float TimeFlow::dusk= 18.f; const float TimeFlow::dawn= 6.f; +TimeFlow::TimeFlow() { + firstTime = false; + tileset = NULL; + time = 0.0f; + lastTime = 0.0f; + timeInc = 0.0f; + //printf("#1a timeInc = %f\n",timeInc); +} + void TimeFlow::init(Tileset *tileset){ firstTime= true; this->tileset= tileset; @@ -36,17 +45,21 @@ void TimeFlow::init(Tileset *tileset){ lastTime= time; Config &config= Config::getInstance(); timeInc= 24.f * (1.f / config.getFloat("DayTime")) / GameConstants::updateFps; + //printf("#1 timeInc = %f\n",timeInc); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] timeInc = %f\n",__FILE__,__FUNCTION__,__LINE__,timeInc); } void TimeFlow::update() { + //printf("START TimeFlow::update() time = %f\n",time); //update time time += isDay()? timeInc: timeInc*2; if(time > 24.f){ time -= 24.f; } + //printf("END TimeFlow::update() time = %f\n",time); + //sounds SoundRenderer &soundRenderer= SoundRenderer::getInstance(); AmbientSounds *ambientSounds= NULL; @@ -147,11 +160,13 @@ void TimeFlow::saveGame(XmlNode *rootNode) { // bool firstTime; // Tileset *tileset; // float time; - timeflowNode->addAttribute("time",floatToStr(time), mapTagReplacements); + timeflowNode->addAttribute("time",floatToStr(time,16), mapTagReplacements); // float lastTime; - timeflowNode->addAttribute("lastTime",floatToStr(lastTime), mapTagReplacements); + timeflowNode->addAttribute("lastTime",floatToStr(lastTime,16), mapTagReplacements); // float timeInc; - timeflowNode->addAttribute("timeInc",floatToStr(timeInc), mapTagReplacements); + //printf("#2 timeInc = %f\n",timeInc); + timeflowNode->addAttribute("timeInc",floatToStr(timeInc,16), mapTagReplacements); + //printf("#3 timeInc = %f\n",timeInc); } void TimeFlow::loadGame(const XmlNode *rootNode) { @@ -161,6 +176,7 @@ void TimeFlow::loadGame(const XmlNode *rootNode) { time = timeflowNode->getAttribute("time")->getFloatValue(); lastTime = timeflowNode->getAttribute("lastTime")->getFloatValue(); timeInc = timeflowNode->getAttribute("timeInc")->getFloatValue(); + //printf("#4 timeInc = %f\n",timeInc); } }}//end namespace diff --git a/source/glest_game/world/time_flow.h b/source/glest_game/world/time_flow.h index fc8ab597..55f8732f 100644 --- a/source/glest_game/world/time_flow.h +++ b/source/glest_game/world/time_flow.h @@ -47,13 +47,7 @@ private: float timeInc; public: - TimeFlow() { - firstTime = false; - tileset = NULL; - time = 0.0f; - lastTime = 0.0f; - timeInc = 0.0f; - } + TimeFlow(); void init(Tileset *tileset); inline float getTime() const {return time;} diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index e804c965..b5e8c97d 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -2618,7 +2618,7 @@ void UnitUpdater::saveGame(XmlNode *rootNode) { // RandomGen random; //unitupdaterNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements); // float attackWarnRange; - unitupdaterNode->addAttribute("attackWarnRange",floatToStr(attackWarnRange), mapTagReplacements); + unitupdaterNode->addAttribute("attackWarnRange",floatToStr(attackWarnRange,16), mapTagReplacements); // AttackWarnings attackWarnings; // // Mutex mutexUnitRangeCellsLookupItemCache; diff --git a/source/shared_lib/include/xml/xml_parser.h b/source/shared_lib/include/xml/xml_parser.h index d68707e4..90a1af43 100644 --- a/source/shared_lib/include/xml/xml_parser.h +++ b/source/shared_lib/include/xml/xml_parser.h @@ -148,6 +148,7 @@ public: vector getChildList(const string &childName) const; bool hasChildAtIndex(const string &childName, int childIndex=0) const; bool hasChild(const string &childName) const; + int clearChild(const string &childName); XmlNode *getParent() const; diff --git a/source/shared_lib/sources/graphics/interpolation.cpp b/source/shared_lib/sources/graphics/interpolation.cpp index f247e32e..5ca67cd8 100644 --- a/source/shared_lib/sources/graphics/interpolation.cpp +++ b/source/shared_lib/sources/graphics/interpolation.cpp @@ -85,7 +85,7 @@ void InterpolationData::updateVertices(float t, bool cycle) { } //assert(t>=0.0f && t<=1.0f); if(t < 0.0f || t > 1.0f) { - throw megaglest_runtime_error("t < 0.0f || t > 1.0f t = [" + floatToStr(t) + "]"); + throw megaglest_runtime_error("t < 0.0f || t > 1.0f t = [" + floatToStr(t,16) + "]"); assert(t >= 0.f && t <= 1.f); } @@ -145,7 +145,7 @@ void InterpolationData::updateVertices(float t, bool cycle) { void InterpolationData::updateNormals(float t, bool cycle){ if(t < 0.0f || t > 1.0f) { - throw megaglest_runtime_error("t < 0.0f || t > 1.0f t = [" + floatToStr(t) + "]"); + throw megaglest_runtime_error("t < 0.0f || t > 1.0f t = [" + floatToStr(t,16) + "]"); assert(t>=0.0f && t<=1.0f); } diff --git a/source/shared_lib/sources/graphics/particle.cpp b/source/shared_lib/sources/graphics/particle.cpp index 854c6f94..9ed597ff 100644 --- a/source/shared_lib/sources/graphics/particle.cpp +++ b/source/shared_lib/sources/graphics/particle.cpp @@ -55,7 +55,7 @@ void Particle::saveGame(XmlNode *rootNode) { // Vec4f color; particleNode->addAttribute("color",color.getString(), mapTagReplacements); // float size; - particleNode->addAttribute("size",floatToStr(size), mapTagReplacements); + particleNode->addAttribute("size",floatToStr(size,16), mapTagReplacements); // int energy; particleNode->addAttribute("energy",intToStr(energy), mapTagReplacements); } @@ -290,12 +290,12 @@ string ParticleSystem::toString() const { result += "\npos = " + pos.getString(); result += "\ncolor = " + color.getString(); result += "\ncolorNoEnergy = " + colorNoEnergy.getString(); - result += "\nemissionRate = " + floatToStr(emissionRate); - result += "\nemissionState = " + floatToStr(emissionState); + result += "\nemissionRate = " + floatToStr(emissionRate,16); + result += "\nemissionState = " + floatToStr(emissionState,16); result += "\nmaxParticleEnergy = " + intToStr(maxParticleEnergy); result += "\nvarParticleEnergy = " + intToStr(varParticleEnergy); - result += "\nparticleSize = " + floatToStr(particleSize); - result += "\nspeed = " + floatToStr(speed); + result += "\nparticleSize = " + floatToStr(particleSize,16); + result += "\nspeed = " + floatToStr(speed,16); result += "\nfactionColor = " + factionColor.getString(); result += "\nteamcolorNoEnergy = " + intToStr(teamcolorNoEnergy); result += "\nteamcolorEnergy = " + intToStr(teamcolorEnergy); @@ -348,17 +348,17 @@ void ParticleSystem::saveGame(XmlNode *rootNode) { // Vec4f colorNoEnergy; particleSystemNode->addAttribute("colorNoEnergy",colorNoEnergy.getString(), mapTagReplacements); // float emissionRate; - particleSystemNode->addAttribute("emissionRate",floatToStr(emissionRate), mapTagReplacements); + particleSystemNode->addAttribute("emissionRate",floatToStr(emissionRate,16), mapTagReplacements); // float emissionState; - particleSystemNode->addAttribute("emissionState",floatToStr(emissionState), mapTagReplacements); + particleSystemNode->addAttribute("emissionState",floatToStr(emissionState,16), 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); + particleSystemNode->addAttribute("particleSize",floatToStr(particleSize,16), mapTagReplacements); // float speed; - particleSystemNode->addAttribute("speed",floatToStr(speed), mapTagReplacements); + particleSystemNode->addAttribute("speed",floatToStr(speed,16), mapTagReplacements); // Vec3f factionColor; particleSystemNode->addAttribute("factionColor",factionColor.getString(), mapTagReplacements); // bool teamcolorNoEnergy; @@ -674,7 +674,7 @@ void FireParticleSystem::saveGame(XmlNode *rootNode) { ParticleSystem::saveGame(fireParticleSystemNode); // float radius; - fireParticleSystemNode->addAttribute("radius",floatToStr(radius), mapTagReplacements); + fireParticleSystemNode->addAttribute("radius",floatToStr(radius,16), mapTagReplacements); // Vec3f windSpeed; fireParticleSystemNode->addAttribute("windSpeed",windSpeed.getString(), mapTagReplacements); } @@ -841,13 +841,13 @@ void GameParticleSystem::saveGame(XmlNode *rootNode) { gameParticleSystemNode->addAttribute("model",model->getFileName(), mapTagReplacements); } // float modelCycle; - gameParticleSystemNode->addAttribute("modelCycle",floatToStr(modelCycle), mapTagReplacements); + gameParticleSystemNode->addAttribute("modelCycle",floatToStr(modelCycle,16), mapTagReplacements); // Vec3f offset; gameParticleSystemNode->addAttribute("offset",offset.getString(), mapTagReplacements); // Vec3f direction; gameParticleSystemNode->addAttribute("direction",direction.getString(), mapTagReplacements); // float tween; - gameParticleSystemNode->addAttribute("tween",floatToStr(tween), mapTagReplacements); + gameParticleSystemNode->addAttribute("tween",floatToStr(tween,16), mapTagReplacements); } void GameParticleSystem::loadGame(const XmlNode *rootNode) { const XmlNode *gameParticleSystemNode = rootNode->getChild("GameParticleSystem"); @@ -1166,9 +1166,9 @@ void UnitParticleSystem::saveGame(XmlNode *rootNode) { GameParticleSystem::saveGame(unitParticleSystemNode); // float radius; - unitParticleSystemNode->addAttribute("radius",floatToStr(radius), mapTagReplacements); + unitParticleSystemNode->addAttribute("radius",floatToStr(radius,16), mapTagReplacements); // float minRadius; - unitParticleSystemNode->addAttribute("minRadius",floatToStr(minRadius), mapTagReplacements); + unitParticleSystemNode->addAttribute("minRadius",floatToStr(minRadius,16), mapTagReplacements); // Vec3f windSpeed; unitParticleSystemNode->addAttribute("windSpeed",windSpeed.getString(), mapTagReplacements); // Vec3f cRotation; @@ -1180,9 +1180,9 @@ void UnitParticleSystem::saveGame(XmlNode *rootNode) { // bool energyUp; unitParticleSystemNode->addAttribute("energyUp",intToStr(energyUp), mapTagReplacements); // float startTime; - unitParticleSystemNode->addAttribute("startTime",floatToStr(startTime), mapTagReplacements); + unitParticleSystemNode->addAttribute("startTime",floatToStr(startTime,16), mapTagReplacements); // float endTime; - unitParticleSystemNode->addAttribute("endTime",floatToStr(endTime), mapTagReplacements); + unitParticleSystemNode->addAttribute("endTime",floatToStr(endTime,16), mapTagReplacements); // bool relative; unitParticleSystemNode->addAttribute("relative",intToStr(relative), mapTagReplacements); // bool relativeDirection; @@ -1192,13 +1192,13 @@ void UnitParticleSystem::saveGame(XmlNode *rootNode) { // Shape shape; unitParticleSystemNode->addAttribute("shape",intToStr(shape), mapTagReplacements); // float angle; - unitParticleSystemNode->addAttribute("angle",floatToStr(angle), mapTagReplacements); + unitParticleSystemNode->addAttribute("angle",floatToStr(angle,16), mapTagReplacements); // float sizeNoEnergy; - unitParticleSystemNode->addAttribute("sizeNoEnergy",floatToStr(sizeNoEnergy), mapTagReplacements); + unitParticleSystemNode->addAttribute("sizeNoEnergy",floatToStr(sizeNoEnergy,16), mapTagReplacements); // float gravity; - unitParticleSystemNode->addAttribute("gravity",floatToStr(gravity), mapTagReplacements); + unitParticleSystemNode->addAttribute("gravity",floatToStr(gravity,16), mapTagReplacements); // float rotation; - unitParticleSystemNode->addAttribute("rotation",floatToStr(rotation), mapTagReplacements); + unitParticleSystemNode->addAttribute("rotation",floatToStr(rotation,16), mapTagReplacements); // bool isVisibleAtNight; unitParticleSystemNode->addAttribute("isVisibleAtNight",intToStr(isVisibleAtNight), mapTagReplacements); // bool isVisibleAtDay; @@ -1214,7 +1214,7 @@ void UnitParticleSystem::saveGame(XmlNode *rootNode) { // int lifetime; unitParticleSystemNode->addAttribute("lifetime",intToStr(lifetime), mapTagReplacements); // float emissionRateFade; - unitParticleSystemNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade), mapTagReplacements); + unitParticleSystemNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade,16), mapTagReplacements); // GameParticleSystem* parent; //if(parent != NULL) { // parent->saveGame(unitParticleSystemNode); @@ -1416,9 +1416,9 @@ void AttackParticleSystem::saveGame(XmlNode *rootNode) { GameParticleSystem::saveGame(attackParticleSystemNode); // float sizeNoEnergy; - attackParticleSystemNode->addAttribute("sizeNoEnergy",floatToStr(sizeNoEnergy), mapTagReplacements); + attackParticleSystemNode->addAttribute("sizeNoEnergy",floatToStr(sizeNoEnergy,16), mapTagReplacements); // float gravity; - attackParticleSystemNode->addAttribute("gravity",floatToStr(gravity), mapTagReplacements); + attackParticleSystemNode->addAttribute("gravity",floatToStr(gravity,16), mapTagReplacements); } void AttackParticleSystem::loadGame(const XmlNode *rootNode) { @@ -1668,12 +1668,12 @@ void ProjectileParticleSystem::saveGame(XmlNode *rootNode) { // Trajectory trajectory; projectileParticleSystemNode->addAttribute("trajectory",intToStr(trajectory), mapTagReplacements); // float trajectorySpeed; - projectileParticleSystemNode->addAttribute("trajectorySpeed",floatToStr(trajectorySpeed), mapTagReplacements); + projectileParticleSystemNode->addAttribute("trajectorySpeed",floatToStr(trajectorySpeed,16), mapTagReplacements); // //parabolic // float trajectoryScale; - projectileParticleSystemNode->addAttribute("trajectoryScale",floatToStr(trajectoryScale), mapTagReplacements); + projectileParticleSystemNode->addAttribute("trajectoryScale",floatToStr(trajectoryScale,16), mapTagReplacements); // float trajectoryFrequency; - projectileParticleSystemNode->addAttribute("trajectoryFrequency",floatToStr(trajectoryFrequency), mapTagReplacements); + projectileParticleSystemNode->addAttribute("trajectoryFrequency",floatToStr(trajectoryFrequency,16), mapTagReplacements); } void ProjectileParticleSystem::loadGame(const XmlNode *rootNode) { @@ -1802,18 +1802,18 @@ void SplashParticleSystem::saveGame(XmlNode *rootNode) { } // float emissionRateFade; - splashParticleSystemNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade), mapTagReplacements); + splashParticleSystemNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade,16), mapTagReplacements); // float verticalSpreadA; - splashParticleSystemNode->addAttribute("verticalSpreadA",floatToStr(verticalSpreadA), mapTagReplacements); + splashParticleSystemNode->addAttribute("verticalSpreadA",floatToStr(verticalSpreadA,16), mapTagReplacements); // float verticalSpreadB; - splashParticleSystemNode->addAttribute("verticalSpreadB",floatToStr(verticalSpreadB), mapTagReplacements); + splashParticleSystemNode->addAttribute("verticalSpreadB",floatToStr(verticalSpreadB,16), mapTagReplacements); // float horizontalSpreadA; - splashParticleSystemNode->addAttribute("horizontalSpreadA",floatToStr(horizontalSpreadA), mapTagReplacements); + splashParticleSystemNode->addAttribute("horizontalSpreadA",floatToStr(horizontalSpreadA,16), mapTagReplacements); // float horizontalSpreadB; - splashParticleSystemNode->addAttribute("horizontalSpreadB",floatToStr(horizontalSpreadB), mapTagReplacements); + splashParticleSystemNode->addAttribute("horizontalSpreadB",floatToStr(horizontalSpreadB,16), mapTagReplacements); // // float startEmissionRate; - splashParticleSystemNode->addAttribute("startEmissionRate",floatToStr(startEmissionRate), mapTagReplacements); + splashParticleSystemNode->addAttribute("startEmissionRate",floatToStr(startEmissionRate,16), mapTagReplacements); } void SplashParticleSystem::loadGame(const XmlNode *rootNode) { diff --git a/source/shared_lib/sources/util/properties.cpp b/source/shared_lib/sources/util/properties.cpp index 709164d9..9a315620 100644 --- a/source/shared_lib/sources/util/properties.cpp +++ b/source/shared_lib/sources/util/properties.cpp @@ -413,7 +413,7 @@ float Properties::getFloat(const string &key, const char *defaultValueIfNotFound float Properties::getFloat(const string &key, float min, float max, const char *defaultValueIfNotFound) const{ float f= getFloat(key,defaultValueIfNotFound); if(fmax){ - throw megaglest_runtime_error("Value out of range: " + key + ", min: " + floatToStr(min) + ", max: " + floatToStr(max)); + throw megaglest_runtime_error("Value out of range: " + key + ", min: " + floatToStr(min,16) + ", max: " + floatToStr(max,16)); } return f; } @@ -470,7 +470,7 @@ void Properties::setBool(const string &key, bool value){ } void Properties::setFloat(const string &key, float value){ - setString(key, floatToStr(value)); + setString(key, floatToStr(value,16)); } void Properties::setString(const string &key, const string &value){ diff --git a/source/shared_lib/sources/xml/xml_parser.cpp b/source/shared_lib/sources/xml/xml_parser.cpp index 233b2c36..87683793 100644 --- a/source/shared_lib/sources/xml/xml_parser.cpp +++ b/source/shared_lib/sources/xml/xml_parser.cpp @@ -613,6 +613,18 @@ bool XmlNode::hasAttribute(const string &name) const { return result; } +int XmlNode::clearChild(const string &childName) { + int clearChildCount = 0; + for(int i = children.size()-1; i >= 0; --i) { + if(children[i]->getName() == childName) { + delete children[i]; + children.erase(children.begin()+i); + clearChildCount++; + } + } + return clearChildCount; +} + XmlNode *XmlNode::getChild(unsigned int i) const { assert(!superNode); if(i >= children.size()) {