L L4D2node

CTestScriptMgr::StartLoop

0x0021a0a0 · 703 bytes · __thiscall

_ZN14CTestScriptMgr9StartLoopEPKc

Decompiled

undefined (2 params)

/* CTestScriptMgr::StartLoop(char const*) */

void __thiscall CTestScriptMgr::StartLoop(CTestScriptMgr *this,char *param_1)

{
  int iVar1;
  int iVar2;
  undefined4 *puVar3;
  undefined4 uVar4;
  void *pvVar5;
  int iVar6;
  int iVar7;
  longdouble lVar8;
  
  if (*(int *)(this + 4) == 0) {
    Error("CTestScriptMgr: not initialized.");
  }
  iVar2 = FindLoop(this,param_1);
  if (iVar2 != 0) {
    Error("CTestScriptMgr::StartLoop( %s ): loop already exists.",param_1);
  }
  puVar3 = operator_new(0x54);
  V_strncpy((char *)(puVar3 + 3),param_1,0x40);
  *puVar3 = 0;
  lVar8 = (longdouble)Plat_FloatTime();
  iVar2 = g_pFileSystem;
  *(double *)(puVar3 + 1) = (double)lVar8;
  uVar4 = (**(code **)(*(int *)(iVar2 + 4) + 0x14))(iVar2 + 4,*(undefined4 *)(this + 4));
  puVar3[0x13] = uVar4;
  iVar2 = *(int *)(this + 0x44);
  if (iVar2 != -1) {
    iVar7 = iVar2 * 0xc;
    iVar6 = *(int *)(this + 0x30) + iVar7;
    *(undefined4 *)(this + 0x44) = *(undefined4 *)(iVar6 + 8);
    goto LAB_0021a147;
  }
  iVar6 = *(int *)(this + 0x50);
  iVar7 = *(int *)(this + 0x34);
  if ((iVar6 < 0) || (iVar7 <= iVar6)) {
    iVar2 = 0;
    if (iVar7 < 1) goto LAB_0021a1d9;
  }
  else {
    iVar2 = iVar6 + 1;
    if ((iVar2 < 0) || (iVar7 <= iVar2)) {
LAB_0021a1d9:
      iVar2 = *(int *)(this + 0x38);
      if (iVar2 < 0) {
        pvVar5 = *(void **)(this + 0x30);
      }
      else {
        iVar1 = iVar7 + 1;
        if (iVar2 == 0) {
          iVar2 = 3;
          if (iVar7 != 0) {
            iVar2 = iVar7;
          }
          while (iVar7 = iVar2, iVar7 < iVar1) {
            iVar2 = iVar7 * 2;
          }
        }
        else {
          for (iVar7 = iVar2 * (iVar7 / iVar2 + 1); iVar7 < iVar1; iVar7 = (iVar7 + iVar1) / 2) {
          }
        }
        *(int *)(this + 0x34) = iVar7;
        if (*(void **)(this + 0x30) == (void *)0x0) {
          pvVar5 = malloc(iVar7 * 0xc);
          *(void **)(this + 0x30) = pvVar5;
        }
        else {
          pvVar5 = realloc(*(void **)(this + 0x30),iVar7 * 0xc);
          iVar6 = *(int *)(this + 0x50);
          iVar7 = *(int *)(this + 0x34);
          *(void **)(this + 0x30) = pvVar5;
        }
      }
      *(void **)(this + 0x54) = pvVar5;
      if ((iVar6 < 0) || (iVar7 <= iVar6)) {
        iVar2 = 0;
        if (0 < iVar7) goto LAB_0021a2aa;
      }
      else {
        iVar2 = iVar6 + 1;
        if ((-1 < iVar2) && (iVar2 < iVar7)) goto LAB_0021a2c8;
      }
      if (CUtlLinkedList<CLoopInfo*,int,false,int,CUtlMemory<UtlLinkedListElem_t<CLoopInfo*,int>,int>>
          ::AllocInternal(bool)::__executeCount < 10) {
        CUtlLinkedList<CLoopInfo*,int,false,int,CUtlMemory<UtlLinkedListElem_t<CLoopInfo*,int>,int>>
        ::AllocInternal(bool)::__executeCount =
             CUtlLinkedList<CLoopInfo*,int,false,int,CUtlMemory<UtlLinkedListElem_t<CLoopInfo*,int>,int>>
             ::AllocInternal(bool)::__executeCount + 1;
        Warning("CUtlLinkedList overflow! (exhausted memory allocator)\n");
      }
LAB_0021a290:
      puVar3[0x14] = 0xffffffff;
      return;
    }
LAB_0021a2c8:
    if (iVar2 == -1) {
      if (CUtlLinkedList<CLoopInfo*,int,false,int,CUtlMemory<UtlLinkedListElem_t<CLoopInfo*,int>,int>>
          ::AllocInternal(bool)::__executeCount < 10) {
        CUtlLinkedList<CLoopInfo*,int,false,int,CUtlMemory<UtlLinkedListElem_t<CLoopInfo*,int>,int>>
        ::AllocInternal(bool)::__executeCount =
             CUtlLinkedList<CLoopInfo*,int,false,int,CUtlMemory<UtlLinkedListElem_t<CLoopInfo*,int>,int>>
             ::AllocInternal(bool)::__executeCount + 1;
        Warning("CUtlLinkedList overflow! (exhausted index range)\n");
      }
      goto LAB_0021a290;
    }
  }
LAB_0021a2aa:
  *(int *)(this + 0x50) = iVar2;
  *(int *)(this + 0x4c) = *(int *)(this + 0x4c) + 1;
  iVar7 = iVar2 * 0xc;
  iVar6 = *(int *)(this + 0x30) + iVar7;
LAB_0021a147:
  *(int *)(iVar6 + 8) = iVar2;
  *(int *)(*(int *)(this + 0x30) + 4 + iVar7) = iVar2;
  CUtlLinkedList<CLoopInfo*,int,false,int,CUtlMemory<UtlLinkedListElem_t<CLoopInfo*,int>,int>>::
  Unlink((CUtlLinkedList<CLoopInfo*,int,false,int,CUtlMemory<UtlLinkedListElem_t<CLoopInfo*,int>,int>>
          *)(this + 0x30),iVar2);
  iVar6 = *(int *)(this + 0x30);
  *(undefined4 *)(iVar6 + iVar7 + 8) = 0xffffffff;
  iVar1 = *(int *)(this + 0x40);
  *(int *)(iVar6 + iVar7 + 4) = iVar1;
  *(int *)(this + 0x40) = iVar2;
  if (iVar1 == -1) {
    *(int *)(this + 0x3c) = iVar2;
  }
  else {
    *(int *)(*(int *)(this + 0x30) + iVar1 * 0xc + 8) = iVar2;
  }
  *(int *)(this + 0x48) = *(int *)(this + 0x48) + 1;
  if ((undefined4 *)(iVar7 + *(int *)(this + 0x30)) != (undefined4 *)0x0) {
    *(undefined4 *)(iVar7 + *(int *)(this + 0x30)) = puVar3;
  }
  puVar3[0x14] = iVar2;
  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)