L L4D2node

CDecalEmitterSystem::LoadDecalsFromScript

0x00446aa0 · 1464 bytes · __thiscall

_ZN19CDecalEmitterSystem20LoadDecalsFromScriptEPKc

Decompiled

undefined (2 params)

/* CDecalEmitterSystem::LoadDecalsFromScript(char const*) */

void __thiscall CDecalEmitterSystem::LoadDecalsFromScript(CDecalEmitterSystem *this,char *param_1)

{
  undefined2 uVar1;
  char cVar2;
  byte bVar3;
  IBaseFileSystem *pIVar4;
  int iVar5;
  char *pcVar6;
  KeyValues *pKVar7;
  int iVar8;
  size_t __size;
  void *pvVar9;
  undefined4 uVar10;
  undefined4 uVar11;
  long lVar13;
  int iVar14;
  undefined2 *puVar15;
  longdouble lVar16;
  uint in_stack_ffffff88;
  KeyValues *local_5c;
  KeyValues *local_54;
  int local_38;
  char *local_34;
  int local_30;
  undefined4 local_2c;
  int local_28;
  char *local_24;
  int local_20;
  int iVar12;
  
  local_54 = KeyValues::operator_new((KeyValues *)0x2c,in_stack_ffffff88);
                    /* try { // try from 00446ad7 to 00446adb has its CatchHandler @ 0044709a */
  KeyValues::KeyValues(local_54,param_1,(IKeyValuesSystem *)0x0,false);
  if (local_54 == (KeyValues *)0x0) {
    return;
  }
  pIVar4 = (IBaseFileSystem *)0x0;
  if (filesystem != 0) {
    pIVar4 = (IBaseFileSystem *)(filesystem + 4);
  }
  cVar2 = KeyValues::LoadFromFile(local_54,pIVar4,param_1,(char *)0x0);
  if (cVar2 == '\0') {
    Msg("CDecalEmitterSystem::LoadDecalsFromScript:  Unable to load \'%s\'\n",param_1);
  }
  else {
    local_5c = (KeyValues *)0x0;
    do {
      iVar5 = KeyValues::GetFirstSubKey(local_54);
      if (iVar5 != 0) {
        pcVar6 = (char *)KeyValues::GetName(local_54);
        iVar5 = _V_stricmp(pcVar6,"TranslationData");
        if (iVar5 == 0) {
          local_5c = local_54;
        }
        else {
          local_34 = (char *)0x0;
          local_30 = 0;
          local_2c = 0;
          local_28 = 0;
          local_24 = (char *)0x0;
                    /* try { // try from 00446ba9 to 00446d58 has its CatchHandler @ 00447070 */
          pKVar7 = (KeyValues *)KeyValues::GetFirstSubKey(local_54);
          for (; pKVar7 != (KeyValues *)0x0; pKVar7 = (KeyValues *)KeyValues::GetNextKey(pKVar7)) {
            KeyValues::GetName(pKVar7);
            CUtlSymbolTable::AddString((char *)&local_38);
            uVar1 = (ushort)local_38;
            lVar16 = (longdouble)KeyValues::GetFloat(pKVar7,(char *)0x0,0.0);
            iVar12 = *(int *)(this + 0x1c);
            iVar14 = *(int *)(this + 0x14);
            iVar5 = iVar12 + 1;
            if (iVar14 < iVar5) {
              iVar8 = *(int *)(this + 0x18);
              if (iVar8 < 0) goto LAB_00446bc0;
              if (iVar8 == 0) {
                if (iVar14 == 0) {
                  if (iVar5 < 4) {
                    iVar8 = 3;
                    goto LAB_00446caf;
                  }
                  iVar14 = 3;
                }
                do {
                  iVar8 = iVar14;
                  iVar14 = iVar8 * 2;
                } while (iVar14 < iVar5);
                pvVar9 = *(void **)(this + 0x10);
                *(int *)(this + 0x14) = iVar14;
                __size = iVar8 * 0x18;
                if (pvVar9 == (void *)0x0) goto LAB_00446d2e;
LAB_00446cbf:
                pvVar9 = realloc(pvVar9,__size);
                *(void **)(this + 0x10) = pvVar9;
                iVar5 = *(int *)(this + 0x1c) + 1;
              }
              else {
                for (iVar8 = (iVar12 / iVar8 + 1) * iVar8; iVar8 < iVar5;
                    iVar8 = (iVar8 + iVar5) / 2) {
                }
LAB_00446caf:
                pvVar9 = *(void **)(this + 0x10);
                *(int *)(this + 0x14) = iVar8;
                __size = iVar8 * 0xc;
                if (pvVar9 != (void *)0x0) goto LAB_00446cbf;
LAB_00446d2e:
                pvVar9 = malloc(__size);
                *(void **)(this + 0x10) = pvVar9;
              }
            }
            else {
LAB_00446bc0:
              pvVar9 = *(void **)(this + 0x10);
            }
            *(int *)(this + 0x1c) = iVar5;
            iVar5 = (iVar5 - iVar12) + -1;
            *(void **)(this + 0x20) = pvVar9;
            iVar14 = iVar12 * 0xc;
            if (0 < iVar5) {
              _V_memmove((void *)((int)pvVar9 + iVar14 + 0xc),(void *)((int)pvVar9 + iVar14),
                         iVar5 * 0xc);
              pvVar9 = *(void **)(this + 0x10);
            }
            puVar15 = (undefined2 *)(iVar14 + (int)pvVar9);
            if (puVar15 != (undefined2 *)0x0) {
              *(undefined4 *)(puVar15 + 2) = 0xffffffff;
              *(float *)(puVar15 + 4) = (float)lVar16;
              *puVar15 = uVar1;
            }
            local_38 = iVar12;
            CUtlVector<int,CUtlMemory<int,int>>::InsertBefore
                      ((CUtlVector<int,CUtlMemory<int,int>> *)&local_34,local_28,&local_38);
          }
          CUtlDict<CDecalEmitterSystem::DecalEntry,int>::Insert
                    ((CUtlDict<CDecalEmitterSystem::DecalEntry,int> *)(this + 0x24),pcVar6,
                     (DecalEntry *)&local_34);
          local_28 = 0;
          CUtlMemory<int,int>::Purge((CUtlMemory<int,int> *)&local_34);
          local_24 = local_34;
          CUtlMemory<int,int>::Purge((CUtlMemory<int,int> *)&local_34);
        }
      }
      local_54 = (KeyValues *)KeyValues::GetNextKey(local_54);
    } while (local_54 != (KeyValues *)0x0);
    if (local_5c != (KeyValues *)0x0) {
      for (pKVar7 = (KeyValues *)KeyValues::GetFirstSubKey(local_5c); pKVar7 != (KeyValues *)0x0;
          pKVar7 = (KeyValues *)KeyValues::GetNextKey(pKVar7)) {
        pcVar6 = (char *)KeyValues::GetString(pKVar7,(char *)0x0,"");
        iVar5 = _V_stricmp(pcVar6,"");
        if (iVar5 != 0) {
          pcVar6 = (char *)KeyValues::GetString(pKVar7,(char *)0x0,"");
          if (pcVar6 != (char *)0x0) {
            iVar5 = *(int *)(this + 0x34);
            local_30 = 0;
            local_2c = 0;
            local_28 = 0;
            local_24 = (char *)0x0;
            local_20 = 0;
            local_34 = pcVar6;
            if (iVar5 != -1) {
              iVar12 = *(int *)(this + 0x28);
              do {
                while( true ) {
                  iVar14 = iVar5 * 0x28;
                    /* try { // try from 00446eb6 to 00446ed1 has its CatchHandler @ 00447085 */
                  cVar2 = (**(code **)(this + 0x24))(&local_34,iVar12 + 0x10 + iVar14);
                  if (cVar2 != '\0') break;
                  cVar2 = (**(code **)(this + 0x24))
                                    (*(int *)(this + 0x28) + iVar14 + 0x10,&local_34);
                  if (cVar2 == '\0') {
                    local_24 = (char *)0x0;
                    CUtlMemory<int,int>::Purge((CUtlMemory<int,int> *)&local_30);
                    local_20 = local_30;
                    CUtlMemory<int,int>::Purge((CUtlMemory<int,int> *)&local_30);
                    if (iVar5 == -1) goto LAB_00446f16;
                    pcVar6 = (char *)KeyValues::GetName(pKVar7);
                    if ((int)*pcVar6 - 0x30U < 10) {
                      lVar13 = strtol(pcVar6,(char **)0x0,10);
                      bVar3 = (byte)lVar13;
                    }
                    else {
                      iVar12 = toupper((int)*pcVar6);
                      bVar3 = (byte)iVar12;
                    }
                    local_38._0_2_ = (ushort)bVar3;
                    local_34 = strdup((char *)&local_38);
                    local_30 = iVar5;
                    CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
                    ::Insert((CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
                              *)(this + 0x80),(Node_t *)&local_34);
                    goto LAB_00446de8;
                  }
                  if ((CUtlRBTree<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int,CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int>,int>>
                       ::Links(int)::s_Sentinel == '\0') &&
                     (iVar5 = __cxa_guard_acquire(&
                                                  CUtlRBTree<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int,CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int>,int>>
                                                  ::Links(int)::s_Sentinel), iVar5 != 0)) {
                    CUtlRBTree<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int,CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int>,int>>
                    ::Links(int)::s_Sentinel = 0xffffffff;
                    DAT_00f158c8 = 0xffffffff;
                    DAT_00f158cc = 0xffffffff;
                    __cxa_guard_release(&CUtlRBTree<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int,CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int>,int>>
                                         ::Links(int)::s_Sentinel);
                  }
                  iVar12 = *(int *)(this + 0x28);
                  iVar5 = *(int *)(iVar12 + 4 + iVar14);
                  if (iVar5 == -1) goto LAB_00446ef3;
                }
                if ((CUtlRBTree<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int,CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int>,int>>
                     ::Links(int)::s_Sentinel == '\0') &&
                   (iVar12 = __cxa_guard_acquire(&CUtlRBTree<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int,CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int>,int>>
                                                  ::Links(int)::s_Sentinel), iVar12 != 0)) {
                  CUtlRBTree<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int,CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int>,int>>
                  ::Links(int)::s_Sentinel = 0xffffffff;
                  DAT_00f158c8 = 0xffffffff;
                  DAT_00f158cc = 0xffffffff;
                  __cxa_guard_release(&CUtlRBTree<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int,CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,CDecalEmitterSystem::DecalEntry,int>::Node_t,int>,int>>
                                       ::Links(int)::s_Sentinel);
                }
                iVar12 = *(int *)(this + 0x28);
                iVar5 = *(int *)(iVar12 + iVar5 * 0x28);
              } while (iVar5 != -1);
            }
LAB_00446ef3:
            local_24 = (char *)0x0;
            CUtlMemory<int,int>::Purge((CUtlMemory<int,int> *)&local_30);
            local_20 = local_30;
            CUtlMemory<int,int>::Purge((CUtlMemory<int,int> *)&local_30);
          }
LAB_00446f16:
          uVar10 = KeyValues::GetString(pKVar7,(char *)0x0,"");
          uVar11 = KeyValues::GetName(pKVar7);
          Msg("CDecalEmitterSystem::LoadDecalsFromScript:  Translation for game material type \'%s\' references unknown decal \'%s\'\n"
              ,uVar11,uVar10);
        }
LAB_00446de8:
      }
      goto LAB_00446db6;
    }
  }
  Msg("CDecalEmitterSystem::LoadDecalsFromScript:  Script \'%s\' missing section \'%s\'\n",param_1,
      "TranslationData");
LAB_00446db6:
  KeyValues::deleteThis();
  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)