Key_ForceBind_f
0x001844b0 · 670 bytes · __cdecl
_Z15Key_ForceBind_fRK8CCommand
Decompiled
undefined (1 param)
/* Key_ForceBind_f(CCommand const&) */
void Key_ForceBind_f(CCommand *param_1)
{
int iVar1;
KeyValues *pKVar2;
int iVar3;
int iVar4;
uint uVar5;
undefined4 uVar6;
char *pcVar7;
uint uVar8;
int iVar9;
int in_GS_OFFSET;
Color local_28;
undefined1 local_27;
undefined1 local_26;
undefined1 local_25;
Color local_24;
undefined1 local_23;
undefined1 local_22;
undefined1 local_21;
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
iVar1 = *(int *)param_1;
if (1 < iVar1) {
pKVar2 = (KeyValues *)GetDefaultKeyBindings();
local_28 = (Color)0x0;
local_27 = 0xff;
local_26 = 0x40;
local_25 = 0xff;
local_24 = (Color)0xff;
local_23 = 0;
local_22 = 0x40;
local_21 = 0xff;
iVar9 = 1;
do {
while( true ) {
pcVar7 = "";
if (iVar9 < *(int *)param_1) {
pcVar7 = *(char **)(param_1 + iVar9 * 4 + 0x408);
}
iVar3 = Key_NameForBinding(pcVar7,0xffffffff,0,0xffffffff);
iVar4 = GetSuggestedBinding(pcVar7,pKVar2);
if (iVar3 != 0) break;
if (iVar4 != 0) {
uVar5 = (**(code **)(*g_pInputSystem + 0x74))(g_pInputSystem,iVar4);
if (uVar5 < 0x2a3) {
if (((char *)(&s_KeyContext)[uVar5 * 2] != (char *)0x0) &&
(*(char *)(&s_KeyContext)[uVar5 * 2] != '\0')) {
uVar8 = uVar5 + 1;
if (0x6a < (int)uVar8) {
uVar8 = 1;
}
goto joined_r0x001845a1;
}
LAB_00184710:
ConColorMsg(&local_28,"Bound \"%s\" to key %s\n",pcVar7,iVar4);
Key_SetBinding(uVar5,pcVar7);
}
else {
uVar8 = 0;
if (uVar5 != 0xffffffff) goto LAB_00184710;
joined_r0x001845a1:
while (uVar5 != uVar8) {
uVar6 = (**(code **)(*g_pInputSystem + 0x6c))(g_pInputSystem,uVar8);
if (((0x2a2 < uVar8) || ((char *)(&s_KeyContext)[uVar8 * 2] == (char *)0x0)) ||
(*(char *)(&s_KeyContext)[uVar8 * 2] == '\0')) {
ConColorMsg(&local_28,"Bound \"%s\" to key %s\n",pcVar7,uVar6);
Key_SetBinding(uVar8,pcVar7);
break;
}
uVar8 = uVar8 + 1;
if (0x6a < (int)uVar8) {
uVar8 = 1;
}
}
}
iVar3 = Key_NameForBinding(pcVar7,0xffffffff,0,0xffffffff);
if (iVar3 == 0) {
ConColorMsg(&local_24,"Unable to bind \"%s\" to a key\n",pcVar7);
}
}
LAB_00184648:
iVar9 = iVar9 + 1;
if (iVar9 == iVar1) goto LAB_00184654;
}
if (((iVar4 != 0) ||
(iVar3 = (**(code **)(*g_pInputSystem + 0x74))(g_pInputSystem,iVar3), iVar3 == 0x46)) ||
(iVar3 == -1)) goto LAB_00184648;
iVar9 = iVar9 + 1;
ConColorMsg(&local_28,"Unbound obsolete command \"%s\"\n",pcVar7);
Key_SetBinding(iVar3,&DAT_002c79d4);
} while (iVar9 != iVar1);
LAB_00184654:
KeyValues::deleteThis();
}
if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
return;
}
SourceMod gamedata
paste intoaddons/sourcemod/gamedata/<your_plugin>.txt
used as the SourceMod key — change to fit your plugin's convention
SourceMod library name (server / engine / matchmaking)
Just a Signatures{} block, ready to drop into a gamedata
file. Wire it up in your plugin however you like - SDKCall, DHooks,
raw memory ops, or anything else.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.