diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-08-02 03:20:10 +0100 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-08-02 03:20:10 +0100 |
commit | eb56fcbe02f35ed4f418a7dc53cd9eb0ad95a504 (patch) | |
tree | 352923d1b6735502a71f4202e542af7ab84b3946 /NorthstarDedicatedTest/filesystem.cpp | |
parent | 30e67549449a0ffbb58f7fc736bdd9e4ce7ec9d5 (diff) | |
download | NorthstarLauncher-eb56fcbe02f35ed4f418a7dc53cd9eb0ad95a504.tar.gz NorthstarLauncher-eb56fcbe02f35ed4f418a7dc53cd9eb0ad95a504.zip |
add dynamic keyvalue building, client serverbrowser stuff
Diffstat (limited to 'NorthstarDedicatedTest/filesystem.cpp')
-rw-r--r-- | NorthstarDedicatedTest/filesystem.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/NorthstarDedicatedTest/filesystem.cpp b/NorthstarDedicatedTest/filesystem.cpp index 323b8756..15b8b4dd 100644 --- a/NorthstarDedicatedTest/filesystem.cpp +++ b/NorthstarDedicatedTest/filesystem.cpp @@ -88,12 +88,13 @@ void SetNewModSearchPaths(Mod* mod) } -bool TryReplaceFile(char* path) +bool TryReplaceFile(char* path, bool shouldCompile) { if (readingOriginalFile) return false; - (*g_ModManager).CompileAssetsForFile(path); + if (shouldCompile) + (*g_ModManager).CompileAssetsForFile(path); // idk how efficient the lexically normal check is // can't just set all /s in path to \, since some paths aren't in writeable memory @@ -111,7 +112,9 @@ FileHandle_t ReadFileFromVPKHook(VPKData* vpkInfo, __int64* b, char* filename) { // move this to a convar at some point when we can read them in native //spdlog::info("ReadFileFromVPKHook {} {}", filename, vpkInfo->path); - if (TryReplaceFile(filename)) + + // there is literally never any reason to compile here, since we'll always compile in ReadFileFromFilesystemHook in the same codepath this is called + if (TryReplaceFile(filename, false)) { *b = -1; return b; @@ -125,7 +128,7 @@ bool ReadFromCacheHook(IFileSystem* filesystem, char* path, void* result) // move this to a convar at some point when we can read them in native //spdlog::info("ReadFromCacheHook {}", path); - if (TryReplaceFile(path)) + if (TryReplaceFile(path, true)) return false; return readFromCache(filesystem, path, result); @@ -146,6 +149,9 @@ void AddSearchPathHook(IFileSystem* fileSystem, const char* pPath, const char* p FileHandle_t ReadFileFromFilesystemHook(IFileSystem* filesystem, const char* pPath, const char* pOptions, int64_t a4, uint32_t a5) { // this isn't super efficient, but it's necessary, since calling addsearchpath in readfilefromvpk doesn't work, possibly refactor later - TryReplaceFile((char*)pPath); + // it also might be possible to hook functions that are called later, idk look into callstack for ReadFileFromVPK + if (!readingOriginalFile) + TryReplaceFile((char*)pPath, true); + return readFileFromFilesystem(filesystem, pPath, pOptions, a4, a5); }
\ No newline at end of file |