L L4D2node

CServerManager::OnEvent

0x0005a8b0 · 2082 bytes · __thiscall

_ZN14CServerManager7OnEventEP9KeyValues

Decompiled

undefined (2 params)

/* CServerManager::OnEvent(KeyValues*) */

void __thiscall CServerManager::OnEvent(CServerManager *this,KeyValues *param_1)

{
  char cVar1;
  undefined2 uVar2;
  undefined2 uVar3;
  char *pcVar4;
  int iVar5;
  KeyValues *pKVar6;
  undefined4 uVar7;
  uint uVar8;
  KeyValues *pKVar9;
  char *this_00;
  int *piVar10;
  int iVar11;
  CServer *pCVar12;
  undefined4 uVar13;
  CUtlVector<CServer*,CUtlMemory<CServer*,int>> *this_01;
  netadr_s *pnVar14;
  int in_GS_OFFSET;
  longdouble lVar15;
  longdouble lVar16;
  longlong lVar17;
  undefined *puVar18;
  CServer *local_6c;
  char *local_68;
  char *local_64;
  char *local_60;
  netadr_s local_5c [12];
  netadr_s local_50 [12];
  netadr_s local_44 [14];
  char local_36;
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  pcVar4 = (char *)KeyValues::GetName(param_1);
  iVar5 = _V_stricmp(pcVar4,"OnNetLanConnectionlessPacket");
  if (iVar5 == 0) {
    local_68 = "LanSearchServerPing";
    pnVar14 = (netadr_s *)&local_64;
    pcVar4 = "LanSearchServerPing";
    local_64 = "ConnectServerDetailsRequest";
    local_60 = "InetSearchServerDetails";
    while( true ) {
      iVar5 = KeyValues::FindKey(param_1,pcVar4,false);
      if (iVar5 != 0) break;
      if (pnVar14 == local_5c) {
        this_00 = (char *)param_1;
        pKVar6 = (KeyValues *)KeyValues::FindKey(param_1,"GameDetailsServer",false);
        if (pKVar6 == (KeyValues *)0x0) goto LAB_0005acb0;
        lVar15 = (longdouble)KeyValues::GetFloat(pKVar6,"LanSearchServerPing/timestamp",0.0);
        if ((float)lVar15 != 0.0) {
          lVar16 = (longdouble)Plat_FloatTime();
          iVar5 = (int)(((float)lVar16 - (float)lVar15) * 1000.0);
          if (iVar5 < 0) {
            iVar11 = 0;
          }
          else {
            iVar11 = 999;
            if (iVar5 < 1000) {
              iVar11 = iVar5;
            }
          }
          goto LAB_0005a9ef;
        }
        uVar7 = 0;
        lVar17 = KeyValues::GetUint64((char *)pKVar6,0xb41e0);
        if (lVar17 == 0) {
          puVar18 = &DAT_000b2b65;
          iVar5 = KeyValues::GetString(pKVar6,"ConnectServerDetailsRequest/server","");
          this_00 = (char *)pKVar6;
          if (iVar5 != 0) {
            this_00 = *(char **)(g_pMatchExtensions + 0x54);
            (**(code **)(*(int *)this_00 + 0x2c))(this_00,(short)param_1,puVar18,uVar7);
          }
          goto LAB_0005acb0;
        }
        this_00 = (char *)this;
        piVar10 = (int *)GetServerRecordByOnlineId
                                   ((CUtlVector *)this,
                                    CONCAT44((int)lVar17,
                                             (CUtlVector<CServer*,CUtlMemory<CServer*,int>> *)
                                             (this + 0x28)));
        if (piVar10 == (int *)0x0) goto LAB_0005acb0;
        lVar15 = (longdouble)KeyValues::GetFloat(pKVar6,"InetSearchServerDetails/timestamp",0.0);
        if ((float)lVar15 == 0.0) {
LAB_0005ae15:
          iVar11 = 0;
        }
        else {
          lVar16 = (longdouble)Plat_FloatTime();
          iVar5 = (int)(((float)lVar16 - (float)lVar15) * 1000.0);
          if (iVar5 < 0) goto LAB_0005ae15;
          iVar11 = 999;
          if (iVar5 < 1000) {
            iVar11 = iVar5;
          }
        }
        if (*(int *)(this + 0x34) < 1) goto LAB_0005ae50;
        iVar5 = 0;
        if (piVar10 == (int *)**(int **)(this + 0x28)) goto LAB_0005af74;
        iVar5 = 0;
        goto LAB_0005ae49;
      }
      pcVar4 = *(char **)pnVar14;
      pnVar14 = pnVar14 + 4;
    }
    this_00 = (char *)(**(code **)(*g_pMatchFramework + 0x28))(g_pMatchFramework);
    pKVar6 = (KeyValues *)(**(code **)(*(int *)this_00 + 4))(this_00,(short)param_1);
    if (pKVar6 != (KeyValues *)0x0) {
                    /* try { // try from 0005aeeb to 0005af53 has its CatchHandler @ 0005b116 */
      iVar11 = KeyValues::FindKey(pKVar6,"Server",false);
      if (iVar11 != 0) {
        pKVar9 = (KeyValues *)KeyValues::FindKey(pKVar6,pcVar4,true);
        KeyValues::MergeFrom(pKVar9,(short)iVar5,1);
        uVar7 = KeyValues::GetString(param_1,"from","");
        CConnectionlessLanMgr::SendPacket
                  ((CConnectionlessLanMgr *)g_pConnectionlessLanMgr,(short)pKVar6,uVar7,1);
      }
      KeyValues::deleteThis();
      this_00 = (char *)pKVar6;
    }
  }
  else {
    uVar2 = SUB42(pcVar4,0);
    uVar3 = (undefined2)((uint)pcVar4 >> 0x10);
    this_00 = "Client::ResendGameDetailsRequest";
    iVar5 = _V_stricmp("Client::ResendGameDetailsRequest",pcVar4);
    if (iVar5 == 0) {
      pKVar6 = KeyValues::operator_new((KeyValues *)0x2c,CONCAT22(uVar3,uVar2));
                    /* try { // try from 0005ad0d to 0005ad11 has its CatchHandler @ 0005b104 */
      KeyValues::KeyValues(pKVar6,"ConnectServerDetailsRequest",(IKeyValuesSystem *)0x0,false);
                    /* try { // try from 0005ad28 to 0005ad75 has its CatchHandler @ 0005b128 */
      pcVar4 = (char *)KeyValues::GetString(param_1,"to","");
      KeyValues::SetString(pKVar6,"server",pcVar4);
      uVar7 = KeyValues::GetString(param_1,"to","");
      this_00 = g_pConnectionlessLanMgr;
      CConnectionlessLanMgr::SendPacket
                ((CConnectionlessLanMgr *)g_pConnectionlessLanMgr,(short)pKVar6,uVar7,0);
      if (pKVar6 != (KeyValues *)0x0) {
        KeyValues::deleteThis();
        this_00 = (char *)pKVar6;
      }
    }
  }
  goto LAB_0005acb0;
  while (piVar10 != (int *)(*(int **)(this + 0x28))[iVar5]) {
LAB_0005ae49:
    iVar5 = iVar5 + 1;
    if (iVar5 == *(int *)(this + 0x34)) goto LAB_0005ae50;
  }
  if (iVar5 != -1) {
LAB_0005af74:
    CUtlVector<CServer*,CUtlMemory<CServer*,int>>::ShiftElementsLeft
              ((CUtlVector<CServer*,CUtlMemory<CServer*,int>> *)(this + 0x28),iVar5,1);
    *(int *)(this + 0x34) = *(int *)(this + 0x34) + -1;
  }
LAB_0005ae50:
  (**(code **)(*piVar10 + 0x14))(piVar10);
LAB_0005a9ef:
  this_00 = (char *)pKVar6;
  pcVar4 = (char *)KeyValues::GetString(pKVar6,"Server/adronline",(char *)0x0);
  if ((pcVar4 != (char *)0x0) && (*pcVar4 != '\0')) {
    this_00 = (char *)local_50;
    pnVar14 = local_44;
    netadr_s::SetIP(local_5c,0);
    netadr_s::SetPort(local_5c,0);
    netadr_s::SetType(local_5c,3);
    netadr_s::SetType(local_5c,3);
    netadr_s::SetPort(local_5c,0x6987);
    netadr_s::SetFromString(local_5c,pcVar4,false);
    netadr_s::SetIP((netadr_s *)this_00,0);
    netadr_s::SetPort((netadr_s *)this_00,0);
    netadr_s::SetType((netadr_s *)this_00,3);
    netadr_s::SetIP(pnVar14,0);
    netadr_s::SetPort(pnVar14,0);
    netadr_s::SetType(pnVar14,3);
    (**(code **)(**(int **)(g_pMatchExtensions + 0x54) + 0x18))
              (*(int **)(g_pMatchExtensions + 0x54),(short)this_00);
    if ((local_36 == '\0') ||
       ((cVar1 = netadr_s::CompareAdr((netadr_s *)this_00,local_5c,false), cVar1 == '\0' &&
        (cVar1 = netadr_s::CompareAdr(pnVar14,local_5c,false), this_00 = (char *)pnVar14,
        cVar1 == '\0')))) {
      uVar7 = netadr_s::GetIP(local_5c);
      uVar8 = netadr_s::GetPort(local_5c);
      uVar8 = uVar8 & 0xffff;
      pKVar6 = (KeyValues *)KeyValues::MakeCopy(pKVar6);
      KeyValues::SetName(pKVar6,"Settings");
      pKVar9 = (KeyValues *)KeyValues::FindKey(pKVar6,"LanSearch",false);
      if (pKVar9 != (KeyValues *)0x0) {
        KeyValues::RemoveSubKey(pKVar6,pKVar9);
        KeyValues::deleteThis();
      }
      KeyValues::SetInt(pKVar6,"Server/ping",iVar11);
      pcVar4 = (char *)KeyValues::GetString(param_1,"from",(char *)0x0);
      if (pcVar4 != (char *)0x0) {
        KeyValues::SetString(pKVar6,"Server/connectstring",pcVar4);
      }
      uVar2 = (undefined2)uVar7;
      uVar3 = (undefined2)((uint)uVar7 >> 0x10);
      this_01 = (CUtlVector<CServer*,CUtlMemory<CServer*,int>> *)this;
      local_6c = (CServer *)(**(code **)(*(int *)this + 0xc))(this,uVar2,uVar8);
      if (local_6c == (CServer *)0x0) {
        pCVar12 = operator_new(0x1c);
                    /* try { // try from 0005b08f to 0005b093 has its CatchHandler @ 0005b150 */
        CServer::CServer(pCVar12);
        *(uint *)(pCVar12 + 0xc) = uVar8;
        *(undefined4 *)(pCVar12 + 8) = uVar7;
        local_6c = pCVar12;
        uVar2 = netadr_s::GetPort(local_5c);
        uVar3 = netadr_s::GetPort(local_5c);
        uVar13 = netadr_s::addr_htonl(local_5c);
        *(undefined2 *)(local_6c + 0x14) = uVar2;
        *(undefined4 *)(local_6c + 0x18) = uVar13;
        *(undefined2 *)(local_6c + 0x16) = uVar3;
        iVar5 = *(int *)(this + 0x20);
        uVar2 = (undefined2)iVar5;
        uVar3 = (undefined2)((uint)iVar5 >> 0x10);
        this_01 = (CUtlVector<CServer*,CUtlMemory<CServer*,int>> *)(this + 0x14);
        CUtlVector<CServer*,CUtlMemory<CServer*,int>>::InsertBefore(this_01,iVar5,&local_6c);
      }
      if (*(KeyValues **)(local_6c + 0x10) != (KeyValues *)0x0) {
        uVar2 = 0x40d5;
        uVar3 = 0xb;
        iVar5 = KeyValues::GetInt(*(KeyValues **)(local_6c + 0x10),"Server/ping",0);
        if (iVar5 < iVar11) {
          uVar2 = 0x40d5;
          uVar3 = 0xb;
          KeyValues::SetInt(pKVar6,"Server/ping",(iVar5 * 9 + iVar11) / 10);
        }
        this_01 = *(CUtlVector<CServer*,CUtlMemory<CServer*,int>> **)(local_6c + 0x10);
        KeyValues::deleteThis();
      }
      pCVar12 = local_6c;
      *(KeyValues **)(local_6c + 0x10) = pKVar6;
      lVar15 = (longdouble)Plat_FloatTime(this_01);
      *(float *)(pCVar12 + 4) = (float)lVar15;
      pKVar6 = KeyValues::operator_new((KeyValues *)0x2c,CONCAT22(uVar3,uVar2));
                    /* try { // try from 0005ac76 to 0005ac7a has its CatchHandler @ 0005b13e */
      KeyValues::KeyValues(pKVar6,"OnMatchServerMgrUpdate","update","server");
      uVar2 = 0x4d28;
      KeyValues::SetUint64((char *)pKVar6,CONCAT44(uVar7,"xuid"));
      this_00 = (char *)(**(code **)(*g_pMatchFramework + 0x1c))
                                  (g_pMatchFramework,uVar2,uVar7,uVar8);
      (**(code **)(*(int *)this_00 + 8))(this_00,(short)pKVar6);
    }
  }
LAB_0005acb0:
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail(this_00);
  }
  return;
}

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)