Temporary fix for rpaks not loading from override dir

This commit is contained in:
Kawe Mazidjatari 2022-08-06 22:17:47 +02:00
parent 587b92659e
commit 0c583d7522
4 changed files with 11 additions and 9 deletions

View File

@ -1,7 +1,7 @@
REM Remove log files ('log' is no longer used. 'logs' contains current logs, these get automatically cleaned if they exceed 10mb). REM Remove log files ('log' is no longer used. 'logs' contains current logs, these get automatically cleaned if they exceed 10mb).
rd /S /Q "%~dp0log" rd /S /Q "%~dp0log"
rd /S /Q "%~dp0logs" rd /S /Q "%~dp0logs"
REM Remove old navmesh files which where included as an attempt to debug/suppress warnings. REM Remove old NavMesh files which where included as an attempt to debug/suppress warnings.
rd /S /Q "%~dp0platform\maps\graphs" rd /S /Q "%~dp0platform\maps\graphs"
rd /S /Q "%~dp0platform\maps\navmesh" rd /S /Q "%~dp0platform\maps\navmesh"
REM Remove deprecated binary and configuration files (these are no longer used). REM Remove deprecated binary and configuration files (these are no longer used).
@ -12,3 +12,4 @@ del /Q "%~dp0..\r5reloaded.exe"
del /Q "%~dp0..\r5apexsdkd64.dll" del /Q "%~dp0..\r5apexsdkd64.dll"
del /Q "%~dp0..\r5detours.dll" del /Q "%~dp0..\r5detours.dll"
del /Q "%~dp0..\r5dev.dll" del /Q "%~dp0..\r5dev.dll"
del /Q "%~dp0..\paks\Win32\common_empty.rpak"

View File

@ -18,17 +18,17 @@ vector<RPakHandle_t> g_vLoadedPakHandle;
// *pMalloc - // *pMalloc -
// nIdx - // nIdx -
// bUnk - // bUnk -
// Output : pak file handle on success, -1 (INVALID_PAK_HANDLE) on failure // Output : pak file handle on success, INVALID_PAK_HANDLE on failure
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
RPakHandle_t CPakFile::LoadAsync(const char* szPakFileName, uintptr_t pMalloc, int nIdx, bool bUnk) RPakHandle_t CPakFile::LoadAsync(const char* szPakFileName, uintptr_t pMalloc, int nIdx, bool bUnk)
{ {
RPakHandle_t pakHandle = -1; RPakHandle_t pakHandle = INVALID_PAK_HANDLE;
#ifdef DEDICATED #ifdef DEDICATED
// Extraneous files (useless on the dedicated server). // Extraneous files (useless on the dedicated server).
if (strcmp(szPakFileName, "ui.rpak") == 0) if (strcmp(szPakFileName, "ui.rpak") == 0)
{ {
static const char* szReplacement = "common_empty.rpak"; static const char* szReplacement = "empty.rpak";
// Returning -1 (invalid handle) triggers engine error, call is inline. // Returning INVALID_PAK_HANDLE triggers engine error, call is inline.
// Replacing the ui.rpak file here with a stub to avoid having to patch. // Replacing the ui.rpak file here with a stub to avoid having to patch.
DevMsg(eDLL_T::RTECH, "Loading pak file: '%s' for '%s'\n", szReplacement, szPakFileName); DevMsg(eDLL_T::RTECH, "Loading pak file: '%s' for '%s'\n", szReplacement, szPakFileName);
return pakHandle = CPakFile_LoadAsync(szReplacement, pMalloc, nIdx, bUnk); return pakHandle = CPakFile_LoadAsync(szReplacement, pMalloc, nIdx, bUnk);
@ -49,7 +49,7 @@ RPakHandle_t CPakFile::LoadAsync(const char* szPakFileName, uintptr_t pMalloc, i
DevMsg(eDLL_T::RTECH, "Loading pak file: '%s'\n", szPakFileName); DevMsg(eDLL_T::RTECH, "Loading pak file: '%s'\n", szPakFileName);
pakHandle = CPakFile_LoadAsync(szPakFileName, pMalloc, nIdx, bUnk); pakHandle = CPakFile_LoadAsync(szPakFileName, pMalloc, nIdx, bUnk);
if (pakHandle == -1) if (pakHandle == INVALID_PAK_HANDLE)
{ {
Error(eDLL_T::RTECH, "%s: Failed read '%s' results '%u'\n", __FUNCTION__, szPakFileName, pakHandle); Error(eDLL_T::RTECH, "%s: Failed read '%s' results '%u'\n", __FUNCTION__, szPakFileName, pakHandle);
} }

View File

@ -2,6 +2,7 @@
#include "tier0/tslist.h" #include "tier0/tslist.h"
typedef int RPakHandle_t; typedef int RPakHandle_t;
constexpr int INVALID_PAK_HANDLE = -1;
enum class ePakStatus : int enum class ePakStatus : int
{ {

View File

@ -632,7 +632,7 @@ int32_t RTech::OpenFile(const char* szFilePath, void* unused, int64_t* fileSizeO
const int32_t fileIdx = RTech_FindFreeSlotInFiles(s_pFileArray); const int32_t fileIdx = RTech_FindFreeSlotInFiles(s_pFileArray);
ReleaseSRWLockExclusive(reinterpret_cast<PSRWLOCK>(&*g_pPakFileSlotLock)); ReleaseSRWLockExclusive(reinterpret_cast<PSRWLOCK>(&*g_pPakFileSlotLock));
const int32_t fileHandleIdx = fileIdx & 0x3FF; // Something with ArraySize. const int32_t fileHandleIdx = (fileIdx & 0x3FF); // Something with ArraySize.
m_FileHandles->self[fileHandleIdx].m_nFileNumber = fileIdx; m_FileHandles->self[fileHandleIdx].m_nFileNumber = fileIdx;
m_FileHandles->self[fileHandleIdx].m_hFileHandle = hFile; m_FileHandles->self[fileHandleIdx].m_hFileHandle = hFile;
@ -688,7 +688,7 @@ RPakLoadedInfo_t* RTech::GetPakLoadedInfo(const char* szPakName)
void RTech_Utils_Attach() void RTech_Utils_Attach()
{ {
DetourAttach((LPVOID*)&RTech_OpenFile, &RTech::OpenFile); //DetourAttach((LPVOID*)&RTech_OpenFile, &RTech::OpenFile); // !FIXME: Loading override rpaks doesn't work with this, disabled for now.
#if not defined DEDICATED && defined (GAMEDLL_S3) #if not defined DEDICATED && defined (GAMEDLL_S3)
DetourAttach((LPVOID*)&RTech_CreateDXTexture, &RTech::CreateDXTexture); DetourAttach((LPVOID*)&RTech_CreateDXTexture, &RTech::CreateDXTexture);
@ -698,7 +698,7 @@ void RTech_Utils_Attach()
void RTech_Utils_Detach() void RTech_Utils_Detach()
{ {
// [ PIXIE ]: Everything related to RTech::OpenFile should be compatible across seasons. // [ PIXIE ]: Everything related to RTech::OpenFile should be compatible across seasons.
DetourDetach((LPVOID*)&RTech_OpenFile, &RTech::OpenFile); //DetourDetach((LPVOID*)&RTech_OpenFile, &RTech::OpenFile);
#if not defined DEDICATED && defined (GAMEDLL_S3) #if not defined DEDICATED && defined (GAMEDLL_S3)
DetourDetach((LPVOID*)&RTech_CreateDXTexture, &RTech::CreateDXTexture); DetourDetach((LPVOID*)&RTech_CreateDXTexture, &RTech::CreateDXTexture);