NET_ListenSocket
0x001c4b50 · 513 bytes · __cdecl
_Z16NET_ListenSocketib
Decompiled
undefined (2 params)
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* NET_ListenSocket(int, bool) */
void NET_ListenSocket(int param_1,bool param_2)
{
int iVar1;
ushort *puVar2;
char *pcVar3;
int in_GS_OFFSET;
int local_34;
sockaddr local_30;
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
puVar2 = (ushort *)(net_sockets + param_1 * 0x10);
if (*(int *)(puVar2 + 6) != 0) {
NET_CloseSocket(*(int *)(puVar2 + 6),param_1);
}
if (((net_multiplayer == '\0') || (net_notcp != '\0')) || (!param_2)) goto LAB_001c4b96;
pcVar3 = "FCVAR_NEVER_AS_STRING";
if ((ipname[0x15] & 0x10) == 0) {
pcVar3 = "";
if (*(char **)(ipname._28_4_ + 0x24) != (char *)0x0) {
pcVar3 = *(char **)(ipname._28_4_ + 0x24);
}
}
iVar1 = NET_OpenSocket(pcVar3,(int *)puVar2,1);
*(int *)(puVar2 + 6) = iVar1;
if (iVar1 == 0) {
Msg("Warning! NET_ListenSocket failed opening socket %i, port %i.\n",param_1,
*(undefined4 *)(net_sockets + param_1 * 0x10));
goto LAB_001c4b96;
}
if (*pcVar3 == '\0') {
LAB_001c4bfe:
local_30.sa_data[2] = '\0';
local_30.sa_data[3] = '\0';
local_30.sa_data[4] = '\0';
local_30.sa_data[5] = '\0';
}
else {
iVar1 = _V_strcmp(pcVar3,"localhost");
if (iVar1 == 0) goto LAB_001c4bfe;
NET_StringToSockaddr(pcVar3,&local_30);
}
local_30.sa_family = 2;
local_30.sa_data._0_2_ = *puVar2 >> 8 | *puVar2 << 8;
iVar1 = (**(code **)(_g_pVCR + 0xc))();
if (iVar1 != 2) {
local_34 = bind(*(int *)(puVar2 + 6),&local_30,0x10);
}
(**(code **)(_g_pVCR + 0x74))("bind",&local_34,4);
if (local_34 == -1) {
NET_GetLastError();
Msg("WARNING: NET_ListenSocket bind failed on socket %i, port %i.\n",*(undefined4 *)(puVar2 + 6)
,*(undefined4 *)puVar2);
}
else {
iVar1 = (**(code **)(_g_pVCR + 0xc))();
if (iVar1 != 2) {
local_34 = listen(*(int *)(puVar2 + 6),8);
}
(**(code **)(_g_pVCR + 0x74))("listen",&local_34,4);
if (local_34 == -1) {
NET_GetLastError();
Msg("WARNING: NET_ListenSocket listen failed on socket %i, port %i.\n",
*(undefined4 *)(puVar2 + 6),*(undefined4 *)puVar2);
}
else {
*(undefined1 *)(puVar2 + 2) = 1;
}
}
LAB_001c4b96:
if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
return;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
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.