aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/core/filesystem/filesystem.cpp
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2023-12-20 13:24:07 +0000
committerGitHub <noreply@github.com>2023-12-20 14:24:07 +0100
commit0438b5c8cfa99ac01c7e142d959aa40f88f1cc70 (patch)
treebbfdded20f8686cf188dba148db4b6c1b1211872 /NorthstarDLL/core/filesystem/filesystem.cpp
parent210dab2b0e5c686829bafdc857d2910f6b216b85 (diff)
downloadNorthstarLauncher-0438b5c8cfa99ac01c7e142d959aa40f88f1cc70.tar.gz
NorthstarLauncher-0438b5c8cfa99ac01c7e142d959aa40f88f1cc70.zip
Cherry pick "remove unnecessary namespaces" from primedev (#618)v1.21.2-rc2
Cherry-picks the removal of unnecessary namespaces from `primedev` https://github.com/F1F7Y/NorthstarPrime/ Co-authored-by: F1F7Y <filip.bartos07@proton.me>
Diffstat (limited to 'NorthstarDLL/core/filesystem/filesystem.cpp')
-rw-r--r--NorthstarDLL/core/filesystem/filesystem.cpp54
1 files changed, 24 insertions, 30 deletions
diff --git a/NorthstarDLL/core/filesystem/filesystem.cpp b/NorthstarDLL/core/filesystem/filesystem.cpp
index e4da647f..b39939e4 100644
--- a/NorthstarDLL/core/filesystem/filesystem.cpp
+++ b/NorthstarDLL/core/filesystem/filesystem.cpp
@@ -7,48 +7,42 @@
AUTOHOOK_INIT()
-using namespace R2;
-
bool bReadingOriginalFile = false;
std::string sCurrentModPath;
ConVar* Cvar_ns_fs_log_reads;
-// use the R2 namespace for game funcs
-namespace R2
+SourceInterface<IFileSystem>* g_pFilesystem;
+
+std::string ReadVPKFile(const char* path)
{
- SourceInterface<IFileSystem>* g_pFilesystem;
+ // read scripts.rson file, todo: check if this can be overwritten
+ FileHandle_t fileHandle = (*g_pFilesystem)->m_vtable2->Open(&(*g_pFilesystem)->m_vtable2, path, "rb", "GAME", 0);
- std::string ReadVPKFile(const char* path)
+ std::stringstream fileStream;
+ int bytesRead = 0;
+ char data[4096];
+ do
{
- // read scripts.rson file, todo: check if this can be overwritten
- FileHandle_t fileHandle = (*g_pFilesystem)->m_vtable2->Open(&(*g_pFilesystem)->m_vtable2, path, "rb", "GAME", 0);
-
- std::stringstream fileStream;
- int bytesRead = 0;
- char data[4096];
- do
- {
- bytesRead = (*g_pFilesystem)->m_vtable2->Read(&(*g_pFilesystem)->m_vtable2, data, (int)std::size(data), fileHandle);
- fileStream.write(data, bytesRead);
- } while (bytesRead == std::size(data));
+ bytesRead = (*g_pFilesystem)->m_vtable2->Read(&(*g_pFilesystem)->m_vtable2, data, (int)std::size(data), fileHandle);
+ fileStream.write(data, bytesRead);
+ } while (bytesRead == std::size(data));
- (*g_pFilesystem)->m_vtable2->Close(*g_pFilesystem, fileHandle);
+ (*g_pFilesystem)->m_vtable2->Close(*g_pFilesystem, fileHandle);
- return fileStream.str();
- }
+ return fileStream.str();
+}
- std::string ReadVPKOriginalFile(const char* path)
- {
- // todo: should probably set search path to be g_pModName here also
+std::string ReadVPKOriginalFile(const char* path)
+{
+ // todo: should probably set search path to be g_pModName here also
- bReadingOriginalFile = true;
- std::string ret = ReadVPKFile(path);
- bReadingOriginalFile = false;
+ bReadingOriginalFile = true;
+ std::string ret = ReadVPKFile(path);
+ bReadingOriginalFile = false;
- return ret;
- }
-} // namespace R2
+ return ret;
+}
// clang-format off
HOOK(AddSearchPathHook, AddSearchPath,
@@ -175,7 +169,7 @@ ON_DLL_LOAD("filesystem_stdio.dll", Filesystem, (CModule module))
{
AUTOHOOK_DISPATCH()
- R2::g_pFilesystem = new SourceInterface<IFileSystem>("filesystem_stdio.dll", "VFileSystem017");
+ g_pFilesystem = new SourceInterface<IFileSystem>("filesystem_stdio.dll", "VFileSystem017");
AddSearchPathHook.Dispatch((LPVOID)(*g_pFilesystem)->m_vtable->AddSearchPath);
ReadFromCacheHook.Dispatch((LPVOID)(*g_pFilesystem)->m_vtable->ReadFromCache);