mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Unloading rpaks poperly now that we load on map load.
This commit is contained in:
parent
89a8909cbb
commit
2045f52ad8
@ -35,14 +35,12 @@ void MOD_PreloadPak(const std::string& svSetFile)
|
||||
{
|
||||
if (!jsIn["rpak"].is_null())
|
||||
{
|
||||
int iPakIdx{};
|
||||
for (auto it = jsIn["rpak"].begin(); it != jsIn["rpak"].end(); ++it)
|
||||
{
|
||||
if (it.value().is_string())
|
||||
{
|
||||
std::string svToLoad = it.value().get<std::string>() + ".rpak";
|
||||
unsigned int nPakId = 0;
|
||||
nPakId = RTech_AsyncLoad((void*)svToLoad.c_str(), g_pMallocPool.GetPtr(), 4, 0);
|
||||
std::uint32_t nPakId = RTech_AsyncLoad((void*)svToLoad.c_str(), g_pMallocPool.GetPtr(), 4, 0);
|
||||
|
||||
if (nPakId == -1)
|
||||
{
|
||||
@ -50,8 +48,7 @@ void MOD_PreloadPak(const std::string& svSetFile)
|
||||
}
|
||||
else
|
||||
{
|
||||
g_nLoadedPakFileId[iPakIdx] = nPakId;
|
||||
iPakIdx++;
|
||||
g_nLoadedPakFileId.push_back(nPakId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,11 +85,13 @@ FORCEINLINE void CHostState::FrameUpdate(void* rcx, void* rdx, float time)
|
||||
case HostStates_t::HS_CHANGE_LEVEL_SP:
|
||||
{
|
||||
g_pHostState->State_ChangeLevelSP();
|
||||
g_pHostState->UnloadPakFile(); // Unload our loaded rpaks. Calling this before the actual level change happens kills the game.
|
||||
break;
|
||||
}
|
||||
case HostStates_t::HS_CHANGE_LEVEL_MP:
|
||||
{
|
||||
g_pHostState->State_ChangeLevelMP();
|
||||
g_pHostState->UnloadPakFile(); // Unload our loaded rpaks. Calling this before the actual level change happens kills the game.
|
||||
break;
|
||||
}
|
||||
case HostStates_t::HS_RUN:
|
||||
@ -101,6 +103,7 @@ FORCEINLINE void CHostState::FrameUpdate(void* rcx, void* rdx, float time)
|
||||
{
|
||||
DevMsg(eDLL_T::ENGINE, "%s - Shutdown host game\n", "CHostState::FrameUpdate");
|
||||
|
||||
g_pHostState->UnloadPakFile();
|
||||
g_bLevelResourceInitialized = false;
|
||||
Host_Game_ShutdownFn(g_pHostState);
|
||||
break;
|
||||
@ -275,18 +278,14 @@ FORCEINLINE void CHostState::GameShutDown(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
FORCEINLINE void CHostState::UnloadPakFile(void)
|
||||
{
|
||||
for (int i = 0; i < sizeof(g_nLoadedPakFileId); i++)
|
||||
for (auto& it : g_nLoadedPakFileId)
|
||||
{
|
||||
if (g_nLoadedPakFileId[i] > 0)
|
||||
if (it >= 0) // [ PIXIE ] TODO: Create RTech function to get RPakLoadedInfo by ID and print which rpak is getting unloaded.
|
||||
{
|
||||
RTech_UnloadPak(g_nLoadedPakFileId[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(g_nLoadedPakFileId, '\0', sizeof(g_nLoadedPakFileId));
|
||||
break;
|
||||
RTech_UnloadPak(it);
|
||||
}
|
||||
}
|
||||
g_nLoadedPakFileId.clear();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -7,7 +7,8 @@
|
||||
#include "engine/host_cmd.h"
|
||||
#include "engine/sys_utils.h"
|
||||
#include "rtech/rtech_game.h"
|
||||
int g_nLoadedPakFileId[256]{};
|
||||
|
||||
std::vector<int> g_nLoadedPakFileId{ };
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: unloads asset files from the memory pool
|
||||
|
@ -58,7 +58,7 @@ void HRtech_AsyncLoad(std::string svPakFileName);
|
||||
void RTech_Game_Attach();
|
||||
void RTech_Game_Detach();
|
||||
|
||||
extern int g_nLoadedPakFileId[256];
|
||||
extern std::vector<int> g_nLoadedPakFileId;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class HRTechGame : public IDetour
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user