L L4D2node

Mod_GetMaterialCount

0x0019caf0 · 268 bytes · __cdecl

_Z20Mod_GetMaterialCountP7model_t

Decompiled

undefined (1 param)

/* Mod_GetMaterialCount(model_t*) */

int Mod_GetMaterialCount(model_t *param_1)

{
  byte *pbVar1;
  int iVar2;
  int iVar3;
  int iVar4;
  CUtlMemory<IMaterial*,int> *local_40;
  IMaterial *local_34;
  int *local_30;
  undefined4 local_2c;
  undefined4 local_28;
  int local_24;
  int *local_20;
  
  if (*(int *)(param_1 + 0x110) != 1) {
    return 0;
  }
  iVar4 = 0;
  local_2c = 0x20;
  local_28 = 0;
  local_30 = malloc(0x80);
  local_24 = 0;
  local_20 = local_30;
  if (0 < *(int *)(param_1 + 0x13c)) {
    iVar3 = 0;
    do {
      pbVar1 = (byte *)((*(int *)(param_1 + 0x138) + iVar3) * 0x20 +
                       *(int *)(*(int *)(param_1 + 0x134) + 0x78));
      if ((*pbVar1 & 0x10) == 0) {
        local_34 = *(IMaterial **)
                    ((uint)(*(ushort *)(pbVar1 + 0x16) >> 1) * 0x50 +
                     *(int *)(*(int *)(param_1 + 0x134) + 0x5c) + 0x4c);
        if (iVar4 < 1) {
LAB_0019cba4:
                    /* try { // try from 0019cbb5 to 0019cbb9 has its CatchHandler @ 0019cc08 */
          CUtlVector<IMaterial*,CUtlMemory<IMaterial*,int>>::InsertBefore
                    ((CUtlVector<IMaterial*,CUtlMemory<IMaterial*,int>> *)&local_30,iVar4,&local_34)
          ;
          iVar4 = local_24;
        }
        else if (local_34 != (IMaterial *)*local_30) {
          iVar2 = 0;
          do {
            iVar2 = iVar2 + 1;
            if (iVar2 == iVar4) goto LAB_0019cba4;
          } while (local_34 != (IMaterial *)local_30[iVar2]);
          if (iVar2 < 0) goto LAB_0019cba4;
        }
      }
      iVar3 = iVar3 + 1;
    } while (iVar3 < *(int *)(param_1 + 0x13c));
  }
  local_40 = (CUtlMemory<IMaterial*,int> *)&local_30;
  local_24 = 0;
  CUtlMemory<IMaterial*,int>::Purge(local_40);
  local_20 = local_30;
  CUtlMemory<IMaterial*,int>::Purge(local_40);
  return iVar4;
}

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)