L L4D2node

NET_ConnectSocket

0x001c2fa0 · 365 bytes · __cdecl

_Z17NET_ConnectSocketiRK8netadr_s

Decompiled

undefined (2 params)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* NET_ConnectSocket(int, netadr_s const&) */

undefined4 NET_ConnectSocket(int param_1,netadr_s *param_2)

{
  undefined4 uVar1;
  char *pcVar2;
  int iVar3;
  int iVar4;
  int iVar5;
  int in_GS_OFFSET;
  int local_38;
  int local_34;
  sockaddr local_30;
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  iVar5 = param_1 * 0x10;
  iVar4 = net_sockets + iVar5;
  if (*(int *)(iVar4 + 0xc) != 0) {
    NET_CloseSocket(*(int *)(iVar4 + 0xc),param_1);
  }
  uVar1 = 0;
  if (net_notcp == '\0') {
    netadr_s::ToSockadr(param_2,&local_30);
    local_38 = -1;
    pcVar2 = "FCVAR_NEVER_AS_STRING";
    if ((ipname[0x15] & 0x10) == 0) {
      pcVar2 = "";
      if (*(char **)(ipname._28_4_ + 0x24) != (char *)0x0) {
        pcVar2 = *(char **)(ipname._28_4_ + 0x24);
      }
    }
    iVar3 = NET_OpenSocket(pcVar2,&local_38,1);
    *(int *)(iVar4 + 0xc) = iVar3;
    if (iVar3 == 0) {
      Msg("Warning! NET_ConnectSocket failed opening socket %i, port %i.\n",param_1,
          *(undefined4 *)(net_sockets + iVar5));
      uVar1 = 0;
    }
    else {
      iVar3 = (**(code **)(_g_pVCR + 0xc))();
      if (iVar3 != 2) {
        local_34 = connect(*(int *)(iVar4 + 0xc),&local_30,0x10);
      }
      (**(code **)(_g_pVCR + 0x74))("connect",&local_34,4);
      if ((local_34 == -1) && (NET_GetLastError(), net_error != 0xb)) {
        uVar1 = NET_ErrorString(net_error);
        Msg("NET_ConnectSocket: %s\n",uVar1);
        uVar1 = 0;
      }
      else {
        uVar1 = *(undefined4 *)(net_sockets + 0xc + iVar5);
      }
    }
  }
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail();
  }
  return uVar1;
}

SourceMod gamedata

paste into addons/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.



        

        

          

Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.

Return-type handling cheatsheet (DHookReturn)