From 7cae2b53f1a26ad4fb13e4ede8afba68b25cf261 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Mon, 27 Jan 2014 20:12:14 -0800 Subject: [PATCH] - bugfix for windows processing var tags in ini files (was crashing on windows when using the new glest-dev.ini) --- source/glest_game/main/main.cpp | 4 --- source/glest_game/menu/server_line.cpp | 6 ++-- source/shared_lib/include/util/properties.h | 2 ++ source/shared_lib/sources/util/properties.cpp | 36 ++++++++++++++++++- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 5b371b62..a7f3cce5 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -1311,11 +1311,9 @@ int setupGameItemPaths(int argc, char** argv, Config *config) { if(devProperties.hasString("ServerListPath") == true) { string devItem = devProperties.getString("ServerListPath"); - Properties::applyTagsToValue(devItem); if(devItem != "") { endPathWithSlash(devItem); } - if(config != NULL) { config->setString("ServerListPath",devItem,true); } @@ -1323,11 +1321,9 @@ int setupGameItemPaths(int argc, char** argv, Config *config) { if(devProperties.hasString("GlestKeysIniPath") == true) { string devItem = devProperties.getString("GlestKeysIniPath"); - Properties::applyTagsToValue(devItem); if(devItem != "") { endPathWithSlash(devItem); } - if(config != NULL) { config->setString("GlestKeysIniPath",devItem,true); } diff --git a/source/glest_game/menu/server_line.cpp b/source/glest_game/menu/server_line.cpp index de54d208..b494ade8 100644 --- a/source/glest_game/menu/server_line.cpp +++ b/source/glest_game/menu/server_line.cpp @@ -56,8 +56,10 @@ ServerLine::ServerLine(MasterServerInfo *mServerInfo, int lineIndex, int baseY, i+= 70; string platform=masterServerInfo.getPlatform(); - int revOffset=platform.find("-Rev"); - platform=platform.substr(0,revOffset); + size_t revOffset = platform.find("-Rev"); + if(revOffset != platform.npos) { + platform = platform.substr(0,revOffset); + } platformLabel.init(i, baseY - lineOffset); platformLabel.setTextColor(color); diff --git a/source/shared_lib/include/util/properties.h b/source/shared_lib/include/util/properties.h index 977acae6..03418749 100644 --- a/source/shared_lib/include/util/properties.h +++ b/source/shared_lib/include/util/properties.h @@ -102,6 +102,8 @@ public: static bool applyTagsToValue(string &value, const std::map *mapTagReplacementValues=NULL); static std::map getTagReplacementValues(std::map *mapExtraTagReplacementValues=NULL); + static bool isValuePathVariable(const string &value); + static void Properties::updateValuePathVariable(string &value); string getpath() const { return path;} diff --git a/source/shared_lib/sources/util/properties.cpp b/source/shared_lib/sources/util/properties.cpp index 11c62875..a7178be0 100644 --- a/source/shared_lib/sources/util/properties.cpp +++ b/source/shared_lib/sources/util/properties.cpp @@ -261,9 +261,39 @@ std::map Properties::getTagReplacementValues(std::map *mapTagReplacementValues) { string originalValue = value; - + bool valueRequiresPathUpdate = Properties::isValuePathVariable(value); //if(originalValue.find("$APPLICATIONDATAPATH") != string::npos) { // printf("\nBEFORE SUBSTITUTE [%s] app [%s] mapTagReplacementValues [%p]\n",originalValue.c_str(),Properties::applicationPath.c_str(),mapTagReplacementValues); //} @@ -357,6 +387,10 @@ bool Properties::applyTagsToValue(string &value, const std::map * //if(originalValue != value || originalValue.find("$APPLICATIONDATAPATH") != string::npos) { // printf("\nBEFORE SUBSTITUTE [%s] AFTER [%s]\n",originalValue.c_str(),value.c_str()); //} + + if(valueRequiresPathUpdate == true) { + Properties::updateValuePathVariable(value); + } return (originalValue != value); }