Skip to content

Commit f994756

Browse files
committed
dos: Clean up paths for better logging
1. Prevents warnings in `--verbose` mode from unimplemented `SDL_GetBase/PrefPath`. These were the first 4 "This operation is not supported" messages that were logged previously. 2. Removes Linux directories from MPQ search paths on DOS. 3. Uses backslash directory separator on DOS. DJGPP libc supports both but this is DOS, we should use backslash. Now the `--verbose` SDL_LOG.txt looks much cleaner: ``` VERBOSE: Paths: base: pref: config: assets: assets\ VERBOSE: MPQ search paths: 1. '' VERBOSE: Found: devx in VERBOSE: Missing: fonts DEBUG: DOS: Keyboard ISR code size is 48 bytes DEBUG: Unknown pixel format DEBUG: SVGA: Ignoring mode 0x102: Bad attributes DEBUG: SVGA: Ignoring mode 0x104: Bad attributes DEBUG: SVGA: Ignoring mode 0x106: Bad attributes DEBUG: SVGA: Ignoring mode 0x107: No double-buffering DEBUG: SVGA: Ignoring mode 0x112: No double-buffering DEBUG: SVGA: Ignoring mode 0x115: No double-buffering DEBUG: SVGA: Ignoring mode 0x116: No double-buffering DEBUG: SVGA: Ignoring mode 0x117: No double-buffering DEBUG: SVGA: Ignoring mode 0x209: No double-buffering DEBUG: SVGA: Ignoring mode 0x20A: No double-buffering DEBUG: SVGA: Ignoring mode 0x225: No double-buffering DEBUG: SVGA: VBE lists 42 modes VERBOSE: Removed file: Diablo1ReadOnlyTest.foo VERBOSE: Paths: base: pref: config: assets: assets\ VERBOSE: MPQ search paths: 1. '' VERBOSE: Paths: base: pref: config: assets: assets\ VERBOSE: MPQ search paths: 1. '' VERBOSE: Found: DIABDAT in VERBOSE: Missing: hfbard VERBOSE: Missing: hfbarb DEBUG: That operation is not supported VERBOSE: Control: device None -> KeyboardAndMouse, mode None -> KeyboardAndMouse ```
1 parent 09e105f commit f994756

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

Source/engine/assets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ std::vector<std::string> GetMPQSearchPaths()
330330
if (paths[0] == paths[1] || (paths.size() == 3 && (paths[0] == paths[2] || paths[1] == paths[2])))
331331
paths.pop_back();
332332

333-
#if (defined(__unix__) || defined(__APPLE__)) && !defined(__ANDROID__)
333+
#if (defined(__unix__) || defined(__APPLE__)) && !defined(__ANDROID__) && !defined(__DJGPP__)
334334
// `XDG_DATA_HOME` is usually the root path of `paths::PrefPath()`, so we only
335335
// add `XDG_DATA_DIRS`.
336336
const char *xdgDataDirs = std::getenv("XDG_DATA_DIRS");

Source/utils/file_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace devilution {
1111

12-
#ifdef _WIN32
12+
#if defined(_WIN32) || defined(__DJGPP__)
1313
constexpr char DirectorySeparator = '\\';
1414
#define DIRECTORY_SEPARATOR_STR "\\"
1515
#else

Source/utils/paths.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void AddTrailingSlash(std::string &path)
4242
path += DirectorySeparator;
4343
}
4444

45-
std::string FromSDL(char *s)
45+
[[maybe_unused]] std::string FromSDL(char *s)
4646
{
4747
const SDLUniquePtr<char> pinned(s);
4848
std::string result = (s != nullptr ? s : "");
@@ -72,21 +72,27 @@ const std::string &NxdkGetPrefPath()
7272
const std::string &BasePath()
7373
{
7474
if (!basePath) {
75+
#if defined(__DJGPP__)
76+
basePath = std::string();
77+
#else
7578
basePath = FromSDL(SDL_GetBasePath());
79+
#endif
7680
}
7781
return *basePath;
7882
}
7983

8084
const std::string &PrefPath()
8185
{
8286
if (!prefPath) {
83-
#if defined(__IPHONEOS__)
87+
#if defined(__DJGPP__)
88+
prefPath = std::string();
89+
#elif defined(__IPHONEOS__)
8490
prefPath = FromSDL(IOSGetPrefPath());
8591
#elif defined(NXDK)
8692
prefPath = NxdkGetPrefPath();
8793
#else
8894
prefPath = FromSDL(SDL_GetPrefPath("diasurgical", "devilution"));
89-
#if !defined(__amigaos__)
95+
#if !defined(__amigaos__) && !defined(__DJGPP__)
9096
if (FileExistsAndIsWriteable("diablo.ini")) {
9197
prefPath = std::string();
9298
}
@@ -99,13 +105,15 @@ const std::string &PrefPath()
99105
const std::string &ConfigPath()
100106
{
101107
if (!configPath) {
102-
#if defined(__IPHONEOS__)
108+
#if defined(__DJGPP__)
109+
configPath = std::string();
110+
#elif defined(__IPHONEOS__)
103111
configPath = FromSDL(IOSGetPrefPath());
104112
#elif defined(NXDK)
105113
configPath = NxdkGetPrefPath();
106114
#else
107115
configPath = FromSDL(SDL_GetPrefPath("diasurgical", "devilution"));
108-
#if !defined(__amigaos__)
116+
#if !defined(__amigaos__) && !defined(__DJGPP__)
109117
if (FileExistsAndIsWriteable("diablo.ini")) {
110118
configPath = std::string();
111119
}
@@ -118,8 +126,8 @@ const std::string &ConfigPath()
118126
const std::string &AssetsPath()
119127
{
120128
if (!assetsPath) {
121-
#if __EMSCRIPTEN__
122-
assetsPath.emplace("assets/");
129+
#if __EMSCRIPTEN__ || defined(__DJGPP__)
130+
assetsPath.emplace("assets" DIRECTORY_SEPARATOR_STR);
123131
#elif defined(NXDK)
124132
assetsPath.emplace("D:\\assets\\");
125133
#elif defined(__3DS__) || defined(__SWITCH__)

0 commit comments

Comments
 (0)