mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Only attempt to load .VMT files from the disk if VPK mode is 0
Only load from disk if mode is 0. Mode can be set to 0 using the '-novpk' launch parameter.
This commit is contained in:
parent
44abceb78a
commit
dcb909cab9
@ -52,7 +52,40 @@ void CBaseFileSystem::Warning(CBaseFileSystem* pFileSystem, FileWarningLevel_t l
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
// Purpose: attempts to load files from disk if exist before loading from VPK
|
// Purpose: attempts to load files from disk if exist before loading from VPK/cache
|
||||||
|
// Input : *pszFilePath -
|
||||||
|
// Output : handle to file on success, NULL on failure
|
||||||
|
//---------------------------------------------------------------------------------
|
||||||
|
bool CBaseFileSystem::VCheckDisk(const char* pszFilePath)
|
||||||
|
{
|
||||||
|
// Only load material files from the disk if the mode isn't zero,
|
||||||
|
// use -novpk to load valve materials from the disk.
|
||||||
|
if (FileSystem()->CheckVPKMode(0) && strstr(pszFilePath, ".vmt"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string svFilePath = ConvertToWinPath(pszFilePath);
|
||||||
|
|
||||||
|
if (svFilePath.find("\\\*\\") != string::npos)
|
||||||
|
{
|
||||||
|
// Erase '//*/'.
|
||||||
|
svFilePath.erase(0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: obtain 'mod' SearchPath's instead.
|
||||||
|
svFilePath.insert(0, "platform\\");
|
||||||
|
|
||||||
|
if (::FileExists(svFilePath) /*|| ::FileExists(pszFilePath)*/)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------
|
||||||
|
// Purpose: loads files from VPK
|
||||||
// Input : *this -
|
// Input : *this -
|
||||||
// *pResults -
|
// *pResults -
|
||||||
// *pszFilePath -
|
// *pszFilePath -
|
||||||
@ -60,27 +93,17 @@ void CBaseFileSystem::Warning(CBaseFileSystem* pFileSystem, FileWarningLevel_t l
|
|||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
FileHandle_t CBaseFileSystem::VReadFromVPK(CBaseFileSystem* pFileSystem, FileHandle_t pResults, char* pszFilePath)
|
FileHandle_t CBaseFileSystem::VReadFromVPK(CBaseFileSystem* pFileSystem, FileHandle_t pResults, char* pszFilePath)
|
||||||
{
|
{
|
||||||
std::string svFilePath = ConvertToWinPath(pszFilePath);
|
if (VCheckDisk(pszFilePath))
|
||||||
|
|
||||||
if (svFilePath.find("\\\*\\") != string::npos)
|
|
||||||
{
|
|
||||||
// Erase '//*/'.
|
|
||||||
svFilePath.erase(0, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: obtain 'mod' SearchPath's instead.
|
|
||||||
svFilePath.insert(0, "platform\\");
|
|
||||||
|
|
||||||
if (::FileExists(svFilePath) /*|| ::FileExists(pszFilePath)*/)
|
|
||||||
{
|
{
|
||||||
*reinterpret_cast<int64_t*>(pResults) = -1;
|
*reinterpret_cast<int64_t*>(pResults) = -1;
|
||||||
return pResults;
|
return pResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
return v_CBaseFileSystem_LoadFromVPK(pFileSystem, pResults, pszFilePath);
|
return v_CBaseFileSystem_LoadFromVPK(pFileSystem, pResults, pszFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
// Purpose: attempts to load files from disk if exist before loading from cache
|
// Purpose: loads files from cache
|
||||||
// Input : *this -
|
// Input : *this -
|
||||||
// *pszFilePath -
|
// *pszFilePath -
|
||||||
// *pResults -
|
// *pResults -
|
||||||
@ -88,21 +111,11 @@ FileHandle_t CBaseFileSystem::VReadFromVPK(CBaseFileSystem* pFileSystem, FileHan
|
|||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
bool CBaseFileSystem::VReadFromCache(CBaseFileSystem* pFileSystem, char* pszFilePath, void* pResults)
|
bool CBaseFileSystem::VReadFromCache(CBaseFileSystem* pFileSystem, char* pszFilePath, void* pResults)
|
||||||
{
|
{
|
||||||
std::string svFilePath = ConvertToWinPath(pszFilePath);
|
if (VCheckDisk(pszFilePath))
|
||||||
|
|
||||||
if (svFilePath.find("\\\*\\") != string::npos)
|
|
||||||
{
|
|
||||||
// Erase '//*/'.
|
|
||||||
svFilePath.erase(0, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: obtain 'mod' SearchPath's instead.
|
|
||||||
svFilePath.insert(0, "platform\\");
|
|
||||||
|
|
||||||
if (::FileExists(svFilePath) /*|| ::FileExists(pszFilePath)*/)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return v_CBaseFileSystem_LoadFromCache(pFileSystem, pszFilePath, pResults);
|
return v_CBaseFileSystem_LoadFromCache(pFileSystem, pszFilePath, pResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ public:
|
|||||||
// Purpose: Static methods used for hooking.
|
// Purpose: Static methods used for hooking.
|
||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
static void Warning(CBaseFileSystem* pFileSystem, FileWarningLevel_t level, const char* fmt, ...);
|
static void Warning(CBaseFileSystem* pFileSystem, FileWarningLevel_t level, const char* fmt, ...);
|
||||||
|
static bool VCheckDisk(const char* pszFilePath);
|
||||||
static FileHandle_t VReadFromVPK(CBaseFileSystem* pFileSystem, FileHandle_t pResults, char* pszFilePath);
|
static FileHandle_t VReadFromVPK(CBaseFileSystem* pFileSystem, FileHandle_t pResults, char* pszFilePath);
|
||||||
static bool VReadFromCache(CBaseFileSystem* pFileSystem, char* pszFilePath, void* pResults);
|
static bool VReadFromCache(CBaseFileSystem* pFileSystem, char* pszFilePath, void* pResults);
|
||||||
static VPKData_t* VMountVPKFile(CBaseFileSystem* pFileSystem, const char* pszVpkPath);
|
static VPKData_t* VMountVPKFile(CBaseFileSystem* pFileSystem, const char* pszVpkPath);
|
||||||
|
@ -385,7 +385,7 @@ public:
|
|||||||
virtual bool __fastcall sub_140383E00(__int64 a2) = 0;
|
virtual bool __fastcall sub_140383E00(__int64 a2) = 0;
|
||||||
virtual bool sub_1403836A0() = 0;
|
virtual bool sub_1403836A0() = 0;
|
||||||
virtual __int64 __fastcall sub_140384310(int a1) = 0;
|
virtual __int64 __fastcall sub_140384310(int a1) = 0;
|
||||||
virtual __int64 __fastcall sub_140383820(int a1) = 0;
|
virtual __int64 __fastcall CheckVPKMode(int nMode) = 0; // Checks if the VPK mode equals the mode input.
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user