diff options
author | BobTheBob9 <for.oliver.kirkham@gmail.com> | 2022-08-19 19:29:15 +0100 |
---|---|---|
committer | BobTheBob9 <for.oliver.kirkham@gmail.com> | 2022-08-19 19:29:15 +0100 |
commit | 554033c01afc51c283e0997d28573abe7599ef24 (patch) | |
tree | d21213f4a553bcd9ce1fde585cb51305feda4c3b /NorthstarDLL/rpakfilesystem.h | |
parent | e85a3eee190e623e1d6397b4460817170b7bfced (diff) | |
download | NorthstarLauncher-554033c01afc51c283e0997d28573abe7599ef24.tar.gz NorthstarLauncher-554033c01afc51c283e0997d28573abe7599ef24.zip |
improve rpakfilesystem
Diffstat (limited to 'NorthstarDLL/rpakfilesystem.h')
-rw-r--r-- | NorthstarDLL/rpakfilesystem.h | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/NorthstarDLL/rpakfilesystem.h b/NorthstarDLL/rpakfilesystem.h index 28b29b52..f8774083 100644 --- a/NorthstarDLL/rpakfilesystem.h +++ b/NorthstarDLL/rpakfilesystem.h @@ -1,14 +1,38 @@ -#pragma once - -class PakLoadManager -{ - public: - void LoadPakSync(const char* path); - void LoadPakAsync(const char* path, bool bMarkForUnload); - void UnloadPaks(); - - private: - std::vector<int> m_pakHandlesToUnload; -}; - -extern PakLoadManager* g_pPakLoadManager; +#pragma once
+
+enum class ePakLoadSource
+{
+ UNTRACKED = -1, // not a pak we loaded, we shouldn't touch this one
+
+ CONSTANT, // should be loaded at all times
+ MAP // loaded from a map, should be unloaded when the map is unloaded
+};
+
+struct LoadedPak
+{
+ ePakLoadSource m_nLoadSource;
+ int m_nPakHandle;
+ size_t m_nPakNameHash;
+};
+
+class PakLoadManager
+{
+ private:
+ std::map<int, LoadedPak> m_vLoadedPaks {};
+ std::unordered_map<size_t, int> m_HashToPakHandle {};
+
+ public:
+ int LoadPakAsync(const char* pPath, const ePakLoadSource nLoadSource);
+ void UnloadPak(const int nPakHandle);
+ void UnloadMapPaks();
+
+ LoadedPak* TrackLoadedPak(ePakLoadSource nLoadSource, int nPakHandle, size_t nPakNameHash);
+ void RemoveLoadedPak(int nPakHandle);
+
+ LoadedPak* GetPakInfo(const int nPakHandle);
+
+ int GetPakHandle(const size_t nPakNameHash);
+ int GetPakHandle(const char* pPath);
+};
+
+extern PakLoadManager* g_pPakLoadManager;
|