|
|
|
|
@ -32,6 +32,7 @@ namespace {
|
|
|
|
|
|
|
|
|
|
bool directFileAccess = false; |
|
|
|
|
std::optional<std::string> SBasePath; |
|
|
|
|
std::optional<std::string> AssetsPath; |
|
|
|
|
|
|
|
|
|
SdlMutex Mutex; |
|
|
|
|
|
|
|
|
|
@ -128,6 +129,14 @@ bool SFileOpenFile(const char *filename, HANDLE *phFile)
|
|
|
|
|
result = SFileOpenFileEx((HANDLE)diabdat_mpq, filename, SFILE_OPEN_FROM_MPQ, phFile); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// As last fallback always search app content folder
|
|
|
|
|
if (!result && AssetsPath) { |
|
|
|
|
std::string path = *AssetsPath + filename; |
|
|
|
|
for (std::size_t i = SBasePath->size(); i < path.size(); ++i) |
|
|
|
|
path[i] = AsciiToLowerTable_Path[static_cast<unsigned char>(path[i])]; |
|
|
|
|
result = SFileOpenFileEx((HANDLE) nullptr, path.c_str(), SFILE_OPEN_LOCAL_FILE, phFile); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!result || (*phFile == nullptr)) { |
|
|
|
|
const auto error = SErrGetLastError(); |
|
|
|
|
if (error == STORM_ERROR_FILE_NOT_FOUND) { |
|
|
|
|
@ -154,6 +163,11 @@ void SFileSetBasePath(string_view path)
|
|
|
|
|
SBasePath.emplace(path); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SFileSetAssetsPath(string_view path) |
|
|
|
|
{ |
|
|
|
|
AssetsPath.emplace(path); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool SFileEnableDirectAccess(bool enable) |
|
|
|
|
{ |
|
|
|
|
directFileAccess = enable; |
|
|
|
|
|