add bindlist cmd
This commit is contained in:
parent
f35b102d44
commit
4967ed9569
@ -477,6 +477,11 @@ namespace command
|
|||||||
game::Com_GameMode_SetDesiredGameMode(game::GAME_MODE_CP);
|
game::Com_GameMode_SetDesiredGameMode(game::GAME_MODE_CP);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
add("bindlist", []()
|
||||||
|
{
|
||||||
|
game::Key_Bindlist_f();
|
||||||
|
});
|
||||||
|
|
||||||
add_sv("god", [](const int client_num, const params_sv&)
|
add_sv("god", [](const int client_num, const params_sv&)
|
||||||
{
|
{
|
||||||
if (!game::shared::cheats_ok(client_num, true))
|
if (!game::shared::cheats_ok(client_num, true))
|
||||||
|
@ -17,7 +17,6 @@ namespace input
|
|||||||
utils::hook::detour cl_char_event_hook;
|
utils::hook::detour cl_char_event_hook;
|
||||||
utils::hook::detour cl_key_event_hook;
|
utils::hook::detour cl_key_event_hook;
|
||||||
utils::hook::detour cl_execute_key_hook;
|
utils::hook::detour cl_execute_key_hook;
|
||||||
utils::hook::detour key_get_binding_for_key_hook;
|
|
||||||
|
|
||||||
int key_get_binding_for_cmd_stub(const char* command);
|
int key_get_binding_for_cmd_stub(const char* command);
|
||||||
|
|
||||||
@ -125,6 +124,18 @@ namespace input
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<std::string*> get_custom_binding_for_key(int key)
|
||||||
|
{
|
||||||
|
key -= get_num_keys();
|
||||||
|
|
||||||
|
if (static_cast<size_t>(key) < custom_binds.size() && !custom_binds[key].empty())
|
||||||
|
{
|
||||||
|
return { &custom_binds[key] };
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
int key_get_binding_for_cmd_stub(const char* command)
|
int key_get_binding_for_cmd_stub(const char* command)
|
||||||
{
|
{
|
||||||
// original binds
|
// original binds
|
||||||
@ -140,16 +151,19 @@ namespace input
|
|||||||
return get_num_keys() + get_binding_for_custom_command(command);
|
return get_num_keys() + get_binding_for_custom_command(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> get_custom_binding_for_key(int key)
|
const char* key_get_cmd_for_binding_stub(int localClientNum, int keyBinding)
|
||||||
{
|
{
|
||||||
key -= get_num_keys();
|
if (keyBinding >= get_num_keys())
|
||||||
|
|
||||||
if (static_cast<size_t>(key) < custom_binds.size() && !custom_binds[key].empty())
|
|
||||||
{
|
{
|
||||||
return { custom_binds[key] };
|
const auto bind = get_custom_binding_for_key(keyBinding);
|
||||||
|
if (bind.has_value())
|
||||||
|
{
|
||||||
|
return bind.value()->data();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return game::command_whitelist[keyBinding];
|
||||||
}
|
}
|
||||||
|
|
||||||
void cl_execute_key_stub(const int local_client_num, int key, const int down, const unsigned int time)
|
void cl_execute_key_stub(const int local_client_num, int key, const int down, const unsigned int time)
|
||||||
@ -162,7 +176,7 @@ namespace input
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return game::Cbuf_AddText(local_client_num, utils::string::va("%s\n", bind.value().data()));
|
return game::Cbuf_AddText(local_client_num, utils::string::va("%s\n", bind.value()->data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_execute_key_hook.invoke<void>(local_client_num, key, down, time);
|
cl_execute_key_hook.invoke<void>(local_client_num, key, down, time);
|
||||||
@ -190,6 +204,7 @@ namespace input
|
|||||||
|
|
||||||
// links a custom command to an index
|
// links a custom command to an index
|
||||||
utils::hook::jump(0x1409A8EA0, key_get_binding_for_cmd_stub);
|
utils::hook::jump(0x1409A8EA0, key_get_binding_for_cmd_stub);
|
||||||
|
utils::hook::jump(0x1409A91D0, key_get_cmd_for_binding_stub);
|
||||||
|
|
||||||
// execute custom binds
|
// execute custom binds
|
||||||
cl_execute_key_hook.create(0x14032A3B0, &cl_execute_key_stub);
|
cl_execute_key_hook.create(0x14032A3B0, &cl_execute_key_stub);
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include "game.hpp"
|
#include "game.hpp"
|
||||||
#include "dvars.hpp"
|
#include "dvars.hpp"
|
||||||
|
|
||||||
|
#include "component/console/console.hpp"
|
||||||
|
|
||||||
#include <utils/flags.hpp>
|
#include <utils/flags.hpp>
|
||||||
#include <utils/string.hpp>
|
#include <utils/string.hpp>
|
||||||
#include <utils/io.hpp>
|
#include <utils/io.hpp>
|
||||||
@ -253,6 +255,22 @@ namespace game
|
|||||||
va_buffer
|
va_buffer
|
||||||
), true);
|
), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Key_Bindlist_f()
|
||||||
|
{
|
||||||
|
for (int keynum = 0; keynum < 256; ++keynum)
|
||||||
|
{
|
||||||
|
auto value = game::Key_GetActiveBinding(0, keynum);
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
auto* binding = game::Key_GetCmdForBinding(0, value);
|
||||||
|
if (*binding)
|
||||||
|
{
|
||||||
|
console::info("%s \"%s\"\n", game::Key_KeynumToString(keynum, 0, 0), binding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t reverse_b(const size_t ptr)
|
size_t reverse_b(const size_t ptr)
|
||||||
|
@ -69,6 +69,8 @@ namespace game
|
|||||||
bool SV_ClientIsBot(unsigned int client_num);
|
bool SV_ClientIsBot(unsigned int client_num);
|
||||||
|
|
||||||
void G_LogPrintf(const char* fmt, ...);
|
void G_LogPrintf(const char* fmt, ...);
|
||||||
|
|
||||||
|
void Key_Bindlist_f();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t reverse_b(const size_t ptr);
|
size_t reverse_b(const size_t ptr);
|
||||||
|
@ -347,7 +347,7 @@ namespace game
|
|||||||
int overstrikeMode;
|
int overstrikeMode;
|
||||||
int anyKeyDown;
|
int anyKeyDown;
|
||||||
KeyState keys[256];
|
KeyState keys[256];
|
||||||
field_t test;
|
field_t chatField;
|
||||||
char __pad0[8];
|
char __pad0[8];
|
||||||
}; static_assert(sizeof(PlayerKeyState) == 0x1128);
|
}; static_assert(sizeof(PlayerKeyState) == 0x1128);
|
||||||
|
|
||||||
@ -897,7 +897,27 @@ namespace game
|
|||||||
entityState_t s; // 0
|
entityState_t s; // 0
|
||||||
char __pad0[368 - sizeof(entityState_t)];
|
char __pad0[368 - sizeof(entityState_t)];
|
||||||
gclient_s* client; // 368
|
gclient_s* client; // 368
|
||||||
char __pad1[80];
|
void* turret;
|
||||||
|
void* agent;
|
||||||
|
void* sentient;
|
||||||
|
void* vehicle;
|
||||||
|
__int64 physObjId;
|
||||||
|
unsigned __int16 model;
|
||||||
|
unsigned __int8 physicsObject;
|
||||||
|
unsigned __int8 takedamage;
|
||||||
|
unsigned __int8 active;
|
||||||
|
unsigned __int8 handler;
|
||||||
|
unsigned __int8 team;
|
||||||
|
bool freeAfterEvent;
|
||||||
|
unsigned __int16 disconnectedLinks;
|
||||||
|
__int16 padding_short2;
|
||||||
|
scr_string_t classname;
|
||||||
|
scr_string_t script_classname;
|
||||||
|
scr_string_t script_linkName;
|
||||||
|
scr_string_t target;
|
||||||
|
scr_string_t targetname;
|
||||||
|
unsigned int attachIgnoreCollision;
|
||||||
|
int spawnflags;
|
||||||
int flags; // 456
|
int flags; // 456
|
||||||
char __pad3[556];
|
char __pad3[556];
|
||||||
}; static_assert(sizeof(gentity_s) == 1016);
|
}; static_assert(sizeof(gentity_s) == 1016);
|
||||||
|
@ -89,6 +89,7 @@ namespace game
|
|||||||
WEAK symbol<char* (const char* filename, char* buf, int size)> DB_ReadRawFile{ 0x140A79E30 };
|
WEAK symbol<char* (const char* filename, char* buf, int size)> DB_ReadRawFile{ 0x140A79E30 };
|
||||||
WEAK symbol<int(const RawFile* rawfile)> DB_GetRawFileLen{ 0x140F20AF0 };
|
WEAK symbol<int(const RawFile* rawfile)> DB_GetRawFileLen{ 0x140F20AF0 };
|
||||||
WEAK symbol<void(int flags)> DB_UnloadFastfilesByZoneFlags{ 0x140A7BCE0 };
|
WEAK symbol<void(int flags)> DB_UnloadFastfilesByZoneFlags{ 0x140A7BCE0 };
|
||||||
|
WEAK symbol<int()> DB_Zones_GetInUseFlags{ 0x1403BC160 };
|
||||||
|
|
||||||
WEAK symbol<const char* (const DDLState* state, int enumValue)> DDL_Lookup_GetEnumString{ 0x140030430 };
|
WEAK symbol<const char* (const DDLState* state, int enumValue)> DDL_Lookup_GetEnumString{ 0x140030430 };
|
||||||
WEAK symbol<bool(const DDLState* state)> DDL_StateIsLeaf{ 0x14002E3C0 };
|
WEAK symbol<bool(const DDLState* state)> DDL_StateIsLeaf{ 0x14002E3C0 };
|
||||||
@ -151,7 +152,10 @@ namespace game
|
|||||||
|
|
||||||
WEAK symbol<char* (char* string)> I_CleanStr{ 0x140CFACC0 };
|
WEAK symbol<char* (char* string)> I_CleanStr{ 0x140CFACC0 };
|
||||||
|
|
||||||
WEAK symbol<const char* (int, int, int)> Key_KeynumToString{ 0x1409A95E0 };
|
WEAK symbol<const char* (int keynum, int translate, int gamePadOnly)> Key_KeynumToString{ 0x1409A95E0 };
|
||||||
|
WEAK symbol<int (int localClientNum, int keynum)> Key_GetActiveBinding{ 0x1409A8E80 };
|
||||||
|
WEAK symbol<const char* (int localClientNum, int keyBinding)> Key_GetCmdForBinding{ 0x1409A91D0 };
|
||||||
|
WEAK symbol<const char* (const char* cmd)> Key_GetBindingForCmd{ 0x1409A8EA0 };
|
||||||
|
|
||||||
WEAK symbol<bool()> LUI_CoD_InFrontEnd{ 0x140615080 };
|
WEAK symbol<bool()> LUI_CoD_InFrontEnd{ 0x140615080 };
|
||||||
WEAK symbol<void(bool frontend, bool errorRecovery)> LUI_CoD_Init{ 0x140615090 };
|
WEAK symbol<void(bool frontend, bool errorRecovery)> LUI_CoD_Init{ 0x140615090 };
|
||||||
|
Loading…
Reference in New Issue
Block a user