Browse Source

specify path to diablo.ini (#928)

pull/932/head
qndel 5 years ago committed by GitHub
parent
commit
9c7d6c96ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      Source/diablo.cpp
  2. 16
      SourceS/paths.cpp
  3. 2
      SourceS/paths.h
  4. 2
      SourceX/storm/storm.cpp

3
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) {

16
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

2
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

2
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;
}

Loading…
Cancel
Save