L L4D2node

COcclusionSystem::IsOccluded

0x001ce240 · 2713 bytes · __thiscall

_ZN16COcclusionSystem10IsOccludedERK6VectorS2_

Decompiled

undefined (3 params)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* COcclusionSystem::IsOccluded(Vector const&, Vector const&) */

undefined4 __thiscall
COcclusionSystem::IsOccluded(COcclusionSystem *this,Vector *param_1,Vector *param_2)

{
  uint *puVar1;
  undefined4 uVar2;
  undefined4 uVar3;
  uint uVar4;
  char cVar5;
  int iVar6;
  uint uVar7;
  float *pfVar8;
  int iVar9;
  float *pfVar10;
  undefined4 uVar11;
  bool bVar12;
  float fVar13;
  float fVar14;
  float fVar15;
  float fVar16;
  float fVar17;
  int local_1e0;
  uint local_1d8;
  undefined4 local_1d4;
  undefined4 local_1d0;
  Vector *local_1c8 [2];
  float local_1c0 [2];
  undefined4 local_1b8;
  undefined4 local_1b4;
  undefined4 local_1b0;
  undefined4 local_1ac;
  float local_1a8 [4];
  float local_198;
  float local_194;
  int aiStack_190 [6];
  cplane_t *local_178;
  float local_174;
  float local_170;
  float local_16c;
  cplane_t *local_168;
  float *local_164;
  undefined1 local_160;
  float local_15c [4];
  float local_14c;
  float local_148;
  float local_144;
  float local_140;
  float local_13c;
  float local_138;
  float local_134;
  float local_130;
  cplane_t local_12c [48];
  float local_fc;
  float local_f8 [4];
  float local_e8 [19];
  float local_9c [4];
  float local_8c [31];
  
  if (*(int *)(r_occlusion._28_4_ + 0x30) == 0) {
    return 0;
  }
  local_1d4 = 0;
  local_1d0 = 0;
  if (_Plat_SetBenchmarkMode == 0) {
    local_1e0 = 0;
  }
  else {
    (**(code **)(_Plat_SetBenchmarkMode + 0x50))
              (_Plat_SetBenchmarkMode,&local_1d4,0,0,0,0,"/data/src/engine/./occlusionsystem.cpp",
               0xa9a,&IsOccluded(Vector_const&,Vector_const&)::tm_fmt,"(%s)%s","Occlusion",
               "COcclusionSystem::IsOccluded");
    local_1e0 = _Plat_SetBenchmarkMode;
  }
  uVar3 = local_1d0;
  uVar2 = local_1d4;
  iVar9 = _DAT_0040b9d4;
                    /* try { // try from 001ce31c to 001ce320 has its CatchHandler @ 001ced09 */
  if (((_DAT_0040b028 != 0) || (DAT_0040b02c == '\0')) &&
     (iVar6 = ThreadGetCurrentId(), iVar9 == iVar6)) {
    if ((char *)*_DAT_0040b030 != "COcclusionSystem::IsOccluded") {
                    /* try { // try from 001ce8e0 to 001ce903 has its CatchHandler @ 001ced09 */
      _DAT_0040b030 =
           (int *)CVProfNode::GetSubNode((char *)_DAT_0040b030,0x2bd4f9,(char *)0x0,0x2b8040);
    }
    puVar1 = (uint *)(_DAT_0040b0bc + 4 + _DAT_0040b030[0x1c] * 8);
    *puVar1 = *puVar1 | 4;
    CVProfNode::EnterScope();
    DAT_0040b02c = '\0';
  }
  if ((IsOccluded(Vector_const&,Vector_const&)::mutex == '\0') &&
     (iVar9 = __cxa_guard_acquire(&IsOccluded(Vector_const&,Vector_const&)::mutex), iVar9 != 0)) {
    IsOccluded(Vector_const&,Vector_const&)::mutex = 0;
    DAT_003acf0c = 0;
    __cxa_guard_release(&IsOccluded(Vector_const&,Vector_const&)::mutex);
  }
                    /* try { // try from 001ce336 to 001ce33a has its CatchHandler @ 001ced4f */
  uVar7 = ThreadGetCurrentId();
  if (uVar7 == IsOccluded(Vector_const&,Vector_const&)::mutex) {
LAB_001ce356:
    DAT_003acf0c = DAT_003acf0c + 1;
  }
  else {
    LOCK();
    bVar12 = IsOccluded(Vector_const&,Vector_const&)::mutex == 0;
    uVar4 = uVar7;
    if (!bVar12) {
      uVar4 = IsOccluded(Vector_const&,Vector_const&)::mutex;
    }
    IsOccluded(Vector_const&,Vector_const&)::mutex = uVar4;
    UNLOCK();
    if (bVar12) goto LAB_001ce356;
                    /* try { // try from 001ce57d to 001ce581 has its CatchHandler @ 001ced4f */
    CThreadFastMutex::Lock(0x3acf08,uVar7);
  }
  if (*(int *)(this + 0x284) != 0) {
    fVar13 = ((*(float *)(param_1 + 4) + *(float *)(param_2 + 4)) * 0.5 - *(float *)(this + 0x9c)) *
             *(float *)(this + 0xa8) +
             ((*(float *)param_1 + *(float *)param_2) * 0.5 - *(float *)(this + 0x98)) *
             *(float *)(this + 0xa4) +
             ((*(float *)(param_1 + 8) + *(float *)(param_2 + 8)) * 0.5 - *(float *)(this + 0xa0)) *
             *(float *)(this + 0xac);
    if (0.0 < fVar13) {
      fVar17 = *(float *)param_2 - *(float *)param_1;
      fVar15 = *(float *)(param_2 + 8) - *(float *)(param_1 + 8);
      fVar16 = *(float *)(param_2 + 4) - *(float *)(param_1 + 4);
      fVar13 = fVar13 + *(float *)(this + 0xb8);
      fVar14 = *(float *)(r_occludeemaxarea._28_4_ + 0x2c) * 0.01;
      if (fVar14 == 0.0) {
        fVar14 = *(float *)(this + 0x2b4);
      }
      if ((*(float *)(this + 0xbc) * 0.25 * (fVar16 * fVar16 + fVar17 * fVar17 + fVar15 * fVar15)) /
          (fVar13 * fVar13) < fVar14) {
        s_WingedTestEdgeList._136_4_ = 0;
        s_WingedTestEdgeList._156_4_ = 0;
        local_1ac = 0x3f800000;
        local_1c8[0] = param_1;
        local_1c8[1] = param_2;
        local_1b0 = *(undefined4 *)(param_1 + 8);
        local_1b4 = *(undefined4 *)(param_1 + 4);
        local_1b8 = *(undefined4 *)param_1;
                    /* try { // try from 001ce603 to 001ce607 has its CatchHandler @ 001ceda6 */
        Vector4DMultiply((VMatrix *)(this + 8),(Vector4D *)&local_1b8,(Vector4D *)local_9c);
        if (0.0 < local_9c[3]) {
          local_9c[3] = 1.0 / local_9c[3];
          local_15c[3] = *(float *)(this + 0x38) * fVar17;
          local_15c[2] = *(float *)(this + 0x28) * fVar17;
          local_15c[1] = *(float *)(this + 0x18) * fVar17;
          local_15c[0] = fVar17 * *(float *)(this + 8);
          local_140 = *(float *)(this + 0x3c) * fVar16;
          local_144 = *(float *)(this + 0x2c) * fVar16;
          local_148 = *(float *)(this + 0x1c) * fVar16;
          local_14c = fVar16 * *(float *)(this + 0xc);
          local_130 = *(float *)(this + 0x40) * fVar15;
          local_134 = *(float *)(this + 0x30) * fVar15;
          local_138 = *(float *)(this + 0x20) * fVar15;
          local_fc = local_9c[3] * local_9c[0];
          local_13c = fVar15 * *(float *)(this + 0x10);
          local_f8[0] = local_9c[1] * local_9c[3];
          local_f8[1] = local_9c[2] * local_9c[3];
          if (0.0 < local_9c[2] * local_9c[3]) {
            pfVar8 = local_9c + 7;
            local_1d8 = 1;
            pfVar10 = local_e8;
            do {
              iVar9 = *(int *)(s_pDeltaIndices + local_1d8 * 4);
              iVar6 = *(int *)(s_pSourceIndices + local_1d8 * 4);
              pfVar8[-3] = local_15c[iVar9 * 4] + local_9c[iVar6 * 4];
              pfVar8[-2] = local_15c[iVar9 * 4 + 1] + local_9c[iVar6 * 4 + 1];
              pfVar8[-1] = local_15c[iVar9 * 4 + 2] + local_9c[iVar6 * 4 + 2];
              fVar13 = local_15c[iVar9 * 4 + 3] + local_9c[iVar6 * 4 + 3];
              *pfVar8 = fVar13;
              if (fVar13 <= 0.0) goto LAB_001ce4a3;
              fVar14 = pfVar8[-1];
              fVar13 = 1.0 / fVar13;
              fVar15 = pfVar8[-2];
              fVar16 = pfVar8[-3];
              *pfVar10 = fVar14 * fVar13;
              pfVar10[-1] = fVar15 * fVar13;
              pfVar10[-2] = fVar13 * fVar16;
              if (fVar14 * fVar13 <= 0.0) goto LAB_001ce4a3;
              local_1d8 = local_1d8 + 1;
              pfVar8 = pfVar8 + 4;
              pfVar10 = pfVar10 + 3;
            } while (local_1d8 != 8);
            local_1c0[0] = -1.0;
            local_1c0[1] = 1.0;
            local_1d8 = 0;
            local_1a8[0] = *(float *)param_1 - *(float *)(this + 0x98);
            local_1a8[1] = *(float *)(param_1 + 4) - *(float *)(this + 0x9c);
            fVar13 = *(float *)param_2;
            local_1a8[2] = *(float *)(param_1 + 8) - *(float *)(this + 0xa0);
            fVar14 = *(float *)(param_2 + 4);
            fVar15 = *(float *)(param_2 + 8);
            *(int *)(this + 700) = *(int *)(this + 700) + 1;
            local_1a8[3] = *(float *)(this + 0x98) - fVar13;
            local_198 = *(float *)(this + 0x9c) - fVar14;
            local_194 = *(float *)(this + 0xa0) - fVar15;
            do {
              uVar7 = local_1d8 & 1;
              iVar6 = (int)local_1d8 >> 1;
              iVar9 = iVar6 * 4;
              if (0.0 < local_1a8[iVar6 + uVar7 * 3]) {
                fVar13 = local_1c0[uVar7];
                local_174 = *(float *)(this + iVar9 + 0x58) * fVar13;
                local_178 = (cplane_t *)(*(float *)(this + iVar9 + 0x48) * fVar13);
                local_170 = *(float *)(this + iVar9 + 0x68) * fVar13;
                local_16c = *(float *)(this + 100) * local_174 +
                            *(float *)(this + 0x54) * (float)local_178 +
                            *(float *)(this + 0x74) * local_170 +
                            fVar13 * *(float *)(local_1c8[uVar7] + iVar6 * 4) *
                            (local_170 * local_170 + (float)local_178 * (float)local_178 +
                            local_174 * local_174);
                ComputeScreenSpacePlane(this,(cplane_t *)&local_178,local_12c);
                    /* try { // try from 001cea80 to 001cea84 has its CatchHandler @ 001ceda6 */
                iVar9 = CWingedEdgeList::AddSurface
                                  ((CWingedEdgeList *)s_WingedTestEdgeList,local_12c);
                aiStack_190[local_1d8] = iVar9;
                uVar11 = *(undefined4 *)(this + 700);
                iVar6 = local_1d8 * 0x10;
                *(undefined4 *)(&DAT_00341744 + *(int *)(s_pFaceEdges + iVar6) * 0xc) = uVar11;
                *(undefined4 *)(&DAT_00341744 + *(int *)(s_pFaceEdges + iVar6 + 4) * 0xc) = uVar11;
                iVar9 = *(int *)(s_pFaceEdges + iVar6 + 0xc);
                *(undefined4 *)(&DAT_00341744 + *(int *)(s_pFaceEdges + iVar6 + 8) * 0xc) = uVar11;
                *(undefined4 *)(&DAT_00341744 + iVar9 * 0xc) = uVar11;
              }
              else {
                aiStack_190[local_1d8] = -1;
              }
              local_1d8 = local_1d8 + 1;
            } while ((int)local_1d8 < 6);
            local_174 = 1.68156e-44;
            local_178 = local_12c;
            local_168 = local_12c;
            local_164 = &local_fc;
            local_170 = -NAN;
            local_16c = 0.0;
            local_160 = 0;
            local_1d8 = 0;
            do {
              if (*(int *)(&DAT_00341744 + local_1d8 * 0xc) == *(int *)(this + 700)) {
                (&DAT_00341748)[local_1d8 * 3] =
                     (uint)(local_f8[(uint)(byte)(&DAT_00341741)[local_1d8 * 0xc] * 3] <=
                           local_f8[(uint)(byte)(&s_pEdges)[local_1d8 * 0xc] * 3]);
                    /* try { // try from 001cebea to 001cec91 has its CatchHandler @ 001cedc7 */
                CUtlSortVector<int,WingedEdgeLessFunc>::Insert
                          ((CUtlSortVector<int,WingedEdgeLessFunc> *)&local_178,(int *)&local_1d8);
              }
              fVar13 = local_16c;
              local_1d8 = local_1d8 + 1;
            } while ((int)local_1d8 < 0xc);
            local_1d8 = 0;
            if (0 < (int)local_16c) {
              do {
                iVar6 = *(int *)(local_178 + local_1d8 * 4) * 0xc;
                iVar9 = (&DAT_00341748)[*(int *)(local_178 + local_1d8 * 4) * 3];
                CWingedEdgeList::AddEdge
                          ((CWingedEdgeList *)s_WingedTestEdgeList,
                           (Vector *)(local_f8 + (uint)(byte)(&s_pEdges)[iVar6 + iVar9] * 3 + -1),
                           (Vector *)
                           (local_f8 + (uint)(byte)(&DAT_00341741)[iVar6 + -iVar9] * 3 + -1),
                           aiStack_190[(byte)(&DAT_00341742)[iVar9 + iVar6]],
                           aiStack_190[*(byte *)(iVar6 + -iVar9 + 0x341743)]);
                local_1d8 = local_1d8 + 1;
              } while ((int)local_1d8 < (int)fVar13);
            }
            uVar11 = CWingedEdgeList::IsOccludingEdgeList
                               ((CWingedEdgeList *)(this + 0x1fc),
                                (CWingedEdgeList *)s_WingedTestEdgeList);
            if ((char)uVar11 != '\0') {
              *(int *)(this + 0x2c0) = *(int *)(this + 0x2c0) + 1;
            }
            local_16c = 0.0;
            CUtlMemory<int,int>::Purge((CUtlMemory<int,int> *)&local_178);
            local_168 = local_178;
            CUtlMemory<int,int>::Purge((CUtlMemory<int,int> *)&local_178);
            goto LAB_001ce4a5;
          }
        }
      }
    }
  }
LAB_001ce4a3:
  uVar11 = 0;
LAB_001ce4a5:
  iVar9 = _DAT_0040b9d4;
  DAT_003acf0c = DAT_003acf0c + -1;
  if (DAT_003acf0c == 0) {
    LOCK();
    UNLOCK();
    IsOccluded(Vector_const&,Vector_const&)::mutex = 0;
  }
  if (((DAT_0040b02c == '\0') || (_DAT_0040b028 != 0)) &&
     (iVar6 = ThreadGetCurrentId(), iVar9 == iVar6)) {
    cVar5 = CVProfNode::ExitScope();
    if (cVar5 != '\0') {
      _DAT_0040b030 = (int *)_DAT_0040b030[0x19];
    }
    DAT_0040b02c = _DAT_0040b030 == (int *)0x40b034;
  }
  if (local_1e0 != 0) {
    (**(code **)(local_1e0 + 0x54))(local_1e0,uVar2,uVar3,0,0,0);
  }
  return uVar11;
}

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)