L L4D2node

CDirectorItemManager::PopulateWorldWithItems

0x008a72f0 · 3307 bytes · __thiscall

_ZN20CDirectorItemManager22PopulateWorldWithItemsEv

Decompiled

undefined (1 param)

/* CDirectorItemManager::PopulateWorldWithItems() */

void __thiscall CDirectorItemManager::PopulateWorldWithItems(CDirectorItemManager *this)

{
  CBaseEdict *pCVar1;
  char cVar2;
  int *piVar3;
  CMapInfo *this_00;
  KeyValues *this_01;
  int iVar4;
  int iVar5;
  int iVar6;
  int iVar7;
  int iVar8;
  int iVar9;
  undefined4 uVar10;
  CBaseEntity *pCVar11;
  int iVar12;
  uint uVar13;
  float fVar14;
  int iVar15;
  int iVar16;
  int iVar17;
  char *pcVar18;
  int iVar19;
  undefined4 *puVar20;
  longdouble lVar21;
  int local_60;
  int local_5c;
  float local_50;
  float local_44;
  int local_40 [3];
  int local_34;
  int local_30;
  int local_2c;
  int local_28;
  int local_24;
  uint local_20;
  
  if (DAT_00fe6000 < 1) {
    local_50 = 0.0;
  }
  else {
    local_50 = 0.0;
    piVar3 = TheNavAreas;
    do {
      iVar15 = *piVar3;
      if ((0.0 < *(float *)(iVar15 + 0x154) || *(float *)(iVar15 + 0x154) == 0.0) &&
         ((*(byte *)(iVar15 + 300) & 0x40) == 0)) {
        local_50 = local_50 +
                   (*(float *)(iVar15 + 0x14) - *(float *)(iVar15 + 8)) *
                   (*(float *)(iVar15 + 0x10) - *(float *)(iVar15 + 4));
      }
      piVar3 = piVar3 + 1;
    } while (piVar3 != TheNavAreas + DAT_00fe6000);
    local_50 = local_50 * 7.716049e-08;
  }
  if (*(int *)(director_debug_scavenge_items._28_4_ + 0x30) != 0) {
    DevMsg("Total walkable area = %f sq 100 yards\n",(double)local_50);
  }
  this_00 = (CMapInfo *)GetMapInfo();
  if (this_00 == (CMapInfo *)0x0) {
    return;
  }
  this_01 = (KeyValues *)CTerrorGameRules::GetMissionCurrentMap((KeyValues **)0x0);
  if (this_01 != (KeyValues *)0x0) {
    cVar2 = CTerrorGameRules::IsVersusMode();
    if (cVar2 == '\0') {
      pcVar18 = (char *)KeyValues::GetString(this_01,"revisit_source",(char *)0x0);
      if (pcVar18 == (char *)0x0) goto LAB_008a73bb;
    }
    else {
      if (TheDirector[0x4e5] == (CDirector)0x0) goto LAB_008a73bb;
      pcVar18 = *(char **)(gpGlobals + 0x3c);
      if (pcVar18 == (char *)0x0) {
        pcVar18 = "";
      }
    }
    iVar15 = GetMapRevisitPopulationInfo(this,pcVar18);
    if ((iVar15 != 0) && (iVar15 = GetMapRevisitPopulationInfo(this,pcVar18), iVar15 != 0)) {
      if (*(int *)(director_debug_revisit._28_4_ + 0x30) != 0) {
        DevMsg("REVISIT: revisit source found, removing all items\n");
      }
      RemoveAllItems();
      if (*(int *)(iVar15 + 0x8c) < 1) {
        fVar14 = 0.0;
      }
      else {
        local_5c = 0;
        local_60 = 0;
        local_50 = 0.0;
        do {
          puVar20 = (undefined4 *)(local_5c + *(int *)(iVar15 + 0x80));
          if (0 < (int)puVar20[5]) {
            iVar4 = 0;
            do {
              while( true ) {
                piVar3 = (int *)(puVar20[2] + iVar4 * 0x24);
                local_40[0] = *piVar3;
                local_40[1] = piVar3[1];
                local_40[2] = piVar3[2];
                local_34 = piVar3[3];
                local_30 = piVar3[4];
                local_2c = piVar3[5];
                local_28 = piVar3[6];
                local_24 = piVar3[7];
                local_20 = piVar3[8];
                if (puVar20[1] != 1) break;
                if (*(int *)(director_debug_revisit._28_4_ + 0x30) != 0) {
                  DevMsg("REVISIT: restoring prop_physics ( %s )\n",*puVar20);
                }
                pCVar11 = (CBaseEntity *)CreateEntityByName("prop_physics",-1,true);
                if (pCVar11 != (CBaseEntity *)0x0) {
                  (**(code **)(*(int *)pCVar11 + 0x70))(pCVar11,*puVar20);
                  CBaseEntity::SetAbsOrigin(pCVar11,(Vector *)local_40);
                  CBaseEntity::SetAbsAngles(pCVar11,(QAngle *)&local_34);
                  DispatchSpawn(pCVar11,true);
                }
LAB_008a7b3e:
                iVar4 = iVar4 + 1;
                if ((int)puVar20[5] <= iVar4) goto LAB_008a7ca9;
              }
              iVar5 = CreateEntityByName((char *)*puVar20,-1,true);
              if ((iVar5 == 0) ||
                 (pCVar11 = (CBaseEntity *)
                            __dynamic_cast(iVar5,&CBaseEntity::typeinfo,&CWeaponSpawn::typeinfo,0),
                 pCVar11 == (CBaseEntity *)0x0)) goto LAB_008a7b3e;
              if (*(int *)(director_debug_revisit._28_4_ + 0x30) != 0) {
                DevMsg("REVISIT: restoring %s\n",*puVar20);
              }
              CBaseEntity::SetAbsOrigin(pCVar11,(Vector *)local_40);
              CBaseEntity::SetAbsAngles(pCVar11,(QAngle *)&local_34);
              uVar13 = *(uint *)(pCVar11 + 0x148) | 0x8000;
              if (*(uint *)(pCVar11 + 0x148) != uVar13) {
                if (pCVar11[0x6c] == (CBaseEntity)0x0) {
                  pCVar1 = *(CBaseEdict **)(pCVar11 + 0x30);
                  if (pCVar1 != (CBaseEdict *)0x0) {
                    *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
                    iVar5 = CBaseEdict::GetChangeAccessor(pCVar1);
                    *(undefined2 *)(iVar5 + 2) = 0;
                  }
                }
                else {
                  pCVar11[0x70] = (CBaseEntity)((byte)pCVar11[0x70] | 1);
                }
                *(uint *)(pCVar11 + 0x148) = uVar13;
              }
              *(int *)(pCVar11 + 0x144c) = local_24;
              if (puVar20[1] == 2) {
                (**(code **)(*(int *)pCVar11 + 0x3d8))(pCVar11,local_28);
                if (*(int *)(director_debug_revisit._28_4_ + 0x30) != 0) {
                  DevMsg("REVISIT: ( weaponid = %d )\n",local_28);
                }
                cVar2 = CTerrorGameRules::IsGenericCooperativeMode();
                if (cVar2 != '\0') {
                  *(undefined4 *)(pCVar11 + 0x144c) = 5;
                }
              }
              else if ((puVar20[1] == 3) &&
                      (iVar5 = __dynamic_cast(pCVar11,&CWeaponSpawn::typeinfo,
                                              &CWeaponMeleeSpawn::typeinfo,0), iVar5 != 0)) {
                if (*(int *)(director_debug_revisit._28_4_ + 0x30) != 0) {
                  DevMsg("REVISIT: ( melee info handle = %d )\n",local_28);
                }
                *(int *)(iVar5 + 0x1468) = local_28;
                uVar13 = local_20 | *(uint *)(iVar5 + 0x148);
                if (*(uint *)(iVar5 + 0x148) != uVar13) {
                  if (*(char *)(iVar5 + 0x6c) == '\0') {
                    pCVar1 = *(CBaseEdict **)(iVar5 + 0x30);
                    if (pCVar1 != (CBaseEdict *)0x0) {
                      *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
                      iVar6 = CBaseEdict::GetChangeAccessor(pCVar1);
                      *(undefined2 *)(iVar6 + 2) = 0;
                    }
                  }
                  else {
                    *(byte *)(iVar5 + 0x70) = *(byte *)(iVar5 + 0x70) | 1;
                  }
                  *(uint *)(iVar5 + 0x148) = uVar13;
                }
              }
              iVar5 = (**(code **)(*(int *)pCVar11 + 0x3cc))(pCVar11);
              if (iVar5 - 0xdU < 0xd) {
                local_50 = (float)(((int)local_50 + 1) -
                                  (uint)((1 << ((byte)(iVar5 - 0xdU) & 0x1f) & 0x1c07U) == 0));
              }
              iVar4 = iVar4 + 1;
              DispatchSpawn(pCVar11,true);
            } while (iVar4 < (int)puVar20[5]);
          }
LAB_008a7ca9:
          local_60 = local_60 + 1;
          local_5c = local_5c + 0x1c;
        } while (local_60 < *(int *)(iVar15 + 0x8c));
        fVar14 = (float)0;
        if (-1 < (int)local_50) {
          fVar14 = local_50;
        }
      }
      *(undefined4 *)(this + 0x1c) = 0;
      this[0x28] = (CDirectorItemManager)0x1;
      *(undefined4 *)(this + 0x24) = 0;
      CollectAllItemLocations(this);
      CL4D_GameStats._932_4_ = fVar14;
      return;
    }
  }
LAB_008a73bb:
  if (local_50 <= 0.0) {
    local_50 = 1.0;
  }
  lVar21 = (longdouble)CMapInfo::GetDefibrillatorDensity(this_00);
  iVar15 = (int)((float)lVar21 * local_50);
  cVar2 = CTerrorGameRules::IsVersusMode();
  if (((cVar2 != '\0') || (cVar2 = CTerrorGameRules::IsScavengeMode(), cVar2 != '\0')) &&
     (0 < iVar15)) {
    iVar15 = 1;
  }
  iVar15 = PopulateItems<CHandle<CBaseEntity>>(this,this + 0x270,iVar15,1);
  lVar21 = (longdouble)CMapInfo::GetPainPillDensity(this_00);
  iVar4 = PopulateItems<CHandle<CBaseEntity>>(this,this + 0x34,(int)((float)lVar21 * local_50),1);
  lVar21 = (longdouble)CMapInfo::GetMolotovDensity(this_00);
  iVar5 = PopulateItems<CHandle<CBaseEntity>>(this,this + 0x68,(int)((float)lVar21 * local_50),1);
  lVar21 = (longdouble)CMapInfo::GetPipeBombDensity(this_00);
  iVar6 = PopulateItems<CHandle<CBaseEntity>>(this,this + 0xd0,(int)((float)lVar21 * local_50),1);
  lVar21 = (longdouble)CMapInfo::GetAdrenalineDensity(this_00);
  iVar7 = PopulateItems<CHandle<CBaseEntity>>(this,this + 0x23c,(int)((float)lVar21 * local_50),1);
  lVar21 = (longdouble)CMapInfo::GetVomitJarDensity(this_00);
  iVar8 = PopulateItems<CHandle<CBaseEntity>>(this,this + 0x2a4,(int)((float)lVar21 * local_50),1);
  lVar21 = (longdouble)CMapInfo::GetMeleeWeaponDensity(this_00);
  PopulateItems<CHandle<CBaseEntity>>(this,this + 0x208,(int)((float)lVar21 * local_50),1);
  lVar21 = (longdouble)CMapInfo::GetAmmoDensity(this_00);
  PopulateItems<CHandle<CBaseEntity>>(this,this + 0x9c,(int)((float)lVar21 * local_50),1);
  lVar21 = (longdouble)CMapInfo::GetPistolDensity(this_00);
  PopulateItems<CHandle<CBaseEntity>>(this,this + 0x104,(int)((float)lVar21 * local_50),1);
  lVar21 = (longdouble)CMapInfo::GetGasCanDensity(this_00);
  PopulateItems<CHandle<CBaseEntity>>(this,this + 0x16c,(int)((float)lVar21 * local_50),1);
  lVar21 = (longdouble)CMapInfo::GetPropaneTankDensity(this_00);
  PopulateItems<CHandle<CBaseEntity>>(this,this + 0x1a0,(int)((float)lVar21 * local_50),1);
  lVar21 = (longdouble)CMapInfo::GetOxygenTankDensity(this_00);
  PopulateItems<CHandle<CBaseEntity>>(this,this + 0x1d4,(int)((float)lVar21 * local_50),1);
  lVar21 = (longdouble)CMapInfo::GetUpgradePackDensity(this_00);
  PopulateItems<CHandle<CBaseEntity>>(this,this + 0x30c,(int)((float)lVar21 * local_50),1);
  cVar2 = CMapInfo::ShouldCullConfigurableWeapons(this_00);
  if (cVar2 != '\0') {
    lVar21 = (longdouble)CMapInfo::GetConfigurableWeaponDensity(this_00);
    PopulateItems<CHandle<CBaseEntity>>(this,this + 0x3dc,(int)((float)lVar21 * local_50),1);
  }
  cVar2 = CMapInfo::ShouldCullMagnums(this_00);
  if (cVar2 != '\0') {
    lVar21 = (longdouble)CMapInfo::GetMagnumDensity(this_00);
    PopulateItems<CHandle<CBaseEntity>>(this,this + 0x138,(int)((float)lVar21 * local_50),1);
  }
  lVar21 = (longdouble)CMapInfo::GetSuperWeaponDensity(this_00);
  local_50 = (float)lVar21 * local_50;
  iVar16 = (int)local_50;
  if (((local_50 < 1.0) && (0.0 < local_50)) &&
     (lVar21 = (longdouble)(**(code **)(*random_valve + 4))(random_valve,0),
     (float)lVar21 < local_50)) {
    iVar16 = 1;
  }
  local_40[0] = 0;
  local_40[2] = 0;
  local_30 = 0;
  local_40[1] = *(int *)(this + 0x34c);
  local_34 = *(int *)(this + 0x380);
  local_2c = *(int *)(this + 0x3b4);
  iVar12 = local_2c + local_34 + local_40[1];
  if (iVar12 < iVar16) {
    iVar16 = iVar12;
  }
  iVar12 = (**(code **)(*random_valve + 8))(random_valve,0);
  if (iVar16 < 1) {
    iVar9 = 0;
    iVar17 = 0;
    iVar19 = 0;
  }
  else {
    do {
      if (local_40[iVar12 * 2] < local_40[iVar12 * 2 + 1]) {
        iVar16 = iVar16 + -1;
        local_40[iVar12 * 2] = local_40[iVar12 * 2] + 1;
      }
      iVar12 = (iVar12 + 1) % 3;
      iVar9 = local_40[0];
      iVar17 = local_30;
      iVar19 = local_40[2];
    } while (0 < iVar16);
  }
  PopulateItems<CHandle<CBaseEntity>>(this,this + 0x340,iVar9,0);
  PopulateItems<CHandle<CBaseEntity>>(this,this + 0x374,iVar19,0);
  PopulateItems<CHandle<CBaseEntity>>(this,this + 0x3a8,iVar17,0);
  fVar14 = *(float *)(director_per_map_weapon_upgrade_chance._28_4_ + 0x2c);
  lVar21 = (longdouble)(**(code **)(*random_valve + 4))(random_valve,0);
  PopulateItems<CHandle<CBaseEntity>>(this,this + 0x2d8,(float)lVar21 < fVar14,0);
  uVar10 = CMapInfo::GetFinaleItemClusterCount(this_00);
  iVar16 = PopulateItems<CHandle<CBaseEntity>>(this,this + 0x41c,uVar10,0);
  iVar16 = iVar8 + iVar15 + iVar4 + iVar5 + iVar6 + iVar7 + iVar16;
  CL4D_GameStats._932_4_ = 0;
  if (-1 < iVar16) {
    CL4D_GameStats._932_4_ = iVar16;
  }
  cVar2 = CTerrorGameRules::IsScavengeMode();
  if ((cVar2 != '\0') || (cVar2 = CTerrorGameRules::IsSurvivalMode(), cVar2 != '\0')) {
    pCVar11 = (CBaseEntity *)0x0;
    while (pCVar11 = (CBaseEntity *)
                     CGlobalEntityList::FindEntityByClassname
                               ((CGlobalEntityList *)gEntList,pCVar11,"weapon_spawn"),
          pCVar11 != (CBaseEntity *)0x0) {
      UTIL_Remove(pCVar11);
    }
    pCVar11 = (CBaseEntity *)0x0;
    while (pCVar11 = (CBaseEntity *)
                     CGlobalEntityList::FindEntityByClassname
                               ((CGlobalEntityList *)gEntList,pCVar11,"weapon_first_aid_kit_spawn"),
          pCVar11 != (CBaseEntity *)0x0) {
      UTIL_Remove(pCVar11);
    }
  }
  cVar2 = CTerrorGameRules::HasPlayerControlledZombies();
  if ((((cVar2 == '\0') &&
       (cVar2 = CDirectorChallengeMode::AllowPillConversion
                          (*(CDirectorChallengeMode **)(TheDirector + 0x648)), cVar2 != '\0')) &&
      (iVar15 = CDirector::GetHealthkitConversionMode(TheDirector,&local_44), iVar15 == 2)) &&
     (FixedConvertPillsToKits(this,local_44), *(float *)(this + 0xc) != -1.0)) {
    (**(code **)(*(int *)(this + 4) + 4))(this + 4,this + 0xc);
    *(undefined4 *)(this + 0xc) = 0xbf800000;
  }
  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)