From e12f168a01d4f2798dc4bf7d8ea0c8d64b12aa76 Mon Sep 17 00:00:00 2001 From: mathusummut Date: Sat, 6 Oct 2018 17:20:22 +0200 Subject: [PATCH] Added const strings for versions --- source/g3d_viewer/main.cpp | 6 ++-- source/glest_game/facilities/game_util.cpp | 18 ++++------ source/glest_game/facilities/game_util.h | 1 - source/glest_game/game/game.cpp | 33 ++++++++++--------- source/glest_game/main/intro.cpp | 2 +- source/glest_game/main/main.cpp | 7 ++-- .../menu/menu_state_connected_game.cpp | 11 +++---- .../menu/menu_state_custom_game.cpp | 14 ++++---- .../glest_game/menu/menu_state_load_game.cpp | 10 +++--- .../menu/menu_state_masterserver.cpp | 6 ++-- source/glest_game/menu/menu_state_mods.cpp | 10 +++--- source/glest_game/menu/menu_state_root.cpp | 14 ++++---- source/glest_game/menu/server_line.cpp | 6 ++-- .../glest_game/network/client_interface.cpp | 6 ++-- source/glest_game/network/connection_slot.cpp | 9 ++--- .../glest_game/network/server_interface.cpp | 5 +-- source/glest_map_editor/main.cpp | 7 ++-- .../include/platform/common/platform_common.h | 5 --- ...orm_definitions.h => shared_definitions.h} | 11 ++++--- source/shared_lib/include/util/properties.h | 9 ----- .../platform/common/platform_common.cpp | 22 ++----------- .../sources/platform/posix/ircclient.cpp | 4 +-- source/shared_lib/sources/util/properties.cpp | 6 ++-- 23 files changed, 98 insertions(+), 124 deletions(-) rename source/shared_lib/include/platform/win32/{platform_definitions.h => shared_definitions.h} (67%) diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index dce32ab73..404e669e2 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -37,7 +37,7 @@ #include #include #include "common_scoped_ptr.h" -#include "versions.h" +#include "shared_definitions.h" #ifndef WIN32 #include @@ -179,7 +179,7 @@ namespace Shared { } // "================================================================================" - printf("\n%s %s, [Using %s]\n", extractFileFromDirectoryPath(argv0).c_str(), G3D_VIEWER_VERSION, (const char *) wxConvCurrent->cWX2MB(wxVERSION_STRING)); + printf("\n%s %s, [Using %s]\n", extractFileFromDirectoryPath(argv0).c_str(), G3DViewerVersionString, (const char *) wxConvCurrent->cWX2MB(wxVERSION_STRING)); printf("\nDisplays glest 3D-models and unit/projectile/splash particle systems.\n"); printf("\nRotate with left mouse button. Zoom with right mouse button or mousewheel."); @@ -292,7 +292,7 @@ namespace Shared { // class MainWindow // =============================================== - const string MainWindow::winHeader = string("ZetaGlest G3D viewer ") + G3D_VIEWER_VERSION; + const string MainWindow::winHeader = string("ZetaGlest G3D viewer ") + G3DViewerVersionString; const float defaultspeed = 0.025f; diff --git a/source/glest_game/facilities/game_util.cpp b/source/glest_game/facilities/game_util.cpp index 512ede986..aac4040b9 100644 --- a/source/glest_game/facilities/game_util.cpp +++ b/source/glest_game/facilities/game_util.cpp @@ -32,8 +32,9 @@ #include "cache_manager.h" #include "errno.h" #include "leak_dumper.h" -#include "versions.h" +#include "shared_definitions.h" +using namespace Shared; using namespace Shared::Util; using namespace Shared::Platform; @@ -42,7 +43,7 @@ namespace Glest { const char *mailString = "https://github.com/ZetaGlest"; string getCrashDumpFileName() { - return (string("zetaglest") + GAME_VERSION) + ".dmp"; + return (string("zetaglest") + GameVersionString) + ".dmp"; } string getPlatformTypeNameString() { static string platform; @@ -174,7 +175,7 @@ namespace Glest { static string version = ""; if (version == "") { version = - string(GAME_VERSION) + "-" + getCompilerNameString() + "-" + + GameVersionString + "-" + getCompilerNameString() + "-" + getCompileDateTime(); } return version; @@ -184,7 +185,7 @@ namespace Glest { static string version = ""; if (version == "") { version = - GAME_VERSION + getCompilerNameString(); + GameVersionString + getCompilerNameString(); } return version; } @@ -197,17 +198,13 @@ namespace Glest { return result; } - string getNetworkPlatformFreeVersionString() { - return GAME_VERSION; - } - string getAboutString1(int i) { //case 1: return "Built: " + string(__DATE__) + " " + GIT_Rev; switch (i) { case 0: - return string("ZetaGlest ") + GAME_VERSION; + return string("ZetaGlest ") + GameVersionString; case 1: - return GAME_VERSION; + return GameVersionString; case 2: return "Copyright 2001-2010 The Glest Team"; case 3: @@ -394,7 +391,6 @@ namespace Glest { getCompilerNameString(); getNetworkVersionString(); getNetworkVersionGITString(); - getNetworkPlatformFreeVersionString(); getCompileDateTime(); } diff --git a/source/glest_game/facilities/game_util.h b/source/glest_game/facilities/game_util.h index dfbe7bc37..c4071ffa8 100644 --- a/source/glest_game/facilities/game_util.h +++ b/source/glest_game/facilities/game_util.h @@ -47,7 +47,6 @@ namespace Glest { string getCompilerNameString(); string getNetworkVersionString(); string getNetworkVersionGITString(); - string getNetworkPlatformFreeVersionString(); string getAboutString1(int i); string getAboutString2(int i); string getTeammateName(int i); diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index e9cf1cf35..f3b24e37d 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -41,9 +41,10 @@ #include "cache_manager.h" #include "conversion.h" #include "steam.h" -#include "versions.h" +#include "shared_definitions.h" #include "leak_dumper.h" +using namespace Shared; using namespace Shared::Graphics; using namespace Shared::Util; using namespace Shared::Platform; @@ -6838,7 +6839,7 @@ namespace Glest { #endif logFile << "World CRC debug information:" << std::endl; logFile << "============================" << std::endl; - logFile << "Software version: " << GAME_VERSION << "-" << + logFile << "Software version: " << GameVersionString << "-" << getCompilerNameString() << std::endl; logFile << "Maximum framecount: " << world. getFaction(0)->getCRC_DetailsForWorldFrameCount() << std::endl; @@ -8739,7 +8740,7 @@ namespace Glest { char szBuf[4096] = ""; strftime(szBuf, 4095, "%Y-%m-%d %H:%M:%S", &loctime); - rootNodeReplay->addAttribute("version", GAME_VERSION, + rootNodeReplay->addAttribute("version", GameVersionString, mapTagReplacements); rootNodeReplay->addAttribute("timestamp", szBuf, mapTagReplacements); @@ -8776,7 +8777,7 @@ namespace Glest { char szBuf[4096] = ""; strftime(szBuf, 4095, "%Y-%m-%d %H:%M:%S", &loctime); - rootNode->addAttribute("version", GAME_VERSION, + rootNode->addAttribute("version", GameVersionString, mapTagReplacements); rootNode->addAttribute("timestamp", szBuf, mapTagReplacements); @@ -9013,20 +9014,20 @@ namespace Glest { Lang & lang = Lang::getInstance(); string gameVer = versionNode->getAttribute("version")->getValue(); - if (gameVer != GAME_VERSION + if (gameVer != GameVersionString && checkVersionComptability(gameVer, - GAME_VERSION) == false) { + GameVersionString) == false) { char szBuf[8096] = ""; snprintf(szBuf, 8096, lang.getString("SavedGameBadVersion").c_str(), - gameVer.c_str(), GAME_VERSION); + gameVer.c_str(), GameVersionString.c_str()); throw megaglest_runtime_error(szBuf, true); } if (SystemFlags::VERBOSE_MODE_ENABLED) printf ("Found saved game version that matches your application version: [%s] --> [%s]\n", - gameVer.c_str(), GAME_VERSION); + gameVer.c_str(), GameVersionString.c_str()); XmlNode *gameNode = rootNode->getChild("Game"); @@ -9101,22 +9102,22 @@ namespace Glest { Lang & lang = Lang::getInstance(); string gameVer = versionNode->getAttribute("version")->getValue(); // this is the version check for loading normal save games from menu_state_load_game - if (gameVer != GAME_VERSION + if (gameVer != GameVersionString && (compareMajorMinorVersion - (gameVer, LAST_COMPATIBLE_VERSION) < 0 - || compareMajorMinorVersion(GAME_VERSION, gameVer) < 0)) { + (gameVer, LastCompatibleVersionString) < 0 + || compareMajorMinorVersion(GameVersionString, gameVer) < 0)) { char szBuf[8096] = ""; snprintf(szBuf, 8096, lang.getString("SavedGameBadVersion").c_str(), - gameVer.c_str(), GAME_VERSION); + gameVer.c_str(), GameVersionString.c_str()); throw megaglest_runtime_error(szBuf, true); } if (SystemFlags::VERBOSE_MODE_ENABLED) printf ("Found saved game version that matches your application version: [%s] --> [%s]\n", - gameVer.c_str(), GAME_VERSION); + gameVer.c_str(), GameVersionString.c_str()); XmlNode *gameNode = rootNode->getChild("Game"); GameSettings newGameSettings; @@ -9129,13 +9130,13 @@ namespace Glest { XmlNode *statsNode = worldNode->getChild("Stats"); XmlNode *minimapNode = worldNode->getChild("Minimap"); - if (gameVer != GAME_VERSION + if (gameVer != GameVersionString && checkVersionComptability(gameVer, - GAME_VERSION) == false) { + GameVersionString) == false) { char szBuf[8096] = ""; snprintf(szBuf, 8096, lang.getString("SavedGameBadVersion").c_str(), - gameVer.c_str(), GAME_VERSION); + gameVer.c_str(), GameVersionString.c_str()); throw megaglest_runtime_error(szBuf, true); } // This is explored fog of war for the host player, clear it diff --git a/source/glest_game/main/intro.cpp b/source/glest_game/main/intro.cpp index e8fb69f50..cffa510f8 100644 --- a/source/glest_game/main/intro.cpp +++ b/source/glest_game/main/intro.cpp @@ -495,7 +495,7 @@ namespace Glest { texts.push_back(new Text(lineText, Vec2i(-1, -1), disappear *(++displayItemNumber), coreData.getMenuFontVeryBig(),coreData.getMenuFontVeryBig3D())); texts.push_back(new Text(coreData.getLogoTexture(), Vec2i(w/2-128, h/2-64), Vec2i(256, 128), disappear *(++displayItemNumber))); - texts.push_back(new Text(GAME_VERSION, Vec2i(w/2+45, h/2-45), disappear *(displayItemNumber++), coreData.getMenuFontNormal(),coreData.getMenuFontNormal3D())); + texts.push_back(new Text(GameVersionString, Vec2i(w/2+45, h/2-45), disappear *(displayItemNumber++), coreData.getMenuFontNormal(),coreData.getMenuFontNormal3D())); lineText = "www.megaglest.org"; //texts.push_back(new Text(lineText, Vec2i(-1, -1), disappear *(displayItemNumber++), coreData.getMenuFontVeryBig(),coreData.getMenuFontVeryBig3D())); texts.push_back(new Text(lineText, Vec2i(-1, h/2-45-18), disappear *(displayItemNumber-1), coreData.getMenuFontVeryBig(),coreData.getMenuFontVeryBig3D())); diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 69bca3d72..c1335504f 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -60,7 +60,7 @@ #include "lua_script.h" #include "interpolation.h" #include "common_scoped_ptr.h" -#include "versions.h" +#include "shared_definitions.h" // To handle signal catching #if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD) @@ -5733,7 +5733,6 @@ namespace Properties::setApplicationPath(executable_path(argv[0])); Properties::setApplicationDataPath(executable_path(argv[0])); - Properties::setGameVersion(GAME_VERSION); ServerSocket::setMaxPlayerCount(GameConstants::maxPlayers); @@ -5906,8 +5905,6 @@ namespace if (haveSpecialOutputCommandLineOption == false || hasCommandArgument(argc, argv, GAME_ARGS[GAME_ARG_VERSION]) == true) { - printf("%s %s", extractFileFromDirectoryPath(argv[0]).c_str(), - getNetworkPlatformFreeVersionString().c_str()); // printf("\nCompiled using: %s on: %s platform: %s endianness: %s",getCompilerNameString().c_str(),getCompileDateTime().c_str(),getPlatformNameString().c_str(),(::Shared::PlatformByteOrder::isBigEndian() == true ? "big" : "little")); printf("\nCompiled using: %s platform: %s endianness: %s", getCompilerNameString().c_str(), @@ -5991,7 +5988,7 @@ namespace SwitchSetupRequest().getDataSize()); } - printf("\nversion: [%s]", GAME_VERSION); + printf("\nversion: [%s]", GameVersionString.c_str()); #ifdef USE_STREFLOP diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 0a31ef7f5..ba7f8db8c 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -42,14 +42,13 @@ #include "map_preview.h" #include #include "compression_utils.h" -#include "versions.h" +#include "shared_definitions.h" #include "leak_dumper.h" -using namespace -Shared::Util; -using namespace -Shared::CompressionUtil; +using namespace Shared; +using namespace Shared::Util; +using namespace Shared::CompressionUtil; namespace Glest { namespace Game { @@ -1311,7 +1310,7 @@ namespace Glest { config.getString("phpVersionParam", "?version=0.1"); string gameVersion = - "&glestVersion=" + SystemFlags::escapeURL(GAME_VERSION); + "&glestVersion=" + SystemFlags::escapeURL(GameVersionString); string playerUUID = "&uuid=" + diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index d49619032..35ded40ed 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -45,14 +45,14 @@ #include #include "map_preview.h" #include "gen_uuid.h" -#include "versions.h" +#include "shared_definitions.h" #include "leak_dumper.h" +using namespace Shared; +using namespace Shared::Util; + namespace Glest { namespace Game { - - using namespace::Shared::Util; - const int MASTERSERVER_BROADCAST_MAX_WAIT_RESPONSE_SECONDS = 15; static const char *SAVED_GAME_FILENAME = "lastCustomGameSettings.mgg"; static const char *DEFAULT_GAME_FILENAME = "data/defaultGameSetup.mgg"; @@ -415,7 +415,7 @@ namespace Glest { ServerSocket::setExternalPort(strToInt(externalPort)); //labelLocalGameVersion.setText(glestVersionString + " [" + getCompileDateTime() + ", " + getGITRevisionString() + "]"); - labelLocalGameVersion.setText(GAME_VERSION); + labelLocalGameVersion.setText(GameVersionString); xoffset = 65; // MapFilter @@ -1065,7 +1065,7 @@ namespace Glest { //labelLocalGameVersion.setText(glestVersionString + " [" + getCompileDateTime() + ", " + getGITRevisionString() + "]"); - labelLocalGameVersion.setText(GAME_VERSION); + labelLocalGameVersion.setText(GameVersionString); //vector teamItems, controlItems, results , rMultiplier; @@ -3604,7 +3604,7 @@ namespace Glest { Config::getInstance().getString("PlayerId", ""); //?status=waiting&system=linux&info=titus - publishToServerInfo["glestVersion"] = GAME_VERSION; + publishToServerInfo["glestVersion"] = GameVersionString; publishToServerInfo["platform"] = getPlatformNameString(); publishToServerInfo["binaryCompileDate"] = getCompileDateTime(); diff --git a/source/glest_game/menu/menu_state_load_game.cpp b/source/glest_game/menu/menu_state_load_game.cpp index 9555f0245..476b0820f 100644 --- a/source/glest_game/menu/menu_state_load_game.cpp +++ b/source/glest_game/menu/menu_state_load_game.cpp @@ -31,10 +31,12 @@ #include "network_message.h" #include "game.h" #include "auto_test.h" -#include "versions.h" +#include "shared_definitions.h" #include "leak_dumper.h" +using namespace Shared; + namespace Glest { namespace Game { @@ -399,14 +401,14 @@ namespace Glest { const XmlNode *versionNode = rootNode; string gameVer = versionNode->getAttribute("version")->getValue(); - if (gameVer != GAME_VERSION + if (gameVer != GameVersionString && checkVersionComptability(gameVer, - GAME_VERSION) == + GameVersionString) == false) { char szBuf[8096] = ""; snprintf(szBuf, 8096, lang.getString("SavedGameBadVersion").c_str(), - gameVer.c_str(), GAME_VERSION); + gameVer.c_str(), GameVersionString.c_str()); versionWarningLabel.setText(szBuf); } else { versionWarningLabel.setText(""); diff --git a/source/glest_game/menu/menu_state_masterserver.cpp b/source/glest_game/menu/menu_state_masterserver.cpp index 589f4b204..c0d8ade36 100644 --- a/source/glest_game/menu/menu_state_masterserver.cpp +++ b/source/glest_game/menu/menu_state_masterserver.cpp @@ -39,9 +39,11 @@ #include "masterserver_info.h" #include #include "cache_manager.h" -#include "versions.h" +#include "shared_definitions.h" #include "leak_dumper.h" +using namespace Shared; + namespace Glest { namespace Game { @@ -1305,7 +1307,7 @@ namespace Glest { string versionURL = Config::getInstance().getString("VersionURL", "http://zetaglest.dreamhosters.com/files/versions/") - + GAME_VERSION + ".txt"; + + GameVersionString + ".txt"; //printf("\nversionURL=%s\n",versionURL.c_str()); if (versionURL != "") { safeMutex.ReleaseLock(true); diff --git a/source/glest_game/menu/menu_state_mods.cpp b/source/glest_game/menu/menu_state_mods.cpp index 3a81d4973..24b27d10e 100644 --- a/source/glest_game/menu/menu_state_mods.cpp +++ b/source/glest_game/menu/menu_state_mods.cpp @@ -34,14 +34,14 @@ #include "cache_manager.h" // Need the include below for vc++ 2010 because Microsoft messed up their STL! #include -#include "versions.h" +#include "shared_definitions.h" #include "leak_dumper.h" +using namespace Shared; +using namespace Shared::Util; + namespace Glest { namespace Game { - - using namespace::Shared::Util; - struct FormatString { void operator () (string & s) { s = formatString(s); @@ -566,7 +566,7 @@ namespace Glest { SystemFlags::escapeURL(Config::getInstance(). getString("PlayerId", "")); string gameVersion = - "&glestVersion=" + SystemFlags::escapeURL(GAME_VERSION); + "&glestVersion=" + SystemFlags::escapeURL(GameVersionString); if (SystemFlags::VERBOSE_MODE_ENABLED) printf diff --git a/source/glest_game/menu/menu_state_root.cpp b/source/glest_game/menu/menu_state_root.cpp index 829827a0d..aabf69f1c 100644 --- a/source/glest_game/menu/menu_state_root.cpp +++ b/source/glest_game/menu/menu_state_root.cpp @@ -39,10 +39,12 @@ #include "cache_manager.h" #include "steam.h" #include -#include "versions.h" +#include "shared_definitions.h" #include "leak_dumper.h" +using namespace Shared; + namespace Glest { namespace Game { @@ -87,7 +89,7 @@ namespace Glest { } else {*/ labelVersion.init(buttonXPosition, yPos); //labelVersion.setText(glestVersionString + " [" + getCompileDateTime() + ", " + getGITRevisionString() + "]"); - labelVersion.setText(GAME_VERSION); + labelVersion.setText(GameVersionString); //} labelGreeting.init(labelVersion.getX(), labelVersion.getY() - 16); @@ -228,7 +230,7 @@ namespace Glest { console.resetFonts(); //labelVersion.setText(glestVersionString + " [" + getCompileDateTime() + ", " + getGITRevisionString() + "]"); - labelVersion.setText(GAME_VERSION); + labelVersion.setText(GameVersionString); buttonNewGame.setText(lang.getString("NewGame")); buttonLoadGame.setText(lang.getString("LoadGame")); @@ -848,18 +850,18 @@ namespace Glest { props.loadFromText(updateMetaData); int compareResult = - compareMajorMinorVersion(GAME_VERSION, + compareMajorMinorVersion(GameVersionString, props.getString("LatestGameVersion", "")); if (compareResult == 0) { - if (GAME_VERSION != + if (GameVersionString != props.getString("LatestGameVersion", "")) { compareResult = -1; } } if (SystemFlags::VERBOSE_MODE_ENABLED) printf("compareResult = %d local [%s] remote [%s]\n", - compareResult, GAME_VERSION, + compareResult, GameVersionString, props.getString("LatestGameVersion", "").c_str()); if (compareResult < 0) { diff --git a/source/glest_game/menu/server_line.cpp b/source/glest_game/menu/server_line.cpp index d078ebcd7..ca20bc403 100644 --- a/source/glest_game/menu/server_line.cpp +++ b/source/glest_game/menu/server_line.cpp @@ -29,10 +29,12 @@ #include "metrics.h" #include "auto_test.h" #include "masterserver_info.h" -#include "versions.h" +#include "shared_definitions.h" #include "leak_dumper.h" +using namespace Shared; + namespace Glest { namespace Game { @@ -195,7 +197,7 @@ namespace Glest { //printf("glestVersionString [%s] masterServerInfo->getGlestVersion() [%s]\n",glestVersionString.c_str(),masterServerInfo->getGlestVersion().c_str()); compatible = - checkVersionComptability(GAME_VERSION, + checkVersionComptability(GameVersionString, masterServerInfo.getGlestVersion()); selectButton.setEnabled(compatible); selectButton.setEditable(compatible); diff --git a/source/glest_game/network/client_interface.cpp b/source/glest_game/network/client_interface.cpp index e0e6379a5..6740a0c85 100644 --- a/source/glest_game/network/client_interface.cpp +++ b/source/glest_game/network/client_interface.cpp @@ -33,10 +33,11 @@ #include "config.h" #include #include - +#include "shared_definitions.h" #include "leak_dumper.h" using namespace std; +using namespace Shared; using namespace Shared::Platform; using namespace Shared::Util; @@ -582,10 +583,9 @@ namespace Glest { if (SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork, "In [%s::%s Line: %d]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); bool versionMatched = false; - string platformFreeVersion = getNetworkPlatformFreeVersionString(); string sErr = ""; - if (strncmp(platformFreeVersion.c_str(), networkMessageIntro.getVersionString().c_str(), strlen(platformFreeVersion.c_str())) != 0) { + if (strncmp(GameVersionString.c_str(), networkMessageIntro.getVersionString().c_str(), GameVersionString.length()) != 0) { string playerNameStr = getHumanPlayerName(); sErr = "Server and client binary mismatch!\nYou have to use the exactly same binaries!\n\nServer: " + networkMessageIntro.getVersionString() + "\nClient: " + getNetworkVersionGITString() + " player [" + playerNameStr + "]"; diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index 962f23302..721d6122a 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -27,10 +27,12 @@ #include "network_message.h" #include "platform_util.h" #include +#include "shared_definitions.h" #include "leak_dumper.h" using namespace std; +using namespace Shared; using namespace Shared::Util; namespace Glest { @@ -881,16 +883,15 @@ namespace Glest { if (SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork, "In [%s::%s Line: %d]\n", __FILE__, __FUNCTION__, __LINE__); bool versionMatched = false; - string platformFreeVersion = getNetworkPlatformFreeVersionString(); string sErr = ""; - if (strncmp(platformFreeVersion.c_str(), networkMessageIntro.getVersionString().c_str(), strlen(platformFreeVersion.c_str())) != 0) { + if (strncmp(GameVersionString.c_str(), networkMessageIntro.getVersionString().c_str(), GameVersionString.length()) != 0) { string playerNameStr = name; - sErr = "Server and client binary mismatch!\nYou have to use the exactly same binaries!\n\nServer: " + getNetworkVersionGITString() + + sErr = "Server and client version mismatch!\nYou have to use the exactly same versions!\n\nServer: " + getNetworkVersionGITString() + "\nClient: " + networkMessageIntro.getVersionString() + " player [" + playerNameStr + "]"; printf("%s\n", sErr.c_str()); - serverInterface->sendTextMessage("Server and client binary mismatch!!", -1, true, "", lockedSlotIndex); + serverInterface->sendTextMessage("Server and client version mismatch!", -1, true, "", lockedSlotIndex); serverInterface->sendTextMessage(" Server:" + getNetworkVersionGITString(), -1, true, "", lockedSlotIndex); serverInterface->sendTextMessage(" Client: " + networkMessageIntro.getVersionString(), -1, true, "", lockedSlotIndex); serverInterface->sendTextMessage(" Client player [" + playerNameStr + "]", -1, true, "", lockedSlotIndex); diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index 69e8ae44c..a7efeddd8 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -40,11 +40,12 @@ #include #include #include -#include "versions.h" +#include "shared_definitions.h" #include "leak_dumper.h" using namespace std; +using namespace Shared; using namespace Shared::Platform; using namespace Shared::Util; using namespace Shared::Map; @@ -2827,7 +2828,7 @@ namespace Glest { } } publishToServerInfo["uuid"] = Config::getInstance().getString("PlayerId", ""); - publishToServerInfo["glestVersion"] = GAME_VERSION; + publishToServerInfo["glestVersion"] = GameVersionString; publishToServerInfo["platform"] = getPlatformNameString(); publishToServerInfo["binaryCompileDate"] = getCompileDateTime(); publishToServerInfo["serverTitle"] = this->getGameSettings()->getGameName(); diff --git a/source/glest_map_editor/main.cpp b/source/glest_map_editor/main.cpp index 6addff071..96d6f383a 100644 --- a/source/glest_map_editor/main.cpp +++ b/source/glest_map_editor/main.cpp @@ -33,9 +33,10 @@ #include #endif #include "common_scoped_ptr.h" -#include "versions.h" +#include "shared_definitions.h" //#include +using namespace Shared; using namespace Shared::Util; using namespace Shared::PlatformCommon; using namespace Glest::Game; @@ -60,7 +61,7 @@ namespace Glest { } namespace MapEditor { - const string MainWindow::winHeader = string("ZetaGlest Map Editor ") + MAP_EDITOR_VERSION; + const string MainWindow::winHeader = string("ZetaGlest Map Editor ") + MapEditorVersionString; // =============================================== // class Global functions @@ -1648,7 +1649,7 @@ wxT("Help")).ShowModal(); string fileparam; if (argc == 2) { if (argv[1][0] == '-') { // any flag gives help and exits program. - std::cout << std::endl << "ZetaGlest Map Editor " << MAP_EDITOR_VERSION << " [Using " << (const char *) wxConvCurrent->cWX2MB(wxVERSION_STRING) << "]" << std::endl << std::endl; + std::cout << std::endl << "ZetaGlest Map Editor " << MapEditorVersionString << " [Using " << (const char *) wxConvCurrent->cWX2MB(wxVERSION_STRING) << "]" << std::endl << std::endl; //std::cout << "\nglest_map_editor [MGM FILE]" << std::endl << std::endl; std::cout << "Creates or edits zetaglest/glest maps. [.zgm/.mgm/.gbm]" << std::endl << std::endl; std::cout << "Draw with left mouse button." << std::endl; diff --git a/source/shared_lib/include/platform/common/platform_common.h b/source/shared_lib/include/platform/common/platform_common.h index 49521ba01..22e513c40 100644 --- a/source/shared_lib/include/platform/common/platform_common.h +++ b/source/shared_lib/include/platform/common/platform_common.h @@ -195,11 +195,6 @@ namespace Shared { void findAll(const string &path, vector &results, bool cutExtension = false, bool errorOnNotFound = true); vector getFolderTreeContentsListRecursively(const string &path, const string &filterFileExt, bool includeFolders = false, vector *recursiveMap = NULL); - //string getGameVersion(); - //string getGameGITVersion(); - void setGameVersion(const string &version); - void setGameGITVersion(const string &git); - string getCRCCacheFilePath(); void setCRCCacheFilePath(const string &path); diff --git a/source/shared_lib/include/platform/win32/platform_definitions.h b/source/shared_lib/include/platform/win32/shared_definitions.h similarity index 67% rename from source/shared_lib/include/platform/win32/platform_definitions.h rename to source/shared_lib/include/platform/win32/shared_definitions.h index cb4e39676..3c2882c12 100644 --- a/source/shared_lib/include/platform/win32/platform_definitions.h +++ b/source/shared_lib/include/platform/win32/shared_definitions.h @@ -12,14 +12,15 @@ #ifndef _SHARED_PLATFORM_DEFINITIONS_H_ #define _SHARED_PLATFORM_DEFINITIONS_H_ +#include +#include "versions.h" #include "leak_dumper.h" namespace Shared { - namespace Platform { - - - - } + const std::string GameVersionString = GAME_VERSION; + const std::string LastCompatibleVersionString = LAST_COMPATIBLE_VERSION; + const std::string G3DViewerVersionString = G3D_VIEWER_VERSION; + const std::string MapEditorVersionString = MAP_EDITOR_VERSION; }//end namespace #endif diff --git a/source/shared_lib/include/util/properties.h b/source/shared_lib/include/util/properties.h index a87cb3388..7dc864cd5 100644 --- a/source/shared_lib/include/util/properties.h +++ b/source/shared_lib/include/util/properties.h @@ -50,7 +50,6 @@ namespace Shared { string path; static string applicationPath; static string applicationDataPath; - static string gameVersion; static string techtreePath; static string scenarioPath; @@ -76,14 +75,6 @@ namespace Shared { return applicationDataPath; } - static void setGameVersion(string value) { - Shared::PlatformCommon::replaceAll(value, "\\", "/"); - gameVersion = value; - } - static string getGameVersion() { - return gameVersion; - } - static void setTechtreePath(string value) { Shared::PlatformCommon::replaceAll(value, "\\", "/"); techtreePath = value; diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index d94beb5ef..45996a628 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -71,6 +71,7 @@ #include "platform_util.h" #include "utf8.h" #include "byte_order.h" +#include "shared_definitions.h" #if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED #include @@ -97,8 +98,6 @@ namespace Shared { const time_t REFRESH_CRC_DAY_SECONDS = 60 * 60 * 24; static string crcCachePath = ""; static void(*unexpected_handler)(const char*) = NULL; - static string gameVersion = ""; - static string gameGITVersion = ""; namespace Private { @@ -687,19 +686,6 @@ namespace Shared { unexpected_handler = handler; } - //string getGameVersion() { - // return gameVersion; - //} - //string getGameGITVersion() { - // return gameGITVersion; - //} - void setGameVersion(const string &version) { - gameVersion = version; - } - void setGameGITVersion(const string &git) { - gameGITVersion = git; - } - string getCRCCacheFileName(std::pair cacheKeys) { string crcCacheFile = cacheKeys.first + cacheKeys.second; return crcCacheFile; @@ -859,8 +845,7 @@ namespace Shared { char szBuf1[100] = ""; strftime(szBuf1, 100, "%Y-%m-%d %H:%M:%S", &loctime); - string writeGameVer = Shared::PlatformByteOrder::toCommonEndian(gameVersion); - string writeGameGITVersion = Shared::PlatformByteOrder::toCommonEndian(gameGITVersion); + string writeGameVer = Shared::PlatformByteOrder::toCommonEndian(GameVersionString); string writeActualFileName = Shared::PlatformByteOrder::toCommonEndian(actualFileName); fprintf(fp, "%20ld,%20u,%20ld", @@ -868,9 +853,8 @@ namespace Shared { Shared::PlatformByteOrder::toCommonEndian(crcValue), (long) Shared::PlatformByteOrder::toCommonEndian(now)); - fprintf(fp, "\n%s\n%s\n%s", + fprintf(fp, "\n%s\n%s", writeGameVer.c_str(), - writeGameGITVersion.c_str(), writeActualFileName.c_str()); fclose(fp); diff --git a/source/shared_lib/sources/platform/posix/ircclient.cpp b/source/shared_lib/sources/platform/posix/ircclient.cpp index a0c7ce0db..e4aa0add4 100644 --- a/source/shared_lib/sources/platform/posix/ircclient.cpp +++ b/source/shared_lib/sources/platform/posix/ircclient.cpp @@ -38,7 +38,7 @@ #include #include #include "conversion.h" -#include "versions.h" +#include "shared_definitions.h" using namespace Shared::Util; using namespace Shared::PlatformCommon; @@ -837,7 +837,7 @@ namespace Shared { if (SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf("===> IRC: Line: %d\n", __LINE__); safeMutex.Lock(); - if (irc_connect(ircSession, argv[0].c_str(), IRC_SERVER_PORT, 0, this->nick.c_str(), this->username.c_str(), (string("ZetaGlest ") + GAME_VERSION).c_str())) { + if (irc_connect(ircSession, argv[0].c_str(), IRC_SERVER_PORT, 0, this->nick.c_str(), this->username.c_str(), (string("ZetaGlest ") + GameVersionString).c_str())) { safeMutex.ReleaseLock(); if (SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf("===> IRC Could not connect: %s\n", irc_strerror(irc_errno(ircSession))); return; diff --git a/source/shared_lib/sources/util/properties.cpp b/source/shared_lib/sources/util/properties.cpp index 445f139dd..7b7b5a05a 100644 --- a/source/shared_lib/sources/util/properties.cpp +++ b/source/shared_lib/sources/util/properties.cpp @@ -33,6 +33,7 @@ #include "utf8.h" #include "font.h" #include "string_utils.h" +#include "shared_definitions.h" #include "leak_dumper.h" using namespace std; @@ -45,7 +46,6 @@ namespace Shared { string Properties::applicationPath = ""; string Properties::applicationDataPath = ""; - string Properties::gameVersion = ""; string Properties::techtreePath = ""; string Properties::scenarioPath = ""; @@ -270,7 +270,7 @@ namespace Shared { mapTagReplacementValues["{SCENARIOPATH}"] = Properties::scenarioPath; mapTagReplacementValues["{TUTORIALPATH}"] = Properties::tutorialPath; - mapTagReplacementValues["$GAMEVERSION"] = Properties::gameVersion; + mapTagReplacementValues["$GAMEVERSION"] = GameVersionString; // // #2 @@ -407,7 +407,7 @@ namespace Shared { // } replaceAll(value, "{TUTORIALPATH}", Properties::tutorialPath); - replaceAll(value, "$GAMEVERSION", Properties::gameVersion); + replaceAll(value, "$GAMEVERSION", GameVersionString); } //if(originalValue != value || originalValue.find("$APPLICATIONDATAPATH") != string::npos) {