L L4D2node

TerrorNavMesh::InitializeCheckpoints

0x0086c8d0 · 778 bytes · __thiscall

_ZN13TerrorNavMesh21InitializeCheckpointsEv

Decompiled

undefined (1 param)

/* TerrorNavMesh::InitializeCheckpoints() */

void __thiscall TerrorNavMesh::InitializeCheckpoints(TerrorNavMesh *this)

{
  int iVar1;
  void *pvVar2;
  int iVar3;
  Checkpoint *pCVar4;
  int iVar5;
  char *pcVar6;
  int iVar7;
  CUtlMemory<TerrorNavArea*,int> *local_40;
  Checkpoint *local_38;
  CUtlVector<TerrorNavArea*,CUtlMemory<TerrorNavArea*,int>> *local_34;
  undefined4 *local_30;
  undefined4 local_2c;
  undefined4 local_28;
  int local_24;
  undefined4 *local_20;
  
  iVar7 = 0;
  pvVar2 = *(void **)(this + 0x664);
  if (0 < *(int *)(this + 0x670)) {
    do {
      pCVar4 = *(Checkpoint **)((int)pvVar2 + iVar7 * 4);
      if (pCVar4 != (Checkpoint *)0x0) {
        Checkpoint::~Checkpoint(pCVar4);
        operator_delete(pCVar4);
        pvVar2 = *(void **)(this + 0x664);
      }
      iVar7 = iVar7 + 1;
    } while (iVar7 < *(int *)(this + 0x670));
  }
  *(undefined4 *)(this + 0x670) = 0;
  if (-1 < *(int *)(this + 0x66c)) {
    if (pvVar2 != (void *)0x0) {
      free(pvVar2);
      *(undefined4 *)(this + 0x664) = 0;
    }
    *(undefined4 *)(this + 0x668) = 0;
    pvVar2 = (void *)0x0;
  }
  iVar7 = DAT_00fe6000;
  *(void **)(this + 0x674) = pvVar2;
  local_30 = (undefined4 *)0x0;
  local_2c = 0;
  local_28 = 0;
  local_24 = 0;
  local_20 = (undefined4 *)0x0;
  if (0 < iVar7) {
    iVar7 = 0;
    do {
      local_38 = *(Checkpoint **)(TheNavAreas + iVar7 * 4);
      if (((((byte)local_38[0x12d] & 8) != 0) &&
          (*(float *)(local_38 + 4) < *(float *)(local_38 + 0x10))) &&
         (*(float *)(local_38 + 8) < *(float *)(local_38 + 0x14))) {
        if (*(int *)(local_38 + 0x8c) == 0x8140e) {
          pcVar6 = *(char **)(gpGlobals + 0x3c);
          if (pcVar6 == (char *)0x0) {
            pcVar6 = "";
          }
          else if (pcVar6 == "c4m4_milltown_b") goto LAB_0086c9ae;
          iVar3 = _V_stricmp(pcVar6,"c4m4_milltown_b");
          if (iVar3 == 0) goto LAB_0086c9ae;
        }
                    /* try { // try from 0086c9a9 to 0086cb69 has its CatchHandler @ 0086cbf4 */
        CUtlVector<TerrorNavArea*,CUtlMemory<TerrorNavArea*,int>>::InsertBefore
                  ((CUtlVector<TerrorNavArea*,CUtlMemory<TerrorNavArea*,int>> *)&local_30,local_24,
                   (TerrorNavArea **)&local_38);
      }
LAB_0086c9ae:
      iVar7 = iVar7 + 1;
    } while (iVar7 < DAT_00fe6000);
    while (0 < local_24) {
      pCVar4 = ::operator_new(0x60);
      Checkpoint::Checkpoint(pCVar4);
      iVar3 = *(int *)(this + 0x670);
      iVar5 = *(int *)(this + 0x668);
      iVar7 = iVar3 + 1;
      if (iVar5 < iVar7) {
        iVar1 = *(int *)(this + 0x66c);
        if (iVar1 < 0) goto LAB_0086ca28;
        if (iVar1 == 0) {
          if (iVar5 == 0) {
            if (iVar7 < 9) {
              iVar5 = 8;
              goto LAB_0086cb0f;
            }
            iVar5 = 8;
          }
          do {
            iVar5 = iVar5 * 2;
          } while (iVar5 < iVar7);
        }
        else {
          for (iVar5 = (iVar3 / iVar1 + 1) * iVar1; iVar5 < iVar7; iVar5 = (iVar5 + iVar7) / 2) {
          }
        }
LAB_0086cb0f:
        *(int *)(this + 0x668) = iVar5;
        if (*(void **)(this + 0x664) == (void *)0x0) {
          pvVar2 = malloc(iVar5 << 2);
          *(void **)(this + 0x664) = pvVar2;
        }
        else {
          pvVar2 = realloc(*(void **)(this + 0x664),iVar5 << 2);
          *(void **)(this + 0x664) = pvVar2;
          iVar7 = *(int *)(this + 0x670) + 1;
        }
      }
      else {
LAB_0086ca28:
        pvVar2 = *(void **)(this + 0x664);
      }
      *(int *)(this + 0x670) = iVar7;
      iVar7 = (iVar7 - iVar3) + -1;
      *(void **)(this + 0x674) = pvVar2;
      iVar3 = iVar3 * 4;
      if (0 < iVar7) {
        _V_memmove((void *)((int)pvVar2 + iVar3 + 4),(void *)((int)pvVar2 + iVar3),iVar7 * 4);
        pvVar2 = *(void **)(this + 0x664);
      }
      if ((undefined4 *)(iVar3 + (int)pvVar2) != (undefined4 *)0x0) {
        *(undefined4 *)(iVar3 + (int)pvVar2) = pCVar4;
      }
      local_38 = pCVar4;
      local_34 = (CUtlVector<TerrorNavArea*,CUtlMemory<TerrorNavArea*,int>> *)&local_30;
      if (0 < local_24) {
        SearchSurroundingAreas<CheckpointCollector>
                  ((CNavArea *)*local_30,(Vector *)((CNavArea *)*local_30 + 0x2c),
                   (CheckpointCollector *)&local_38,-1.0,0,-1);
      }
      Checkpoint::OnRoundRestart(pCVar4);
    }
  }
  local_40 = (CUtlMemory<TerrorNavArea*,int> *)&local_30;
  local_24 = 0;
  CUtlMemory<TerrorNavArea*,int>::Purge(local_40);
  local_20 = local_30;
  CUtlMemory<TerrorNavArea*,int>::Purge(local_40);
  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)