Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
Deduplicate find_override_file
Browse files Browse the repository at this point in the history
  • Loading branch information
vswarte committed Jan 13, 2024
1 parent fb2044a commit b34fa30
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
4 changes: 1 addition & 3 deletions src/modengine/ext/mod_loader/archive_file_overrides.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ namespace modengine::ext {
// the easiest and most robust way to do this. It also has the bonus of allowing files that don't go through the asset system
// (like the data archives and some of the sounds) to be overridable.

namespace fs = std::filesystem;

concurrency::concurrent_unordered_map<std::wstring, std::optional<std::filesystem::path>> archive_override_paths;
concurrency::concurrent_unordered_map<std::wstring, std::optional<std::filesystem::path>> file_override_paths;

Expand Down Expand Up @@ -241,4 +239,4 @@ void* __cdecl virtual_to_archive_path_eldenring(DLString<modengine::GameType::SE
return res;
}

}
}
7 changes: 6 additions & 1 deletion src/modengine/ext/mod_loader/archive_file_overrides.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
#include "gametypes/dantelion/dlstring.h"

#include <set>
#include <filesystem>
#include <concurrent_vector.h>

namespace modengine::ext {

namespace fs = std::filesystem;

// String type used in DS2/DS3
typedef struct
{
Expand Down Expand Up @@ -43,4 +46,6 @@ HANDLE WINAPI tCreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwSh
LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile);

}
std::optional<fs::path> find_override_file(const fs::path& game_path);

}
14 changes: 0 additions & 14 deletions src/modengine/ext/mod_loader/wwise_file_overrides.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,6 @@ namespace fs = std::filesystem;

using namespace spdlog;

std::optional<fs::path> find_override_file(const fs::path game_path)
{
for (const auto& root : hooked_file_roots) {
trace(L"Searching for {} in {}", game_path.wstring(), root);

auto file_path = root / fs::path(game_path);
if (fs::exists(file_path)) {
return file_path;
}
}

return {};
}

const wchar_t* prefixes[3] = {
L"sd/",
L"sd/enus/",
Expand Down

0 comments on commit b34fa30

Please sign in to comment.