mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
RTech: return the most recently loaded pak in Pak_GetPakInfo
Make sure to always return the most recently loaded pak instead of the first hit with provided name. The pak system supports live asset hot swapping so we need to take this into account here.
This commit is contained in:
parent
5742163756
commit
291a99e3ae
@ -263,7 +263,14 @@ PakLoadedInfo_s* Pak_GetPakInfo(const PakHandle_t pakId)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
const PakLoadedInfo_s* Pak_GetPakInfo(const char* const pakName)
|
const PakLoadedInfo_s* Pak_GetPakInfo(const char* const pakName)
|
||||||
{
|
{
|
||||||
for (int16_t i = 0; i < PAK_MAX_LOADED_PAKS; ++i)
|
// a pak under the same name can be loaded more than once, the hotswap
|
||||||
|
// system just switches the asset pointers to the new 'live' pak if
|
||||||
|
// there are assets that overlap the ones in the previous pak. we want
|
||||||
|
// to find the most recently loaded pak under the provided name and
|
||||||
|
// return that to the caller. the higher the handle, the newer it is.
|
||||||
|
PakHandle_t highestHandle = PAK_INVALID_HANDLE;
|
||||||
|
|
||||||
|
for (uint16_t i = 0; i < PAK_MAX_LOADED_PAKS; ++i)
|
||||||
{
|
{
|
||||||
const PakLoadedInfo_s* const info = &g_pakGlobals->loadedPaks[i];
|
const PakLoadedInfo_s* const info = &g_pakGlobals->loadedPaks[i];
|
||||||
if (!info)
|
if (!info)
|
||||||
@ -275,11 +282,17 @@ const PakLoadedInfo_s* Pak_GetPakInfo(const char* const pakName)
|
|||||||
if (strcmp(pakName, info->fileName) != 0)
|
if (strcmp(pakName, info->fileName) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return info;
|
if (info->handle > highestHandle)
|
||||||
|
highestHandle = info->handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
DevWarning(eDLL_T::RTECH, "%s - Failed to retrieve pak info for name '%s'\n", __FUNCTION__, pakName);
|
if (highestHandle == PAK_INVALID_HANDLE)
|
||||||
return nullptr;
|
{
|
||||||
|
DevWarning(eDLL_T::RTECH, "%s - Failed to retrieve pak info for name '%s'\n", __FUNCTION__, pakName);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Pak_GetPakInfo(highestHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user