L L4D2node

CVisibilityMonitor::FrameUpdatePostEntityThink

0x00664b50 · 1633 bytes · __thiscall

_ZN18CVisibilityMonitor26FrameUpdatePostEntityThinkEv

Decompiled

undefined (1 param)

/* CVisibilityMonitor::FrameUpdatePostEntityThink() */

void __thiscall CVisibilityMonitor::FrameUpdatePostEntityThink(CVisibilityMonitor *this)

{
  uint *puVar1;
  int iVar2;
  uint uVar3;
  CBaseEntity *this_00;
  code *pcVar4;
  char cVar5;
  int iVar6;
  CBaseEntity *this_01;
  undefined4 uVar7;
  Vector *pVVar8;
  int *piVar9;
  undefined *puVar10;
  uint *puVar11;
  uint uVar12;
  int iVar13;
  undefined4 local_44;
  int local_3c;
  undefined4 local_34;
  int local_30;
  int local_20 [4];
  
  uVar7 = debug_visibility_monitor._28_4_;
  if (*(float *)(this + 0x24) <= *(float *)(gpGlobals + 0xc)) {
    *(float *)(this + 0x24) =
         *(float *)(gpGlobals + 0xc) + *(float *)(vismon_poll_frequency._28_4_ + 0x2c);
    iVar2 = *(int *)(uVar7 + 0x30);
    local_30 = *(int *)(this + 0x18);
    if (*(int *)(this + 0x2c) < local_30) {
      *(int *)(this + 0x2c) = local_30;
    }
    if (1 < iVar2) {
      Msg("\nVisMon: Polling now. (Frequency: %f)\n",(double)*(float *)(this + 0x20));
      Msg("VisMon: Time: %f - Tracking %d Entities. (Max:%d)\n",(double)*(float *)(gpGlobals + 0xc),
          *(undefined4 *)(this + 0x18),*(undefined4 *)(this + 0x2c));
      local_30 = *(int *)(this + 0x18);
    }
    if (0 < local_30) {
      iVar6 = 0;
      do {
        while( true ) {
          puVar11 = (uint *)(*(int *)(this + 0xc) + iVar6 * 0x14);
          uVar12 = *puVar11;
          if ((((uVar12 != 0xffffffff) &&
               (puVar10 = g_pEntityList + (uVar12 & 0xfff) * 0x10,
               puVar10 != (undefined *)0xfffffffc)) && (*(uint *)(puVar10 + 8) == uVar12 >> 0xc)) &&
             (*(int *)(puVar10 + 4) != 0)) break;
          if (local_30 < 1) {
            local_30 = *(int *)(this + 0x18);
          }
          else {
            if (iVar6 != local_30 + -1) {
              puVar1 = (uint *)(*(int *)(this + 0xc) + (local_30 + -1) * 0x14);
              *puVar11 = *puVar1;
              puVar11[1] = puVar1[1];
              puVar11[2] = puVar1[2];
              puVar11[3] = puVar1[3];
              puVar11[4] = puVar1[4];
            }
            local_30 = *(int *)(this + 0x18) + -1;
            *(int *)(this + 0x18) = local_30;
          }
          if ((local_30 <= iVar6) || (iVar6 = iVar6 + 1, local_30 <= iVar6)) goto LAB_00664cb2;
        }
        iVar6 = iVar6 + 1;
        local_30 = *(int *)(this + 0x18);
      } while (iVar6 < local_30);
    }
LAB_00664cb2:
    local_3c = *(int *)(this + 0x30);
    local_20[0] = 0;
    if (local_30 <= local_3c) {
      if (1 < iVar2) {
        Msg("VisMon: RESET\n");
      }
      *(undefined4 *)(this + 0x30) = 0;
      local_3c = 0;
    }
    if (1 < iVar2) {
      Msg("VisMon: Starting at element: %d\n",local_3c);
      local_3c = *(int *)(this + 0x30);
    }
    if (local_3c < *(int *)(this + 0x18)) {
      local_30 = local_3c * 0x14;
      iVar6 = gpGlobals;
      do {
        if (0 < *(int *)(iVar6 + 0x14)) {
          iVar13 = 1;
          do {
            while( true ) {
              uVar12 = 1 << ((byte)iVar13 & 0x1f);
              this_01 = (CBaseEntity *)UTIL_PlayerByIndex(iVar13);
              if (((this_01 != (CBaseEntity *)0x0) &&
                  (cVar5 = (**(code **)(*(int *)this_01 + 300))(this_01), cVar5 != '\0')) &&
                 (cVar5 = (**(code **)(*(int *)this_01 + 0x778))(this_01), cVar5 == '\0')) break;
              puVar11 = (uint *)(local_30 + *(int *)(this + 0xc) + 8);
              *puVar11 = *puVar11 & ~uVar12;
LAB_00664d48:
              iVar13 = iVar13 + 1;
              iVar6 = gpGlobals;
              if (*(int *)(gpGlobals + 0x14) < iVar13) goto LAB_00664f00;
            }
            puVar11 = (uint *)(local_30 + *(int *)(this + 0xc));
            uVar3 = *puVar11;
            if ((((uVar3 == 0xffffffff) ||
                 (puVar10 = g_pEntityList + (uVar3 & 0xfff) * 0x10,
                 puVar10 == (undefined *)0xfffffffc)) || (*(uint *)(puVar10 + 8) != uVar3 >> 0xc))
               || (((this_00 = *(CBaseEntity **)(puVar10 + 4), this_00 == (CBaseEntity *)0x0 ||
                    ((uVar12 & puVar11[2]) != 0)) ||
                   (cVar5 = (**(code **)(*(int *)this + 0x44))(this,puVar11,this_01,local_20),
                   cVar5 == '\0')))) goto LAB_00664d48;
            pcVar4 = (code *)((uint *)(local_30 + *(int *)(this + 0xc)))[4];
            if (pcVar4 == (code *)0x0) {
LAB_00664f60:
              if (0 < iVar2) {
                CBaseEntity::GetDebugName(this_00);
                uVar7 = CBaseEntity::GetDebugName(this_01);
                Msg("VisMon: Player %s sees Entity: %s\n",uVar7);
                pVVar8 = (Vector *)(**(code **)(*(int *)this_00 + 0x288))(this_00);
                NDebugOverlay::Cross3D(pVVar8,16.0,0,0xff,0,false,10.0);
              }
              pcVar4 = (code *)((uint *)(local_30 + *(int *)(this + 0xc)))[3];
              if (pcVar4 == (code *)0x0) {
LAB_0066504f:
                piVar9 = (int *)(**(code **)(*gameeventmanager + 0x1c))
                                          (gameeventmanager,"entity_visible",0,0);
                if (piVar9 != (int *)0x0) {
                  pcVar4 = *(code **)(*piVar9 + 0x30);
                  (**(code **)(*engine + 0x40))(engine,*(undefined4 *)(this_01 + 0x30));
                  (*pcVar4)(piVar9,"userid");
                  (**(code **)(*piVar9 + 0x30))(piVar9,"subject");
                  (**(code **)(*piVar9 + 0x3c))(piVar9,"classname");
                  (**(code **)(*piVar9 + 0x3c))(piVar9,"entityname");
                  (**(code **)(*gameeventmanager + 0x20))(gameeventmanager);
                }
              }
              else {
                uVar3 = *(uint *)(local_30 + *(int *)(this + 0xc));
                local_34 = 0;
                if (((uVar3 != 0xffffffff) &&
                    (puVar10 = g_pEntityList + (uVar3 & 0xfff) * 0x10,
                    puVar10 != (undefined *)0xfffffffc)) && (*(uint *)(puVar10 + 8) == uVar3 >> 0xc)
                   ) {
                  local_34 = *(undefined4 *)(puVar10 + 4);
                }
                cVar5 = (*pcVar4)(local_34);
                if (cVar5 != '\0') goto LAB_0066504f;
              }
              puVar11 = (uint *)(local_30 + *(int *)(this + 0xc) + 8);
              *puVar11 = *puVar11 | uVar12;
              goto LAB_00664d48;
            }
            uVar3 = *(uint *)(local_30 + *(int *)(this + 0xc));
            local_44 = 0;
            if (((uVar3 != 0xffffffff) &&
                (puVar10 = g_pEntityList + (uVar3 & 0xfff) * 0x10,
                puVar10 != (undefined *)0xfffffffc)) && (*(uint *)(puVar10 + 8) == uVar3 >> 0xc)) {
              local_44 = *(undefined4 *)(puVar10 + 4);
            }
            cVar5 = (*pcVar4)(local_44);
            if (cVar5 != '\0') goto LAB_00664f60;
            if (iVar2 < 1) goto LAB_00664d48;
            iVar13 = iVar13 + 1;
            CBaseEntity::GetDebugName(this_00);
            uVar7 = CBaseEntity::GetDebugName(this_01);
            Msg("VisMon: Player %s IGNORING VISIBILE Entity: %s\n",uVar7);
            pVVar8 = (Vector *)(**(code **)(*(int *)this_00 + 0x288))(this_00);
            NDebugOverlay::Cross3D(pVVar8,16.0,0xff,0,0,false,10.0);
            iVar6 = gpGlobals;
          } while (iVar13 <= *(int *)(gpGlobals + 0x14));
        }
LAB_00664f00:
        if (*(int *)(vismon_trace_limit._28_4_ + 0x30) <= local_20[0]) {
          if (1 < iVar2) {
            Msg("VisMon: MAX Traces. Stopping after element %d\n",local_3c);
          }
          *(int *)(this + 0x30) = local_3c + 1;
          goto LAB_00664f33;
        }
        local_3c = local_3c + 1;
        local_30 = local_30 + 0x14;
      } while (local_3c < *(int *)(this + 0x18));
    }
    *(undefined4 *)(this + 0x30) = 0;
LAB_00664f33:
    if (*(int *)(this + 0x28) < local_20[0]) {
      *(int *)(this + 0x28) = local_20[0];
    }
    if (1 < iVar2) {
      Msg("VisMon: %d traces performed during this polling cycle (Max: %d)\n\n",local_20[0],
          *(undefined4 *)(this + 0x28));
    }
  }
  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)