L L4D2node

SelectModelByPopulation

0x00a12450 · 1339 bytes · __cdecl

_Z23SelectModelByPopulationPKcR10CUtlVectorIS0_10CUtlMemoryIS0_iEE

Decompiled

undefined (2 params)

/* WARNING: Removing unreachable block (ram,0x00a12754) */
/* SelectModelByPopulation(char const*, CUtlVector<char const*, CUtlMemory<char const*, int> >&) */

char * SelectModelByPopulation(char *param_1,CUtlVector *param_2)

{
  char cVar1;
  KeyValues *this;
  KeyValues *this_00;
  int iVar2;
  int iVar3;
  int iVar4;
  char *pcVar5;
  char *pcVar6;
  int in_GS_OFFSET;
  longdouble lVar7;
  char *local_14c;
  int local_148;
  KeyValues *local_144;
  undefined1 local_13c [4];
  undefined1 local_138 [4];
  int local_134;
  int local_130;
  CFmtStrN<256> local_12c [5];
  char local_127 [263];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  if (*(int *)(param_2 + 0xc) < 1) {
LAB_00a12830:
    pcVar5 = (char *)0x0;
    goto LAB_00a1260f;
  }
  cVar1 = CTerrorGameRules::IsCoopMode();
  iVar2 = TheZombieManager;
  if (cVar1 != '\0') {
    pcVar5 = *(char **)(gpGlobals + 0x3c);
    if (pcVar5 == (char *)0x0) {
      pcVar5 = "";
LAB_00a126a5:
      iVar3 = _V_stricmp(pcVar5,"c1m4_atrium");
      if (iVar3 != 0) goto LAB_00a1248b;
    }
    else if (pcVar5 != "c1m4_atrium") goto LAB_00a126a5;
    GetCurrentDate(local_13c,local_138,&local_134);
    GetCurrentDayOfTheYear(&local_130);
    if (((((0x7d9 < local_134) || (0x14a < local_130)) &&
         ((local_130 + -0x14b + (local_134 + -0x7d9) * 0x16d) % 0xf == 0)) &&
        ((0.0 < *(float *)(iVar2 + 0x24) &&
         (lVar7 = (longdouble)CountdownTimer::Now(), *(float *)(iVar2 + 0x24) <= (float)lVar7)))) &&
       (*(char *)(TheZombieManager + 0x18) == '\0')) {
      pcVar5 = *(char **)(gpGlobals + 0x3c);
      if (pcVar5 == (char *)0x0) {
        pcVar5 = "";
LAB_00a12725:
        iVar2 = _V_stricmp(pcVar5,"c1m4_atrium");
        if (iVar2 != 0) goto LAB_00a1248b;
      }
      else if (pcVar5 != "c1m4_atrium") goto LAB_00a12725;
      *(undefined1 *)(TheZombieManager + 0x18) = 1;
      lVar7 = (longdouble)RandomFloat(0,0x42c80000);
      if ((float)lVar7 < 33.0) {
        pcVar5 = "models/infected/common_male_jimmy.mdl";
        goto LAB_00a1260f;
      }
    }
  }
LAB_00a1248b:
  this = (KeyValues *)CDirector::GetPopulationData(TheDirector);
  if (this == (KeyValues *)0x0) {
    iVar2 = *(int *)(param_2 + 0xc);
    if (iVar2 == 0) goto LAB_00a12830;
    if (*(int *)(ZombieDebugPopulation._28_4_ + 0x30) != 0) {
      Warning("spawning a random zombie without population data\n");
      iVar2 = *(int *)(param_2 + 0xc);
    }
  }
  else {
    if (*(int *)(TheZombieManager + 0x28c) == 1) {
      CFmtStrN<256>::CFmtStrN(local_12c,"%s_mob",param_1);
      this_00 = (KeyValues *)KeyValues::FindKey(this,local_127,false);
      if (this_00 == (KeyValues *)0x0) goto LAB_00a124b4;
LAB_00a124d8:
      iVar2 = RandomInt(1,100);
      local_144 = (KeyValues *)KeyValues::GetFirstSubKey(this_00);
      local_148 = 0;
      if (local_144 != (KeyValues *)0x0) {
        pcVar5 = local_127;
        do {
          iVar3 = KeyValues::GetInt(local_144,(char *)0x0,0);
          local_148 = local_148 + iVar3;
          if (iVar2 <= local_148) {
            local_14c = (char *)KeyValues::GetName(local_144);
            if ((*(int *)(z_forcezombiemodel._28_4_ + 0x30) != 0) &&
               (local_14c = "FCVAR_NEVER_AS_STRING", (z_forcezombiemodelname[0x15] & 0x10) == 0)) {
              local_14c = "";
              if (*(char **)(z_forcezombiemodelname._28_4_ + 0x24) != (char *)0x0) {
                local_14c = *(char **)(z_forcezombiemodelname._28_4_ + 0x24);
              }
            }
            CFmtStrN<256>::CFmtStrN(local_12c,"models/infected/%s.mdl",local_14c);
            if (0 < *(int *)(param_2 + 0xc)) {
              pcVar6 = (char *)**(undefined4 **)param_2;
              if (pcVar6 != pcVar5) {
                iVar3 = 0;
LAB_00a125e1:
                iVar4 = _V_stricmp(pcVar6,pcVar5);
                if (iVar4 == 0) goto LAB_00a125fd;
                iVar3 = iVar3 + 1;
                if (iVar3 < *(int *)(param_2 + 0xc)) goto code_r0x00a125d8;
                goto LAB_00a12638;
              }
              if (*(int *)(ZombieDebugPopulation._28_4_ + 0x30) != 0) {
LAB_00a12768:
                Msg("spawning %s in %s, %d%%\n",local_14c,param_1,iVar2);
              }
              goto LAB_00a1260f;
            }
          }
LAB_00a12638:
          local_144 = (KeyValues *)KeyValues::GetNextKey(local_144);
        } while (local_144 != (KeyValues *)0x0);
      }
      if (*(int *)(ZombieDebugPopulation._28_4_ + 0x30) != 0) {
        Warning("spawning a random zombie in area \'%s\' - %d%% < 100%%?\n",param_1,local_148);
      }
    }
    else {
LAB_00a124b4:
      this_00 = (KeyValues *)KeyValues::FindKey(this,param_1,false);
      if (this_00 != (KeyValues *)0x0) goto LAB_00a124d8;
      pcVar5 = "FCVAR_NEVER_AS_STRING";
      if ((ZombiePopulation[0x15] & 0x10) == 0) {
        pcVar5 = "";
        if (*(char **)(ZombiePopulation._28_4_ + 0x24) != (char *)0x0) {
          pcVar5 = *(char **)(ZombiePopulation._28_4_ + 0x24);
        }
      }
      this_00 = (KeyValues *)KeyValues::FindKey(this,pcVar5,false);
      if (this_00 != (KeyValues *)0x0) goto LAB_00a124d8;
      if (*(int *)(ZombieDebugPopulation._28_4_ + 0x30) != 0) {
        Warning("spawning a random zombie in unpopulated area \'%s\'\n",param_1);
      }
    }
    iVar2 = *(int *)(param_2 + 0xc);
  }
  iVar2 = RandomInt(0,iVar2 + -1);
  pcVar5 = *(char **)(*(int *)param_2 + iVar2 * 4);
LAB_00a1260f:
  if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
    return pcVar5;
  }
                    /* WARNING: Subroutine does not return */
  __stack_chk_fail();
code_r0x00a125d8:
  pcVar6 = *(char **)(*(int *)param_2 + iVar3 * 4);
  if (pcVar6 == pcVar5) {
LAB_00a125fd:
    pcVar5 = pcVar6;
    if (*(int *)(ZombieDebugPopulation._28_4_ + 0x30) == 0) goto LAB_00a1260f;
    goto LAB_00a12768;
  }
  goto LAB_00a125e1;
}

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)