@@ -89,6 +89,38 @@ char *D_DoomExeDir(void)
89
89
return base ;
90
90
}
91
91
92
+ // [FG] get the path to the default configuration dir to use
93
+
94
+ char * D_DoomPrefDir (void )
95
+ {
96
+ static char * dir ;
97
+
98
+ if (dir == NULL )
99
+ {
100
+ #if !defined(_WIN32 ) || defined(_WIN32_WCE )
101
+ // Configuration settings are stored in an OS-appropriate path
102
+ // determined by SDL. On typical Unix systems, this might be
103
+ // ~/.local/share/chocolate-doom. On Windows, we behave like
104
+ // Vanilla Doom and save in the current directory.
105
+
106
+ char * result = SDL_GetPrefPath ("" , PROJECT_SHORTNAME );
107
+ if (result != NULL )
108
+ {
109
+ dir = M_DirName (result );
110
+ SDL_free (result );
111
+ }
112
+ else
113
+ #endif /* #ifndef _WIN32 */
114
+ {
115
+ dir = D_DoomExeDir ();
116
+ }
117
+
118
+ M_MakeDirectory (dir );
119
+ }
120
+
121
+ return dir ;
122
+ }
123
+
92
124
// This is Windows-specific code that automatically finds the location
93
125
// of installed IWAD files. The registry is inspected to find special
94
126
// keys installed by the Windows installers for various CD versions
@@ -547,7 +579,9 @@ void BuildIWADDirList(void)
547
579
548
580
// Next check the directory where the executable is located. This might
549
581
// be different from the current directory.
550
- array_push (iwad_dirs , D_DoomExeDir ());
582
+ // D_DoomPrefDir() returns the executable directory on Windows,
583
+ // and a user-writable config directory everywhere else.
584
+ array_push (iwad_dirs , D_DoomPrefDir ());
551
585
552
586
// Add DOOMWADDIR if it is in the environment
553
587
env = M_getenv ("DOOMWADDIR" );
0 commit comments