L L4D2node

CDirectorItemManager::PopulateItemsAlongFlow<CHandle<CBaseEntity>>

0x008ac340 · 3767 bytes · __thiscall

_ZN20CDirectorItemManager22PopulateItemsAlongFlowI7CHandleI11CBaseEntityEEEvP10CUtlVectorIP18EntityLocationInfoIT_E10CUtlMemoryIS8_iEEi

Decompiled

void (3 params)

/* void CDirectorItemManager::PopulateItemsAlongFlow<CHandle<CBaseEntity>
   >(CUtlVector<EntityLocationInfo<CHandle<CBaseEntity> >*,
   CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity> >*, int> >*, int) */

void __thiscall
CDirectorItemManager::PopulateItemsAlongFlow<CHandle<CBaseEntity>>
          (CDirectorItemManager *this,CUtlVector *param_1,int param_2)

{
  EntityLocationInfo *pEVar1;
  uint uVar2;
  bool bVar3;
  int iVar4;
  int iVar5;
  int iVar6;
  undefined *puVar7;
  int iVar8;
  EntityLocationInfo *pEVar9;
  longdouble lVar10;
  longdouble lVar11;
  longdouble lVar12;
  float fVar13;
  float fVar14;
  float fVar15;
  float fVar16;
  float local_74;
  int local_70;
  int local_6c;
  int local_64;
  int local_60;
  float local_5c;
  float local_58;
  int local_54;
  Vector *local_48;
  EntityLocationInfo **local_44;
  undefined4 local_40;
  undefined4 local_3c;
  int local_38;
  EntityLocationInfo **local_34;
  EntityLocationInfo **local_30;
  undefined4 local_2c;
  undefined4 local_28;
  int local_24;
  EntityLocationInfo **local_20;
  
  fVar14 = *(float *)(TheNavMesh + 0x5f8);
  iVar6 = *(int *)(param_1 + 0xc);
  if (iVar6 == 0) {
    return;
  }
  if (iVar6 <= param_2) {
    param_2 = iVar6;
  }
  if (*(int *)(director_item_placement_method._28_4_ + 0x30) == 1) {
    if (*(int *)(director_item_placement_spew._28_4_ + 0x30) != 0) {
      Msg("Starting requested placement of %d items\n",param_2);
      iVar6 = *(int *)(param_1 + 0xc);
    }
    if (iVar6 < 1) {
      fVar16 = 0.0;
      fVar14 = 1e+09;
      fVar15 = -1e+09;
      iVar6 = *(int *)(director_item_placement_spew._28_4_ + 0x30);
    }
    else {
      fVar14 = 1e+09;
      iVar6 = 0;
      fVar16 = 0.0;
      do {
        iVar4 = CNavMesh::GetNearestNavArea
                          (TheNavMesh,*(Vector **)(*(int *)param_1 + iVar6 * 4),false,10000.0,false,
                           true,false);
        if ((iVar4 != 0) && (fVar15 = *(float *)(iVar4 + 0x154), 0.0 < fVar15)) {
          if (fVar15 <= fVar14) {
            fVar14 = fVar15;
          }
          if (fVar16 <= fVar15) {
            fVar16 = fVar15;
          }
        }
        iVar6 = iVar6 + 1;
      } while (iVar6 < *(int *)(param_1 + 0xc));
      fVar15 = fVar16 - fVar14;
      iVar6 = *(int *)(director_item_placement_spew._28_4_ + 0x30);
    }
    if (iVar6 != 0) {
      Msg(" first potential item at %2.2f, last at %2.2f, total dist is %2.2f, desired spacing is %2.2f.\n"
          ,(double)fVar14,(double)fVar16,(double)fVar15,(double)(fVar15 / (float)param_2));
    }
    lVar10 = (longdouble)Plat_FloatTime();
    iVar6 = *(int *)(param_1 + 0xc);
    local_44 = (EntityLocationInfo **)0x0;
    local_40 = 0;
    local_3c = 0;
    local_38 = 0;
    local_34 = (EntityLocationInfo **)0x0;
    if (iVar6 != 0) {
      CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
      ::GrowVector((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                    *)&local_44,iVar6);
                    /* try { // try from 008ad0ce to 008ad0d2 has its CatchHandler @ 008ad0f3 */
      CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
      ::ShiftElementsRight
                ((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                  *)&local_44,0,iVar6);
      if (0 < iVar6) {
        iVar4 = 0;
        do {
          local_44[iVar4] = *(EntityLocationInfo **)(*(int *)param_1 + iVar4 * 4);
          iVar4 = iVar4 + 1;
        } while (iVar4 != iVar6);
      }
    }
    *(undefined4 *)(param_1 + 0xc) = 0;
    local_30 = (EntityLocationInfo **)0x0;
    local_2c = 0;
    local_28 = 0;
    local_24 = 0;
    local_20 = (EntityLocationInfo **)0x0;
    while ((iVar6 = CNavMesh::GetNearestNavArea
                              (TheNavMesh,(Vector *)*local_44,false,10000.0,false,true,false),
           iVar6 == 0 ||
           (iVar6 = CNavMesh::GetNearestNavArea
                              (TheNavMesh,(Vector *)*local_44,false,10000.0,false,true,false),
           *(float *)(iVar6 + 0x154) <= 0.0 && *(float *)(iVar6 + 0x154) != 0.0))) {
                    /* try { // try from 008aca54 to 008ace4c has its CatchHandler @ 008ad108 */
      CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
      ::InsertBefore((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                      *)&local_30,local_24,local_44);
      CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
      ::ShiftElementsLeft((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                           *)&local_44,0,1);
      local_38 = local_38 + -1;
      if (local_38 == 0) {
        local_24 = 0;
        CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>::Purge
                  ((CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int> *)&local_30);
        local_20 = local_30;
        CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>::Purge
                  ((CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int> *)&local_30);
        local_38 = 0;
        CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>::Purge
                  ((CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int> *)&local_44);
        local_34 = local_44;
        CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>::Purge
                  ((CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int> *)&local_44);
        return;
      }
    }
    CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
    ::InsertBefore((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                    *)param_1,*(int *)(param_1 + 0xc),local_44);
    CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
    ::ShiftElementsLeft((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                         *)&local_44,0,1);
    local_38 = local_38 + -1;
    if ((1 < param_2) && (0 < local_38)) {
      iVar6 = 0;
      local_70 = 0;
      local_64 = 1;
      local_74 = 0.5;
      do {
        fVar14 = 1.0;
        if (local_74 <= 1.0) {
          fVar14 = local_74;
        }
        iVar6 = iVar6 + 1;
        lVar11 = (longdouble)RandomFloat(1.0 - fVar14,0x3f800000);
        lVar12 = (longdouble)RandomFloat(0x3f800000,local_74 + 1.0);
        iVar4 = RandomInt(0,local_38 + -1);
        local_48 = (Vector *)local_44[iVar4];
        iVar8 = CNavMesh::GetNearestNavArea(TheNavMesh,local_48,false,10000.0,false,true,false);
        if ((iVar8 == 0) || (fVar14 = *(float *)(iVar8 + 0x154), fVar14 < 0.0)) {
                    /* try { // try from 008acf21 to 008acfb6 has its CatchHandler @ 008ad108 */
          CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
          ::InsertBefore((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                          *)&local_30,local_24,(EntityLocationInfo **)&local_48);
          CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
          ::ShiftElementsLeft((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                               *)&local_44,iVar4,1);
          local_38 = local_38 + -1;
        }
        else {
          if (*(int *)(param_1 + 0xc) < 1) {
LAB_008acf4f:
            if (local_70 < 0xb) {
LAB_008acd28:
              local_70 = local_70 + 1;
              if (0x32 < local_70) {
                local_70 = 0;
                local_74 = local_74 + 0.1;
              }
              if (param_2 * 100 < iVar6) {
                if (*(int *)(director_item_placement_spew._28_4_ + 0x30) != 0) {
                  Msg(" aborting after %d attempts. Had already placed %d items.\n",param_2 * 100,
                      *(undefined4 *)(param_1 + 0xc));
                }
                iVar4 = *(int *)(param_1 + 0xc);
                for (; (iVar4 < param_2 && (0 < local_38)); local_38 = local_38 + -1) {
                  CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                  ::InsertBefore((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                                  *)param_1,iVar4,local_44);
                  CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                  ::ShiftElementsLeft((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                                       *)&local_44,0,1);
                  iVar4 = *(int *)(param_1 + 0xc);
                  local_64 = local_64 + 1;
                }
              }
              goto LAB_008acdb9;
            }
          }
          else {
            iVar8 = 0;
            bVar3 = false;
            do {
              iVar5 = CNavMesh::GetNearestNavArea
                                (TheNavMesh,*(Vector **)(*(int *)param_1 + iVar8 * 4),false,10000.0,
                                 false,true,false);
              fVar16 = ABS(fVar14 - *(float *)(iVar5 + 0x154));
              if (fVar16 < (float)lVar11 * (fVar15 / (float)param_2)) goto LAB_008acd28;
              if (fVar16 < (float)lVar12 * (fVar15 / (float)param_2)) {
                bVar3 = true;
              }
              iVar8 = iVar8 + 1;
            } while (iVar8 < *(int *)(param_1 + 0xc));
            if (!bVar3) goto LAB_008acf4f;
          }
          CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
          ::InsertBefore((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                          *)param_1,*(int *)(param_1 + 0xc),(EntityLocationInfo **)&local_48);
          CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
          ::ShiftElementsLeft((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                               *)&local_44,iVar4,1);
          local_38 = local_38 + -1;
          local_70 = 0;
          local_64 = local_64 + 1;
        }
LAB_008acdb9:
      } while ((local_64 < param_2) && (0 < local_38));
    }
    lVar11 = (longdouble)Plat_FloatTime();
    if (*(int *)(director_item_placement_spew._28_4_ + 0x30) != 0) {
                    /* try { // try from 008ad05f to 008ad0a7 has its CatchHandler @ 008ad108 */
      Msg("Placement finished. Requested %d, placed %d of %d potential items.\n",param_2,
          *(int *)(param_1 + 0xc),local_24 + *(int *)(param_1 + 0xc) + local_38);
      Msg(" %d items were on invalid NavMesh.\n",local_24);
      Msg(" %2.2f seconds spent on placement.\n",(double)((float)lVar11 - (float)lVar10));
    }
    iVar6 = 0;
    if (0 < local_38) {
      do {
        pEVar1 = local_44[iVar6];
        pEVar9 = pEVar1;
        do {
          uVar2 = *(uint *)(pEVar9 + 0x1c);
          if ((((uVar2 == 0xffffffff) ||
               (puVar7 = g_pEntityList + (uVar2 & 0xfff) * 0x10, puVar7 == (undefined *)0xfffffffc))
              || (*(uint *)(puVar7 + 8) != uVar2 >> 0xc)) ||
             (*(CBaseEntity **)(puVar7 + 4) == (CBaseEntity *)0x0)) {
            pEVar9 = *(EntityLocationInfo **)(pEVar9 + 0x18);
          }
          else {
            UTIL_Remove(*(CBaseEntity **)(puVar7 + 4));
            *(undefined4 *)(pEVar9 + 0x1c) = 0xffffffff;
            pEVar9 = *(EntityLocationInfo **)(pEVar9 + 0x18);
          }
        } while ((pEVar9 != pEVar1) && (pEVar9 != (EntityLocationInfo *)0x0));
        iVar6 = iVar6 + 1;
      } while (iVar6 < local_38);
    }
    local_24 = 0;
    CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>::Purge
              ((CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int> *)&local_30);
    local_20 = local_30;
    CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>::Purge
              ((CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int> *)&local_30);
    local_38 = 0;
    CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>::Purge
              ((CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int> *)&local_44);
    local_34 = local_44;
    CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>::Purge
              ((CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int> *)&local_44);
  }
  else {
    lVar10 = (longdouble)Plat_FloatTime();
    iVar6 = *(int *)(param_1 + 0xc);
    local_30 = (EntityLocationInfo **)0x0;
    local_2c = 0;
    local_28 = 0;
    local_24 = 0;
    local_20 = (EntityLocationInfo **)0x0;
    if (iVar6 != 0) {
      CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
      ::GrowVector((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                    *)&local_30,iVar6);
                    /* try { // try from 008ad1c7 to 008ad1cb has its CatchHandler @ 008ad194 */
      CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
      ::ShiftElementsRight
                ((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                  *)&local_30,0,iVar6);
      if (0 < iVar6) {
        iVar4 = 0;
        do {
          local_30[iVar4] = *(EntityLocationInfo **)(*(int *)param_1 + iVar4 * 4);
          iVar4 = iVar4 + 1;
        } while (iVar4 != iVar6);
      }
    }
    *(undefined4 *)(param_1 + 0xc) = 0;
                    /* try { // try from 008ac3d4 to 008ac65c has its CatchHandler @ 008ad194 */
    CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
    ::InsertBefore((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                    *)param_1,0,local_30);
    CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
    ::ShiftElementsLeft((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                         *)&local_30,0,1);
    local_24 = local_24 + -1;
    iVar6 = local_24 * local_24;
    if (1 < param_2) {
      if (iVar6 == 0) {
        local_6c = 1;
      }
      else {
        local_70 = 0;
        local_6c = 1;
        do {
          lVar11 = (longdouble)RandomFloat(0x3f000000,0x3f800000);
          fVar15 = (float)lVar11 * (fVar14 / (float)param_2);
          lVar11 = (longdouble)RandomFloat(0x3f800000,0x3fc00000);
          fVar16 = (float)lVar11 * (fVar14 / (float)param_2);
          if (0 < local_24) {
            local_58 = 0.0;
            do {
              iVar4 = CNavMesh::GetNearestNavArea
                                (TheNavMesh,(Vector *)local_30[(int)local_58],false,10000.0,false,
                                 true,false);
              if ((iVar4 != 0) && (0 < *(int *)(param_1 + 0xc))) {
                iVar8 = 0;
                do {
                  iVar5 = CNavMesh::GetNearestNavArea
                                    (TheNavMesh,*(Vector **)(*(int *)param_1 + iVar8 * 4),false,
                                     10000.0,false,true,false);
                  if (((iVar5 != 0) &&
                      (fVar13 = *(float *)(iVar5 + 0x154) - *(float *)(iVar4 + 0x154),
                      fVar13 = fVar13 * fVar13, fVar13 <= fVar16 * fVar16)) &&
                     (fVar15 * fVar15 <= fVar13)) {
                    /* try { // try from 008acece to 008aceec has its CatchHandler @ 008ad194 */
                    CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                    ::InsertBefore((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                                    *)param_1,*(int *)(param_1 + 0xc),local_30 + (int)local_58);
                    CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                    ::ShiftElementsLeft((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                                         *)&local_30,(int)local_58,1);
                    local_24 = local_24 + -1;
                    local_6c = local_6c + 1;
                    goto LAB_008ac584;
                  }
                  iVar8 = iVar8 + 1;
                } while (iVar8 < *(int *)(param_1 + 0xc));
              }
              local_58 = (float)((int)local_58 + 1);
            } while ((int)local_58 < local_24);
          }
LAB_008ac584:
          if (param_2 <= local_6c) goto LAB_008ac5dd;
          local_70 = local_70 + 1;
        } while (iVar6 != local_70);
      }
      do {
        CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
        ::InsertBefore((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                        *)param_1,*(int *)(param_1 + 0xc),local_30);
        CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
        ::ShiftElementsLeft((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>*,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>>
                             *)&local_30,0,1);
        local_6c = local_6c + 1;
        local_24 = local_24 + -1;
      } while (local_6c < param_2);
    }
LAB_008ac5dd:
    lVar11 = (longdouble)Plat_FloatTime();
    if (*(int *)(director_item_placement_spew._28_4_ + 0x30) != 0) {
                    /* try { // try from 008ad141 to 008ad173 has its CatchHandler @ 008ad194 */
      Msg("Placement finished. Requested %d, placed %d of %d potential items.\n",param_2,
          *(int *)(param_1 + 0xc),local_24 + *(int *)(param_1 + 0xc));
      Msg(" %2.2f seconds spent on placement.\n",(double)((float)lVar11 - (float)lVar10));
    }
    iVar6 = 0;
    if (0 < local_24) {
      do {
        pEVar1 = local_30[iVar6];
        pEVar9 = pEVar1;
        do {
          uVar2 = *(uint *)(pEVar9 + 0x1c);
          if (((uVar2 == 0xffffffff) ||
              (puVar7 = g_pEntityList + (uVar2 & 0xfff) * 0x10, puVar7 == (undefined *)0xfffffffc))
             || ((*(uint *)(puVar7 + 8) != uVar2 >> 0xc ||
                 (*(CBaseEntity **)(puVar7 + 4) == (CBaseEntity *)0x0)))) {
            pEVar9 = *(EntityLocationInfo **)(pEVar9 + 0x18);
          }
          else {
            UTIL_Remove(*(CBaseEntity **)(puVar7 + 4));
            *(undefined4 *)(pEVar9 + 0x1c) = 0xffffffff;
            pEVar9 = *(EntityLocationInfo **)(pEVar9 + 0x18);
          }
        } while ((pEVar9 != pEVar1) && (pEVar9 != (EntityLocationInfo *)0x0));
        iVar6 = iVar6 + 1;
      } while (iVar6 < local_24);
    }
    local_24 = 0;
    CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>::Purge
              ((CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int> *)&local_30);
    local_20 = local_30;
    CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int>::Purge
              ((CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>*,int> *)&local_30);
  }
  if ((*(int *)(director_item_placement_spew._28_4_ + 0x30) == 0) || (*(int *)(param_1 + 0xc) < 2))
  {
    return;
  }
  iVar6 = CNavMesh::GetNearestNavArea
                    (TheNavMesh,(Vector *)**(undefined4 **)param_1,false,10000.0,false,true,false);
  if (*(int *)(param_1 + 0xc) < 1) {
    local_54 = 0;
  }
  else {
    iVar4 = 0;
    local_54 = 0;
    do {
      iVar8 = CNavMesh::GetNearestNavArea
                        (TheNavMesh,*(Vector **)(*(int *)param_1 + iVar4 * 4),false,10000.0,false,
                         true,false);
      if (*(float *)(iVar8 + 0x154) <= *(float *)(iVar6 + 0x154) &&
          *(float *)(iVar6 + 0x154) != *(float *)(iVar8 + 0x154)) {
        local_54 = iVar4;
        iVar6 = iVar8;
      }
      iVar4 = iVar4 + 1;
    } while (iVar4 < *(int *)(param_1 + 0xc));
  }
  Msg("First encounter: %d, %2.2f\n",local_54,(double)*(float *)(iVar6 + 0x154));
  fVar15 = 0.0;
  local_5c = 0.0;
  local_58 = 1e+08;
  fVar14 = local_5c;
  while (local_5c = fVar14, iVar4 = *(int *)(param_1 + 0xc), 0 < iVar4) {
    fVar14 = 1e+10;
    iVar5 = 0;
    iVar8 = 0;
    local_60 = -1;
    do {
      if (local_54 != iVar5) {
        iVar4 = CNavMesh::GetNearestNavArea
                          (TheNavMesh,*(Vector **)(*(int *)param_1 + iVar5 * 4),false,10000.0,false,
                           true,false);
        fVar16 = *(float *)(iVar4 + 0x154) - *(float *)(iVar6 + 0x154);
        if ((fVar16 < fVar14) && (0.0 < fVar16)) {
          iVar8 = iVar4;
          fVar14 = fVar16;
          local_60 = iVar5;
        }
        iVar4 = *(int *)(param_1 + 0xc);
      }
      iVar5 = iVar5 + 1;
    } while (iVar5 < iVar4);
    if (iVar8 == 0) break;
    Msg(" next encounter: %d %2.2f\n",local_60,(double)*(float *)(iVar8 + 0x154));
    fVar15 = fVar15 + fVar14;
    local_54 = local_60;
    if (fVar14 <= local_58) {
      local_58 = fVar14;
    }
    iVar6 = iVar8;
    if (fVar14 <= local_5c) {
      fVar14 = local_5c;
    }
  }
  Msg("Avg dist: %2.2f, min: %2.2f, max: %2.2f\n",(double)(fVar15 / (float)(iVar4 + -1)),
      (double)local_58,(double)local_5c);
  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)