L L4D2node

CGameEventManager::RegisterEvent

0x001657b0 · 1117 bytes · __thiscall

_ZN17CGameEventManager13RegisterEventEP9KeyValues

Decompiled

undefined (2 params)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* CGameEventManager::RegisterEvent(KeyValues*) */

undefined4 __thiscall CGameEventManager::RegisterEvent(CGameEventManager *this,KeyValues *param_1)

{
  uint uVar1;
  CGameEventManager *pCVar2;
  uint uVar3;
  Node_t *pNVar4;
  KeyValues *pKVar5;
  char *pcVar6;
  char *pcVar7;
  int iVar8;
  char *pcVar9;
  undefined4 uVar10;
  undefined1 *puVar11;
  Node_t *pNVar12;
  int local_34;
  char *local_24;
  int local_20;
  
  if (param_1 == (KeyValues *)0x0) {
    return 0;
  }
  pCVar2 = this + 0x9c;
  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_00165872;
    }
    (**(code **)(_SetSeed + 0x60))
              (_SetSeed,0,0,0,"/data/src/public/tier0/vprof_telemetry.h",0x3eb,pCVar2,
               &CTelemetryLock::CTelemetryLock(void*,char_const*)::tm_fmt,&DAT_002c48a3,
               "CGameEventManager");
  }
LAB_00165872:
                    /* try { // try from 00165872 to 001658a9 has its CatchHandler @ 00165c75 */
  uVar3 = ThreadGetCurrentId();
  if (uVar3 != *(uint *)(this + 0x9c)) {
    LOCK();
    uVar1 = *(uint *)pCVar2;
    if (uVar1 == 0) {
      *(uint *)pCVar2 = uVar3;
    }
    UNLOCK();
    if (uVar1 != 0) {
      CThreadFastMutex::Lock((uint)pCVar2,uVar3);
      goto LAB_001658c1;
    }
  }
  *(int *)(this + 0xa0) = *(int *)(this + 0xa0) + 1;
LAB_001658c1:
                    /* try { // try from 00165908 to 001659a6 has its CatchHandler @ 00165c71 */
  if ((_SetSeed != 0) &&
     ((**(code **)(_SetSeed + 100))
                (_SetSeed,0,0,"/data/src/public/tier0/vprof_telemetry.h",0x3f3,
                 &CTelemetryLock::Locked()::tm_fmt,pCVar2,0), _SetSeed != 0)) {
    (**(code **)(_SetSeed + 0x6c))
              (_SetSeed,pCVar2,2,"/data/src/public/tier0/vprof_telemetry.h",0x3f4,
               &CTelemetryLock::Locked()::tm_fmt,"%s Locked","CGameEventManager");
  }
  if (*(int *)(this + 0x10) == 0x200) {
                    /* try { // try from 00165b9a to 00165c16 has its CatchHandler @ 00165c71 */
    uVar10 = KeyValues::GetName(param_1);
    DevMsg("CGameEventManager: couldn\'t register event \'%s\', limit reached (%i).\n",uVar10,0x200)
    ;
    uVar10 = 0;
  }
  else {
    pNVar4 = (Node_t *)KeyValues::GetName(param_1);
    pNVar12 = pNVar4;
    local_34 = GetEventDescriptor(this,(char *)pNVar4,(int *)0x0);
    if (local_34 == 0) {
      iVar8 = CUtlVector<CGameEventDescriptor,CUtlMemory<CGameEventDescriptor,int>>::InsertBefore
                        ((CUtlVector<CGameEventDescriptor,CUtlMemory<CGameEventDescriptor,int>> *)
                         (this + 4),*(int *)(this + 0x10));
      local_34 = iVar8 * 0x34 + *(int *)(this + 4);
      pcVar6 = (char *)KeyValues::GetName(param_1);
      local_24 = strdup(pcVar6);
      pNVar12 = (Node_t *)&local_24;
      local_20 = iVar8;
      uVar10 = CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
               ::Insert((CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
                         *)(this + 0x78),pNVar12);
      *(undefined4 *)(local_34 + 4) = uVar10;
    }
    else {
      KeyValues::deleteThis();
    }
    pKVar5 = KeyValues::operator_new((KeyValues *)0x2c,(uint)pNVar12);
                    /* try { // try from 001659c4 to 001659c8 has its CatchHandler @ 00165c22 */
    KeyValues::KeyValues(pKVar5,"descriptor",(IKeyValuesSystem *)0x0,false);
    *(KeyValues **)(local_34 + 8) = pKVar5;
                    /* try { // try from 001659d2 to 00165b07 has its CatchHandler @ 00165c71 */
    for (pKVar5 = (KeyValues *)KeyValues::GetFirstSubKey(param_1); pKVar5 != (KeyValues *)0x0;
        pKVar5 = (KeyValues *)KeyValues::GetNextKey(pKVar5)) {
      pcVar6 = (char *)KeyValues::GetName(pKVar5);
      pcVar7 = (char *)KeyValues::GetString(pKVar5,(char *)0x0,"");
      iVar8 = _V_strcmp("local",pcVar6);
      if (iVar8 == 0) {
        iVar8 = V_atoi(pcVar7);
        *(bool *)(local_34 + 0x20) = iVar8 != 0;
      }
      else {
        iVar8 = _V_strcmp("reliable",pcVar6);
        if (iVar8 == 0) {
          iVar8 = V_atoi(pcVar7);
          *(bool *)(local_34 + 0x21) = iVar8 != 0;
        }
        else {
          puVar11 = s_GameEventTypesMap;
          pcVar9 = "local";
          do {
            if ((pcVar7 != (char *)0x0) && (iVar8 = _V_strcmp(pcVar7,pcVar9), iVar8 == 0)) break;
            puVar11 = (undefined1 *)((int)puVar11 + 8);
            pcVar9 = *(char **)puVar11;
          } while (pcVar9 != (char *)0x0);
          if (*(int *)((int)puVar11 + 4) < 0) {
            KeyValues::SetInt(*(KeyValues **)(local_34 + 8),pcVar6,0);
            uVar10 = KeyValues::GetName(pKVar5);
            DevMsg("CGameEventManager:: unknown type \'%s\' for key \'%s\' [%s].\n",pcVar7,uVar10,
                   pNVar4);
          }
          else {
            KeyValues::SetInt(*(KeyValues **)(local_34 + 8),pcVar6,*(int *)((int)puVar11 + 4));
          }
        }
      }
    }
    uVar10 = 1;
  }
  *(int *)(this + 0xa0) = *(int *)(this + 0xa0) + -1;
  if (*(int *)(this + 0xa0) == 0) {
    LOCK();
    *(uint *)pCVar2 = 0;
    UNLOCK();
  }
  if ((pCVar2 != (CGameEventManager *)0x0) && (_SetSeed != 0)) {
    (**(code **)(_SetSeed + 0x6c))
              (_SetSeed,pCVar2,1,"/data/src/public/tier0/vprof_telemetry.h",0x3fa,
               &CTelemetryLock::Unlocked()::tm_fmt,"%s Released","CGameEventManager");
  }
  return uVar10;
}

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)