L L4D2node

CUtlVector<thinkfunc_t,CUtlMemory<thinkfunc_t,int>>::InsertBefore

0x00412070 · 339 bytes · __thiscall

_ZN10CUtlVectorI11thinkfunc_t10CUtlMemoryIS0_iEE12InsertBeforeEiRKS0_

Decompiled

undefined (3 params)

/* CUtlVector<thinkfunc_t, CUtlMemory<thinkfunc_t, int> >::InsertBefore(int, thinkfunc_t const&) */

int __thiscall
CUtlVector<thinkfunc_t,CUtlMemory<thinkfunc_t,int>>::InsertBefore
          (CUtlVector<thinkfunc_t,CUtlMemory<thinkfunc_t,int>> *this,int param_1,
          thinkfunc_t *param_2)

{
  int iVar1;
  undefined4 *puVar2;
  void *pvVar3;
  int iVar4;
  int iVar5;
  
  iVar4 = *(int *)(this + 4);
  iVar5 = *(int *)(this + 0xc) + 1;
  if (iVar4 < iVar5) {
    iVar1 = *(int *)(this + 8);
    if (iVar1 < 0) goto LAB_00412092;
    if (iVar1 == 0) {
      if (iVar4 == 0) {
        if (iVar5 < 3) {
          iVar4 = 2;
          goto LAB_00412106;
        }
        iVar4 = 2;
      }
      do {
        iVar4 = iVar4 * 2;
      } while (iVar4 < iVar5);
    }
    else {
      for (iVar4 = iVar1 * (*(int *)(this + 0xc) / iVar1 + 1); iVar4 < iVar5;
          iVar4 = (iVar4 + iVar5) / 2) {
      }
    }
LAB_00412106:
    *(int *)(this + 4) = iVar4;
    if (*(void **)this != (void *)0x0) {
      pvVar3 = realloc(*(void **)this,iVar4 * 0x14);
      iVar5 = *(int *)(this + 0xc);
      *(void **)this = pvVar3;
      *(void **)(this + 0x10) = pvVar3;
      *(int *)(this + 0xc) = iVar5 + 1;
      iVar5 = (iVar5 + 1) - param_1;
      goto joined_r0x00412140;
    }
    pvVar3 = malloc(iVar4 * 0x14);
    *(void **)this = pvVar3;
  }
  else {
LAB_00412092:
    pvVar3 = *(void **)this;
  }
  *(int *)(this + 0xc) = iVar5;
  iVar5 = iVar5 - param_1;
  *(void **)(this + 0x10) = pvVar3;
joined_r0x00412140:
  if (0 < iVar5 + -1) {
    _V_memmove((void *)((int)pvVar3 + param_1 * 0x14 + 0x14),(void *)((int)pvVar3 + param_1 * 0x14),
               (iVar5 + -1) * 0x14);
    pvVar3 = *(void **)this;
  }
  puVar2 = (undefined4 *)((int)pvVar3 + param_1 * 0x14);
  if (puVar2 != (undefined4 *)0x0) {
    *puVar2 = *(undefined4 *)param_2;
    puVar2[1] = *(undefined4 *)(param_2 + 4);
    puVar2[2] = *(undefined4 *)(param_2 + 8);
    puVar2[3] = *(undefined4 *)(param_2 + 0xc);
    puVar2[4] = *(undefined4 *)(param_2 + 0x10);
  }
  return param_1;
}

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)