From 402ae16657f076f3d45211bd674019592cae843f Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 2 May 2011 18:28:57 +0000 Subject: [PATCH] - added support for specifying data and log paths in the standard glest.ini and glestuser.ini DataPath=x LogPath=x --- source/glest_game/main/main.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index bdf5f635..981edb2b 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -1038,7 +1038,7 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) { printf("\n\n"); } -int setupGameItemPaths(int argc, char** argv) { +int setupGameItemPaths(int argc, char** argv, Config *config) { // Setup path cache for files and folders used in the game std::map &pathCache = CacheManager::getCachedItem< std::map >(GameConstants::pathCacheLookupKey); @@ -1064,6 +1064,12 @@ int setupGameItemPaths(int argc, char** argv) { return -1; } } + else if(config != NULL) { + if(config->getString("DataPath","") != "") { + pathCache[GameConstants::path_data_CacheLookupKey] = config->getString("DataPath",""); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using ini specified data path [%s]\n",config->getString("DataPath","").c_str()); + } + } //GAME_ARG_INI_PATH if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_INI_PATH]) == true) { @@ -1110,6 +1116,13 @@ int setupGameItemPaths(int argc, char** argv) { return -1; } } + else if(config != NULL) { + if(config->getString("LogPath","") != "") { + pathCache[GameConstants::path_logs_CacheLookupKey] = config->getString("LogPath",""); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using ini specified logs path [%s]\n",config->getString("LogPath","").c_str()); + } + } + return 0; } @@ -2083,13 +2096,14 @@ int glestMain(int argc, char** argv) { try { // Setup paths to game items (like data, logs, ini etc) - int setupResult = setupGameItemPaths(argc, argv); + int setupResult = setupGameItemPaths(argc, argv, NULL); if(setupResult != 0) { return setupResult; } // Attempt to read ini files Config &config = Config::getInstance(); + setupGameItemPaths(argc, argv, &config); string userData = config.getString("UserData_Root",""); if(userData != "") {