L L4D2node

CNavMesh::LoadPlaceDatabase

0x00740c70 · 1103 bytes · __thiscall

_ZN8CNavMesh17LoadPlaceDatabaseEv

Decompiled

undefined (1 param)

/* CNavMesh::LoadPlaceDatabase() */

void __thiscall CNavMesh::LoadPlaceDatabase(CNavMesh *this)

{
  char cVar1;
  KeyValues *pKVar2;
  IBaseFileSystem *pIVar3;
  char *pcVar4;
  int iVar5;
  size_t sVar6;
  char *__dest;
  void *pvVar7;
  uint uVar8;
  int in_GS_OFFSET;
  uint in_stack_fffffed8;
  char *local_f0;
  char *local_ec;
  undefined4 local_e8;
  undefined4 local_e4;
  uint local_e0;
  char *local_dc;
  int local_d8;
  int local_d4;
  undefined4 local_d0;
  uint local_cc;
  int local_c8;
  char local_c4;
  char acStack_a2 [130];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  *(undefined4 *)(this + 0x454) = 0;
  pKVar2 = KeyValues::operator_new((KeyValues *)0x2c,in_stack_fffffed8);
                    /* try { // try from 00740cca to 00740cce has its CatchHandler @ 0074112e */
  KeyValues::KeyValues(pKVar2,"population",(IKeyValuesSystem *)0x0,false);
  pIVar3 = (IBaseFileSystem *)0x0;
  if (filesystem != 0) {
    pIVar3 = (IBaseFileSystem *)(filesystem + 4);
  }
  cVar1 = KeyValues::LoadFromFile(pKVar2,pIVar3,"scripts/population.txt",(char *)0x0);
  if (cVar1 == '\0') {
    KeyValues::deleteThis();
    CUtlBuffer::CUtlBuffer((CUtlBuffer *)&local_d8,0,0,1);
                    /* try { // try from 00740f1e to 00740f20 has its CatchHandler @ 00741146 */
    (**(code **)(*(int *)(filesystem + 4) + 0x38))
              (filesystem + 4,"NavPlace.db","GAME",(CUtlBuffer *)&local_d8,0,0,0);
    if (local_d4 == 0) {
      CUtlMemory<unsigned_char,int>::Purge((CUtlMemory<unsigned_char,int> *)&local_d8);
    }
    else {
      local_ec = (char *)0x0;
      local_e8 = 0;
      pcVar4 = acStack_a2 + 2;
      local_e4 = 0;
      local_e0 = 0;
      local_dc = (char *)0x0;
      while (CUtlBuffer::GetLine((CUtlBuffer *)&local_d8,pcVar4,0x80), local_c4 == '\0') {
                    /* try { // try from 00740f73 to 007410ac has its CatchHandler @ 007410c6 */
        iVar5 = _V_strlen(pcVar4);
        if (1 < iVar5) {
          if (acStack_a2[iVar5 + 1] == '\n') {
            acStack_a2[iVar5 + 1] = '\0';
          }
          if (acStack_a2[iVar5] == '\r') {
            acStack_a2[iVar5] = '\0';
          }
          local_f0 = operator_new__(iVar5 + 1U);
          V_strncpy(local_f0,pcVar4,iVar5 + 1U);
          CUtlVector<char*,CUtlMemory<char*,int>>::InsertBefore
                    ((CUtlVector<char*,CUtlMemory<char*,int>> *)&local_ec,local_e0,&local_f0);
        }
      }
      uVar8 = 0xffffffff;
      if (local_e0 < 0x1fc00001) {
        uVar8 = local_e0 * 4;
      }
      *(uint *)(this + 0x454) = local_e0;
      pvVar7 = operator_new__(uVar8);
      uVar8 = 0;
      *(void **)(this + 0x450) = pvVar7;
      if (*(int *)(this + 0x454) != 0) {
        while( true ) {
          *(undefined4 *)((int)pvVar7 + uVar8 * 4) = *(undefined4 *)(local_ec + uVar8 * 4);
          uVar8 = uVar8 + 1;
          if (*(uint *)(this + 0x454) <= uVar8) break;
          pvVar7 = *(void **)(this + 0x450);
        }
      }
      local_e0 = 0;
      CUtlMemory<char*,int>::Purge((CUtlMemory<char*,int> *)&local_ec);
      local_dc = local_ec;
      CUtlMemory<char*,int>::Purge((CUtlMemory<char*,int> *)&local_ec);
      CUtlMemory<unsigned_char,int>::Purge((CUtlMemory<unsigned_char,int> *)&local_d8);
    }
  }
  else {
    local_d8 = 0;
    local_d4 = 0;
    local_d0 = 0;
    local_cc = 0;
    local_c8 = 0;
                    /* try { // try from 00740d44 to 00740e4d has its CatchHandler @ 007410fe */
    pKVar2 = (KeyValues *)KeyValues::GetFirstTrueSubKey(pKVar2);
    if (pKVar2 != (KeyValues *)0x0) {
      do {
        pcVar4 = (char *)KeyValues::GetName(pKVar2);
        if ((pcVar4 != "default") && (iVar5 = _V_stricmp(pcVar4,"default"), iVar5 != 0)) {
          pcVar4 = (char *)KeyValues::GetName(pKVar2);
          sVar6 = strlen(pcVar4);
          __dest = operator_new__(sVar6 + 1);
          strcpy(__dest,pcVar4);
          local_ec = __dest;
          CUtlVector<char*,CUtlMemory<char*,int>>::InsertBefore
                    ((CUtlVector<char*,CUtlMemory<char*,int>> *)&local_d8,local_cc,&local_ec);
        }
        pKVar2 = (KeyValues *)KeyValues::GetNextTrueSubKey(pKVar2);
      } while (pKVar2 != (KeyValues *)0x0);
    }
    *(uint *)(this + 0x454) = local_cc;
    uVar8 = 0xffffffff;
    if (local_cc < 0x1fc00001) {
      uVar8 = local_cc * 4;
    }
    pvVar7 = operator_new__(uVar8);
    uVar8 = 0;
    *(void **)(this + 0x450) = pvVar7;
    if (*(int *)(this + 0x454) != 0) {
      while( true ) {
        *(undefined4 *)((int)pvVar7 + uVar8 * 4) = *(undefined4 *)(local_d8 + uVar8 * 4);
        uVar8 = uVar8 + 1;
        if (*(uint *)(this + 0x454) <= uVar8) break;
        pvVar7 = *(void **)(this + 0x450);
      }
    }
    KeyValues::deleteThis();
    local_cc = 0;
    CUtlMemory<char*,int>::Purge((CUtlMemory<char*,int> *)&local_d8);
    local_c8 = local_d8;
    CUtlMemory<char*,int>::Purge((CUtlMemory<char*,int> *)&local_d8);
  }
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail();
  }
  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)