L L4D2node

CGameEventManager::AddListener

0x00164840 · 885 bytes · __thiscall

_ZN17CGameEventManager11AddListenerEPvP20CGameEventDescriptori

Decompiled

undefined (4 params)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* CGameEventManager::AddListener(void*, CGameEventDescriptor*, int) */

bool __thiscall
CGameEventManager::AddListener
          (CGameEventManager *this,void *param_1,CGameEventDescriptor *param_2,int param_3)

{
  int *piVar1;
  CGameEventManager *pCVar2;
  uint uVar3;
  char *pcVar4;
  bool bVar5;
  uint uVar6;
  int iVar7;
  int iVar8;
  int *piVar9;
  char *pcVar10;
  char *pcVar11;
  CGameEventCallback *local_28;
  CGameEventManager *local_24;
  char *local_20;
  
  local_20 = "CGameEventManager";
  pCVar2 = this + 0x9c;
  local_24 = pCVar2;
  if (_SetSeed != 0) {
    if (CTelemetryLock::CTelemetryLock(void*,char_const*)::s_bNameSet == '\0') {
      (**(code **)(_SetSeed + 0x5c))
                (_SetSeed,pCVar2,&CTelemetryLock::CTelemetryLock(void*,char_const*)::tm_fmt,
                 "CGameEventManager");
      CTelemetryLock::CTelemetryLock(void*,char_const*)::s_bNameSet = '\x01';
      if (_SetSeed == 0) goto LAB_001648fe;
    }
    (**(code **)(_SetSeed + 0x60))
              (_SetSeed,0,0,0,"/data/src/public/tier0/vprof_telemetry.h",0x3eb,local_24,
               &CTelemetryLock::CTelemetryLock(void*,char_const*)::tm_fmt,&DAT_002c48a3,local_20);
  }
LAB_001648fe:
                    /* try { // try from 001648fe to 00164902 has its CatchHandler @ 00164bda */
  uVar6 = ThreadGetCurrentId();
  if (uVar6 == *(uint *)(this + 0x9c)) {
LAB_0016491e:
    *(int *)(this + 0xa0) = *(int *)(this + 0xa0) + 1;
  }
  else {
    LOCK();
    uVar3 = *(uint *)pCVar2;
    if (uVar3 == 0) {
      *(uint *)pCVar2 = uVar6;
    }
    UNLOCK();
    if (uVar3 == 0) goto LAB_0016491e;
                    /* try { // try from 00164ba4 to 00164ba8 has its CatchHandler @ 00164bda */
    CThreadFastMutex::Lock((uint)pCVar2,uVar6);
  }
                    /* try { // try from 00164974 to 001649bb has its CatchHandler @ 00164bef */
  if ((_SetSeed != 0) &&
     ((**(code **)(_SetSeed + 100))
                (_SetSeed,0,0,"/data/src/public/tier0/vprof_telemetry.h",0x3f3,
                 &CTelemetryLock::Locked()::tm_fmt,local_24,0), _SetSeed != 0)) {
    (**(code **)(_SetSeed + 0x6c))
              (_SetSeed,local_24,2,"/data/src/public/tier0/vprof_telemetry.h",0x3f4,
               &CTelemetryLock::Locked()::tm_fmt,"%s Locked",local_20);
  }
  if ((param_1 == (void *)0x0) || (param_2 == (CGameEventDescriptor *)0x0)) {
    bVar5 = false;
    goto LAB_001649c9;
  }
  if (*(int *)(this + 0x24) < 1) {
LAB_00164a72:
    local_28 = (CGameEventCallback *)0x0;
                    /* try { // try from 00164a80 to 00164b68 has its CatchHandler @ 00164bef */
    local_28 = operator_new(8);
    CUtlVector<CGameEventCallback*,CUtlMemory<CGameEventCallback*,int>>::InsertBefore
              ((CUtlVector<CGameEventCallback*,CUtlMemory<CGameEventCallback*,int>> *)(this + 0x18),
               *(int *)(this + 0x24),&local_28);
    *(void **)local_28 = param_1;
    *(int *)(local_28 + 4) = param_3;
  }
  else {
    local_28 = (CGameEventCallback *)**(undefined4 **)(this + 0x18);
    if (param_1 != *(void **)local_28) {
      iVar7 = 0;
      do {
        iVar7 = iVar7 + 1;
        if (iVar7 == *(int *)(this + 0x24)) goto LAB_00164a72;
        local_28 = (CGameEventCallback *)(*(undefined4 **)(this + 0x18))[iVar7];
      } while (param_1 != *(void **)local_28);
    }
  }
  iVar7 = *(int *)(param_2 + 0x18);
  if (iVar7 < 1) {
LAB_00164ae0:
    CUtlVector<CGameEventCallback*,CUtlMemory<CGameEventCallback*,int>>::InsertBefore
              ((CUtlVector<CGameEventCallback*,CUtlMemory<CGameEventCallback*,int>> *)
               (param_2 + 0xc),iVar7,&local_28);
    if (*(int *)(net_showeventlisteners._28_4_ + 0x30) != 0) {
      pcVar4 = *(char **)(*(int *)(this + 0x7c) + *(int *)(param_2 + 4) * 0x18 + 0x10);
      if (param_3 == 0) {
        pcVar11 = "SERVERSIDE";
      }
      else {
        piVar9 = (int *)s_GameListenerTypeMap;
        do {
          pcVar10 = (char *)piVar9[2];
          pcVar11 = tokenset_t<int>::GetNameByToken(int)::unknown;
          if (pcVar10 == (char *)0x0) break;
          piVar1 = piVar9 + 3;
          piVar9 = piVar9 + 2;
          pcVar11 = pcVar10;
        } while (param_3 != *piVar1);
      }
      pcVar10 = "UNKNOWN";
      if (pcVar4 != (char *)0x0) {
        pcVar10 = pcVar4;
      }
      Msg("[GAMEEVENT] Event \'%s\' added %s listener %p\n",pcVar10,pcVar11,param_1);
    }
    bVar5 = param_3 == 1 || param_3 == 4;
    if (param_3 == 1 || param_3 == 4) {
      this[0xa4] = (CGameEventManager)0x1;
      goto LAB_001649c9;
    }
  }
  else if ((CGameEventCallback *)**(undefined4 **)(param_2 + 0xc) != local_28) {
    iVar8 = 0;
    do {
      iVar8 = iVar8 + 1;
      if (iVar8 == iVar7) goto LAB_00164ae0;
    } while ((CGameEventCallback *)(*(undefined4 **)(param_2 + 0xc))[iVar8] != local_28);
    if (iVar8 == -1) goto LAB_00164ae0;
  }
  bVar5 = true;
LAB_001649c9:
  *(int *)(this + 0xa0) = *(int *)(this + 0xa0) + -1;
  if (*(int *)(this + 0xa0) == 0) {
    LOCK();
    *(uint *)pCVar2 = 0;
    UNLOCK();
  }
  if ((local_24 != (CGameEventManager *)0x0) && (_SetSeed != 0)) {
    (**(code **)(_SetSeed + 0x6c))
              (_SetSeed,local_24,1,"/data/src/public/tier0/vprof_telemetry.h",0x3fa,
               &CTelemetryLock::Unlocked()::tm_fmt,"%s Released",local_20);
  }
  return bVar5;
}

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)