L L4D2node

CPointEntityFinder::FindByRandom

0x007db5a0 · 537 bytes · __thiscall

_ZN18CPointEntityFinder12FindByRandomEv

Decompiled

undefined (1 param)

/* CPointEntityFinder::FindByRandom() */

void __thiscall CPointEntityFinder::FindByRandom(CPointEntityFinder *this)

{
  uint uVar1;
  int *piVar2;
  char cVar3;
  CBaseEntity *pCVar4;
  size_t __size;
  int iVar5;
  int iVar6;
  undefined4 *puVar7;
  undefined *puVar8;
  int iVar9;
  CBaseFilter *this_00;
  void *local_30;
  int local_2c;
  int local_28;
  int local_24;
  void *local_20;
  
  puVar8 = g_pEntityList;
  this_00 = (CBaseFilter *)0x0;
  *(undefined4 *)(this + 0x440) = 0xffffffff;
  uVar1 = *(uint *)(this + 0x448);
  if (((uVar1 != 0xffffffff) &&
      (puVar8 = puVar8 + (uVar1 & 0xfff) * 0x10, puVar8 != (undefined *)0xfffffffc)) &&
     (*(uint *)(puVar8 + 8) == uVar1 >> 0xc)) {
    this_00 = *(CBaseFilter **)(puVar8 + 4);
  }
  local_30 = (void *)0x0;
  local_2c = 0;
  local_28 = 0;
  local_24 = 0;
  local_20 = (void *)0x0;
                    /* try { // try from 007db61b to 007db77b has its CatchHandler @ 007db7d0 */
  pCVar4 = (CBaseEntity *)
           CGlobalEntityList::NextEnt((CGlobalEntityList *)gEntList,(CBaseEntity *)0x0);
  do {
    if ((this_00 != (CBaseFilter *)0x0) &&
       (cVar3 = CBaseFilter::PassesFilter(this_00,(CBaseEntity *)this,pCVar4), iVar6 = local_24,
       cVar3 != '\0')) {
      iVar9 = local_24 + 1;
      if ((local_2c < iVar9) && (-1 < local_28)) {
        if (local_28 == 0) {
          if (local_2c == 0) {
            if (iVar9 < 9) {
              local_2c = 8;
              goto LAB_007db6df;
            }
            local_2c = 8;
          }
          do {
            iVar5 = local_2c;
            local_2c = iVar5 * 2;
          } while (local_2c < iVar9);
          __size = iVar5 << 3;
        }
        else {
          for (local_2c = (local_24 / local_28 + 1) * local_28; local_2c < iVar9;
              local_2c = (local_2c + iVar9) / 2) {
          }
LAB_007db6df:
          __size = local_2c << 2;
        }
        if (local_30 == (void *)0x0) {
          local_30 = malloc(__size);
        }
        else {
          local_30 = realloc(local_30,__size);
          iVar9 = local_24 + 1;
        }
      }
      iVar5 = (iVar9 - iVar6) + -1;
      iVar6 = iVar6 * 4;
      local_24 = iVar9;
      local_20 = local_30;
      if (0 < iVar5) {
        _V_memmove((void *)((int)local_30 + iVar6 + 4),(void *)((int)local_30 + iVar6),iVar5 * 4);
      }
      if ((undefined4 *)(iVar6 + (int)local_30) != (undefined4 *)0x0) {
        *(undefined4 *)(iVar6 + (int)local_30) = pCVar4;
      }
    }
    pCVar4 = (CBaseEntity *)CGlobalEntityList::NextEnt((CGlobalEntityList *)gEntList,pCVar4);
    if (pCVar4 == (CBaseEntity *)0x0) {
      if (local_24 != 0) {
        iVar6 = RandomInt(0,local_24 + -1);
        piVar2 = *(int **)((int)local_30 + iVar6 * 4);
        if (piVar2 == (int *)0x0) {
          *(undefined4 *)(this + 0x440) = 0xffffffff;
        }
        else {
          puVar7 = (undefined4 *)(**(code **)(*piVar2 + 0xc))(piVar2);
          *(undefined4 *)(this + 0x440) = *puVar7;
        }
      }
      local_24 = 0;
      CUtlMemory<CBaseEntity*,int>::Purge((CUtlMemory<CBaseEntity*,int> *)&local_30);
      local_20 = local_30;
      CUtlMemory<CBaseEntity*,int>::Purge((CUtlMemory<CBaseEntity*,int> *)&local_30);
      return;
    }
  } while( true );
}

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)