L L4D2node

CSoundEmitterSystem::LevelInitPreEntity

0x004b7140 · 590 bytes · __thiscall

_ZN19CSoundEmitterSystem18LevelInitPreEntityEv

Decompiled

undefined (1 param)

/* CSoundEmitterSystem::LevelInitPreEntity() */

void __thiscall CSoundEmitterSystem::LevelInitPreEntity(CSoundEmitterSystem *this)

{
  char cVar1;
  ushort uVar2;
  undefined1 *puVar3;
  int iVar4;
  int iVar5;
  undefined4 *puVar6;
  undefined4 *puVar7;
  char *pcVar8;
  undefined4 uVar9;
  uint uVar10;
  int in_GS_OFFSET;
  CUtlSymbolTable *this_00;
  char local_320 [256];
  char local_220 [512];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  this_00 = (CUtlSymbolTable *)(this + 0xc);
  CUtlSymbolTable::RemoveAll(this_00);
  if ((this[4] != (CSoundEmitterSystem)0x0) && (*(int *)(this + 8) == 0)) {
    StartLog((CSoundEmitterSystem *)this_00);
  }
  puVar3 = &DAT_00d539c2;
  if (*(undefined1 **)(gpGlobals + 0x3c) != (undefined1 *)0x0) {
    puVar3 = *(undefined1 **)(gpGlobals + 0x3c);
  }
  V_snprintf(local_320,0x100,"maps/%s",puVar3);
  V_FixSlashes(local_320,'/');
  _V_strlower(local_320);
  V_StripExtension(local_320,local_220,0x200);
  V_strncat(local_220,"_level_sounds.txt",0x200,-1);
  cVar1 = (**(code **)(*(int *)(filesystem + 4) + 0x28))(filesystem + 4,local_220,"GAME");
  if (cVar1 != '\0') {
    (**(code **)(*soundemitterbase + 0x9c))(soundemitterbase,local_220);
  }
  for (iVar4 = (**(code **)(*soundemitterbase + 0x4c))(soundemitterbase);
      iVar5 = (**(code **)(*soundemitterbase + 0x54))(soundemitterbase), iVar4 != iVar5;
      iVar4 = (**(code **)(*soundemitterbase + 0x50))(soundemitterbase,iVar4)) {
    iVar5 = (**(code **)(*soundemitterbase + 0x58))(soundemitterbase,iVar4);
    if (((*(byte *)(iVar5 + 0x1a) & 8) != 0) &&
       (puVar6 = (undefined4 *)(**(code **)(*soundemitterbase + 0x58))(soundemitterbase,iVar4),
       puVar6 != (undefined4 *)0x0)) {
      uVar2 = *(ushort *)(puVar6 + 2);
      if (uVar2 == 0) {
        uVar9 = (**(code **)(*soundemitterbase + 0x28))(soundemitterbase,iVar4);
        DevMsg("CSoundEmitterSystem:  sounds.txt entry \'%s\' has no waves listed under \'wave\' or \'rndwave\' key!!!\n"
               ,uVar9);
      }
      else {
        uVar10 = (uint)uVar2;
        g_bPermitDirectSoundPrecache = 1;
        iVar5 = 0;
        while( true ) {
          puVar7 = puVar6;
          if (uVar2 != 1) {
            puVar7 = (undefined4 *)*puVar6;
          }
          pcVar8 = (char *)(**(code **)(*soundemitterbase + 0x30))(soundemitterbase,puVar7 + iVar5);
          CBaseEntity::PrecacheSound(pcVar8);
          if (iVar5 == uVar10 - 1) break;
          uVar2 = *(ushort *)(puVar6 + 2);
          iVar5 = iVar5 + 1;
        }
        g_bPermitDirectSoundPrecache = 0;
      }
    }
  }
  CUtlRBTree<CUtlMap<unsigned_int,float,unsigned_short>::Node_t,unsigned_short,CUtlMap<unsigned_int,float,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<unsigned_int,float,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
  ::RemoveAll((CUtlRBTree<CUtlMap<unsigned_int,float,unsigned_short>::Node_t,unsigned_short,CUtlMap<unsigned_int,float,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<unsigned_int,float,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
               *)g_CaptionRepeats);
  g_CaptionRepeats._20_2_ = 0xffff;
  CUtlMemory<UtlRBTreeNode_t<CUtlMap<unsigned_int,float,unsigned_short>::Node_t,unsigned_short>,unsigned_short>
  ::Purge((CUtlMemory<UtlRBTreeNode_t<CUtlMap<unsigned_int,float,unsigned_short>::Node_t,unsigned_short>,unsigned_short>
           *)(g_CaptionRepeats + 4));
  g_CaptionRepeats._22_2_ = 0xffff;
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail();
  }
  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)