L L4D2node

CBSPTreeData::AddHandleToLeaf

0x000bbd40 · 1067 bytes · __thiscall

_ZN12CBSPTreeData15AddHandleToLeafEit

Decompiled

undefined (3 params)

/* CBSPTreeData::AddHandleToLeaf(int, unsigned short) */

void __thiscall CBSPTreeData::AddHandleToLeaf(CBSPTreeData *this,int param_1,ushort param_2)

{
  uint uVar1;
  ushort uVar2;
  int iVar3;
  ushort uVar4;
  uint uVar5;
  uint uVar6;
  uint uVar7;
  int iVar8;
  ushort *puVar9;
  int iVar10;
  ushort local_1e;
  
  local_1e = *(ushort *)(this + 0x48);
  if (local_1e == 0xffff) {
    iVar10 = *(int *)(this + 0x3c);
    if ((int)(uint)*(ushort *)(this + 0x4e) < iVar10) {
      uVar5 = *(ushort *)(this + 0x4e) + 1;
      uVar7 = uVar5 & 0xffff;
      if (iVar10 <= (int)uVar7) {
        uVar5 = 0xffff;
        uVar7 = 0xffff;
      }
    }
    else {
      uVar7 = 0;
      if (iVar10 < 1) {
        uVar7 = 0xffff;
      }
      uVar5 = (0 < iVar10) - 1;
    }
    if ((int)uVar7 < iVar10) {
LAB_000bc013:
      local_1e = (ushort)uVar5;
      if (local_1e != 0xffff) {
        *(ushort *)(this + 0x4e) = local_1e;
        *(short *)(this + 0x4c) = *(short *)(this + 0x4c) + 1;
        iVar10 = (uVar5 & 0xffff) * 6;
        iVar8 = *(int *)(this + 0x38) + iVar10;
        goto LAB_000bbd7b;
      }
      if (CUtlLinkedList<unsigned_short,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<unsigned_short,unsigned_short>,unsigned_short>>
          ::AllocInternal(bool)::__executeCount < 10) {
        CUtlLinkedList<unsigned_short,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<unsigned_short,unsigned_short>,unsigned_short>>
        ::AllocInternal(bool)::__executeCount =
             CUtlLinkedList<unsigned_short,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<unsigned_short,unsigned_short>,unsigned_short>>
             ::AllocInternal(bool)::__executeCount + 1;
        Warning("CUtlLinkedList overflow! (exhausted index range)\n");
      }
LAB_000bc0ae:
      iVar10 = 0x5fffa;
      local_1e = 0xffff;
    }
    else {
      CUtlMemory<UtlLinkedListElem_t<unsigned_short,unsigned_short>,unsigned_short>::Grow
                ((CUtlMemory<UtlLinkedListElem_t<unsigned_short,unsigned_short>,unsigned_short> *)
                 (this + 0x38),1);
      iVar10 = *(int *)(this + 0x3c);
      *(undefined4 *)(this + 0x50) = *(undefined4 *)(this + 0x38);
      if ((int)(uint)*(ushort *)(this + 0x4e) < iVar10) {
        uVar1 = *(ushort *)(this + 0x4e) + 1;
        uVar6 = uVar1 & 0xffff;
        uVar5 = 0xffff;
        uVar7 = 0xffff;
        if ((int)uVar6 < iVar10) {
          uVar5 = uVar1;
          uVar7 = uVar6;
        }
      }
      else {
        uVar7 = 0;
        if (iVar10 < 1) {
          uVar7 = 0xffff;
        }
        uVar5 = (0 < iVar10) - 1;
      }
      if ((int)uVar7 < iVar10) goto LAB_000bc013;
      if (9 < CUtlLinkedList<unsigned_short,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<unsigned_short,unsigned_short>,unsigned_short>>
              ::AllocInternal(bool)::__executeCount) goto LAB_000bc0ae;
      CUtlLinkedList<unsigned_short,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<unsigned_short,unsigned_short>,unsigned_short>>
      ::AllocInternal(bool)::__executeCount =
           CUtlLinkedList<unsigned_short,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<unsigned_short,unsigned_short>,unsigned_short>>
           ::AllocInternal(bool)::__executeCount + 1;
      iVar10 = 0x5fffa;
      Warning("CUtlLinkedList overflow! (exhausted memory allocator)\n");
      local_1e = 0xffff;
    }
  }
  else {
    iVar10 = (uint)local_1e * 6;
    iVar8 = *(int *)(this + 0x38) + iVar10;
    *(undefined2 *)(this + 0x48) = *(undefined2 *)(iVar8 + 4);
LAB_000bbd7b:
    *(undefined2 *)(iVar8 + 4) = 0xffff;
    *(undefined2 *)(*(int *)(this + 0x38) + 2 + iVar10) = 0xffff;
  }
  puVar9 = (ushort *)(*(int *)(this + 8) + param_1 * 2);
  uVar4 = *puVar9;
  if (uVar4 != 0xffff) {
    CUtlLinkedList<unsigned_short,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<unsigned_short,unsigned_short>,unsigned_short>>
    ::Unlink((CUtlLinkedList<unsigned_short,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<unsigned_short,unsigned_short>,unsigned_short>>
              *)(this + 0x38),local_1e);
    iVar3 = *(int *)(this + 0x38);
    *(ushort *)(iVar3 + iVar10 + 4) = uVar4;
    iVar8 = *(int *)(this + 0x38) + (uint)uVar4 * 6;
    uVar4 = *(ushort *)(iVar8 + 2);
    *(ushort *)(iVar3 + iVar10 + 2) = uVar4;
    *(ushort *)(iVar8 + 2) = local_1e;
    if (uVar4 == 0xffff) {
      *(ushort *)(this + 0x44) = local_1e;
    }
    else {
      *(ushort *)(*(int *)(this + 0x38) + (uint)uVar4 * 6 + 4) = local_1e;
    }
    puVar9 = (ushort *)(param_1 * 2 + *(int *)(this + 8));
    *(short *)(this + 0x4a) = *(short *)(this + 0x4a) + 1;
  }
  *puVar9 = local_1e;
  *(ushort *)(*(int *)(this + 0x38) + iVar10) = param_2;
  uVar4 = *(ushort *)(this + 100);
  if (uVar4 == 0xffff) {
    iVar10 = *(int *)(this + 0x58);
    if ((int)(uint)*(ushort *)(this + 0x6a) < iVar10) {
      uVar5 = *(ushort *)(this + 0x6a) + 1;
      uVar7 = uVar5 & 0xffff;
      if (iVar10 <= (int)uVar7) {
        uVar5 = 0xffff;
        uVar7 = 0xffff;
      }
    }
    else {
      uVar7 = 0;
      if (iVar10 < 1) {
        uVar7 = 0xffff;
      }
      uVar5 = (0 < iVar10) - 1;
    }
    if ((int)uVar7 < iVar10) {
LAB_000bbf73:
      uVar4 = (ushort)uVar5;
      if (uVar4 != 0xffff) {
        *(ushort *)(this + 0x6a) = uVar4;
        *(short *)(this + 0x68) = *(short *)(this + 0x68) + 1;
        iVar8 = (uVar5 & 0xffff) * 0xc;
        iVar10 = *(int *)(this + 0x54) + iVar8;
        goto LAB_000bbe48;
      }
      if (CUtlLinkedList<CBSPTreeData::HandleInLeaf_t,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<CBSPTreeData::HandleInLeaf_t,unsigned_short>,unsigned_short>>
          ::AllocInternal(bool)::__executeCount < 10) {
        CUtlLinkedList<CBSPTreeData::HandleInLeaf_t,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<CBSPTreeData::HandleInLeaf_t,unsigned_short>,unsigned_short>>
        ::AllocInternal(bool)::__executeCount =
             CUtlLinkedList<CBSPTreeData::HandleInLeaf_t,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<CBSPTreeData::HandleInLeaf_t,unsigned_short>,unsigned_short>>
             ::AllocInternal(bool)::__executeCount + 1;
        Warning("CUtlLinkedList overflow! (exhausted index range)\n");
      }
    }
    else {
      CUtlMemory<UtlLinkedListElem_t<CBSPTreeData::HandleInLeaf_t,unsigned_short>,unsigned_short>::
      Grow((CUtlMemory<UtlLinkedListElem_t<CBSPTreeData::HandleInLeaf_t,unsigned_short>,unsigned_short>
            *)(this + 0x54),1);
      iVar10 = *(int *)(this + 0x58);
      *(undefined4 *)(this + 0x6c) = *(undefined4 *)(this + 0x54);
      if ((int)(uint)*(ushort *)(this + 0x6a) < iVar10) {
        uVar1 = *(ushort *)(this + 0x6a) + 1;
        uVar6 = uVar1 & 0xffff;
        uVar5 = 0xffff;
        uVar7 = 0xffff;
        if ((int)uVar6 < iVar10) {
          uVar5 = uVar1;
          uVar7 = uVar6;
        }
      }
      else {
        uVar7 = 0;
        if (iVar10 < 1) {
          uVar7 = 0xffff;
        }
        uVar5 = (0 < iVar10) - 1;
      }
      if ((int)uVar7 < iVar10) goto LAB_000bbf73;
      if (CUtlLinkedList<CBSPTreeData::HandleInLeaf_t,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<CBSPTreeData::HandleInLeaf_t,unsigned_short>,unsigned_short>>
          ::AllocInternal(bool)::__executeCount < 10) {
        CUtlLinkedList<CBSPTreeData::HandleInLeaf_t,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<CBSPTreeData::HandleInLeaf_t,unsigned_short>,unsigned_short>>
        ::AllocInternal(bool)::__executeCount =
             CUtlLinkedList<CBSPTreeData::HandleInLeaf_t,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<CBSPTreeData::HandleInLeaf_t,unsigned_short>,unsigned_short>>
             ::AllocInternal(bool)::__executeCount + 1;
        iVar8 = 0xbfff4;
        uVar4 = 0xffff;
        Warning("CUtlLinkedList overflow! (exhausted memory allocator)\n");
        goto LAB_000bbe5e;
      }
    }
    iVar8 = 0xbfff4;
    uVar4 = 0xffff;
  }
  else {
    iVar8 = (uint)uVar4 * 0xc;
    iVar10 = *(int *)(this + 0x54) + iVar8;
    *(undefined2 *)(this + 100) = *(undefined2 *)(iVar10 + 10);
LAB_000bbe48:
    *(undefined2 *)(iVar10 + 10) = 0xffff;
    *(undefined2 *)(*(int *)(this + 0x54) + 8 + iVar8) = 0xffff;
  }
LAB_000bbe5e:
  iVar10 = *(int *)(this + 0x1c) + (uint)param_2 * 0xc;
  uVar2 = *(ushort *)(iVar10 + 4);
  if (uVar2 != 0xffff) {
    CUtlLinkedList<CBSPTreeData::HandleInLeaf_t,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<CBSPTreeData::HandleInLeaf_t,unsigned_short>,unsigned_short>>
    ::Unlink((CUtlLinkedList<CBSPTreeData::HandleInLeaf_t,unsigned_short,true,unsigned_short,CUtlMemory<UtlLinkedListElem_t<CBSPTreeData::HandleInLeaf_t,unsigned_short>,unsigned_short>>
              *)(this + 0x54),uVar4);
    iVar3 = *(int *)(this + 0x54);
    *(ushort *)(iVar3 + iVar8 + 10) = uVar2;
    iVar10 = *(int *)(this + 0x54) + (uint)uVar2 * 0xc;
    uVar2 = *(ushort *)(iVar10 + 8);
    *(ushort *)(iVar3 + iVar8 + 8) = uVar2;
    *(ushort *)(iVar10 + 8) = uVar4;
    if (uVar2 == 0xffff) {
      *(ushort *)(this + 0x60) = uVar4;
    }
    else {
      *(ushort *)(*(int *)(this + 0x54) + (uint)uVar2 * 0xc + 10) = uVar4;
    }
    *(short *)(this + 0x66) = *(short *)(this + 0x66) + 1;
    iVar10 = (uint)param_2 * 0xc + *(int *)(this + 0x1c);
  }
  *(ushort *)(iVar10 + 4) = uVar4;
  *(int *)(*(int *)(this + 0x54) + iVar8) = param_1;
  *(ushort *)(*(int *)(this + 0x54) + 4 + iVar8) = local_1e;
  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)