diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 2217a4448..b67e7a63e 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -113,6 +113,7 @@ static void print_help_and_exit() printf(" %-20s %-30s\n", "--version", "Print the version and exit"); printf(" %-20s %-30s\n", "--data-dir", "Specify the folder of diabdat.mpq"); printf(" %-20s %-30s\n", "--save-dir", "Specify the folder of save files"); + printf(" %-20s %-30s\n", "--config-dir", "Specify the location of diablo.ini"); printf(" %-20s %-30s\n", "-n", "Skip startup videos"); printf(" %-20s %-30s\n", "-f", "Display frames per second"); printf(" %-20s %-30s\n", "-x", "Run in windowed mode"); @@ -156,6 +157,8 @@ static void diablo_parse_flags(int argc, char **argv) SetBasePath(argv[++i]); } else if (strcasecmp("--save-dir", argv[i]) == 0) { SetPrefPath(argv[++i]); + } else if (strcasecmp("--config-dir", argv[i]) == 0) { + SetConfigPath(argv[++i]); } else if (strcasecmp("-n", argv[i]) == 0) { showintrodebug = FALSE; } else if (strcasecmp("-f", argv[i]) == 0) { diff --git a/SourceS/paths.cpp b/SourceS/paths.cpp index 4eb15b07b..3c03b04ad 100644 --- a/SourceS/paths.cpp +++ b/SourceS/paths.cpp @@ -12,6 +12,7 @@ namespace { std::string *basePath = NULL; std::string *prefPath = NULL; +std::string *configPath = NULL; void AddTrailingSlash(std::string *path) { #ifdef _WIN32 @@ -48,6 +49,13 @@ const std::string &GetPrefPath() return *prefPath; } +const std::string &GetConfigPath() +{ + if (configPath == NULL) + configPath = FromSDL(SDL_GetPrefPath("diasurgical", "devilution")); + return *configPath; +} + void SetBasePath(const char *path) { if (basePath == NULL) basePath = new std::string; @@ -62,4 +70,12 @@ void SetPrefPath(const char *path) AddTrailingSlash(prefPath); } +void SetConfigPath(const char *path) +{ + if (configPath == NULL) + configPath = new std::string; + *configPath = path; + AddTrailingSlash(configPath); +} + } // namespace dvl diff --git a/SourceS/paths.h b/SourceS/paths.h index e0aa50f79..6ef064a97 100644 --- a/SourceS/paths.h +++ b/SourceS/paths.h @@ -6,8 +6,10 @@ namespace dvl { const std::string &GetBasePath(); const std::string &GetPrefPath(); +const std::string &GetConfigPath(); void SetBasePath(const char *path); void SetPrefPath(const char *path); +void SetConfigPath(const char *path); } // namespace dvl diff --git a/SourceX/storm/storm.cpp b/SourceX/storm/storm.cpp index ad63e02b0..678ebad0c 100644 --- a/SourceX/storm/storm.cpp +++ b/SourceX/storm/storm.cpp @@ -35,7 +35,7 @@ static bool IsSVidVideoMode = false; #endif radon::File& getIni() { - static radon::File ini(GetPrefPath() + "diablo.ini"); + static radon::File ini(GetConfigPath() + "diablo.ini"); return ini; }