Skip to content
Permalink
Browse files
- bugfix for windows processing var tags in ini files (was crashing o…
…n windows when using the new glest-dev.ini)
  • Loading branch information
softcoder committed Jan 28, 2014
1 parent cce3beb commit 7cae2b53f1a26ad4fb13e4ede8afba68b25cf261
@@ -1311,23 +1311,19 @@ 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);
}
}

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);
}
@@ -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);
@@ -102,6 +102,8 @@ class Properties {

static bool applyTagsToValue(string &value, const std::map<string,string> *mapTagReplacementValues=NULL);
static std::map<string,string> getTagReplacementValues(std::map<string,string> *mapExtraTagReplacementValues=NULL);
static bool isValuePathVariable(const string &value);
static void Properties::updateValuePathVariable(string &value);

string getpath() const { return path;}

@@ -261,9 +261,39 @@ std::map<string,string> Properties::getTagReplacementValues(std::map<string,stri
return mapTagReplacementValues;
}

bool Properties::isValuePathVariable(const string &value) {
if(value.find("~/") != value.npos ||
value.find("$HOME") != value.npos ||
value.find("%%HOME%%") != value.npos ||
value.find("%%USERPROFILE%%") != value.npos ||
value.find("%%HOMEPATH%%") != value.npos ||
value.find("{HOMEPATH}") != value.npos ||
value.find("$APPDATA") != value.npos ||
value.find("%%APPDATA%%") != value.npos ||
value.find("{APPDATA}") != value.npos ||
value.find("$APPLICATIONPATH") != value.npos ||
value.find("%%APPLICATIONPATH%%") != value.npos ||
value.find("{APPLICATIONPATH}") != value.npos ||
value.find("$APPLICATIONDATAPATH") != value.npos ||
value.find("%%APPLICATIONDATAPATH%%") != value.npos ||
value.find("{APPLICATIONDATAPATH}") != value.npos ||
value.find("{TECHTREEPATH}") != value.npos ||
value.find("{SCENARIOPATH}") != value.npos ||
value.find("{TUTORIALPATH}") != value.npos) {

return true;
}
return false;
}
void Properties::updateValuePathVariable(string &value) {
replaceAll(value,"//","/");
replaceAll(value,"\\\\","\\");
updatePathClimbingParts(value);
}

bool Properties::applyTagsToValue(string &value, const std::map<string,string> *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<string,string> *
//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);
}

0 comments on commit 7cae2b5

Please sign in to comment.