aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/core/filesystem
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
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')
-rw-r--r--NorthstarDLL/core/filesystem/filesystem.cpp54
-rw-r--r--NorthstarDLL/core/filesystem/filesystem.h10
-rw-r--r--NorthstarDLL/core/filesystem/rpakfilesystem.cpp4
3 files changed, 29 insertions, 39 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);
diff --git a/NorthstarDLL/core/filesystem/filesystem.h b/NorthstarDLL/core/filesystem/filesystem.h
index ac1c5986..9c4e891b 100644
--- a/NorthstarDLL/core/filesystem/filesystem.h
+++ b/NorthstarDLL/core/filesystem/filesystem.h
@@ -63,11 +63,7 @@ class IFileSystem
VTable2* m_vtable2;
};
-// use the R2 namespace for game funcs
-namespace R2
-{
- extern SourceInterface<IFileSystem>* g_pFilesystem;
+extern SourceInterface<IFileSystem>* g_pFilesystem;
- std::string ReadVPKFile(const char* path);
- std::string ReadVPKOriginalFile(const char* path);
-} // namespace R2
+std::string ReadVPKFile(const char* path);
+std::string ReadVPKOriginalFile(const char* path);
diff --git a/NorthstarDLL/core/filesystem/rpakfilesystem.cpp b/NorthstarDLL/core/filesystem/rpakfilesystem.cpp
index 8d50b07a..da72646b 100644
--- a/NorthstarDLL/core/filesystem/rpakfilesystem.cpp
+++ b/NorthstarDLL/core/filesystem/rpakfilesystem.cpp
@@ -209,8 +209,8 @@ int, __fastcall, (char* pPath, void* unknownSingleton, int flags, void* pCallbac
// dedicated only needs common, common_mp, common_sp, and sp_<map> rpaks
// sp_<map> rpaks contain tutorial ghost data
// sucks to have to load the entire rpak for that but sp was never meant to be done on dedi
- if (IsDedicatedServer() && (Tier0::CommandLine()->CheckParm("-nopakdedi") ||
- strncmp(&originalPath[0], "common", 6) && strncmp(&originalPath[0], "sp_", 3)))
+ if (IsDedicatedServer() &&
+ (CommandLine()->CheckParm("-nopakdedi") || strncmp(&originalPath[0], "common", 6) && strncmp(&originalPath[0], "sp_", 3)))
{
if (bNeedToFreePakName)
delete[] pPath;