- bugfix for custom data path macro usage to avoid compiler errors

This commit is contained in:
Mark Vejvoda 2012-01-24 07:39:16 +00:00
parent 84f06d3cbd
commit ff4c327261
6 changed files with 56 additions and 78 deletions

View File

@ -147,7 +147,7 @@ Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> f
#if defined(CUSTOM_DATA_INSTALL_PATH) #if defined(CUSTOM_DATA_INSTALL_PATH)
if(foundPath == false) { if(foundPath == false) {
foundPath = tryCustomPath(cfgType, fileName, TOSTRING(CUSTOM_DATA_INSTALL_PATH)); foundPath = tryCustomPath(cfgType, fileName, formatPath(TOSTRING(CUSTOM_DATA_INSTALL_PATH)));
} }
#endif #endif

View File

@ -2181,26 +2181,8 @@ void CheckForDuplicateData() {
string duplicateWarnings=""; string duplicateWarnings="";
{ {
// vector<string> maps;
vector<string> results; vector<string> results;
/*
vector<string> mapPaths = config.getPathListForType(ptMaps);
findAll(mapPaths, "*.gbm", results, false, false, true);
copy(results.begin(), results.end(), std::back_inserter(maps));
results.clear();
findAll(mapPaths, "*.mgm", results, false, false, true);
copy(results.begin(), results.end(), std::back_inserter(maps));
results.clear();
std::sort(maps.begin(),maps.end());
if(maps.empty()) {
throw runtime_error("No maps were found!");
}
*/
string scenarioDir = ""; string scenarioDir = "";
vector<string> pathList = config.getPathListForType(ptMaps,scenarioDir); vector<string> pathList = config.getPathListForType(ptMaps,scenarioDir);
vector<string> invalidMapList; vector<string> invalidMapList;
@ -2459,7 +2441,7 @@ int glestMain(int argc, char** argv) {
#if defined(CUSTOM_DATA_INSTALL_PATH) #if defined(CUSTOM_DATA_INSTALL_PATH)
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\nCUSTOM_DATA_INSTALL_PATH = [%s]\n\n",TOSTRING(CUSTOM_DATA_INSTALL_PATH)); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\nCUSTOM_DATA_INSTALL_PATH = [%s]\n\n",formatPath(TOSTRING(CUSTOM_DATA_INSTALL_PATH)).c_str());
#endif #endif
const int knownArgCount = sizeof(GAME_ARGS) / sizeof(GAME_ARGS[0]); const int knownArgCount = sizeof(GAME_ARGS) / sizeof(GAME_ARGS[0]);

View File

@ -211,6 +211,7 @@ bool EndsWith(const string &str, const string& key);
void endPathWithSlash(string &path, bool requireOSSlash=false); void endPathWithSlash(string &path, bool requireOSSlash=false);
void trimPathWithStartingSlash(string &path); void trimPathWithStartingSlash(string &path);
void updatePathClimbingParts(string &path); void updatePathClimbingParts(string &path);
void formatPath(string &path);
string replaceAll(string& context, const string& from, const string& to); string replaceAll(string& context, const string& from, const string& to);
bool removeFile(string file); bool removeFile(string file);

View File

@ -500,6 +500,11 @@ void endPathWithSlash(string &path,bool requireOSSlash) {
} }
} }
void formatPath(string &path) {
replaceAll(path, "\"", "");
replaceAll(path, "//", "/");
}
void trimPathWithStartingSlash(string &path) { void trimPathWithStartingSlash(string &path) {
if(StartsWith(path, "/") == true || StartsWith(path, "\\") == true) { if(StartsWith(path, "/") == true || StartsWith(path, "\\") == true) {
path.erase(path.begin(),path.begin()+1); path.erase(path.begin(),path.begin()+1);

View File

@ -77,11 +77,11 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool
#ifndef WIN32 #ifndef WIN32
string mg_icon_file = ""; string mg_icon_file = "";
#if defined(CUSTOM_DATA_INSTALL_PATH_VALUE) #if defined(CUSTOM_DATA_INSTALL_PATH_VALUE)
if(fileExists(CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.png")) { if(fileExists(formatPath(TOSTRING(CUSTOM_DATA_INSTALL_PATH_VALUE)) + "megaglest.png")) {
mg_icon_file = CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.png"; mg_icon_file = formatPath(TOSTRING(CUSTOM_DATA_INSTALL_PATH_VALUE)) + "megaglest.png";
} }
else if(fileExists(CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.bmp")) { else if(fileExists(formatPath(TOSTRING(CUSTOM_DATA_INSTALL_PATH_VALUE)) + "megaglest.bmp")) {
mg_icon_file = CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.bmp"; mg_icon_file = formatPath(TOSTRING(CUSTOM_DATA_INSTALL_PATH_VALUE)) + "megaglest.bmp";
} }
#endif #endif

View File

@ -215,20 +215,15 @@ std::map<string,string> Properties::getTagReplacementValues(std::map<string,stri
mapTagReplacementValues["{APPLICATIONPATH}"] = Properties::applicationPath; mapTagReplacementValues["{APPLICATIONPATH}"] = Properties::applicationPath;
#if defined(CUSTOM_DATA_INSTALL_PATH) #if defined(CUSTOM_DATA_INSTALL_PATH)
mapTagReplacementValues["$APPLICATIONDATAPATH"] = TOSTRING(CUSTOM_DATA_INSTALL_PATH); mapTagReplacementValues["$APPLICATIONDATAPATH"] = formatPath(TOSTRING(CUSTOM_DATA_INSTALL_PATH));
mapTagReplacementValues["%%APPLICATIONDATAPATH%%"] = TOSTRING(CUSTOM_DATA_INSTALL_PATH); mapTagReplacementValues["%%APPLICATIONDATAPATH%%"] = formatPath(TOSTRING(CUSTOM_DATA_INSTALL_PATH));
mapTagReplacementValues["{APPLICATIONDATAPATH}"] = TOSTRING(CUSTOM_DATA_INSTALL_PATH); mapTagReplacementValues["{APPLICATIONDATAPATH}"] = formatPath(TOSTRING(CUSTOM_DATA_INSTALL_PATH));
//mapTagReplacementValues["$COMMONDATAPATH", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
//mapTagReplacementValues["%%COMMONDATAPATH%%", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
#else #else
mapTagReplacementValues["$APPLICATIONDATAPATH"] = Properties::applicationPath; mapTagReplacementValues["$APPLICATIONDATAPATH"] = Properties::applicationPath;
mapTagReplacementValues["%%APPLICATIONDATAPATH%%"] = Properties::applicationPath; mapTagReplacementValues["%%APPLICATIONDATAPATH%%"] = Properties::applicationPath;
mapTagReplacementValues["{APPLICATIONDATAPATH}"] = Properties::applicationPath; mapTagReplacementValues["{APPLICATIONDATAPATH}"] = Properties::applicationPath;
//mapTagReplacementValues["$COMMONDATAPATH", Properties::applicationPath + "/commondata/");
//mapTagReplacementValues["%%COMMONDATAPATH%%", Properties::applicationPath + "/commondata/");
#endif #endif
mapTagReplacementValues["$GAMEVERSION"] = Properties::gameVersion; mapTagReplacementValues["$GAMEVERSION"] = Properties::gameVersion;
@ -308,20 +303,15 @@ bool Properties::applyTagsToValue(string &value, std::map<string,string> *mapTag
replaceAll(value, "{APPLICATIONPATH}", Properties::applicationPath); replaceAll(value, "{APPLICATIONPATH}", Properties::applicationPath);
#if defined(CUSTOM_DATA_INSTALL_PATH) #if defined(CUSTOM_DATA_INSTALL_PATH)
replaceAll(value, "$APPLICATIONDATAPATH", TOSTRING(CUSTOM_DATA_INSTALL_PATH)); replaceAll(value, "$APPLICATIONDATAPATH", formatPath(TOSTRING(CUSTOM_DATA_INSTALL_PATH)));
replaceAll(value, "%%APPLICATIONDATAPATH%%", TOSTRING(CUSTOM_DATA_INSTALL_PATH)); replaceAll(value, "%%APPLICATIONDATAPATH%%", formatPath(TOSTRING(CUSTOM_DATA_INSTALL_PATH)));
replaceAll(value, "{APPLICATIONDATAPATH}", TOSTRING(CUSTOM_DATA_INSTALL_PATH)); replaceAll(value, "{APPLICATIONDATAPATH}", formatPath(TOSTRING(CUSTOM_DATA_INSTALL_PATH)));
//replaceAll(value, "$COMMONDATAPATH", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
//replaceAll(value, "%%COMMONDATAPATH%%", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
#else #else
replaceAll(value, "$APPLICATIONDATAPATH", Properties::applicationPath); replaceAll(value, "$APPLICATIONDATAPATH", Properties::applicationPath);
replaceAll(value, "%%APPLICATIONDATAPATH%%", Properties::applicationPath); replaceAll(value, "%%APPLICATIONDATAPATH%%", Properties::applicationPath);
replaceAll(value, "{APPLICATIONDATAPATH}", Properties::applicationPath); replaceAll(value, "{APPLICATIONDATAPATH}", Properties::applicationPath);
//replaceAll(value, "$COMMONDATAPATH", Properties::applicationPath + "/commondata/");
//replaceAll(value, "%%COMMONDATAPATH%%", Properties::applicationPath + "/commondata/");
#endif #endif
replaceAll(value, "$GAMEVERSION", Properties::gameVersion); replaceAll(value, "$GAMEVERSION", Properties::gameVersion);