[AssetHandler]: Added commands with flag 'debug'

This commit is contained in:
JerryALT 2024-06-18 14:55:27 +03:00
parent 4c77a7996d
commit b7668a6d85
2 changed files with 90 additions and 25 deletions

View File

@ -193,35 +193,13 @@ namespace Components
Utils::Hook::Set<Game::XAssetEntry*>(0x45A6E2, entryPool + 1);
}
AssetHandler::AssetHandler()
void AssetHandler::AddDebugAssetCommands()
{
this->reallocateEntryPool();
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_IMAGE, 7168);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_SOUND, 24000);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_LOADED_SOUND, 2700);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_FX, 1200);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_LOCALIZE_ENTRY, 14000);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_XANIMPARTS, 8192);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_XMODEL, 5125);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_PHYSPRESET, 128);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_MENU, 1280);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_MENULIST, 256);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_MATERIAL, 8192);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_WEAPON, ASSET_TYPE_WEAPON_LIMIT);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_STRINGTABLE, 800);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_GAMEWORLD_MP, 1);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_FONT, 32);
//AssetHandler::ClearTemporaryAssets();
//Utils::Hook(Game::DB_FindXAssetHeader, AssetHandler::FindAssetStub).install()->quick();
Command::Add("listassetpool", [](Command::Params* params)
Command::Add("listAssetPool", [](Command::Params* params)
{
if (params->size() < 2)
{
Game::Com_Printf(0, "listassetpool <poolnumber> [filter]: list all the assets in the specified pool\n");
Game::Com_Printf(0, "listAssetPool <poolnumber> [filter]: list all the assets in the specified pool\n");
for (auto i = 0; i < Game::XAssetType::ASSET_TYPE_COUNT; i++)
{
@ -254,6 +232,91 @@ namespace Components
}, true);
}
});
Command::Add("poolUsages", []()
{
for (auto i = 0; i < Game::ASSET_TYPE_COUNT; i++)
{
auto count = 0;
FastFiles::EnumAssets(static_cast<Game::XAssetType>(i), [&](Game::XAssetHeader header)
{
count++;
}, true);
Game::Com_Printf(0, Utils::String::VA("%i %s: %i / %i\n", i, Game::g_assetNames[i], count, Game::g_poolSize[i]));
}
});
Command::Add("poolUsage", [](Command::Params* params)
{
if (params->size() < 2)
{
Game::Com_Printf(0, "poolUsage <poolnumber>: list all the assets in the specified pool\n");
for (auto i = 0; i < Game::XAssetType::ASSET_TYPE_COUNT; i++)
{
Game::Com_Printf(0, "%d %s\n", i, Game::g_assetNames[i]);
}
}
else
{
const auto type = static_cast<Game::XAssetType>(std::atoi(params->get(1)));
auto count = 0;
FastFiles::EnumAssets(type, [&](Game::XAssetHeader header)
{
count++;
}, true);
Game::Com_Printf(0, Utils::String::VA("%i %s: %i / %i\n", type, Game::g_assetNames[type], count, Game::g_poolSize[type]));
}
});
Command::Add("assetCount", [](const Command::Params* params)
{
auto count = 0;
auto totalCount = 0;
for (auto i = 0; i < Game::ASSET_TYPE_COUNT; i++)
{
FastFiles::EnumAssets(static_cast<Game::XAssetType>(i), [&](Game::XAssetHeader header)
{
count++;
}, true);
totalCount += Game::g_poolSize[i];
}
Game::Com_Printf(0, Utils::String::VA("total assets: %i / %i\n", count, totalCount));
});
}
AssetHandler::AssetHandler()
{
this->reallocateEntryPool();
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_IMAGE, 7168);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_SOUND, 24000);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_LOADED_SOUND, 2700);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_FX, 1200);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_LOCALIZE_ENTRY, 14000);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_XANIMPARTS, 8192);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_XMODEL, 5125);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_PHYSPRESET, 128);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_MENU, 1280);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_MENULIST, 256);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_MATERIAL, 8192);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_WEAPON, ASSET_TYPE_WEAPON_LIMIT);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_STRINGTABLE, 800);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_GAMEWORLD_MP, 1);
Game::DB_ReallocXAssetPool(Game::ASSET_TYPE_FONT, 32);
//AssetHandler::ClearTemporaryAssets();
//Utils::Hook(Game::DB_FindXAssetHeader, AssetHandler::FindAssetStub).install()->quick();
if (Game::DebugModeEnabled())
{
AddDebugAssetCommands();
}
}
AssetHandler::~AssetHandler()

View File

@ -50,5 +50,7 @@ namespace Components
static void SetBypassState(bool value);
void reallocateEntryPool();
static void AddDebugAssetCommands();
};
}