diff --git a/README.md b/README.md index 7075f8dcd..c37961f9c 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,11 @@ CPU is also available. ![ZetaGlest ScreenShot](https://zetaglest.github.io/docs/assets/screenshots/screen147.jpg) -## Downloading the game +## Download for Windows -On Windows, the easiest way to get started is to [download and run the -installer](https://github.com/ZetaGlest/windows-installer). If you want +#### Download [ZetaGlest 1.0 from here](https://github.com/ZetaGlest/windows-installer/archive/1.0.zip). + +Additionally, if you want to contribute with the code on Windows, [please follow these instructions](https://github.com/ZetaGlest/zetaglest-source/blob/develop/mk/windows/README.md). @@ -66,12 +67,6 @@ Then run the following command to start the game: * [![RSS](rss_23x23.jpeg)](https://github.com/ZetaGlest/zetaglest.github.io/commits/master.atom) [Recent Commits to the web site](https://github.com/ZetaGlest/zetaglest.github.io/commits/master.atom) -## Why this fork? (Project Goals) - -Because we love MegaGlest! We wanted to take the project into a -slightly different direction, and therefore we forked MegaGlest into -the ZetaGlest project. - ## FAQ The FAQ is located at diff --git a/source/glest_game/facilities/game_util.cpp b/source/glest_game/facilities/game_util.cpp index 2069e5748..16346f199 100644 --- a/source/glest_game/facilities/game_util.cpp +++ b/source/glest_game/facilities/game_util.cpp @@ -185,7 +185,7 @@ namespace Game { string getAboutString2(int i) { switch (i) { case 0: - return "Web: https://github.com/ZetaGlest"; + return "Website: https://zetaglest.github.io"; case 1: return "Bug reports: " + string(mailString); case 2: diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 7fbcf5b26..befe4e458 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -4181,8 +4181,7 @@ namespace Game { ssrft_NetworkPlayerName) == ssrft_NetworkPlayerName) { //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, switchSetupRequests[i]->getSwitchFlags() = %d, switchSetupRequests[i]->getNetworkPlayerName() [%s], labelPlayerNames[i].getText() [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,switchSetupRequests[i]->getSwitchFlags(),switchSetupRequests[i]->getNetworkPlayerName().c_str(),labelPlayerNames[i].getText().c_str()); - if (switchSetupRequests[i]->getNetworkPlayerName() != - GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME) { + if (switchSetupRequests[i]->getNetworkPlayerName().length() != 0) { //labelPlayerNames[i].setText(switchSetupRequests[i]->getNetworkPlayerName()); gameSettings.setNetworkPlayerName(i, switchSetupRequests @@ -4427,7 +4426,7 @@ namespace Game { if (isPlayerObserver == false) { string msg = - "Player #%d [%s] has disconnected, switching player to AI mode!"; + "Player #%d %s has disconnected, switching player to AI mode"; if (lang.hasString("GameSwitchPlayerToAI", languageList[j], true)) { msg = @@ -4439,7 +4438,7 @@ namespace Game { } else { string msg = - "Player #%d [%s] has disconnected, but player was only an observer!"; + "Player #%d %s has disconnected, but player was only an observer"; if (lang.hasString("GameSwitchPlayerObserverToAI", languageList[j], true)) { msg = diff --git a/source/glest_game/game/game_constants.h b/source/glest_game/game/game_constants.h index 8ae2e97ca..b42018303 100644 --- a/source/glest_game/game/game_constants.h +++ b/source/glest_game/game/game_constants.h @@ -208,8 +208,6 @@ namespace Game { static const char * folder_path_tutorials; - static const char * - NETWORK_SLOT_UNCONNECTED_SLOTNAME; static const char * NETWORK_SLOT_CLOSED_SLOTNAME; @@ -268,7 +266,7 @@ namespace Game { static const float ultraMultiplier; static const float - megaMultiplier; + zetaMultiplier; // static const char * diff --git a/source/glest_game/global/config.cpp b/source/glest_game/global/config.cpp index 303144827..55ba348c9 100644 --- a/source/glest_game/global/config.cpp +++ b/source/glest_game/global/config.cpp @@ -42,7 +42,7 @@ namespace Game { const float GameConstants::normalMultiplier = 1.0f; const float GameConstants::easyMultiplier = 0.5f; const float GameConstants::ultraMultiplier = 1.5f; - const float GameConstants::megaMultiplier = 2.5f; + const float GameConstants::zetaMultiplier = 2.5f; const char *GameConstants::folder_path_maps = "maps"; const char *GameConstants::folder_path_scenarios = "scenarios"; @@ -50,7 +50,6 @@ namespace Game { const char *GameConstants::folder_path_tilesets = "tilesets"; const char *GameConstants::folder_path_tutorials = "tutorials"; - const char *GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME = "??"; const char *GameConstants::NETWORK_SLOT_CLOSED_SLOTNAME = "Closed"; const char *GameConstants::folder_path_screenshots = "screens/"; diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index ea9c0ff34..3389823ce 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -1841,7 +1841,7 @@ namespace Game { if (playerName != lineInfo->originalPlayerName && lineInfo->originalPlayerName != "") { playerName = lineInfo->originalPlayerName; } - if (playerName == GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME) { + if (playerName.length() == 0) { playerName = lang.getString("SystemUser"); } //printf("playerName [%s], line [%s]\n",playerName.c_str(),line.c_str()); diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 998033358..dab1ace2e 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -118,6 +118,9 @@ using namespace Shared::Xml; using namespace Shared; void handleUnexpectedError(const char* message) { + Game::Game* currentGame = Game::World::getCurrentGame(); + if (currentGame != NULL && currentGame->isFlagType1BitEnabled(Game::FlagTypes1::ft1_allow_shared_team_resources)) + return; Game::GameNetworkInterface* gameNetworkInterface = Game::NetworkManager::getInstance().getGameNetworkInterface(); if (gameNetworkInterface != NULL) gameNetworkInterface->sendTextMessage(message, -1, true, ""); @@ -7946,6 +7949,9 @@ namespace Game { #endif program->loop(); #ifndef DEBUG + } catch (const std::exception &exc) { + printf("\nAn unhandled error occurred: %s\nAttempting to recover...\n", exc.what()); + goto gameloop; } catch (...) { printf("\nAn unhandled error occurred. Attempting to recover...\n"); goto gameloop; diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 1ea55f85e..5d193d65e 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -299,7 +299,7 @@ namespace Game { checkBoxAllowObservers.setEditable(false); - for (int i = 0; i < 45; ++i) { + for (int i = 0; i <= 45; ++i) { rMultiplier.push_back(floatToStr(0.5f + 0.1f * i, 1)); } @@ -914,7 +914,7 @@ namespace Game { listBoxAISwitchTeamAcceptPercent.setItems(aiswitchteamModeItems); vector < string > rMultiplier; - for (int i = 0; i < 45; ++i) { + for (int i = 0; i <= 45; ++i) { rMultiplier.push_back(floatToStr(0.5f + 0.1f * i, 1)); } listBoxFallbackCpuMultiplier.setItems(rMultiplier); @@ -2165,8 +2165,7 @@ namespace Game { && clientInterface->getJoinGameInProgress() == true) { canGrabSlot = ((listBoxControls[i].getSelectedItemIndex() == ctNetwork - && labelNetStatus[i].getText() == - GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME) + && labelNetStatus[i].getText().length() == 0) || (listBoxControls[i].getSelectedItemIndex() != ctHuman && listBoxControls[i].getSelectedItemIndex() != ctClosed && listBoxControls[i].getSelectedItemIndex() != @@ -2174,8 +2173,7 @@ namespace Game { } else { canGrabSlot = (listBoxControls[i].getSelectedItemIndex() == ctNetwork - && labelNetStatus[i].getText() == - GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME); + && labelNetStatus[i].getText().length() == 0); } if (canGrabSlot == true) { @@ -2437,7 +2435,7 @@ namespace Game { } else if (ct == ctCpuZeta || ct == ctNetworkCpuZeta) { listBoxRMultiplier[index].setSelectedItem(floatToStr (GameConstants:: - megaMultiplier, 1)); + zetaMultiplier, 1)); listBoxRMultiplier[index].setEnabled(true); } else { listBoxRMultiplier[index].setSelectedItem(floatToStr @@ -2792,7 +2790,6 @@ namespace Game { launchingNewGame = true; clientInterface->broadcastGameStart(&gameSettings); } - return; } else { launchingNewGame = true; broadCastGameSettingsToHeadlessServer(needToBroadcastServerSettings); @@ -3675,8 +3672,7 @@ namespace Game { ctNetworkUnassigned) { bool renderIt = true; //printf("Player #%d [%s] control = %d\n",i,labelPlayerNames[i].getText().c_str(),listBoxControls[i].getSelectedItemIndex()); - if (labelNetStatus[i].getText() == - GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME) { + if (labelNetStatus[i].getText().length() == 0) { renderIt = false; } labelPlayers[i].setVisible(renderIt); @@ -3755,8 +3751,7 @@ namespace Game { && clientInterface->getJoinGameInProgress() == true) { canGrabSlot = ((listBoxControls[i].getSelectedItemIndex() == ctNetwork - && labelNetStatus[i].getText() == - GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME) + && labelNetStatus[i].getText().length() == 0) || (listBoxControls[i].getSelectedItemIndex() != ctHuman && listBoxControls[i].getSelectedItemIndex() != ctClosed && listBoxControls[i].getSelectedItemIndex() != @@ -3764,8 +3759,7 @@ namespace Game { } else { canGrabSlot = (listBoxControls[i].getSelectedItemIndex() == ctNetwork - && labelNetStatus[i].getText() == - GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME); + && labelNetStatus[i].getText().length() == 0); } if (canGrabSlot == true) { @@ -3783,8 +3777,7 @@ namespace Game { listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned || listBoxControls[i].getSelectedItemIndex() == ctHuman) { - if (labelNetStatus[i].getText() != - GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME) { + if (labelNetStatus[i].getText().length() != 0) { renderer.renderLabel(&labelPlayerNames[i]); } } @@ -4042,8 +4035,7 @@ namespace Game { hasOpenSlot = true; } if (displayedGamesettings.getFactionControl(i) == ctNetwork && - displayedGamesettings.getNetworkPlayerNameByPlayerIndex(i) != - GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME + displayedGamesettings.getNetworkPlayerNameByPlayerIndex(i).length() != 0 && displayedGamesettings.getNetworkPlayerNameByPlayerIndex(i) != GameConstants::NETWORK_SLOT_CLOSED_SLOTNAME) { //listBoxControls[i].setEditable(false); @@ -5681,9 +5673,7 @@ namespace Game { currentConnectionCount = 0; for (int i = 0; i < GameConstants::maxPlayers; ++i) { if (displayedGamesettings.getFactionControl(i) == ctNetwork && - displayedGamesettings.getNetworkPlayerName(i) != "" && - displayedGamesettings.getNetworkPlayerName(i) != - GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME) { + displayedGamesettings.getNetworkPlayerName(i).length() != 0) { currentConnectionCount++; } } @@ -7701,9 +7691,7 @@ namespace Game { labelNetStatus[slot]. setText(gameSettings->getNetworkPlayerName(i)); if (gameSettings->getThisFactionIndex() != i - && gameSettings->getNetworkPlayerName(i) != "" - && gameSettings->getNetworkPlayerName(i) != - GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME) { + && gameSettings->getNetworkPlayerName(i).length() != 0) { labelPlayerNames[slot]. setText(gameSettings->getNetworkPlayerName(i)); } @@ -7742,9 +7730,7 @@ namespace Game { } if (labelPlayerNames[slot].getText() == "" && - gameSettings->getNetworkPlayerName(i) != "" && - gameSettings->getNetworkPlayerName(i) != - GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME) { + gameSettings->getNetworkPlayerName(i).length() != 0) { labelPlayerNames[slot]. setText(gameSettings->getNetworkPlayerName(i)); } diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index e5bce1dfa..b40ef1cdd 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -502,7 +502,7 @@ namespace Game { checkBoxAllowObservers.setValue(checkBoxAllowObservers.getValue()); vector < string > rMultiplier; - for (int i = 0; i < 45; ++i) { + for (int i = 0; i <= 45; ++i) { rMultiplier.push_back(floatToStr(0.5f + 0.1f * i, 1)); } @@ -2493,7 +2493,7 @@ namespace Game { } forceWaitForShutdown = false; - closeUnusedSlots(); + //closeUnusedSlots(); CoreData & coreData = CoreData::getInstance(); SoundRenderer & soundRenderer = SoundRenderer::getInstance(); soundRenderer.playFx(coreData.getClickSoundC()); @@ -2625,7 +2625,7 @@ namespace Game { safeMutex.ReleaseLock(true); safeMutexCLI.ReleaseLock(true); GameSettings gameSettings; - loadGameSettings(&gameSettings, true); + loadGameSettings(&gameSettings, false); if (SystemFlags:: getSystemSettingType(SystemFlags::debugSystem).enabled) @@ -3311,9 +3311,9 @@ namespace Game { if (listBoxControls[switchFactionIdx].getSelectedItemIndex () == ctNetworkUnassigned) { - serverInterface->removeSlot(switchFactionIdx); + /*serverInterface->removeSlot(switchFactionIdx); listBoxControls[switchFactionIdx].setSelectedItemIndex - (ctClosed); + (ctClosed);*/ labelPlayers[switchFactionIdx].setVisible (switchFactionIdx + 1 <= mapInfo.players); @@ -3388,8 +3388,7 @@ namespace Game { labelPlayerNames[i].getText(). c_str()); - if (switchSetupRequests[i]->getNetworkPlayerName() != - GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME) { + if (switchSetupRequests[i]->getNetworkPlayerName().length() != 0) { labelPlayerNames[i].setText(switchSetupRequests [i]->getNetworkPlayerName ()); @@ -4447,7 +4446,7 @@ namespace Game { #endif gameSettings->setNetworkPlayerName(slotIndex, - GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME); + ""); labelPlayerNames[i].setText(""); } } else if (listBoxControls[i].getSelectedItemIndex() != ctHuman) { @@ -5606,9 +5605,7 @@ namespace Game { } if (index >= 0 && index < GameConstants::maxPlayers && - labelPlayerNames[index].getText() != "" && - labelPlayerNames[index].getText() != - GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME) { + labelPlayerNames[index].getText().length() != 0) { result = labelPlayerNames[index].getText(); if (activeInputLabel != NULL) { diff --git a/source/glest_game/menu/menu_state_custom_game_update.cpp b/source/glest_game/menu/menu_state_custom_game_update.cpp index 9b948336f..574801efa 100644 --- a/source/glest_game/menu/menu_state_custom_game_update.cpp +++ b/source/glest_game/menu/menu_state_custom_game_update.cpp @@ -1033,9 +1033,9 @@ namespace Game { || (listBoxControls[i].getSelectedItemIndex() == ctNetwork && slot->isConnected() == false && i >= mapInfo.players)) { - if (slot->getCanAcceptConnections() == true) { + /*if (slot->getCanAcceptConnections() == true) { slot->setCanAcceptConnections(false); - } + }*/ if (slot->isConnected() == true) { if (listBoxControls[i].getSelectedItemIndex() != ctNetworkUnassigned) { @@ -1104,7 +1104,7 @@ namespace Game { } else if (ct == ctCpuZeta || ct == ctNetworkCpuZeta) { listBoxRMultiplier[index].setSelectedItem(floatToStr (GameConstants:: - megaMultiplier, 1)); + zetaMultiplier, 1)); listBoxRMultiplier[index].setEnabled(checkBoxScenario.getValue() == false); } diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index 888e689b5..51545778b 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -383,7 +383,7 @@ namespace Game { this->receivedNetworkGameStatus = false; this->autoPauseGameCountForLag = 0; - this->skipLagCheck = false; + this->skipLagCheck = true; this->joinGameInProgress = false; this->canAcceptConnections = true; this->startInGameConnectionLaunch = false; @@ -499,7 +499,7 @@ namespace Game { void ConnectionSlot::setReady() { this->ready = true; - this->skipLagCheck = false; + this->skipLagCheck = true; this->joinGameInProgress = false; this->sentSavedGameInfo = false; } @@ -944,7 +944,7 @@ namespace Game { case nmtBroadCastSetup: { if (gotIntro == true) { - if (this->serverInterface->getGameSettings() == NULL || + /*if (this->serverInterface->getGameSettings() == NULL || (joinGameInProgress == false && sessionKey != this->serverInterface->getGameSettings()->getMasterserver_admin())) { string playerNameStr = name; string sErr = "Client has invalid admin sessionid for player [" + playerNameStr + "]"; @@ -953,7 +953,7 @@ namespace Game { close(); return; - } + }*/ NetworkMessageLaunch networkMessageLaunch; if (receiveMessage(&networkMessageLaunch, networkMessageType)) { @@ -1422,7 +1422,7 @@ namespace Game { //printf("ConnectionSlot::close() #1 this->getSocket() = %p\n",this->getSocket()); this->gotIntro = false; - this->skipLagCheck = false; + this->skipLagCheck = true; this->joinGameInProgress = false; this->sentSavedGameInfo = false; this->pauseForInGameConnection = false; diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index df71ae523..1cc02d4a1 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -48,10 +48,10 @@ using namespace Shared::Util; using namespace Shared::Map; namespace Game { - double maxFrameCountLagAllowed = 30; - double maxClientLagTimeAllowed = 25; - double maxFrameCountLagAllowedEver = 30; - double maxClientLagTimeAllowedEver = 25; + double maxFrameCountLagAllowed = 60; + double maxClientLagTimeAllowed = 50; + double maxFrameCountLagAllowedEver = 120; + double maxClientLagTimeAllowedEver = 100; double warnFrameCountLagPercent = 0.50; ServerInterface::ServerInterface(bool publishEnabled, ClientLagCallbackInterface *clientLagCallbackInterface) : GameNetworkInterface() { @@ -793,9 +793,10 @@ namespace Game { //printf("Closing connection slot lagged out!\n"); connectionSlot->close(); - // not needed now, but will be needed when in-game joins and rejoins - // are used + connectionSlot->resetGraceLagCtr(); + connectionSlot->setCurrentLagCount(0); + connectionSlot->setLagCountWarning(false); } } @@ -2477,7 +2478,7 @@ namespace Game { if (gameSettingsBuffer->getFactionControl(factionIndex) == ctNetwork && isClientConnected(slotIndex) == false) { - gameSettingsBuffer->setNetworkPlayerName(factionIndex, GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME); + gameSettingsBuffer->setNetworkPlayerName(factionIndex, ""); } } if (setGameSettingsBuffer == true) { diff --git a/source/glest_game/world/scenario.cpp b/source/glest_game/world/scenario.cpp index b974d5832..06dbece1a 100644 --- a/source/glest_game/world/scenario.cpp +++ b/source/glest_game/world/scenario.cpp @@ -332,7 +332,7 @@ Please contact the ZetaGlest team for more info."; GameConstants::ultraMultiplier; } else if (factionControl == ctCpuZeta) { scenarioInfo->resourceMultipliers[i] = - GameConstants::megaMultiplier; + GameConstants::zetaMultiplier; } } diff --git a/source/glest_game/world/tileset.cpp b/source/glest_game/world/tileset.cpp index 3f37f8a7f..7043ae5a4 100644 --- a/source/glest_game/world/tileset.cpp +++ b/source/glest_game/world/tileset.cpp @@ -236,8 +236,8 @@ namespace Game { // There is no way to figure out parts without loading the texture // unfortunately we must load it even for headless server // to get width and height - bool switchOffNonGraphicalModeEnabled = GlobalStaticFlags::getIsNonGraphicalModeEnabled(); - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + bool isHeadless = GlobalStaticFlags::getIsNonGraphicalModeEnabled(); + if (isHeadless) { GlobalStaticFlags::setIsNonGraphicalModeEnabled(false); } @@ -263,7 +263,7 @@ namespace Game { exceptionError = "Error: " + path + "\n" + ex.what(); } - if (switchOffNonGraphicalModeEnabled == true) { + if (isHeadless) { GlobalStaticFlags::setIsNonGraphicalModeEnabled(true); delete pixmap; diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index 14b201c23..ea85a21d7 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -48,6 +48,7 @@ namespace Game { int MaxExploredCellsLookupItemCache = 9500; //int MaxExploredCellsLookupItemCache = 0; time_t ExploredCellsLookupItem::lastDebug = 0; + Game* World::currentGame = NULL; // ===================== PUBLIC ======================== @@ -335,6 +336,7 @@ namespace Game { ExploredCellsLookupItemCacheTimer.clear(); this->game = game; + currentGame = game; scriptManager = game->getScriptManager(); GameSettings *gs = game->getGameSettings(); diff --git a/source/glest_game/world/world.h b/source/glest_game/world/world.h index 6e4e69330..a0bd6bf18 100644 --- a/source/glest_game/world/world.h +++ b/source/glest_game/world/world.h @@ -91,7 +91,7 @@ namespace Game { static const int indirectSightRange = 5; private: - + static Game* currentGame; Map map; Tileset tileset; TechTree *techTree; @@ -167,6 +167,9 @@ namespace Game { void removeFogOfWarSkillType(const Unit *unit); bool removeFogOfWarSkillTypeFromList(const Unit *unit); + static Game* getCurrentGame() { + return currentGame; + } //get inline int getMaxPlayers() const { return map.getMaxPlayers(); diff --git a/source/shared_lib/sources/util/conversion.cpp b/source/shared_lib/sources/util/conversion.cpp index 5ec448a39..cc2abc487 100644 --- a/source/shared_lib/sources/util/conversion.cpp +++ b/source/shared_lib/sources/util/conversion.cpp @@ -171,19 +171,19 @@ namespace Shared { return (str[0] != '\0' ? str : ""); } - string floatToStr(float f, int precsion) { + string floatToStr(float f, int precision) { setlocale(LC_NUMERIC, "C"); char str[strSize] = ""; - snprintf(str, strSize - 1, "%.*f", precsion, f); + snprintf(str, strSize - 1, "%.*f", precision, f); return (str[0] != '\0' ? str : ""); } - string doubleToStr(double d, int precsion) { + string doubleToStr(double d, int precision) { setlocale(LC_NUMERIC, "C"); char str[strSize] = ""; - snprintf(str, strSize - 1, "%.*f", precsion, d); + snprintf(str, strSize - 1, "%.*f", precision, d); return (str[0] != '\0' ? str : ""); }