L L4D2node

CDirectorItemManager::SpawnWeapons

0x008a6ae0 · 1366 bytes · __thiscall

_ZN20CDirectorItemManager12SpawnWeaponsEv

Decompiled

undefined (1 param)

/* CDirectorItemManager::SpawnWeapons() */

void __thiscall CDirectorItemManager::SpawnWeapons(CDirectorItemManager *this)

{
  uint uVar1;
  CBaseEntity *this_00;
  char cVar2;
  KeyValues *this_01;
  char *pcVar3;
  int iVar4;
  undefined4 *puVar5;
  CMapInfo *this_02;
  EntityLocationInfo *pEVar6;
  undefined *puVar7;
  int iVar8;
  float fVar9;
  longdouble lVar10;
  CUtlVector<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>,CUtlMemory<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>,int>>
  *local_a4;
  undefined4 local_90;
  undefined4 local_8c;
  undefined4 local_88;
  undefined4 local_84;
  undefined4 local_80;
  undefined4 local_7c;
  undefined4 local_78;
  undefined4 local_74;
  undefined4 local_70;
  undefined4 local_6c;
  undefined4 local_68;
  undefined4 local_64;
  undefined4 local_60;
  undefined4 local_5c;
  undefined4 local_58;
  undefined4 local_54;
  char *local_50;
  undefined1 local_4c;
  undefined4 local_48;
  undefined4 local_44;
  undefined4 local_40;
  undefined4 local_3c;
  undefined4 local_38;
  int local_34 [5];
  undefined1 local_20;
  
  this_01 = (KeyValues *)CTerrorGameRules::GetMissionCurrentMap((KeyValues **)0x0);
  if (this_01 != (KeyValues *)0x0) {
    cVar2 = CTerrorGameRules::IsVersusMode();
    if (cVar2 == '\0') {
      pcVar3 = (char *)KeyValues::GetString(this_01,"revisit_source",(char *)0x0);
      if (pcVar3 == (char *)0x0) goto LAB_008a6bf8;
    }
    else {
      if (*(char *)(TheDirector + 0x4e5) == '\0') goto LAB_008a6bf8;
      pcVar3 = *(char **)(gpGlobals + 0x3c);
      if (pcVar3 == (char *)0x0) {
        pcVar3 = "";
      }
    }
    iVar4 = GetMapRevisitPopulationInfo(this,pcVar3);
    if (iVar4 != 0) {
      if (*(int *)(director_debug_revisit._28_4_ + 0x30) != 0) {
        DevMsg("REVISIT: revisit source found, deleting all weapon_spawn entities\n");
      }
      iVar4 = *(int *)(this + 0x43c);
      iVar8 = 0;
      if (0 < iVar4) {
        do {
          while ((((uVar1 = *(uint *)(*(int *)(this + 0x430) + iVar8 * 4), uVar1 != 0xffffffff &&
                   (puVar7 = g_pEntityList + (uVar1 & 0xfff) * 0x10,
                   puVar7 != (undefined *)0xfffffffc)) && (*(uint *)(puVar7 + 8) == uVar1 >> 0xc))
                 && (*(CBaseEntity **)(puVar7 + 4) != (CBaseEntity *)0x0))) {
            iVar8 = iVar8 + 1;
            UTIL_Remove(*(CBaseEntity **)(puVar7 + 4));
            if (iVar8 == iVar4) goto LAB_008a6bbd;
          }
          iVar8 = iVar8 + 1;
        } while (iVar8 != iVar4);
      }
LAB_008a6bbd:
      *(undefined4 *)(this + 0x43c) = 0;
      return;
    }
  }
LAB_008a6bf8:
  iVar4 = *(int *)(this + 0x43c);
  this[0x3d8] = (CDirectorItemManager)0x0;
  *(char **)(this + 0x3d4) = "weapon_spawn";
  this[0x404] = (CDirectorItemManager)0x1;
  *(undefined4 *)(this + 1000) = 0;
  local_48 = 0;
  *(undefined4 *)(this + 0x3fc) = 0;
  local_44 = 0;
  local_40 = 0;
  local_3c = 0;
  local_38 = 0;
  local_34[0] = 0;
  local_34[1] = 0;
  local_34[2] = 0;
  local_34[3] = 0;
  local_34[4] = 0;
  local_50 = "weapon_spawn";
  local_4c = 0;
  local_20 = 1;
  if (0 < iVar4) {
    iVar8 = 0;
    do {
      while (((uVar1 = *(uint *)(*(int *)(this + 0x430) + iVar8 * 4), uVar1 == 0xffffffff ||
              (puVar7 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar7 == (undefined *)0xfffffffc))
             || ((*(uint *)(puVar7 + 8) != uVar1 >> 0xc ||
                 ((this_00 = *(CBaseEntity **)(puVar7 + 4), this_00 == (CBaseEntity *)0x0 ||
                  ((*(uint *)(this_00 + 0x14c) & 1) != 0))))))) {
LAB_008a6ca0:
        iVar8 = iVar8 + 1;
        if (iVar8 == iVar4) goto LAB_008a6e48;
      }
      local_74 = 0xffffffff;
      if ((*(uint *)(this_00 + 0x14c) & 0x800) == 0) {
        local_90 = *(undefined4 *)(this_00 + 0x2e0);
        local_8c = *(undefined4 *)(this_00 + 0x2e4);
        local_88 = *(undefined4 *)(this_00 + 0x2e8);
      }
      else {
        CBaseEntity::CalcAbsolutePosition(this_00);
        local_90 = *(undefined4 *)(this_00 + 0x2e0);
        local_8c = *(undefined4 *)(this_00 + 0x2e4);
        local_88 = *(undefined4 *)(this_00 + 0x2e8);
        if ((*(uint *)(this_00 + 0x14c) & 0x800) != 0) {
          CBaseEntity::CalcAbsolutePosition(this_00);
        }
      }
      local_84 = *(undefined4 *)(this_00 + 0x37c);
      local_78 = 0;
      local_80 = *(undefined4 *)(this_00 + 0x380);
      local_7c = *(undefined4 *)(this_00 + 900);
                    /* try { // try from 008a6d63 to 008a702e has its CatchHandler @ 008a7053 */
      puVar5 = (undefined4 *)(**(code **)(*(int *)this_00 + 0xc))(this_00);
      local_74 = *puVar5;
      CUtlVector<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>,CUtlMemory<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>,int>>
      ::InsertBefore((CUtlVector<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>,CUtlMemory<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>,int>>
                      *)local_34,local_34[3],(EntityLocationInfo *)&local_90);
      if ((this_00[0x1480] != (CBaseEntity)0x0) || (((byte)this_00[0x148] & 2) != 0))
      goto LAB_008a6ca0;
      local_54 = 0xffffffff;
      if (((byte)this_00[0x14d] & 8) == 0) {
        local_70 = *(undefined4 *)(this_00 + 0x2e0);
        local_6c = *(undefined4 *)(this_00 + 0x2e4);
        local_68 = *(undefined4 *)(this_00 + 0x2e8);
      }
      else {
        CBaseEntity::CalcAbsolutePosition(this_00);
        local_70 = *(undefined4 *)(this_00 + 0x2e0);
        local_6c = *(undefined4 *)(this_00 + 0x2e4);
        local_68 = *(undefined4 *)(this_00 + 0x2e8);
        if ((*(uint *)(this_00 + 0x14c) & 0x800) != 0) {
          CBaseEntity::CalcAbsolutePosition(this_00);
        }
      }
      local_64 = *(undefined4 *)(this_00 + 0x37c);
      local_58 = 0;
      local_60 = *(undefined4 *)(this_00 + 0x380);
      local_5c = *(undefined4 *)(this_00 + 900);
      puVar5 = (undefined4 *)(**(code **)(*(int *)this_00 + 0xc))(this_00);
      local_54 = *puVar5;
      CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>,int>>
      ::InsertBefore((CUtlVector<EntityLocationInfo<CHandle<CBaseEntity>>,CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity>>,int>>
                      *)(this + 0x3f0),*(int *)(this + 0x3fc),(EntityLocationInfo *)&local_70);
      iVar8 = iVar8 + 1;
    } while (iVar8 != iVar4);
  }
LAB_008a6e48:
  local_a4 = (CUtlVector<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>,CUtlMemory<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>,int>>
              *)local_34;
  *(undefined4 *)(this + 0x43c) = 0;
  CUtlVector<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>,CUtlMemory<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>,int>>
  ::Sort(local_a4,WeaponSpawnSort);
  fVar9 = *(float *)(director_weapon_cluster_range._28_4_ + 0x2c);
  this_02 = (CMapInfo *)GetMapInfo();
  if (this_02 != (CMapInfo *)0x0) {
    lVar10 = (longdouble)CMapInfo::GetConfigurableWeaponClusterRange(this_02);
    fVar9 = (float)lVar10;
  }
  CollateEncounters<CHandle<CWeaponSpawnConfigurable>>
            (this,(EntityPopulationInfo *)&local_50,false,fVar9,(CUtlVector *)0x0);
  CollateEncounters<CHandle<CBaseEntity>>
            (this,(EntityPopulationInfo *)(this + 0x3d4),false,fVar9,(CUtlVector *)0x0);
  iVar4 = local_34[3];
  iVar8 = 0;
  if (0 < local_34[3]) {
    do {
      while ((((pEVar6 = (EntityLocationInfo *)(iVar8 * 0x20 + local_34[0]),
               pEVar6 == (EntityLocationInfo *)0x0 ||
               (uVar1 = *(uint *)(pEVar6 + 0x1c), uVar1 == 0xffffffff)) ||
              (puVar7 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar7 == (undefined *)0xfffffffc))
             || ((*(uint *)(puVar7 + 8) != uVar1 >> 0xc ||
                 (*(CWeaponSpawnConfigurable **)(puVar7 + 4) == (CWeaponSpawnConfigurable *)0x0)))))
      {
        iVar8 = iVar8 + 1;
        if (iVar8 == iVar4) goto LAB_008a6f3d;
      }
      CWeaponSpawnConfigurable::MakeWeaponSelection
                (*(CWeaponSpawnConfigurable **)(puVar7 + 4),pEVar6);
      iVar8 = iVar8 + 1;
    } while (iVar8 != iVar4);
  }
LAB_008a6f3d:
  local_34[3] = 0;
  CUtlMemory<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>,int>::Purge
            ((CUtlMemory<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>,int> *)local_a4);
  local_34[4] = local_34[0];
  CUtlMemory<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>,int>::Purge
            ((CUtlMemory<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>,int> *)local_a4);
  local_3c = 0;
  CUtlMemory<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>*,int>::Purge
            ((CUtlMemory<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>*,int> *)&local_48);
  local_38 = local_48;
  CUtlMemory<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>*,int>::Purge
            ((CUtlMemory<EntityLocationInfo<CHandle<CWeaponSpawnConfigurable>>*,int> *)&local_48);
  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)