aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/filesystem.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-05-11 14:53:04 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-05-11 14:53:04 +0100
commitc9771185a73ffb324887a85f6d2185bd14da374d (patch)
tree7afe536c0a2a061ebeb13b9275739cd76e104db4 /NorthstarDedicatedTest/filesystem.cpp
parent035c1b1dceeaae7c17798c60f37a229fa5a0d83b (diff)
downloadNorthstarLauncher-c9771185a73ffb324887a85f6d2185bd14da374d.tar.gz
NorthstarLauncher-c9771185a73ffb324887a85f6d2185bd14da374d.zip
replace files in ReadFromCache
Diffstat (limited to 'NorthstarDedicatedTest/filesystem.cpp')
-rw-r--r--NorthstarDedicatedTest/filesystem.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/NorthstarDedicatedTest/filesystem.cpp b/NorthstarDedicatedTest/filesystem.cpp
index 72d7d4fc..73cb5a1a 100644
--- a/NorthstarDedicatedTest/filesystem.cpp
+++ b/NorthstarDedicatedTest/filesystem.cpp
@@ -101,25 +101,23 @@ bool TryReplaceFile(const char* pPath, bool shouldCompile)
return false;
}
+// force modded files to be read from mods, not cache
typedef bool (*ReadFromCacheType)(IFileSystem* filesystem, char* path, void* result);
ReadFromCacheType ReadFromCache;
bool ReadFromCacheHook(IFileSystem* filesystem, char* pPath, void* result)
{
- if (TryReplaceFile(pPath, false))
+ if (TryReplaceFile(pPath, true))
return false;
return ReadFromCache(filesystem, pPath, result);
}
+// force modded files to be read from mods, not vpk
typedef FileHandle_t (*ReadFileFromVPKType)(VPKData* vpkInfo, __int64* b, char* filename);
ReadFileFromVPKType ReadFileFromVPK;
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);
-
- // there is literally never any reason to compile here, since we'll always compile in ReadFileFromFilesystemHook in the same codepath
- // this is called
+ // don't compile here because this is only ever called from OpenEx, which already compiles
if (TryReplaceFile(filename, false))
{
*b = -1;
@@ -134,13 +132,7 @@ typedef FileHandle_t (*CBaseFileSystem__OpenExType)(
CBaseFileSystem__OpenExType CBaseFileSystem__OpenEx;
FileHandle_t CBaseFileSystem__OpenExHook(IFileSystem* filesystem, const char* pPath, const char* pOptions, uint32_t flags, const char* pPathID, char **ppszResolvedFilename)
{
- //if (Cvar_ns_fs_log_reads->GetBool())
-
- // this isn't super efficient, but it's necessary, since calling addsearchpath in readfilefromvpk doesn't work, possibly refactor later
- // it also might be possible to hook functions that are called later, idk look into callstack for ReadFileFromVPK
- if (!bReadingOriginalFile)
- TryReplaceFile(pPath, true);
-
+ TryReplaceFile(pPath, true);
return CBaseFileSystem__OpenEx(filesystem, pPath, pOptions, flags, pPathID, ppszResolvedFilename);
}