Filter_Add_f
0x001efe10 · 1618 bytes · __cdecl
_ZL12Filter_Add_fRK8CCommand
Decompiled
undefined (1 param)
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* Filter_Add_f(CCommand const&) */
void Filter_Add_f(CCommand *param_1)
{
code *pcVar1;
bool bVar2;
char cVar3;
char *pcVar4;
int iVar5;
ipfilter_t *piVar6;
int *piVar7;
netadr_s *pnVar8;
undefined1 *puVar9;
undefined4 uVar10;
int iVar11;
int *piVar12;
int iVar13;
int in_GS_OFFSET;
float fVar14;
float fVar15;
double dVar16;
int local_144;
int local_130;
int local_12c;
char local_120 [256];
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
pcVar4 = "";
if (0 < *(int *)param_1) {
pcVar4 = *(char **)(param_1 + 0x408);
}
iVar5 = _V_stricmp(pcVar4,"banip");
if (iVar5 == 0) {
ConMsg("Note: should use \"addip\" instead of \"banip\".\n");
iVar5 = *(int *)param_1;
}
else {
iVar5 = *(int *)param_1;
}
if (iVar5 != 3) {
ConMsg("Usage: addip < minutes > < ipaddress >\nUse 0 minutes for permanent\n");
goto LAB_001efe6e;
}
cVar3 = Filter_ConvertString(*(char **)(param_1 + 0x410),(ipfilter_t *)&local_130);
iVar5 = DAT_003b2460;
if (cVar3 == '\0') goto LAB_001efe6e;
if (DAT_003b2460 < 1) {
if (DAT_003b2460 != 0) goto LAB_001f0430;
LAB_001f0354:
iVar13 = DAT_003b2460 + 1;
if ((DAT_003b2458 < iVar13) && (-1 < DAT_003b245c)) {
if (DAT_003b245c == 0) {
if (DAT_003b2458 == 0) {
if (iVar13 < 3) {
DAT_003b2458 = 2;
goto LAB_001f03ef;
}
DAT_003b2458 = 2;
}
do {
DAT_003b2458 = DAT_003b2458 * 2;
} while (DAT_003b2458 < iVar13);
}
else {
for (DAT_003b2458 = (DAT_003b2460 / DAT_003b245c + 1) * DAT_003b245c; DAT_003b2458 < iVar13;
DAT_003b2458 = (DAT_003b2458 + iVar13) / 2) {
}
}
LAB_001f03ef:
if (g_IPFilters == (int *)0x0) {
g_IPFilters = malloc(DAT_003b2458 << 4);
}
else {
g_IPFilters = realloc(g_IPFilters,DAT_003b2458 << 4);
iVar13 = DAT_003b2460 + 1;
}
}
local_144 = iVar5 * 0x10;
iVar11 = (iVar13 - iVar5) + -1;
DAT_003b2460 = iVar13;
_DAT_003b2464 = g_IPFilters;
if (0 < iVar11) {
_V_memmove(g_IPFilters + iVar5 * 4 + 4,g_IPFilters + iVar5 * 4,iVar11 * 0x10);
}
bVar2 = true;
}
else {
iVar13 = g_IPFilters[1];
if (iVar13 == -1) {
LAB_001f0430:
local_144 = 0;
}
else {
iVar11 = 0;
piVar12 = g_IPFilters;
do {
if ((iVar13 == local_12c) && (*piVar12 == local_130)) {
local_144 = iVar11 << 4;
break;
}
iVar11 = iVar11 + 1;
if (iVar11 == DAT_003b2460) {
if (iVar11 != 0x8000) goto LAB_001f0354;
ConMsg("addip: IP filter list is full\n");
goto LAB_001efe6e;
}
local_144 = iVar11 * 0x10;
iVar13 = piVar12[5];
piVar12 = piVar12 + 4;
} while (iVar13 != -1);
}
bVar2 = false;
}
pcVar4 = "";
if (1 < *(int *)param_1) {
pcVar4 = *(char **)(param_1 + 0x40c);
}
dVar16 = strtod(pcVar4,(char **)0x0);
piVar6 = (ipfilter_t *)(local_144 + (int)g_IPFilters);
fVar15 = (float)dVar16;
if (fVar15 < 0.01) {
fVar14 = 0.0;
*(undefined4 *)(piVar6 + 0xc) = 0;
fVar15 = 0.0;
}
else {
*(float *)(piVar6 + 0xc) = fVar15;
if (fVar15 == 0.0) {
fVar14 = 0.0;
}
else {
fVar14 = fVar15 * 60.0 + realtime;
}
}
*(float *)(piVar6 + 8) = fVar14;
pcVar4 = "";
if (2 < *(int *)param_1) {
pcVar4 = *(char **)(param_1 + 0x410);
}
cVar3 = Filter_ConvertString(pcVar4,piVar6);
if (cVar3 == '\0') {
*(undefined4 *)((int)g_IPFilters + local_144 + 4) = 0xffffffff;
}
if ((bVar2) && (0 < DAT_003b8080)) {
iVar5 = 0;
do {
piVar12 = *(int **)(DAT_003b8074 + iVar5 * 4);
if ((((piVar12 != (int *)0x0) &&
(cVar3 = (**(code **)(*piVar12 + 0x74))(piVar12), cVar3 != '\0')) &&
(cVar3 = (**(code **)(*piVar12 + 0x6c))(piVar12), cVar3 != '\0')) &&
((cVar3 = (**(code **)(*piVar12 + 0x70))(piVar12), cVar3 != '\0' &&
(cVar3 = (**(code **)(*piVar12 + 0x78))(piVar12), cVar3 == '\0')))) {
piVar7 = (int *)(**(code **)(*piVar12 + 0x20))(piVar12);
pnVar8 = (netadr_s *)(**(code **)(*piVar7 + 200))(piVar7);
cVar3 = Filter_ShouldDiscard(pnVar8);
if (cVar3 != '\0') {
bVar2 = true;
goto LAB_001f00e9;
}
}
iVar5 = iVar5 + 1;
} while (iVar5 < DAT_003b8080);
bVar2 = false;
}
else {
piVar12 = (int *)0x0;
bVar2 = false;
}
LAB_001f00e9:
if (fVar15 == 0.0) {
V_snprintf(local_120,0x100,"permanently");
}
else {
V_snprintf(local_120,0x100,"for %.2f minutes",(double)fVar15);
}
piVar7 = (int *)(**(code **)(s_GameEventManager + 0x1c))(&s_GameEventManager,"server_addban",0,0);
if (piVar7 != (int *)0x0) {
if ((piVar12 == (int *)0x0) || (!bVar2)) {
(**(code **)(*piVar7 + 0x3c))(piVar7,"name",&DAT_002c79d4);
(**(code **)(*piVar7 + 0x30))(piVar7,"userid",0);
(**(code **)(*piVar7 + 0x3c))(piVar7,"networkid",&DAT_002c79d4);
}
else {
(**(code **)(*piVar7 + 0x3c))(piVar7,"name",piVar12 + 0xf);
pcVar1 = *(code **)(*piVar7 + 0x30);
uVar10 = (**(code **)(*piVar12 + 0x14))(piVar12);
(*pcVar1)(piVar7,"userid",uVar10);
pcVar1 = *(code **)(*piVar7 + 0x3c);
uVar10 = (**(code **)(*piVar12 + 0x2c))(piVar12);
(*pcVar1)(piVar7,"networkid",uVar10);
}
puVar9 = &DAT_002c79d4;
if (2 < *(int *)param_1) {
puVar9 = *(undefined1 **)(param_1 + 0x410);
}
(**(code **)(*piVar7 + 0x3c))(piVar7,"ip",puVar9);
(**(code **)(*piVar7 + 0x3c))(piVar7,"duration",local_120);
pcVar4 = "Console";
if (cmd_source != 1) {
pcVar4 = (char *)(host_client + 0x3c);
}
(**(code **)(*piVar7 + 0x3c))(piVar7,"by",pcVar4);
(**(code **)(*piVar7 + 0x2c))(piVar7,"kicked",bVar2 && piVar12 != (int *)0x0);
(**(code **)(s_GameEventManager + 0x20))(&s_GameEventManager,piVar7,0);
}
if ((bVar2) && (piVar12 != (int *)0x0)) {
(**(code **)(*piVar12 + 0x68))
(piVar12,"The server operator has added you to the banned list.\n");
(**(code **)(*piVar12 + 0x3c))(piVar12,"Added to banned list");
}
LAB_001efe6e:
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.