diff --git a/source/glest_game/ai/ai.cpp b/source/glest_game/ai/ai.cpp index a80a365e..26fa25a8 100644 --- a/source/glest_game/ai/ai.cpp +++ b/source/glest_game/ai/ai.cpp @@ -179,7 +179,7 @@ BuildTask * BuildTask::loadGame(const XmlNode *rootNode, Faction *faction) { newTask->resourceType = faction->getTechTree()->getResourceType(resourceTypeName); } - newTask->forcePos = buildTaskNode->getAttribute("forcePos")->getIntValue(); + newTask->forcePos = buildTaskNode->getAttribute("forcePos")->getIntValue() != 0; newTask->pos = Vec2i::strToVec2(buildTaskNode->getAttribute("pos")->getValue()); return newTask; @@ -1203,7 +1203,7 @@ void Ai::loadGame(const XmlNode *rootNode, Faction *faction) { const XmlNode *aiNode = rootNode->getChild("Ai"); startLoc = aiNode->getAttribute("startLoc")->getIntValue(); - randomMinWarriorsReached = aiNode->getAttribute("randomMinWarriorsReached")->getIntValue(); + randomMinWarriorsReached = aiNode->getAttribute("randomMinWarriorsReached")->getIntValue() != 0; vector taskNodeList = aiNode->getChildList("Task"); for(unsigned int i = 0; i < taskNodeList.size(); ++i) { diff --git a/source/glest_game/ai/ai_interface.cpp b/source/glest_game/ai/ai_interface.cpp index 13e43937..ee8c86a5 100644 --- a/source/glest_game/ai/ai_interface.cpp +++ b/source/glest_game/ai/ai_interface.cpp @@ -734,7 +734,7 @@ void AiInterface::loadGame(const XmlNode *rootNode, Faction *faction) { teamIndex = aiInterfaceNode->getAttribute("teamIndex")->getIntValue(); // //config // bool redir; - redir = aiInterfaceNode->getAttribute("redir")->getIntValue(); + redir = aiInterfaceNode->getAttribute("redir")->getIntValue() != 0; // int logLevel; logLevel = aiInterfaceNode->getAttribute("logLevel")->getIntValue(); diff --git a/source/glest_game/ai/path_finder.cpp b/source/glest_game/ai/path_finder.cpp index db6edfe9..337d84cb 100644 --- a/source/glest_game/ai/path_finder.cpp +++ b/source/glest_game/ai/path_finder.cpp @@ -1710,7 +1710,7 @@ void PathFinder::loadGame(const XmlNode *rootNode) { // float heuristic; curNode->heuristic = nodePoolNode->getAttribute("heuristic")->getFloatValue(); // bool exploredCell; - curNode->exploredCell = nodePoolNode->getAttribute("exploredCell")->getIntValue(); + curNode->exploredCell = nodePoolNode->getAttribute("exploredCell")->getIntValue() != 0; } // int nodePoolCount; diff --git a/source/glest_game/game/commander.cpp b/source/glest_game/game/commander.cpp index c82d18c6..bc944d19 100644 --- a/source/glest_game/game/commander.cpp +++ b/source/glest_game/game/commander.cpp @@ -707,7 +707,7 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const { int votingFactionIndex = networkCommand->getUnitId(); int factionIndex = networkCommand->getCommandTypeId(); - bool allowSwitchTeam = networkCommand->getUnitTypeId(); + bool allowSwitchTeam = networkCommand->getUnitTypeId() != 0; Faction *faction = world->getFaction(votingFactionIndex); @@ -806,7 +806,7 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const { commandWasHandled = true; - bool pauseGame = networkCommand->getUnitId(); + bool pauseGame = networkCommand->getUnitId() != 0; Game *game = this->world->getGame(); //printf("nctPauseResume pauseGame = %d\n",pauseGame); diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 6dc45cdf..203f6a6f 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -3949,9 +3949,9 @@ void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode) { newGame->tickCount = gameNode->getAttribute("tickCount")->getIntValue(); //bool paused; - newGame->paused = gameNode->getAttribute("paused")->getIntValue(); + newGame->paused = gameNode->getAttribute("paused")->getIntValue() != 0; //bool gameOver; - newGame->gameOver = gameNode->getAttribute("gameOver")->getIntValue(); + newGame->gameOver = gameNode->getAttribute("gameOver")->getIntValue() != 0; //bool renderNetworkStatus; //bool showFullConsole; //bool mouseMoved; @@ -4004,13 +4004,13 @@ void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode) { //bool photoModeEnabled; //gameNode->addAttribute("photoModeEnabled",intToStr(photoModeEnabled), mapTagReplacements); - newGame->photoModeEnabled = gameNode->getAttribute("photoModeEnabled")->getIntValue(); + newGame->photoModeEnabled = gameNode->getAttribute("photoModeEnabled")->getIntValue() != 0; //bool visibleHUD; //gameNode->addAttribute("visibleHUD",intToStr(visibleHUD), mapTagReplacements); - newGame->visibleHUD = gameNode->getAttribute("visibleHUD")->getIntValue(); + newGame->visibleHUD = gameNode->getAttribute("visibleHUD")->getIntValue() != 0; //bool withRainEffect; //gameNode->addAttribute("withRainEffect",intToStr(withRainEffect), mapTagReplacements); - newGame->withRainEffect = gameNode->getAttribute("withRainEffect")->getIntValue(); + newGame->withRainEffect = gameNode->getAttribute("withRainEffect")->getIntValue() != 0; //Program *program; //bool gameStarted; diff --git a/source/glest_game/game/game_camera.cpp b/source/glest_game/game/game_camera.cpp index e93841a2..0e8af934 100644 --- a/source/glest_game/game/game_camera.cpp +++ b/source/glest_game/game/game_camera.cpp @@ -502,7 +502,7 @@ void GameCamera::loadGame(const XmlNode *rootNode) { // float speed; speed = gamecameraNode->getAttribute("speed")->getFloatValue(); // bool clampBounds; - clampBounds = gamecameraNode->getAttribute("clampBounds")->getIntValue(); + clampBounds = gamecameraNode->getAttribute("clampBounds")->getIntValue() != 0; // //float maxRenderDistance; // float maxHeight; maxHeight = gamecameraNode->getAttribute("maxHeight")->getFloatValue(); diff --git a/source/glest_game/game/game_settings.h b/source/glest_game/game/game_settings.h index 61e8db03..c95661fa 100644 --- a/source/glest_game/game/game_settings.h +++ b/source/glest_game/game/game_settings.h @@ -487,23 +487,23 @@ public: // // // bool defaultUnits; - defaultUnits = gameSettingsNode->getAttribute("defaultUnits")->getIntValue(); + defaultUnits = gameSettingsNode->getAttribute("defaultUnits")->getIntValue() != 0; // bool defaultResources; - defaultResources = gameSettingsNode->getAttribute("defaultResources")->getIntValue(); + defaultResources = gameSettingsNode->getAttribute("defaultResources")->getIntValue() != 0; // bool defaultVictoryConditions; - defaultVictoryConditions = gameSettingsNode->getAttribute("defaultVictoryConditions")->getIntValue(); + defaultVictoryConditions = gameSettingsNode->getAttribute("defaultVictoryConditions")->getIntValue() != 0; // bool fogOfWar; - fogOfWar = gameSettingsNode->getAttribute("fogOfWar")->getIntValue(); + fogOfWar = gameSettingsNode->getAttribute("fogOfWar")->getIntValue() != 0; // bool allowObservers; - allowObservers = gameSettingsNode->getAttribute("allowObservers")->getIntValue(); + allowObservers = gameSettingsNode->getAttribute("allowObservers")->getIntValue() != 0; // bool enableObserverModeAtEndGame; - enableObserverModeAtEndGame = gameSettingsNode->getAttribute("enableObserverModeAtEndGame")->getIntValue(); + enableObserverModeAtEndGame = gameSettingsNode->getAttribute("enableObserverModeAtEndGame")->getIntValue() != 0; // bool enableServerControlledAI; - enableServerControlledAI = gameSettingsNode->getAttribute("enableServerControlledAI")->getIntValue(); + enableServerControlledAI = gameSettingsNode->getAttribute("enableServerControlledAI")->getIntValue() != 0; // int networkFramePeriod; networkFramePeriod = gameSettingsNode->getAttribute("networkFramePeriod")->getIntValue(); // bool networkPauseGameForLaggedClients; - networkPauseGameForLaggedClients = gameSettingsNode->getAttribute("networkPauseGameForLaggedClients")->getIntValue(); + networkPauseGameForLaggedClients = gameSettingsNode->getAttribute("networkPauseGameForLaggedClients")->getIntValue() != 0; // PathFinderType pathFinderType; pathFinderType = static_cast(gameSettingsNode->getAttribute("pathFinderType")->getIntValue()); // uint32 flagTypes1; diff --git a/source/glest_game/game/script_manager.cpp b/source/glest_game/game/script_manager.cpp index 4f3a35f7..40692344 100644 --- a/source/glest_game/game/script_manager.cpp +++ b/source/glest_game/game/script_manager.cpp @@ -105,9 +105,9 @@ void PlayerModifiers::saveGame(XmlNode *rootNode) { void PlayerModifiers::loadGame(const XmlNode *rootNode) { const XmlNode *playerModifiersNode = rootNode; - winner = playerModifiersNode->getAttribute("winner")->getIntValue(); - aiEnabled = playerModifiersNode->getAttribute("aiEnabled")->getIntValue(); - consumeEnabled = playerModifiersNode->getAttribute("consumeEnabled")->getIntValue(); + winner = playerModifiersNode->getAttribute("winner")->getIntValue() != 0; + aiEnabled = playerModifiersNode->getAttribute("aiEnabled")->getIntValue() != 0; + consumeEnabled = playerModifiersNode->getAttribute("consumeEnabled")->getIntValue() != 0; } CellTriggerEvent::CellTriggerEvent() { @@ -173,7 +173,7 @@ void TimerTriggerEvent::saveGame(XmlNode *rootNode) { void TimerTriggerEvent::loadGame(const XmlNode *rootNode) { const XmlNode *timerTriggerEventNode = rootNode->getChild("TimerTriggerEvent"); - running = timerTriggerEventNode->getAttribute("running")->getIntValue(); + running = timerTriggerEventNode->getAttribute("running")->getIntValue() != 0; startFrame = timerTriggerEventNode->getAttribute("startFrame")->getIntValue(); endFrame = timerTriggerEventNode->getAttribute("endFrame")->getIntValue(); if(timerTriggerEventNode->hasAttribute("triggerSecondsElapsed") == true) { @@ -2099,7 +2099,7 @@ int ScriptManager::getIsGameOver(LuaHandle* luaHandle){ int ScriptManager::loadScenario(LuaHandle* luaHandle) { LuaArguments luaArguments(luaHandle); - thisScriptManager->loadScenario(luaArguments.getString(-2),luaArguments.getInt(-1)); + thisScriptManager->loadScenario(luaArguments.getString(-2),luaArguments.getInt(-1) != 0); return luaArguments.getReturnCount(); } @@ -2251,7 +2251,7 @@ void ScriptManager::loadGame(const XmlNode *rootNode) { } // GraphicMessageBox messageBox; - messageBox.setEnabled(scriptManagerNode->getAttribute("messageBox_enabled")->getIntValue()); + messageBox.setEnabled(scriptManagerNode->getAttribute("messageBox_enabled")->getIntValue() != 0); messageBox.setText(wrapString(scriptManagerNode->getAttribute("messageBox_text")->getValue(),messageWrapCount)); messageBox.setHeader(scriptManagerNode->getAttribute("messageBox_header")->getValue()); @@ -2292,9 +2292,9 @@ void ScriptManager::loadGame(const XmlNode *rootNode) { // // // end game state // bool gameOver; - gameOver = scriptManagerNode->getAttribute("gameOver")->getIntValue(); + gameOver = scriptManagerNode->getAttribute("gameOver")->getIntValue() != 0; // bool gameWon; - gameWon = scriptManagerNode->getAttribute("gameWon")->getIntValue(); + gameWon = scriptManagerNode->getAttribute("gameWon")->getIntValue() != 0; // PlayerModifiers playerModifiers[GameConstants::maxPlayers]; vector playerModifiersNodeList = scriptManagerNode->getChildList("PlayerModifiers"); for(unsigned int i = 0; i < playerModifiersNodeList.size(); ++i) { @@ -2327,7 +2327,7 @@ void ScriptManager::loadGame(const XmlNode *rootNode) { } // bool inCellTriggerEvent; - inCellTriggerEvent = scriptManagerNode->getAttribute("inCellTriggerEvent")->getIntValue(); + inCellTriggerEvent = scriptManagerNode->getAttribute("inCellTriggerEvent")->getIntValue() != 0; // std::vector unRegisterCellTriggerEventList; vector unRegisterCellTriggerEventListNodeList = scriptManagerNode->getChildList("unRegisterCellTriggerEventList"); for(unsigned int i = 0; i < unRegisterCellTriggerEventListNodeList.size(); ++i) { diff --git a/source/glest_game/game/stats.cpp b/source/glest_game/game/stats.cpp index a0902dfb..db90a47d 100644 --- a/source/glest_game/game/stats.cpp +++ b/source/glest_game/game/stats.cpp @@ -238,7 +238,7 @@ void Stats::loadGame(const XmlNode *rootNode) { // int teamIndex; stat.teamIndex = statsNodePlayer->getAttribute("teamIndex")->getIntValue(); // bool victory; - stat.victory = statsNodePlayer->getAttribute("victory")->getIntValue(); + stat.victory = statsNodePlayer->getAttribute("victory")->getIntValue() != 0; // int kills; stat.kills = statsNodePlayer->getAttribute("kills")->getIntValue(); // int enemykills; diff --git a/source/glest_game/global/lang.cpp b/source/glest_game/global/lang.cpp index 5ff4843c..aa239c8e 100644 --- a/source/glest_game/global/lang.cpp +++ b/source/glest_game/global/lang.cpp @@ -344,7 +344,7 @@ bool Lang::fileMatchesISO630Code(string uselanguage, string testLanguageFile) { result = true; } } - catch(exception &ex) { + catch(const exception &ex) { } return result; @@ -388,7 +388,7 @@ string Lang::getNativeLanguageName(string uselanguage, string testLanguageFile) try { result = stringsTest.getString("NativeLanguageName"); } - catch(exception &ex) { + catch(const exception &ex) { } return result; diff --git a/source/glest_game/gui/gui.cpp b/source/glest_game/gui/gui.cpp index 8982f6ab..17c2d888 100644 --- a/source/glest_game/gui/gui.cpp +++ b/source/glest_game/gui/gui.cpp @@ -1288,7 +1288,7 @@ void Gui::loadGame(const XmlNode *rootNode, World *world) { //guiNode->addAttribute("posObjWorld",posObjWorld.getString(), mapTagReplacements); posObjWorld = Vec2i::strToVec2(guiNode->getAttribute("posObjWorld")->getValue()); // bool validPosObjWorld; - validPosObjWorld = guiNode->getAttribute("validPosObjWorld")->getIntValue(); + validPosObjWorld = guiNode->getAttribute("validPosObjWorld")->getIntValue() != 0; // //display // const UnitType *choosenBuildingType; // if(choosenBuildingType != NULL) { diff --git a/source/glest_game/menu/menu_state_graphic_info.cpp b/source/glest_game/menu/menu_state_graphic_info.cpp index 8909e866..45cee3f0 100644 --- a/source/glest_game/menu/menu_state_graphic_info.cpp +++ b/source/glest_game/menu/menu_state_graphic_info.cpp @@ -68,8 +68,8 @@ MenuStateGraphicInfo::MenuStateGraphicInfo(Program *program, MainMenu *mainMenu) strInternalInfo += "\nrenderText3DEnabled: " + boolToStr(Renderer::renderText3DEnabled); strInternalInfo += "\nuseTextureCompression: " + boolToStr(Texture::useTextureCompression); strInternalInfo += "\nfontIsRightToLeft: " + boolToStr(Font::fontIsRightToLeft); - strInternalInfo += "\nscaleFontValue: " + boolToStr(Font::scaleFontValue); - strInternalInfo += "\nscaleFontValueCenterHFactor: " + boolToStr(Font::scaleFontValueCenterHFactor); + strInternalInfo += "\nscaleFontValue: " + floatToStr(Font::scaleFontValue); + strInternalInfo += "\nscaleFontValueCenterHFactor: " + floatToStr(Font::scaleFontValueCenterHFactor); strInternalInfo += "\nlangHeightText: " + Font::langHeightText; strInternalInfo += "\nAllowAltEnterFullscreenToggle: " + boolToStr(Window::getAllowAltEnterFullscreenToggle()); strInternalInfo += "\nTryVSynch: " + boolToStr(Window::getTryVSynch()); @@ -106,8 +106,8 @@ void MenuStateGraphicInfo::reloadUI() { strInternalInfo += "\nrenderText3DEnabled: " + boolToStr(Renderer::renderText3DEnabled); strInternalInfo += "\nuseTextureCompression: " + boolToStr(Texture::useTextureCompression); strInternalInfo += "\nfontIsRightToLeft: " + boolToStr(Font::fontIsRightToLeft); - strInternalInfo += "\nscaleFontValue: " + boolToStr(Font::scaleFontValue); - strInternalInfo += "\nscaleFontValueCenterHFactor: " + boolToStr(Font::scaleFontValueCenterHFactor); + strInternalInfo += "\nscaleFontValue: " + floatToStr(Font::scaleFontValue); + strInternalInfo += "\nscaleFontValueCenterHFactor: " + floatToStr(Font::scaleFontValueCenterHFactor); strInternalInfo += "\nlangHeightText: " + Font::langHeightText; strInternalInfo += "\nAllowAltEnterFullscreenToggle: " + boolToStr(Window::getAllowAltEnterFullscreenToggle()); strInternalInfo += "\nTryVSynch: " + boolToStr(Window::getTryVSynch()); diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index 38754dc8..da13f968 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -2059,7 +2059,7 @@ void Faction::loadGame(const XmlNode *rootNode, int factionIndex,GameSettings *s // int startLocationIndex; startLocationIndex = factionNode->getAttribute("startLocationIndex")->getIntValue(); // bool thisFaction; - thisFaction = factionNode->getAttribute("thisFaction")->getIntValue(); + thisFaction = factionNode->getAttribute("thisFaction")->getIntValue() != 0; // bool factionDisconnectHandled; // for(std::map::iterator iterMap = cacheResourceTargetList.begin(); @@ -2089,7 +2089,7 @@ void Faction::loadGame(const XmlNode *rootNode, int factionIndex,GameSettings *s XmlNode *cachedCloseResourceTargetLookupListNode = cachedCloseResourceTargetLookupListNodeList[i]; Vec2i vec = Vec2i::strToVec2(cachedCloseResourceTargetLookupListNode->getAttribute("key")->getValue()); - cachedCloseResourceTargetLookupList[vec] = cachedCloseResourceTargetLookupListNode->getAttribute("value")->getIntValue(); + cachedCloseResourceTargetLookupList[vec] = cachedCloseResourceTargetLookupListNode->getAttribute("value")->getIntValue() != 0; } // RandomGen random; diff --git a/source/glest_game/type_instances/object.cpp b/source/glest_game/type_instances/object.cpp index 3046fffe..ecd0ca69 100644 --- a/source/glest_game/type_instances/object.cpp +++ b/source/glest_game/type_instances/object.cpp @@ -283,7 +283,7 @@ void Object::loadGame(const XmlNode *rootNode,const TechTree *techTree) { // Vec2i mapPos; mapPos = Vec2i::strToVec2(objectNode->getAttribute("mapPos")->getValue()); // bool visible; - visible = objectNode->getAttribute("visible")->getIntValue(); + visible = objectNode->getAttribute("visible")->getIntValue() != 0; } }}//end namespace diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 97b85702..9daa8292 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -3943,11 +3943,11 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction * result->animationRandomCycleCount = unitNode->getAttribute("animationRandomCycleCount")->getIntValue(); // // bool toBeUndertaken; - result->toBeUndertaken = unitNode->getAttribute("toBeUndertaken")->getIntValue(); + result->toBeUndertaken = unitNode->getAttribute("toBeUndertaken")->getIntValue() != 0; // bool alive; - result->alive = unitNode->getAttribute("alive")->getIntValue(); + result->alive = unitNode->getAttribute("alive")->getIntValue() != 0; // bool showUnitParticles; - result->showUnitParticles = unitNode->getAttribute("showUnitParticles")->getIntValue(); + result->showUnitParticles = unitNode->getAttribute("showUnitParticles")->getIntValue() != 0; // Faction *faction; // ParticleSystem *fire; // if(fire != NULL) { @@ -4153,7 +4153,7 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction * // int lastRenderFrame; result->lastRenderFrame = unitNode->getAttribute("lastRenderFrame")->getIntValue(); // bool visible; - result->visible = unitNode->getAttribute("visible")->getIntValue(); + result->visible = unitNode->getAttribute("visible")->getIntValue() != 0; // int retryCurrCommandCount; result->retryCurrCommandCount = unitNode->getAttribute("retryCurrCommandCount")->getIntValue(); // Vec3f screenPos; @@ -4162,7 +4162,7 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction * result->currentUnitTitle = unitNode->getAttribute("currentUnitTitle")->getValue(); // // bool inBailOutAttempt; - result->inBailOutAttempt = unitNode->getAttribute("inBailOutAttempt")->getIntValue(); + result->inBailOutAttempt = unitNode->getAttribute("inBailOutAttempt")->getIntValue() != 0; // //std::vector > badHarvestPosList; // std::map badHarvestPosList; // for(std::map::const_iterator iterMap = badHarvestPosList.begin(); @@ -4187,7 +4187,7 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction * // static Game *game; // // bool ignoreCheckCommand; - result->ignoreCheckCommand = unitNode->getAttribute("ignoreCheckCommand")->getIntValue(); + result->ignoreCheckCommand = unitNode->getAttribute("ignoreCheckCommand")->getIntValue() != 0; // uint32 lastStuckFrame; result->lastStuckFrame = unitNode->getAttribute("lastStuckFrame")->getIntValue(); // Vec2i lastStuckPos; @@ -4197,7 +4197,7 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction * // Vec2i lastPathfindFailedPos; result->lastPathfindFailedPos = Vec2i::strToVec2(unitNode->getAttribute("lastPathfindFailedPos")->getValue()); // bool usePathfinderExtendedMaxNodes; - result->usePathfinderExtendedMaxNodes = unitNode->getAttribute("usePathfinderExtendedMaxNodes")->getIntValue(); + result->usePathfinderExtendedMaxNodes = unitNode->getAttribute("usePathfinderExtendedMaxNodes")->getIntValue() != 0; // int maxQueuedCommandDisplayCount; result->maxQueuedCommandDisplayCount = unitNode->getAttribute("maxQueuedCommandDisplayCount")->getIntValue(); // UnitAttackBoostEffectOriginator currentAttackBoostOriginatorEffect; @@ -4214,7 +4214,7 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction * // //static std::map deletedUnits; // // bool changedActiveCommand; - result->changedActiveCommand = unitNode->getAttribute("changedActiveCommand")->getIntValue(); + result->changedActiveCommand = unitNode->getAttribute("changedActiveCommand")->getIntValue() != 0; // int lastAttackerUnitId; result->lastAttackerUnitId = unitNode->getAttribute("lastAttackerUnitId")->getIntValue(); // int lastAttackedUnitId; diff --git a/source/glest_game/types/upgrade_type.cpp b/source/glest_game/types/upgrade_type.cpp index d0c13708..22166b22 100644 --- a/source/glest_game/types/upgrade_type.cpp +++ b/source/glest_game/types/upgrade_type.cpp @@ -1093,7 +1093,7 @@ void TotalUpgrade::loadGame(const XmlNode *rootNode) { // int maxHp; maxHp = upgradeTypeBaseNode->getAttribute("maxHp")->getIntValue(); // bool maxHpIsMultiplier; - maxHpIsMultiplier = upgradeTypeBaseNode->getAttribute("maxHpIsMultiplier")->getIntValue(); + maxHpIsMultiplier = upgradeTypeBaseNode->getAttribute("maxHpIsMultiplier")->getIntValue() != 0; // int maxHpRegeneration; maxHpRegeneration = upgradeTypeBaseNode->getAttribute("maxHpRegeneration")->getIntValue(); // //bool maxHpRegenerationIsMultiplier; @@ -1101,22 +1101,22 @@ void TotalUpgrade::loadGame(const XmlNode *rootNode) { // int sight; sight = upgradeTypeBaseNode->getAttribute("sight")->getIntValue(); // bool sightIsMultiplier; - sightIsMultiplier = upgradeTypeBaseNode->getAttribute("sightIsMultiplier")->getIntValue(); + sightIsMultiplier = upgradeTypeBaseNode->getAttribute("sightIsMultiplier")->getIntValue() != 0; // int maxEp; maxEp = upgradeTypeBaseNode->getAttribute("maxEp")->getIntValue(); // bool maxEpIsMultiplier; - maxEpIsMultiplier = upgradeTypeBaseNode->getAttribute("maxEpIsMultiplier")->getIntValue(); + maxEpIsMultiplier = upgradeTypeBaseNode->getAttribute("maxEpIsMultiplier")->getIntValue() != 0; // int maxEpRegeneration; maxEpRegeneration = upgradeTypeBaseNode->getAttribute("maxEpRegeneration")->getIntValue(); // //bool maxEpRegenerationIsMultiplier; // int armor; armor = upgradeTypeBaseNode->getAttribute("armor")->getIntValue(); // bool armorIsMultiplier; - armorIsMultiplier = upgradeTypeBaseNode->getAttribute("armorIsMultiplier")->getIntValue(); + armorIsMultiplier = upgradeTypeBaseNode->getAttribute("armorIsMultiplier")->getIntValue() != 0; // int attackStrength; attackStrength = upgradeTypeBaseNode->getAttribute("attackStrength")->getIntValue(); // bool attackStrengthIsMultiplier; - attackStrengthIsMultiplier = upgradeTypeBaseNode->getAttribute("attackStrengthIsMultiplier")->getIntValue(); + attackStrengthIsMultiplier = upgradeTypeBaseNode->getAttribute("attackStrengthIsMultiplier")->getIntValue() != 0; // std::map attackStrengthMultiplierValueList; vector attackStrengthMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("attackStrengthMultiplierValueList"); for(unsigned int i = 0; i < attackStrengthMultiplierValueNodeList.size(); ++i) { @@ -1128,7 +1128,7 @@ void TotalUpgrade::loadGame(const XmlNode *rootNode) { // int attackRange; attackRange = upgradeTypeBaseNode->getAttribute("attackRange")->getIntValue(); // bool attackRangeIsMultiplier; - attackRangeIsMultiplier = upgradeTypeBaseNode->getAttribute("attackRangeIsMultiplier")->getIntValue(); + attackRangeIsMultiplier = upgradeTypeBaseNode->getAttribute("attackRangeIsMultiplier")->getIntValue() != 0; // std::map attackRangeMultiplierValueList; vector attackRangeMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("attackRangeMultiplierValueList"); for(unsigned int i = 0; i < attackRangeMultiplierValueNodeList.size(); ++i) { @@ -1141,7 +1141,7 @@ void TotalUpgrade::loadGame(const XmlNode *rootNode) { // int moveSpeed; moveSpeed = upgradeTypeBaseNode->getAttribute("moveSpeed")->getIntValue(); // bool moveSpeedIsMultiplier; - moveSpeedIsMultiplier = upgradeTypeBaseNode->getAttribute("moveSpeedIsMultiplier")->getIntValue(); + moveSpeedIsMultiplier = upgradeTypeBaseNode->getAttribute("moveSpeedIsMultiplier")->getIntValue() != 0; // std::map moveSpeedIsMultiplierValueList; vector moveSpeedIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("moveSpeedIsMultiplierValueList"); for(unsigned int i = 0; i < moveSpeedIsMultiplierValueNodeList.size(); ++i) { @@ -1154,7 +1154,7 @@ void TotalUpgrade::loadGame(const XmlNode *rootNode) { // int prodSpeed; prodSpeed = upgradeTypeBaseNode->getAttribute("prodSpeed")->getIntValue(); // bool prodSpeedIsMultiplier; - prodSpeedIsMultiplier = upgradeTypeBaseNode->getAttribute("prodSpeedIsMultiplier")->getIntValue(); + prodSpeedIsMultiplier = upgradeTypeBaseNode->getAttribute("prodSpeedIsMultiplier")->getIntValue() != 0; // std::map prodSpeedProduceIsMultiplierValueList; vector prodSpeedProduceIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("prodSpeedProduceIsMultiplierValueList"); for(unsigned int i = 0; i < prodSpeedProduceIsMultiplierValueNodeList.size(); ++i) { diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index d65a697c..9bf031ac 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -1997,7 +1997,7 @@ void Map::loadGame(const XmlNode *rootNode, World *world) { for(unsigned int k = 0; k < tokensExploredValue.size(); ++k) { string value = tokensExploredValue[k]; - surfaceCell.setExplored(k,strToInt(value)); + surfaceCell.setExplored(k,strToInt(value) != 0); } surfaceCellIndexExplored++; } @@ -2020,7 +2020,7 @@ void Map::loadGame(const XmlNode *rootNode, World *world) { for(unsigned int k = 0; k < tokensVisibleValue.size(); ++k) { string value = tokensVisibleValue[k]; - surfaceCell.setVisible(k,strToInt(value)); + surfaceCell.setVisible(k,strToInt(value) != 0); } surfaceCellIndexVisible++; } diff --git a/source/glest_game/world/time_flow.cpp b/source/glest_game/world/time_flow.cpp index ccb8316c..410bbb3e 100644 --- a/source/glest_game/world/time_flow.cpp +++ b/source/glest_game/world/time_flow.cpp @@ -144,7 +144,7 @@ void TimeFlow::saveGame(XmlNode *rootNode) { void TimeFlow::loadGame(const XmlNode *rootNode) { const XmlNode *timeflowNode = rootNode->getChild("TimeFlow"); - firstTime = timeflowNode->getAttribute("firstTime")->getFloatValue(); + firstTime = timeflowNode->getAttribute("firstTime")->getFloatValue() != 0; time = timeflowNode->getAttribute("time")->getFloatValue(); lastTime = timeflowNode->getAttribute("lastTime")->getFloatValue(); timeInc = timeflowNode->getAttribute("timeInc")->getFloatValue(); diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index dc72c1b7..2b87dc83 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -1480,21 +1480,21 @@ void World::initFactionTypes(GameSettings *gs) { safeMutex.ReleaseLock(); // //config // bool fogOfWarOverride; - fogOfWarOverride = loadWorldNode->getAttribute("fogOfWarOverride")->getIntValue(); + fogOfWarOverride = loadWorldNode->getAttribute("fogOfWarOverride")->getIntValue() != 0; // bool fogOfWar; - fogOfWar = loadWorldNode->getAttribute("fogOfWar")->getIntValue(); + fogOfWar = loadWorldNode->getAttribute("fogOfWar")->getIntValue() != 0; // int fogOfWarSmoothingFrameSkip; fogOfWarSmoothingFrameSkip = loadWorldNode->getAttribute("fogOfWarSmoothingFrameSkip")->getIntValue(); // bool fogOfWarSmoothing; - fogOfWarSmoothing = loadWorldNode->getAttribute("fogOfWarSmoothing")->getIntValue(); + fogOfWarSmoothing = loadWorldNode->getAttribute("fogOfWarSmoothing")->getIntValue() != 0; // Game *game; // Chrono chronoPerfTimer; // bool perfTimerEnabled; // // bool unitParticlesEnabled; - unitParticlesEnabled = loadWorldNode->getAttribute("unitParticlesEnabled")->getIntValue(); + unitParticlesEnabled = loadWorldNode->getAttribute("unitParticlesEnabled")->getIntValue() != 0; // bool staggeredFactionUpdates; - staggeredFactionUpdates = loadWorldNode->getAttribute("staggeredFactionUpdates")->getIntValue(); + staggeredFactionUpdates = loadWorldNode->getAttribute("staggeredFactionUpdates")->getIntValue() != 0; // std::map staticSoundList; // std::map streamSoundList; // @@ -1503,7 +1503,7 @@ void World::initFactionTypes(GameSettings *gs) { // string queuedScenarioName; queuedScenarioName = loadWorldNode->getAttribute("queuedScenarioName")->getValue(); // bool queuedScenarioKeepFactions; - queuedScenarioKeepFactions = loadWorldNode->getAttribute("queuedScenarioKeepFactions")->getIntValue(); + queuedScenarioKeepFactions = loadWorldNode->getAttribute("queuedScenarioKeepFactions")->getIntValue() != 0; } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/shared_lib/include/graphics/math_util.h b/source/shared_lib/include/graphics/math_util.h index 8fcfb279..6b8760dd 100644 --- a/source/shared_lib/include/graphics/math_util.h +++ b/source/shared_lib/include/graphics/math_util.h @@ -272,8 +272,8 @@ inline T truncateDecimal(const T &value, int precision=6) { int iSigned = value >= 0 ? 1: -1; #ifdef USE_STREFLOP - unsigned int uiTemp = (value * streflop::pow((streflop::Simple)10, (streflop::Simple)precision)) * iSigned; //Note I'm using unsigned int so that I can increase the precision of the truncate - T result = (((double)uiTemp) / streflop::pow((streflop::Simple)10,(streflop::Simple)precision) * iSigned); + unsigned int uiTemp = (unsigned int)(value * streflop::pow((streflop::Simple)10, (streflop::Simple)precision)) * iSigned; //Note I'm using unsigned int so that I can increase the precision of the truncate + T result = (((T)uiTemp) / streflop::pow((streflop::Simple)10,(streflop::Simple)precision) * iSigned); #else unsigned int uiTemp = (value * pow((T)10, precision)) * iSigned; //Note I'm using unsigned int so that I can increase the precision of the truncate T result = (((double)uiTemp) / pow((T)10,precision) * iSigned); diff --git a/source/shared_lib/include/platform/win32/platform_util.h b/source/shared_lib/include/platform/win32/platform_util.h index 6fb84967..25863c11 100644 --- a/source/shared_lib/include/platform/win32/platform_util.h +++ b/source/shared_lib/include/platform/win32/platform_util.h @@ -26,7 +26,7 @@ namespace Shared{ namespace Platform{ LPWSTR Ansi2WideString(LPCSTR lpaszString); std::string utf8_encode(const std::wstring wstr); -std::wstring utf8_decode(const std::string str); +std::wstring utf8_decode(const std::string &str); class megaglest_runtime_error : public runtime_error { public: diff --git a/source/shared_lib/sources/graphics/particle.cpp b/source/shared_lib/sources/graphics/particle.cpp index 4e91c962..6073b2a0 100644 --- a/source/shared_lib/sources/graphics/particle.cpp +++ b/source/shared_lib/sources/graphics/particle.cpp @@ -421,9 +421,9 @@ void ParticleSystem::loadGame(const XmlNode *rootNode) { // State state; state = static_cast(particleSystemNode->getAttribute("state")->getIntValue()); // bool active; - active = particleSystemNode->getAttribute("active")->getIntValue(); + active = particleSystemNode->getAttribute("active")->getIntValue() != 0; // bool visible; - visible = particleSystemNode->getAttribute("visible")->getIntValue(); + visible = particleSystemNode->getAttribute("visible")->getIntValue() != 0; // int aliveParticleCount; aliveParticleCount = particleSystemNode->getAttribute("aliveParticleCount")->getIntValue(); // int particleCount; @@ -461,9 +461,9 @@ void ParticleSystem::loadGame(const XmlNode *rootNode) { // Vec3f factionColor; factionColor = Vec3f::strToVec3(particleSystemNode->getAttribute("factionColor")->getValue()); // bool teamcolorNoEnergy; - teamcolorNoEnergy = particleSystemNode->getAttribute("teamcolorNoEnergy")->getIntValue(); + teamcolorNoEnergy = particleSystemNode->getAttribute("teamcolorNoEnergy")->getIntValue() != 0; // bool teamcolorEnergy; - teamcolorEnergy = particleSystemNode->getAttribute("teamcolorEnergy")->getIntValue(); + teamcolorEnergy = particleSystemNode->getAttribute("teamcolorEnergy")->getIntValue() != 0; // int alternations; alternations = particleSystemNode->getAttribute("alternations")->getIntValue(); // int particleSystemStartDelay; @@ -1091,7 +1091,7 @@ void UnitParticleSystem::updateParticle(Particle *p){ float energyRatio; if(alternations > 0){ int interval= (maxParticleEnergy / alternations); - float moduloValue= static_cast (static_cast (p->energy)) % interval; + float moduloValue= (float)((int)(static_cast (p->energy)) % interval); if(moduloValue < interval / 2){ energyRatio= (interval - moduloValue) / interval; @@ -1237,17 +1237,17 @@ void UnitParticleSystem::loadGame(const XmlNode *rootNode) { // Vec3f oldPosition; oldPosition = Vec3f::strToVec3(unitParticleSystemNode->getAttribute("oldPosition")->getValue()); // bool energyUp; - energyUp = unitParticleSystemNode->getAttribute("energyUp")->getIntValue(); + energyUp = unitParticleSystemNode->getAttribute("energyUp")->getIntValue() != 0; // float startTime; startTime = unitParticleSystemNode->getAttribute("startTime")->getFloatValue(); // float endTime; endTime = unitParticleSystemNode->getAttribute("endTime")->getFloatValue(); // bool relative; - relative = unitParticleSystemNode->getAttribute("relative")->getIntValue(); + relative = unitParticleSystemNode->getAttribute("relative")->getIntValue() != 0; // bool relativeDirection; - relativeDirection = unitParticleSystemNode->getAttribute("relativeDirection")->getIntValue(); + relativeDirection = unitParticleSystemNode->getAttribute("relativeDirection")->getIntValue() != 0; // bool fixed; - fixed = unitParticleSystemNode->getAttribute("fixed")->getIntValue(); + fixed = unitParticleSystemNode->getAttribute("fixed")->getIntValue() != 0; // Shape shape; shape = static_cast(unitParticleSystemNode->getAttribute("shape")->getIntValue()); // float angle; @@ -1259,13 +1259,13 @@ void UnitParticleSystem::loadGame(const XmlNode *rootNode) { // float rotation; rotation = unitParticleSystemNode->getAttribute("rotation")->getFloatValue(); // bool isVisibleAtNight; - isVisibleAtNight = unitParticleSystemNode->getAttribute("isVisibleAtNight")->getIntValue(); + isVisibleAtNight = unitParticleSystemNode->getAttribute("isVisibleAtNight")->getIntValue() != 0; // bool isVisibleAtDay; - isVisibleAtDay = unitParticleSystemNode->getAttribute("isVisibleAtDay")->getIntValue(); + isVisibleAtDay = unitParticleSystemNode->getAttribute("isVisibleAtDay")->getIntValue() != 0; // bool isDaylightAffected; - isDaylightAffected = unitParticleSystemNode->getAttribute("isDaylightAffected")->getIntValue(); + isDaylightAffected = unitParticleSystemNode->getAttribute("isDaylightAffected")->getIntValue() != 0; // bool radiusBasedStartenergy; - radiusBasedStartenergy = unitParticleSystemNode->getAttribute("radiusBasedStartenergy")->getIntValue(); + radiusBasedStartenergy = unitParticleSystemNode->getAttribute("radiusBasedStartenergy")->getIntValue() != 0; // int staticParticleCount; staticParticleCount = unitParticleSystemNode->getAttribute("staticParticleCount")->getIntValue(); // int delay; diff --git a/source/shared_lib/sources/map/map_preview.cpp b/source/shared_lib/sources/map/map_preview.cpp index 706a4d8c..0ac92985 100644 --- a/source/shared_lib/sources/map/map_preview.cpp +++ b/source/shared_lib/sources/map/map_preview.cpp @@ -1002,7 +1002,7 @@ bool MapPreview::loadMapInfo(string file, MapInfo *mapInfo, string i18nMaxMapPla // static string MapPreview::getMapPath(const vector &pathList, const string &mapName, string scenarioDir, bool errorOnNotFound) { - for(int idx = 0; idx < pathList.size(); idx++) { + for(unsigned int idx = 0; idx < pathList.size(); idx++) { string map_path = pathList[idx]; endPathWithSlash(map_path); @@ -1071,7 +1071,7 @@ vector MapPreview::findAllValidMaps(const vector &pathList, results.clear(); MapInfo mapInfo; - for(int i= 0; i < mapFiles.size(); i++){// fetch info and put map in right list + for(unsigned int i= 0; i < mapFiles.size(); i++){// fetch info and put map in right list //loadMapInfo(string file, MapInfo *mapInfo, string i18nMaxMapPlayersTitle,string i18nMapSizeTitle,bool errorOnInvalidMap=true); //printf("getMapPath [%s]\nmapFiles.at(i) [%s]\nscenarioDir [%s] getUserDataOnly = %d cutExtension = %d\n",getMapPath(pathList,mapFiles.at(i), scenarioDir, false).c_str(),mapFiles.at(i).c_str(),scenarioDir.c_str(), getUserDataOnly, cutExtension); diff --git a/source/shared_lib/sources/platform/miniupnpc/miniwget.c b/source/shared_lib/sources/platform/miniupnpc/miniwget.c index 74f10512..ab4c682f 100644 --- a/source/shared_lib/sources/platform/miniupnpc/miniwget.c +++ b/source/shared_lib/sources/platform/miniupnpc/miniwget.c @@ -70,6 +70,7 @@ getHTTPResponse(int s, int * size) int header_buf_len = 2048; int header_buf_used = 0; char * content_buf; + char *content_buf_new; int content_buf_len = 2048; int content_buf_used = 0; char chunksize_buf[32]; @@ -234,7 +235,7 @@ getHTTPResponse(int s, int * size) else { content_buf_len = content_buf_used + (int)bytestocopy; } - char *content_buf_new = (char *)realloc((void *)content_buf, + content_buf_new = (char *)realloc((void *)content_buf, content_buf_len); if(content_buf_new) { content_buf = content_buf_new; @@ -261,7 +262,7 @@ getHTTPResponse(int s, int * size) } else { content_buf_len = content_buf_used + n; } - char *content_buf_new = (char *)realloc((void *)content_buf, + content_buf_new = (char *)realloc((void *)content_buf, content_buf_len); if(content_buf_new) { content_buf = content_buf_new;