L L4D2node

CSpatialPartition::CreateHandle

0x001de950 · 745 bytes · __thiscall

_ZN17CSpatialPartition12CreateHandleEP13IHandleEntity

Decompiled

undefined (2 params)

/* CSpatialPartition::CreateHandle(IHandleEntity*) */

uint __thiscall CSpatialPartition::CreateHandle(CSpatialPartition *this,IHandleEntity *param_1)

{
  CSpatialPartition *pCVar1;
  ushort uVar2;
  uint uVar3;
  char cVar4;
  undefined2 uVar5;
  uint uVar6;
  uint uVar7;
  undefined *puVar8;
  undefined4 *puVar9;
  int iVar10;
  undefined *puVar11;
  CUtlLinkedList<EntityInfo_t,unsigned_short,false,unsigned_short,CUtlMemoryStack<UtlLinkedListElem_t<EntityInfo_t,unsigned_short>,unsigned_short,65535u,1024u,0u>>
  *local_20;
  
  pCVar1 = this + 0x34;
  uVar6 = ThreadGetCurrentId();
  if (uVar6 == *(uint *)(this + 0x34)) {
LAB_001de97c:
    *(int *)(this + 0x38) = *(int *)(this + 0x38) + 1;
    uVar2 = *(ushort *)(this + 0x28);
    if (uVar2 != 0xffff) goto LAB_001de999;
LAB_001deaed:
    local_20 = (CUtlLinkedList<EntityInfo_t,unsigned_short,false,unsigned_short,CUtlMemoryStack<UtlLinkedListElem_t<EntityInfo_t,unsigned_short>,unsigned_short,65535u,1024u,0u>>
                *)(this + 4);
    uVar6 = (uint)*(ushort *)(this + 0x2e);
    iVar10 = *(int *)(this + 0x20);
    if ((int)uVar6 < iVar10) {
      uVar7 = uVar6 + 1;
      uVar3 = uVar7;
    }
    else {
      uVar7 = -(uint)(iVar10 == 0);
      uVar3 = -(uint)(iVar10 == 0);
    }
    if (iVar10 <= (int)(uVar3 & 0xffff)) {
      iVar10 = iVar10 + 1;
      *(int *)(this + 0x20) = iVar10;
      uVar7 = (-*(int *)(this + 0x1c) & *(int *)(this + 0x1c) + 0x33U) + *(int *)(this + 4);
      if (*(uint *)(this + 8) < uVar7) {
        cVar4 = CMemoryStack::CommitTo((uchar *)local_20);
        uVar6 = (uint)*(ushort *)(this + 0x2e);
        iVar10 = *(int *)(this + 0x20);
        if (cVar4 != '\0') goto LAB_001deb36;
      }
      else {
LAB_001deb36:
        *(uint *)(this + 4) = uVar7;
      }
      *(undefined4 *)(this + 0x30) = *(undefined4 *)(this + 0x10);
      if ((int)uVar6 < iVar10) {
        uVar7 = uVar6 + 1;
        uVar6 = uVar7;
      }
      else {
        uVar7 = -(uint)(iVar10 == 0);
        uVar6 = -(uint)(iVar10 == 0);
      }
      if ((int)(uVar6 & 0xffff) < iVar10) goto LAB_001debc0;
      if (CUtlLinkedList<EntityInfo_t,unsigned_short,false,unsigned_short,CUtlMemoryStack<UtlLinkedListElem_t<EntityInfo_t,unsigned_short>,unsigned_short,65535u,1024u,0u>>
          ::AllocInternal(bool)::__executeCount < 10) {
        CUtlLinkedList<EntityInfo_t,unsigned_short,false,unsigned_short,CUtlMemoryStack<UtlLinkedListElem_t<EntityInfo_t,unsigned_short>,unsigned_short,65535u,1024u,0u>>
        ::AllocInternal(bool)::__executeCount =
             CUtlLinkedList<EntityInfo_t,unsigned_short,false,unsigned_short,CUtlMemoryStack<UtlLinkedListElem_t<EntityInfo_t,unsigned_short>,unsigned_short,65535u,1024u,0u>>
             ::AllocInternal(bool)::__executeCount + 1;
        Warning("CUtlLinkedList overflow! (exhausted memory allocator)\n");
      }
LAB_001deb80:
      puVar11 = &DAT_0033ffcc;
      uVar7 = 0xffffffff;
      *(int *)(this + 0x38) = *(int *)(this + 0x38) + -1;
      iVar10 = *(int *)(this + 0x38);
      goto joined_r0x001deb98;
    }
LAB_001debc0:
    if ((short)uVar7 == -1) {
      if (CUtlLinkedList<EntityInfo_t,unsigned_short,false,unsigned_short,CUtlMemoryStack<UtlLinkedListElem_t<EntityInfo_t,unsigned_short>,unsigned_short,65535u,1024u,0u>>
          ::AllocInternal(bool)::__executeCount < 10) {
        CUtlLinkedList<EntityInfo_t,unsigned_short,false,unsigned_short,CUtlMemoryStack<UtlLinkedListElem_t<EntityInfo_t,unsigned_short>,unsigned_short,65535u,1024u,0u>>
        ::AllocInternal(bool)::__executeCount =
             CUtlLinkedList<EntityInfo_t,unsigned_short,false,unsigned_short,CUtlMemoryStack<UtlLinkedListElem_t<EntityInfo_t,unsigned_short>,unsigned_short,65535u,1024u,0u>>
             ::AllocInternal(bool)::__executeCount + 1;
        Warning("CUtlLinkedList overflow! (exhausted index range)\n");
      }
      goto LAB_001deb80;
    }
    uVar6 = uVar7 & 0xffff;
    *(short *)(this + 0x2c) = *(short *)(this + 0x2c) + 1;
    *(short *)(this + 0x2e) = (short)uVar7;
    puVar11 = (undefined *)(uVar6 * 0x34);
    puVar8 = puVar11 + *(int *)(this + 0x10);
  }
  else {
    LOCK();
    uVar7 = *(uint *)pCVar1;
    if (uVar7 == 0) {
      *(uint *)pCVar1 = uVar6;
    }
    UNLOCK();
    if (uVar7 == 0) goto LAB_001de97c;
    CThreadFastMutex::Lock((uint)pCVar1,uVar6);
    uVar2 = *(ushort *)(this + 0x28);
    if (uVar2 == 0xffff) goto LAB_001deaed;
LAB_001de999:
    uVar7 = (uint)uVar2;
    puVar11 = (undefined *)(uVar7 * 0x34);
    puVar8 = puVar11 + *(int *)(this + 0x10);
    *(undefined2 *)(this + 0x28) = *(undefined2 *)(puVar8 + 0x32);
    uVar6 = uVar7;
  }
  local_20 = (CUtlLinkedList<EntityInfo_t,unsigned_short,false,unsigned_short,CUtlMemoryStack<UtlLinkedListElem_t<EntityInfo_t,unsigned_short>,unsigned_short,65535u,1024u,0u>>
              *)(this + 4);
  uVar5 = (undefined2)uVar7;
  *(undefined2 *)(puVar8 + 0x32) = uVar5;
  *(undefined2 *)(puVar11 + *(int *)(this + 0x10) + 0x30) = uVar5;
  CUtlLinkedList<EntityInfo_t,unsigned_short,false,unsigned_short,CUtlMemoryStack<UtlLinkedListElem_t<EntityInfo_t,unsigned_short>,unsigned_short,65535u,1024u,0u>>
  ::Unlink(local_20,(ushort)uVar6);
  iVar10 = *(int *)(this + 0x10);
  *(undefined2 *)(puVar11 + iVar10 + 0x32) = 0xffff;
  uVar2 = *(ushort *)(this + 0x26);
  *(ushort *)(puVar11 + iVar10 + 0x30) = uVar2;
  *(undefined2 *)(this + 0x26) = uVar5;
  if (uVar2 == 0xffff) {
    *(undefined2 *)(this + 0x24) = uVar5;
  }
  else {
    *(undefined2 *)((uint)uVar2 * 0x34 + *(int *)(this + 0x10) + 0x32) = uVar5;
  }
  *(short *)(this + 0x2a) = *(short *)(this + 0x2a) + 1;
  *(int *)(this + 0x38) = *(int *)(this + 0x38) + -1;
  iVar10 = *(int *)(this + 0x38);
joined_r0x001deb98:
  if (iVar10 == 0) {
    LOCK();
    *(uint *)pCVar1 = 0;
    UNLOCK();
  }
  *(IHandleEntity **)(puVar11 + *(int *)(this + 0x10) + 0x18) = param_1;
  puVar9 = (undefined4 *)(puVar11 + *(int *)(this + 0x10));
  *puVar9 = 0x7f7fffff;
  puVar9[1] = 0x7f7fffff;
  puVar9[2] = 0x7f7fffff;
  iVar10 = *(int *)(this + 0x10);
  *(undefined4 *)(puVar11 + iVar10 + 0xc) = 0x800000;
  *(undefined4 *)(puVar11 + iVar10 + 0x10) = 0x800000;
  *(undefined4 *)(puVar11 + iVar10 + 0x14) = 0x800000;
  *(undefined2 *)(puVar11 + *(int *)(this + 0x10) + 0x1c) = 0;
  puVar11[*(int *)(this + 0x10) + 0x1e] = 0;
  *(undefined2 *)(puVar11 + *(int *)(this + 0x10) + 0x22) = 0xffff;
  puVar11[*(int *)(this + 0x10) + 0x1f] = 0xff;
  *(undefined4 *)(puVar11 + *(int *)(this + 0x10) + 0x28) = 0;
  *(undefined2 *)(puVar11 + *(int *)(this + 0x10) + 0x24) = 0xffff;
  puVar11[*(int *)(this + 0x10) + 0x20] = 0xff;
  *(undefined4 *)(puVar11 + *(int *)(this + 0x10) + 0x2c) = 0;
  return uVar7;
}

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)