L L4D2node

CDirtySpatialPartitionEntityList::OnPreQuery

0x0042bbb0 · 1040 bytes · __thiscall

_ZN32CDirtySpatialPartitionEntityList10OnPreQueryEi

Decompiled

undefined (2 params)

/* CDirtySpatialPartitionEntityList::OnPreQuery(int) */

void __thiscall
CDirtySpatialPartitionEntityList::OnPreQuery(CDirtySpatialPartitionEntityList *this,int param_1)

{
  undefined4 *puVar1;
  undefined4 uVar2;
  uint uVar3;
  int *piVar4;
  char cVar5;
  int *piVar6;
  int iVar7;
  undefined4 *puVar8;
  int iVar9;
  int iVar10;
  size_t __size;
  int local_48;
  void *local_30;
  int local_2c;
  int local_28;
  int local_24;
  void *local_20;
  
  if ((param_1 & 0x13U) == 0) {
    return;
  }
  piVar6 = (int *)___tls_get_addr();
  iVar10 = *piVar6;
  if ((*(int *)(this + 0x30) != 0) && (*(int *)(this + 0x30) == iVar10 + 1)) {
    return;
  }
  if (*(short *)(this + 0x14) != 0) {
    iVar7 = iVar10 + 0xc;
    iVar9 = *(int *)(this + iVar7 * 4 + 4);
    if (iVar9 != 0) goto LAB_0042bdc6;
    local_30 = (void *)0x0;
    local_2c = 0;
    local_28 = 0;
    local_24 = 0;
    local_20 = (void *)0x0;
                    /* try { // try from 0042bc34 to 0042bfae has its CatchHandler @ 0042bfbc */
    iVar7 = ThreadGetCurrentId();
    LOCK();
    *(int *)(this + 0x28) = *(int *)(this + 0x28) + 1;
    UNLOCK();
    if ((0 < *(int *)(this + 0x24)) ||
       (((*(int *)(this + 0x20) != 0 && (iVar7 != *(int *)(this + 0x20))) ||
        (cVar5 = ThreadInterlockedAssignIf64(this + 0x20,iVar7,0,0,0), cVar5 == '\0')))) {
      CThreadSpinRWLock::SpinLockForWrite((uint)(this + 0x20));
    }
    *(int *)(this + 0x30) = iVar10 + 1;
    while( true ) {
      piVar6 = *(int **)(this + 0x10);
      if (piVar6 == (int *)0x0) break;
      cVar5 = ThreadInterlockedAssignIf64
                        (this + 0x10,0,*(uint *)(this + 0x14) & 0xffff0000,piVar6,
                         *(uint *)(this + 0x14));
      if (cVar5 != '\0') {
        do {
          uVar3 = piVar6[2];
          piVar4 = (int *)*piVar6;
          do {
            iVar10 = *(int *)(this + 0x1c);
            iVar7 = *(int *)(this + 0x18);
            *piVar6 = iVar7;
            cVar5 = ThreadInterlockedAssignIf64(this + 0x18,piVar6,iVar10 + 0x10001,iVar7,iVar10);
          } while (cVar5 == '\0');
          if (((uVar3 != 0xffffffff) &&
              (iVar10 = (uVar3 & 0xfff) * 0x10, *(uint *)(gEntList + iVar10 + 8) == uVar3 >> 0xc))
             && ((piVar6 = *(int **)(gEntList + iVar10 + 4), piVar6 != (int *)0x0 &&
                 (iVar7 = (**(code **)(*piVar6 + 0x18))(piVar6), iVar10 = local_24, iVar7 != 0)))) {
            if ((*(byte *)(iVar7 + 0x14c) & 8) == 0) {
              CCollisionProperty::UpdatePartition((CCollisionProperty *)(iVar7 + 0x194));
            }
            else {
              iVar7 = local_24 + 1;
              if ((local_2c < iVar7) && (-1 < local_28)) {
                if (local_28 == 0) {
                  if (local_2c == 0) {
                    if (iVar7 < 9) {
                      local_2c = 8;
                      goto LAB_0042bedf;
                    }
                    local_2c = 8;
                  }
                  do {
                    iVar9 = local_2c;
                    local_2c = iVar9 * 2;
                  } while (local_2c < iVar7);
                  __size = iVar9 << 3;
                }
                else {
                  for (local_2c = (local_24 / local_28 + 1) * local_28; local_2c < iVar7;
                      local_2c = (local_2c + iVar7) / 2) {
                  }
LAB_0042bedf:
                  __size = local_2c << 2;
                }
                if (local_30 == (void *)0x0) {
                  local_30 = malloc(__size);
                }
                else {
                  local_30 = realloc(local_30,__size);
                  iVar7 = local_24 + 1;
                }
              }
              iVar9 = (iVar7 - iVar10) + -1;
              iVar10 = iVar10 * 4;
              local_24 = iVar7;
              local_20 = local_30;
              if (0 < iVar9) {
                _V_memmove((void *)((int)local_30 + iVar10 + 4),(void *)((int)local_30 + iVar10),
                           iVar9 * 4);
              }
              if ((uint *)((int)local_30 + iVar10) != (uint *)0x0) {
                *(uint *)((int)local_30 + iVar10) = uVar3;
              }
            }
          }
          piVar6 = piVar4;
        } while (piVar4 != (int *)0x0);
      }
    }
    if (0 < local_24) {
      local_48 = 0;
      do {
        puVar1 = (undefined4 *)((int)local_30 + local_48 * 4);
        do {
          puVar8 = *(undefined4 **)(this + 0x18);
          if (puVar8 == (undefined4 *)0x0) {
            puVar8 = ::operator_new(0x10);
            puVar8[2] = 0xffffffff;
            break;
          }
          cVar5 = ThreadInterlockedAssignIf64
                            (this + 0x18,*puVar8,*(int *)(this + 0x1c) + -1,puVar8,
                             *(int *)(this + 0x1c));
        } while (cVar5 == '\0');
        puVar8[2] = *puVar1;
        do {
          iVar10 = *(int *)(this + 0x14);
          uVar2 = *(undefined4 *)(this + 0x10);
          *puVar8 = uVar2;
          cVar5 = ThreadInterlockedAssignIf64(this + 0x10,puVar8,iVar10 + 0x10001,uVar2,iVar10);
        } while (cVar5 == '\0');
        local_48 = local_48 + 1;
      } while (local_48 < local_24);
    }
    *(undefined4 *)(this + 0x30) = 0;
    CThreadSpinRWLock::UnlockWrite();
    local_24 = 0;
    CUtlMemory<CBaseHandle,int>::Purge((CUtlMemory<CBaseHandle,int> *)&local_30);
    local_20 = local_30;
    CUtlMemory<CBaseHandle,int>::Purge((CUtlMemory<CBaseHandle,int> *)&local_30);
    piVar6 = (int *)___tls_get_addr();
    iVar10 = *piVar6;
  }
  iVar9 = *(int *)(this + iVar10 * 4 + 0x34);
  iVar7 = iVar10 + 0xc;
  if (iVar9 == 0) {
    CThreadSpinRWLock::LockForRead();
    iVar9 = *(int *)(this + iVar10 * 4 + 0x34);
  }
LAB_0042bdc6:
  *(int *)(this + iVar7 * 4 + 4) = iVar9 + 1;
  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)