add listassetpool & others

This commit is contained in:
m 2022-03-13 07:45:20 -05:00
parent 4747735487
commit 3af1d21166
4 changed files with 78 additions and 57 deletions

View File

@ -277,6 +277,15 @@ namespace command
}
}
void enum_assets(const game::XAssetType type, const std::function<void(game::XAssetHeader)>& callback, const bool includeOverride)
{
game::DB_EnumXAssets_Internal(type, static_cast<void(*)(game::XAssetHeader, void*)>([](game::XAssetHeader header, void* data)
{
const auto& cb = *static_cast<const std::function<void(game::XAssetHeader)>*>(data);
cb(header);
}), &callback, includeOverride);
}
class component final : public component_interface
{
public:
@ -339,7 +348,7 @@ namespace command
console::info("================================ END COMMAND DUMP =================================\n");
});
/*add("listassetpool", [](const params& params)
add("listassetpool", [](const params& params)
{
if (params.size() < 2)
{
@ -378,7 +387,7 @@ namespace command
console::info("%s\n", asset_name);
}, true);
}
});*/
});
add("vstr", [](const params& params)
{
@ -570,7 +579,7 @@ namespace command
: "^1off"));
});
/*add_sv("give", [](const int client_num, const params_sv& params)
add_sv("give", [](const int client_num, const params_sv& params)
{
if (!game::Dvar_FindVar("sv_cheats")->current.enabled)
{
@ -620,7 +629,7 @@ namespace command
{
game::G_TakePlayerWeapon(ps, wp);
}
});*/
});
}
};
}

View File

@ -177,58 +177,6 @@ namespace game_console
game::R_AddCmdDrawText(text, 0x7FFFFFFF, console_font, con.globals.x + offset_x, _y, 1.0f, 1.0f, 0.0f, color, 0);
}
bool match_compare(const std::string& input, const std::string& text, const bool exact)
{
if (exact && text == input) return true;
if (!exact && text.find(input) != std::string::npos) return true;
return false;
}
void find_matches(std::string input, std::vector<dvars::dvar_info>& suggestions, const bool exact)
{
input = utils::string::to_lower(input);
for (const auto& dvar : dvars::dvar_list)
{
auto name = utils::string::to_lower(dvar.name);
if (game::Dvar_FindVar(name.data()) && match_compare(input, name, exact))
{
suggestions.push_back(dvar);
}
if (exact && suggestions.size() > 1)
{
return;
}
}
if (suggestions.size() == 0 && game::Dvar_FindVar(input.data()))
{
suggestions.push_back({input.data(), ""});
}
game::cmd_function_s* cmd = (*game::cmd_functions);
while (cmd)
{
if (cmd->name)
{
std::string name = utils::string::to_lower(cmd->name);
if (match_compare(input, name, exact))
{
suggestions.push_back({cmd->name, ""});
}
if (exact && suggestions.size() > 1)
{
return;
}
}
cmd = cmd->next;
}
}
void draw_input()
{
con.globals.font_height = static_cast<float>(console_font->pixelHeight);
@ -718,6 +666,57 @@ namespace game_console
return true;
}
bool match_compare(const std::string& input, const std::string& text, const bool exact)
{
if (exact && text == input) return true;
if (!exact && text.find(input) != std::string::npos) return true;
return false;
}
void find_matches(std::string input, std::vector<std::string>& suggestions, const bool exact)
{
input = utils::string::to_lower(input);
for (const auto& dvar : dvars::dvar_list)
{
auto name = utils::string::to_lower(dvar);
if (game::Dvar_FindVar(name.data()) && match_compare(input, name, exact))
{
suggestions.push_back(dvar);
}
if (exact && suggestions.size() > 1)
{
return;
}
}
if (suggestions.size() == 0 && game::Dvar_FindVar(input.data()))
{
suggestions.push_back(input.data());
}
game::cmd_function_s* cmd = (*game::cmd_functions);
while (cmd)
{
if (cmd->name)
{
std::string name = utils::string::to_lower(cmd->name);
if (game_console::match_compare(input, name, exact))
{
suggestions.push_back(cmd->name);
}
if (exact && suggestions.size() > 1)
{
return;
}
}
cmd = cmd->next;
}
}
class component final : public component_interface
{

View File

@ -4,4 +4,7 @@ namespace game_console
{
bool console_char_event(int local_client_num, int key);
bool console_key_event(int local_client_num, int key, int down);
}
bool match_compare(const std::string& input, const std::string& text, const bool exact);
void find_matches(std::string input, std::vector<std::string>& suggestions, const bool exact);
}

View File

@ -82,6 +82,12 @@ namespace game
WEAK symbol<void()> G_Glass_Update{0x14026C570, 0x14033A640};
WEAK symbol<int(int clientNum)> G_GetClientScore{0, 0x140342F90};
WEAK symbol<unsigned int(const char* name)> G_GetWeaponForName{0x1402C2A90, 0x14038C300};
WEAK symbol<int(playerState_s* ps, unsigned int weapon, int dualWield,
int startInAltMode, int, int, int, char, ...)> G_GivePlayerWeapon{0x1402C2DF0, 0x14038C750};
WEAK symbol<void(playerState_s* ps, unsigned int weapon, int hadWeapon)> G_InitializeAmmo{0x140270980, 0x14033EDD0};
WEAK symbol<void(int clientNum, unsigned int weapon)> G_SelectWeapon{0x1402C3750, 0x14038D1B0};
WEAK symbol<int(playerState_s* ps, unsigned int weapon)> G_TakePlayerWeapon{0x1402C3900, 0x14038D370};
WEAK symbol<char*(char* string)> I_CleanStr{0x1403CD230, 0x140503D00};
@ -128,6 +134,9 @@ namespace game
WEAK symbol<ScreenPlacement* ()> ScrPlace_GetViewPlacement{0x1401981F0, 0x140288550};
WEAK symbol<void(XAssetType type, void(__cdecl* func)(XAssetHeader, void*), const void* inData, bool includeOverride)>
DB_EnumXAssets_Internal{0x1401C9C10, 0x1402BA830};
WEAK symbol<const char* (const XAsset* asset)> DB_GetXAssetName{0x14019A390, 0x14028BE50};
WEAK symbol<int(XAssetType type)> DB_GetXAssetTypeSize{0x14019A3B0, 0x14028BE70};
WEAK symbol<void(int clientNum, const char* menu,
@ -211,6 +220,7 @@ namespace game
WEAK symbol<dvar_t> dvarPool{0x14C217D20, 0x14D064D00};
WEAK symbol<void*> DB_XAssetPool{0x140DE8C80, 0x140FEB5D0};
WEAK symbol<const char*> g_assetNames{0x1408B0870, 0x140FEA240};
WEAK symbol<int> keyCatchers{0x14243DAF0, 0x142D0BA9C};
WEAK symbol<PlayerKeyState> playerKeys{0x1422A873C, 0x142C19AFC};