- bugfix for windows processing var tags in ini files (was crashing on windows when using the new glest-dev.ini)

This commit is contained in:
SoftCoder 2014-01-27 20:12:14 -08:00
parent cce3beb939
commit 7cae2b53f1
4 changed files with 41 additions and 7 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -102,6 +102,8 @@ public:
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;}

View File

@ -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);
}