L L4D2node

CPhysicsProp::Spawn

0x007eaaa0 · 2396 bytes · __thiscall

_ZN12CPhysicsProp5SpawnEv

Decompiled

undefined (1 param)

/* WARNING: Removing unreachable block (ram,0x007eb1cd) */
/* WARNING: Removing unreachable block (ram,0x007eadc4) */
/* WARNING: Removing unreachable block (ram,0x007eb421) */
/* WARNING: Removing unreachable block (ram,0x007eb408) */
/* CPhysicsProp::Spawn() */

void __thiscall CPhysicsProp::Spawn(CPhysicsProp *this)

{
  CGlowProperty *this_00;
  code *pcVar1;
  uint *puVar2;
  char cVar3;
  int iVar4;
  KeyValues *this_01;
  char *pcVar5;
  char *pcVar6;
  KeyValues *this_02;
  undefined4 uVar7;
  int *piVar8;
  CPhysicsProp CVar9;
  int *piVar10;
  int iVar11;
  uint uVar12;
  longdouble lVar13;
  float fVar14;
  float fVar15;
  float fVar16;
  undefined4 local_44;
  char *local_20 [4];
  
  CBaseEntity::SetNetworkQuantizeOriginAngAngles((CBaseEntity *)this,true);
  if (((byte)this[0x14a] & 0x40) != 0) {
    g_ActiveGibCount = g_ActiveGibCount + 1;
  }
  if ((*(char **)(this + 0x7c) == "physics_prop") ||
     (cVar3 = CBaseEntity::ClassMatchesComplex((CBaseEntity *)this,"physics_prop"), cVar3 != '\0'))
  {
    CBaseEntity::SetClassname((char *)this);
  }
  CBreakableProp::Spawn((CBreakableProp *)this);
  if (((byte)this[0x14c] & 1) != 0) {
    return;
  }
  *(undefined4 *)(this + 0x534) = 0x3dcccccd;
  (**(code **)(*(int *)this + 0x20))();
  pcVar5 = "";
  if (local_20[0] != (char *)0x0) {
    pcVar5 = local_20[0];
  }
  iVar11 = 0;
  do {
    local_44 = 0x7eab48;
    iVar4 = CTerrorWeaponInfo::GetWeaponInfo();
    if (iVar4 != 0) {
      if ((char *)(iVar4 + 0xf6) != pcVar5) {
        local_44 = 0x7eab65;
        iVar4 = _V_stricmp((char *)(iVar4 + 0xf6),pcVar5);
        if (iVar4 != 0) goto LAB_007eab6d;
      }
      local_44 = 0x7eb098;
      CBaseEntity::SetGlobalFadeScale((CBaseEntity *)this,0.0);
      local_44 = 0x7eb0b8;
      VisibilityMonitor_AddEntity
                ((CBaseEntity *)this,400.0,(_func_bool_CBaseEntity_ptr_CBasePlayer_ptr *)0x0,
                 (_func_bool_CBaseEntity_ptr_CBasePlayer_ptr *)0x0);
      if (*(char **)(this + 0x7c) != "prop_physics_override") goto LAB_007eab88;
      goto LAB_007eb0c5;
    }
LAB_007eab6d:
    iVar11 = iVar11 + 1;
  } while (iVar11 != 0x38);
  if (*(char **)(this + 0x7c) == "prop_physics_override") {
LAB_007eb0c5:
    local_44 = 0x7eb0d5;
    CBaseEntity::SetClassname((char *)this);
    uVar12 = *(uint *)(this + 0x148);
    if ((uVar12 & 4) != 0) goto LAB_007eabae;
LAB_007eb0e3:
    local_44 = 0x7eb0f6;
    cVar3 = (**(code **)(*(int *)this + 0x440))();
    if (cVar3 != '\0') {
      uVar12 = *(uint *)(this + 0x148);
      goto LAB_007eabae;
    }
    local_44 = 0x7eb188;
    cVar3 = (**(code **)(*(int *)this + 0x440))();
    if (cVar3 != '\0') {
      local_44 = 0x7eb1a0;
      CBaseEntity::SetCollisionGroup((CBaseEntity *)this,0xb);
    }
  }
  else {
LAB_007eab88:
    local_44 = 0x7eab98;
    cVar3 = CBaseEntity::ClassMatchesComplex((CBaseEntity *)this,"prop_physics_override");
    if (cVar3 != '\0') goto LAB_007eb0c5;
    uVar12 = *(uint *)(this + 0x148);
    if ((uVar12 & 4) == 0) goto LAB_007eb0e3;
LAB_007eabae:
    local_44 = 0x7eabc7;
    CBaseEntity::SetCollisionGroup((CBaseEntity *)this,2 - (uint)((uVar12 & 0x1000) == 0));
  }
  if (((byte)this[0x148] & 0x80) != 0) {
    *(uint *)(this + 0x14c) = *(uint *)(this + 0x14c) | 0x200000;
  }
  local_44 = 0x7eabdf;
  (**(code **)(*(int *)this + 0x290))();
  if (this[0x14ac] == (CPhysicsProp)0x0) {
    local_44 = 0x7eb170;
    CBaseProp::CalculateBlockLOS((CBaseProp *)this);
  }
  this_00 = (CGlowProperty *)(this + 0x1f0);
  local_44 = 0x7eac04;
  CGlowProperty::SetGlowState(this_00,*(int *)(this + 0x166c));
  local_44 = 0x7eac16;
  CGlowProperty::SetGlowRange(this_00,*(int *)(this + 0x1670));
  local_44 = 0x7eac28;
  CGlowProperty::SetGlowRangeMin(this_00,*(int *)(this + 0x1674));
  uVar12 = *(uint *)(this + 0x1678);
  local_44 = 0x7eac3a;
  CGlowProperty::SetGlowColorOverride();
  local_44 = 0x7eac46;
  this_01 = KeyValues::operator_new((KeyValues *)0x2c,uVar12);
                    /* try { // try from 007eac63 to 007eac67 has its CatchHandler @ 007eb40d */
  local_44 = 0x7eac68;
  KeyValues::KeyValues(this_01,"",(IKeyValuesSystem *)0x0,false);
  pcVar1 = *(code **)(*modelinfo + 0x54);
  local_44 = 0x7eac7a;
  CBaseEntity::GetModel((CBaseEntity *)this);
  local_44 = 0x7eac88;
  pcVar5 = (char *)(*pcVar1)();
  pcVar1 = *(code **)(*modelinfo + 0x10);
  local_44 = 0x7eac9f;
  CBaseEntity::GetModel((CBaseEntity *)this);
  local_44 = 0x7eacb0;
  pcVar6 = (char *)(*pcVar1)();
  local_44 = 0x7eacd0;
  cVar3 = KeyValues::LoadFromBuffer(this_01,pcVar6,pcVar5,(IBaseFileSystem *)0x0,(char *)0x0);
  piVar10 = (int *)&stack0xffffffc0;
  if (cVar3 != '\0') {
    local_44 = 0x7eacf0;
    this_02 = (KeyValues *)KeyValues::FindKey(this_01,"ai_addon",false);
    if (this_02 != (KeyValues *)0x0) {
      local_44 = 0x7ead0c;
      KeyValues::GetString(this_02,(char *)0x0,"");
      local_44 = 0x7ead1b;
      AllocPooledString((char *)local_20);
      *(char **)(this + 0x264) = local_20[0];
      KeyValues::deleteThis();
      return;
    }
    local_44 = 0x7ead45;
    (**(code **)(*(int *)this + 0x3c))();
    pcVar5 = "";
    if (local_20[0] != (char *)0x0) {
      pcVar5 = local_20[0];
    }
    piVar10 = &local_44;
    if (*pcVar5 == '\0') {
      *(char **)(this + 0x264) = "ai_addon_thrownprojectile";
      piVar10 = &local_44;
    }
  }
  *piVar10 = (int)this_01;
  piVar10[-1] = 0x7ead70;
  KeyValues::deleteThis();
  if (*(int *)(this + 0x1458) == 0) {
    piVar8 = *(int **)(this + 0x238);
    if (piVar8 == (int *)0x0) goto LAB_007eb382;
    iVar11 = *piVar8;
    *piVar10 = (int)piVar8;
    pcVar1 = *(code **)(iVar11 + 0x78);
    piVar10[-1] = 0x7ead94;
    lVar13 = (longdouble)(*pcVar1)();
    if (AllocTempVector()::s_vecTemp == '\0') {
      *piVar10 = (int)&AllocTempVector()::s_vecTemp;
      piVar10[-1] = 0x7eb321;
      iVar11 = __cxa_guard_acquire();
      if (iVar11 != 0) {
        *piVar10 = (int)&AllocTempVector()::s_vecTemp;
        piVar10[-1] = 0x7eb33a;
        __cxa_guard_release();
      }
    }
    if (AllocTempVector()::s_nIndex == '\0') {
      *piVar10 = (int)&AllocTempVector()::s_nIndex;
      piVar10[-1] = 0x7eb355;
      iVar11 = __cxa_guard_acquire();
      if (iVar11 != 0) {
        *piVar10 = (int)&AllocTempVector()::s_nIndex;
        AllocTempVector()::s_nIndex = 0;
        piVar10[-1] = 0x7eb378;
        __cxa_guard_release();
      }
    }
    AllocTempVector()::s_nIndex = AllocTempVector()::s_nIndex + 0x10001 & 0x7f;
    LOCK();
    UNLOCK();
    iVar11 = AllocTempVector()::s_nIndex * 0xc;
    *(float *)(AllocTempVector()::s_vecTemp + iVar11) =
         *(float *)(this + 0x1a8) - *(float *)(this + 0x19c);
    *(float *)(AllocTempVector()::s_vecTemp + iVar11 + 4) =
         *(float *)(this + 0x1ac) - *(float *)(this + 0x1a0);
    fVar14 = *(float *)(this + 0x1b0);
    fVar15 = *(float *)(this + 0x1a4);
    piVar10[3] = (int)(float)lVar13;
    *(float *)(AllocTempVector()::s_vecTemp + iVar11 + 8) = fVar14 - fVar15;
    *piVar10 = *(undefined4 *)(AllocTempVector()::s_vecTemp + iVar11);
    piVar10[1] = *(int *)(AllocTempVector()::s_vecTemp + iVar11 + 4);
    piVar10[2] = *(int *)(AllocTempVector()::s_vecTemp + iVar11 + 8);
    piVar10[-1] = 0x7eae48;
    uVar7 = GetAutoMultiplayerPhysicsMode();
    *(undefined4 *)(this + 0x1458) = uVar7;
  }
  if (((byte)this[0x149] & 0x20) != 0) {
    iVar11 = *(int *)this;
    piVar10[1] = 2;
    *piVar10 = (int)this;
    pcVar1 = *(code **)(iVar11 + 0x450);
    piVar10[-1] = 0x7eb142;
    (*pcVar1)();
  }
  if (*(int *)(this + 0x1458) == 3) {
    iVar11 = *engine;
    *piVar10 = (int)engine;
    pcVar1 = *(code **)(iVar11 + 0xc);
    piVar10[-1] = 0x7eb295;
    iVar11 = (*pcVar1)();
    if (iVar11 == 0) {
      piVar10[-1] = 0x7eb29e;
      piVar8 = (int *)CommandLine_Tier0();
      iVar11 = *piVar8;
      piVar10[1] = (int)"-makereslists";
      *piVar10 = (int)piVar8;
      pcVar1 = *(code **)(iVar11 + 0x28);
      piVar10[-1] = 0x7eb2ae;
      iVar11 = (*pcVar1)();
      if (iVar11 == 0) {
LAB_007eb382:
        UTIL_Remove((CBaseEntity *)this);
        return;
      }
    }
    iVar11 = *(int *)this;
    piVar10[1] = 2;
    *piVar10 = (int)this;
    pcVar1 = *(code **)(iVar11 + 0x450);
    piVar10[-1] = 0x7eb2c9;
    (*pcVar1)();
  }
  if (*(int *)(DebugZombieBreakables._28_4_ + 0x30) == 0) {
    if (*(int *)(this + 0x1658) == 2) {
      iVar11 = *(int *)this;
      piVar10[1] = 0x11;
      *piVar10 = (int)this;
      pcVar1 = *(code **)(iVar11 + 0x43c);
      piVar10[-1] = 0x7eb3a4;
      (*pcVar1)();
    }
    else if (*(int *)(this + 0x1658) == 1) {
      iVar11 = *(int *)this;
      piVar10[1] = 0x12;
      *piVar10 = (int)this;
      pcVar1 = *(code **)(iVar11 + 0x43c);
      piVar10[-1] = 0x7eb2fc;
      (*pcVar1)();
    }
  }
  iVar11 = *(int *)this;
  piVar10[1] = 0x11;
  *piVar10 = (int)this;
  pcVar1 = *(code **)(iVar11 + 0x440);
  piVar10[-1] = 0x7eae9f;
  cVar3 = (*pcVar1)();
  if (cVar3 != '\0') {
    if (this[0x167d] != (CPhysicsProp)0x1) {
      if (this[0x6c] == (CPhysicsProp)0x0) {
        puVar2 = *(uint **)(this + 0x30);
        if (puVar2 != (uint *)0x0) {
          *puVar2 = *puVar2 | 0x101;
          *piVar10 = (int)puVar2;
          piVar10[-1] = 0x7eaecf;
          iVar11 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*piVar10);
          *(undefined2 *)(iVar11 + 2) = 0;
        }
      }
      else {
        this[0x70] = (CPhysicsProp)((byte)this[0x70] | 1);
      }
      this[0x167d] = (CPhysicsProp)0x1;
    }
    uVar12 = *(uint *)(this + 0x148) | 0x1000;
    if (*(uint *)(this + 0x148) != uVar12) {
      if (this[0x6c] == (CPhysicsProp)0x0) {
        puVar2 = *(uint **)(this + 0x30);
        if (puVar2 != (uint *)0x0) {
          *puVar2 = *puVar2 | 0x101;
          *piVar10 = (int)puVar2;
          piVar10[-1] = 0x7eaf0d;
          iVar11 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*piVar10);
          *(undefined2 *)(iVar11 + 2) = 0;
        }
      }
      else {
        this[0x70] = (CPhysicsProp)((byte)this[0x70] | 1);
      }
      *(uint *)(this + 0x148) = uVar12;
    }
    piVar10[1] = 0;
    *piVar10 = (int)this;
    piVar10[-1] = 0x7eaf29;
    CBaseEntity::SetAIWalkable((CBaseEntity *)*piVar10,SUB41(piVar10[1],0));
    iVar11 = *TheNavMesh;
    piVar10[1] = (int)this;
    *piVar10 = (int)TheNavMesh;
    pcVar1 = *(code **)(iVar11 + 0x54);
    piVar10[-1] = 0x7eaf3a;
    (*pcVar1)();
  }
  iVar11 = *(int *)this;
  piVar10[1] = 0x12;
  *piVar10 = (int)this;
  pcVar1 = *(code **)(iVar11 + 0x440);
  piVar10[-1] = 0x7eaf4d;
  cVar3 = (*pcVar1)();
  if (cVar3 != '\0') {
    uVar12 = *(uint *)(this + 0x148) | 0x2000;
    if (*(uint *)(this + 0x148) != uVar12) {
      if (this[0x6c] == (CPhysicsProp)0x0) {
        puVar2 = *(uint **)(this + 0x30);
        if (puVar2 != (uint *)0x0) {
          *puVar2 = *puVar2 | 0x101;
          *piVar10 = (int)puVar2;
          piVar10[-1] = 0x7eaf84;
          iVar11 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*piVar10);
          *(undefined2 *)(iVar11 + 2) = 0;
        }
      }
      else {
        this[0x70] = (CPhysicsProp)((byte)this[0x70] | 1);
      }
      *(uint *)(this + 0x148) = uVar12;
    }
    piVar10[1] = 0;
    *piVar10 = (int)this;
    piVar10[-1] = 0x7eaf9e;
    CBaseEntity::SetAIWalkable((CBaseEntity *)*piVar10,SUB41(piVar10[1],0));
    iVar11 = *TheNavMesh;
    piVar10[1] = (int)this;
    *piVar10 = (int)TheNavMesh;
    pcVar1 = *(code **)(iVar11 + 0x54);
    piVar10[-1] = 0x7eafaf;
    (*pcVar1)();
  }
  iVar11 = *(int *)this;
  *piVar10 = (int)this;
  pcVar1 = *(code **)(iVar11 + 0xa4);
  piVar10[-1] = 0x7eafba;
  uVar12 = (*pcVar1)();
  CVar9 = (CPhysicsProp)((byte)(uVar12 >> 9) & 1);
  if (CVar9 != this[0x167e]) {
    if (this[0x6c] == (CPhysicsProp)0x0) {
      puVar2 = *(uint **)(this + 0x30);
      if (puVar2 != (uint *)0x0) {
        *puVar2 = *puVar2 | 0x101;
        *piVar10 = (int)puVar2;
        piVar10[-1] = 0x7eafee;
        iVar11 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*piVar10);
        *(undefined2 *)(iVar11 + 2) = 0;
      }
    }
    else {
      this[0x70] = (CPhysicsProp)((byte)this[0x70] | 1);
    }
    this[0x167e] = CVar9;
  }
  if ((((byte)this[0x148] & 8) == 0) && (piVar8 = *(int **)(this + 0x238), piVar8 != (int *)0x0)) {
    iVar11 = *piVar8;
    *piVar10 = (int)piVar8;
    pcVar1 = *(code **)(iVar11 + 0x78);
    piVar10[-1] = 0x7eb016;
    lVar13 = (longdouble)(*pcVar1)();
    if (100.0 <= (float)lVar13) {
      if (AllocTempVector()::s_vecTemp == '\0') {
        *piVar10 = (int)&AllocTempVector()::s_vecTemp;
        piVar10[-1] = 0x7eb3be;
        iVar11 = __cxa_guard_acquire();
        if (iVar11 != 0) {
          *piVar10 = (int)&AllocTempVector()::s_vecTemp;
          piVar10[-1] = 0x7eb3d2;
          __cxa_guard_release();
        }
      }
      if (AllocTempVector()::s_nIndex == '\0') {
        *piVar10 = (int)&AllocTempVector()::s_nIndex;
        piVar10[-1] = 0x7eb3e3;
        iVar11 = __cxa_guard_acquire();
        if (iVar11 != 0) {
          *piVar10 = (int)&AllocTempVector()::s_nIndex;
          AllocTempVector()::s_nIndex = 0;
          piVar10[-1] = 0x7eb401;
          __cxa_guard_release();
        }
      }
      AllocTempVector()::s_nIndex = AllocTempVector()::s_nIndex + 0x10001 & 0x7f;
      LOCK();
      UNLOCK();
      iVar11 = AllocTempVector()::s_nIndex * 0xc;
      fVar15 = *(float *)(this + 0x1a8) - *(float *)(this + 0x19c);
      *(float *)(AllocTempVector()::s_vecTemp + iVar11) = fVar15;
      fVar14 = *(float *)(this + 0x1ac) - *(float *)(this + 0x1a0);
      *(float *)(AllocTempVector()::s_vecTemp + iVar11 + 4) = fVar14;
      fVar16 = *(float *)(this + 0x1b0) - *(float *)(this + 0x1a4);
      *(float *)(AllocTempVector()::s_vecTemp + iVar11 + 8) = fVar16;
      if ((10000.0 < fVar14 * fVar14 + fVar16 * fVar16 + fVar15 * fVar15) &&
         (this[0x167d] != (CPhysicsProp)0x1)) {
        if (this[0x6c] == (CPhysicsProp)0x0) {
          puVar2 = *(uint **)(this + 0x30);
          if (puVar2 != (uint *)0x0) {
            *puVar2 = *puVar2 | 0x101;
            *piVar10 = (int)puVar2;
            piVar10[-1] = 0x7eb276;
            iVar11 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*piVar10);
            *(undefined2 *)(iVar11 + 2) = 0;
          }
        }
        else {
          this[0x70] = (CPhysicsProp)((byte)this[0x70] | 1);
        }
        this[0x167d] = (CPhysicsProp)0x1;
      }
    }
  }
  iVar11 = *(int *)this;
  *piVar10 = (int)this;
  pcVar1 = *(code **)(iVar11 + 0x470);
  piVar10[-1] = 0x7eb03b;
  cVar3 = (*pcVar1)();
  if (cVar3 != '\0') {
    piVar10[1] = (int)(this + 0x154c);
    *piVar10 = (int)TheNavMesh;
    piVar10[-1] = 0x7eb15e;
    CNavMesh::RegisterAvoidanceObstacle((CNavMesh *)*piVar10,(INavAvoidanceObstacle *)piVar10[1]);
  }
  if (this[0x1548] == (CPhysicsProp)0x0) {
    if (this[0x6c] == (CPhysicsProp)0x0) {
      puVar2 = *(uint **)(this + 0x30);
      if (puVar2 != (uint *)0x0) {
        *puVar2 = *puVar2 | 0x101;
        *piVar10 = (int)puVar2;
        piVar10[-1] = 0x7eb06f;
        iVar11 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*piVar10);
        *(undefined2 *)(iVar11 + 2) = 0;
      }
    }
    else {
      this[0x70] = (CPhysicsProp)((byte)this[0x70] | 1);
    }
    this[0x1548] = (CPhysicsProp)0x1;
  }
  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)