Added new ConCommand to list all loaded rpaks. By @r-ex

This commit is contained in:
PixieCore 2022-03-23 20:31:29 +01:00
parent 70b6bb038c
commit 7b5676210b
4 changed files with 96 additions and 0 deletions

View File

@ -50,6 +50,46 @@ namespace
#pragma warning( pop ) #pragma warning( pop )
} }
enum class RPakStatus_t : std::int32_t
{
PAK_STATUS_FREED = 0,
PAK_STATUS_LOAD_PENDING = 1,
PAK_STATUS_REPAK_RUNNING = 2,
PAK_STATUS_REPAK_DONE = 3,
PAK_STATUS_LOAD_STARTING = 4,
PAK_STATUS_LOAD_PAKHDR = 5,
PAK_STATUS_LOAD_PATCH_INIT = 6,
PAK_STATUS_LOAD_PATCH_EDIT_STREAM = 7,
PAK_STATUS_LOAD_ASSETS = 8,
PAK_STATUS_LOADED = 9,
PAK_STATUS_UNLOAD_PENDING = 10,
PAK_STATUS_FREE_PENDING = 11,
PAK_STATUS_CANCELING = 12,
PAK_STATUS_ERROR = 13,
PAK_STATUS_INVALID_PAKHANDLE = 14,
PAK_STATUS_BUSY = 15
};
const std::map<RPakStatus_t, std::string> RPakStatusToString {
{ RPakStatus_t::PAK_STATUS_FREED , "PAK_STATUS_FREED" },
{ RPakStatus_t::PAK_STATUS_LOAD_PENDING , "PAK_STATUS_LOAD_PENDING" },
{ RPakStatus_t::PAK_STATUS_REPAK_RUNNING, "PAK_STATUS_REPAK_RUNNING" },
{ RPakStatus_t::PAK_STATUS_REPAK_DONE, "PAK_STATUS_REPAK_DONE" },
{ RPakStatus_t::PAK_STATUS_LOAD_STARTING, "PAK_STATUS_LOAD_STARTING" },
{ RPakStatus_t::PAK_STATUS_LOAD_PAKHDR, "PAK_STATUS_LOAD_PAKHDR" },
{ RPakStatus_t::PAK_STATUS_LOAD_PATCH_INIT, "PAK_STATUS_LOAD_PATCH_INIT" },
{ RPakStatus_t::PAK_STATUS_LOAD_PATCH_EDIT_STREAM, "PAK_STATUS_LOAD_PATCH_EDIT_STREAM" },
{ RPakStatus_t::PAK_STATUS_LOAD_ASSETS, "PAK_STATUS_LOAD_ASSETS" },
{ RPakStatus_t::PAK_STATUS_LOADED, "PAK_STATUS_LOADED" },
{ RPakStatus_t::PAK_STATUS_UNLOAD_PENDING, "PAK_STATUS_UNLOAD_PENDING" },
{ RPakStatus_t::PAK_STATUS_FREE_PENDING, "PAK_STATUS_FREE_PENDING" },
{ RPakStatus_t::PAK_STATUS_CANCELING, "PAK_STATUS_CANCELING" },
{ RPakStatus_t::PAK_STATUS_ERROR, "PAK_STATUS_ERROR" },
{ RPakStatus_t::PAK_STATUS_INVALID_PAKHANDLE, "PAK_STATUS_INVALID_PAKHANDLE" },
{ RPakStatus_t::PAK_STATUS_BUSY, "PAK_STATUS_BUSY" },
};
struct RPakHeader_t struct RPakHeader_t
{ {
std::uint32_t m_nMagic; // 'RPak' std::uint32_t m_nMagic; // 'RPak'
@ -107,6 +147,21 @@ struct __declspec(align(8)) RPakDecompState_t
std::uint64_t m_nDecompStreamSize; std::uint64_t m_nDecompStreamSize;
}; };
class RPakLoadedInfo_t
{
public:
std::int32_t m_nPakId; //0x0000
RPakStatus_t m_nStatus; //0x0004
std::uint64_t m_nUnk1; //0x0008
std::uint32_t m_nUnk2; //0x0010
std::uint32_t m_nAssetCount; //0x0014
char* m_pszFileName; //0x0018
void* m_pUnk1; //0x0020
std::uint64_t* m_pAssetGuids; //0x0028 size of the array is m_nAssetCount
char pad_0030[128]; //0x0030
std::uint64_t m_nUnkEnd; //0x00B0
}; //Size: 0x00B8
namespace namespace
{ {
/* ==== RTECH =========================================================================================================================================================== */ /* ==== RTECH =========================================================================================================================================================== */

View File

@ -126,6 +126,7 @@ void ConCommand::Init(void)
ConCommand* rtech_strtoguid = new ConCommand("rtech_strtoguid", "Calculates the GUID from input data.", FCVAR_DEVELOPMENTONLY, _RTech_StringToGUID_f_CompletionFunc, nullptr); ConCommand* rtech_strtoguid = new ConCommand("rtech_strtoguid", "Calculates the GUID from input data.", FCVAR_DEVELOPMENTONLY, _RTech_StringToGUID_f_CompletionFunc, nullptr);
ConCommand* rtech_asyncload = new ConCommand("rtech_asyncload", "Loads user specified 'RPak' file.", FCVAR_DEVELOPMENTONLY, _RTech_AsyncLoad_f_CompletionFunc, nullptr); ConCommand* rtech_asyncload = new ConCommand("rtech_asyncload", "Loads user specified 'RPak' file.", FCVAR_DEVELOPMENTONLY, _RTech_AsyncLoad_f_CompletionFunc, nullptr);
ConCommand* rtech_decompress = new ConCommand("rtech_decompress", "Decompresses user specified 'RPak' file.", FCVAR_DEVELOPMENTONLY, _RTech_Decompress_f_CompletionFunc, nullptr); ConCommand* rtech_decompress = new ConCommand("rtech_decompress", "Decompresses user specified 'RPak' file.", FCVAR_DEVELOPMENTONLY, _RTech_Decompress_f_CompletionFunc, nullptr);
ConCommand* pak_listpaks = new ConCommand("pak_listpaks", "Display a list of the loaded Pak files.", FCVAR_DEVELOPMENTONLY, _Pak_ListPaks_f_CompletionFunc, nullptr);
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// NETCHANNEL | // NETCHANNEL |
ConCommand* net_toggletrace = new ConCommand("net_toggletrace", "Logs the sending and receiving datagram to a file on the disk.", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY, _NET_TraceNetChan_f_CompletionFunc, nullptr); ConCommand* net_toggletrace = new ConCommand("net_toggletrace", "Logs the sending and receiving datagram to a file on the disk.", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY, _NET_TraceNetChan_f_CompletionFunc, nullptr);

View File

@ -393,6 +393,45 @@ void _ReloadBanList_f_CompletionFunc(const CCommand& args)
g_pBanSystem->Load(); // Reload banlist. g_pBanSystem->Load(); // Reload banlist.
} }
/*
=====================
_Pak_ListPaks_f_CompletionFunc
=====================
*/
void _Pak_ListPaks_f_CompletionFunc(const CCommand& cmd)
{
#ifdef GAMEDLL_S3
static std::int16_t* s_pLoadedPakCount = ADDRESS(0x167ED7C6C).RCast<std::int16_t*>();
static RPakLoadedInfo_t* g_pLoadedPakInfo = ADDRESS(0x167D40B70).RCast<RPakLoadedInfo_t*>();
DevMsg(eDLL_T::RTECH, "| id | name | status | asset count |\n");
DevMsg(eDLL_T::RTECH, "|----|----------------------------------|--------------------------------------|-------------|\n");
std::uint32_t nActuallyLoaded = 0;
for (int i = 0; i < *s_pLoadedPakCount; ++i)
{
RPakLoadedInfo_t info = g_pLoadedPakInfo[i];
if (info.m_nStatus == RPakStatus_t::PAK_STATUS_FREED)
continue;
std::string rpakStatus = "RPAK_CREATED_A_NEW_STATUS_SOMEHOW";
auto it = RPakStatusToString.find(info.m_nStatus);
if (it != RPakStatusToString.end())
rpakStatus = it->second;
// todo: make status into a string from an array/vector
DevMsg(eDLL_T::RTECH, "| %02i | %-32s | %-36s | %11i |\n", info.m_nPakId, info.m_pszFileName, rpakStatus.c_str(), info.m_nAssetCount);
nActuallyLoaded++;
}
DevMsg(eDLL_T::RTECH, "|----|----------------------------------|--------------------------------------|-------------|\n");
DevMsg(eDLL_T::RTECH, "| %16i loaded paks. |\n", nActuallyLoaded);
DevMsg(eDLL_T::RTECH, "|----|----------------------------------|--------------------------------------|-------------|\n");
#endif
}
/* /*
===================== =====================
_RTech_StringToGUID_f_CompletionFunc _RTech_StringToGUID_f_CompletionFunc

View File

@ -26,6 +26,7 @@ void _Ban_f_CompletionFunc(const CCommand& args);
void _BanID_f_CompletionFunc(const CCommand& args); void _BanID_f_CompletionFunc(const CCommand& args);
void _Unban_f_CompletionFunc(const CCommand& args); void _Unban_f_CompletionFunc(const CCommand& args);
void _ReloadBanList_f_CompletionFunc(const CCommand& args); void _ReloadBanList_f_CompletionFunc(const CCommand& args);
void _Pak_ListPaks_f_CompletionFunc(const CCommand& cmd);
void _RTech_StringToGUID_f_CompletionFunc(const CCommand& args); void _RTech_StringToGUID_f_CompletionFunc(const CCommand& args);
void _RTech_AsyncLoad_f_CompletionFunc(const CCommand& args); void _RTech_AsyncLoad_f_CompletionFunc(const CCommand& args);
void _RTech_Decompress_f_CompletionFunc(const CCommand& args); void _RTech_Decompress_f_CompletionFunc(const CCommand& args);