L L4D2node

CBaseEntity::PrecacheScriptSound

0x004b3140 · 829 bytes · __cdecl

_ZN11CBaseEntity19PrecacheScriptSoundEPKc

Decompiled

undefined (1 param)

/* CBaseEntity::PrecacheScriptSound(char const*) */

undefined4 CBaseEntity::PrecacheScriptSound(char *param_1)

{
  code *pcVar1;
  char cVar2;
  ushort uVar3;
  undefined4 uVar4;
  int iVar5;
  undefined4 *puVar6;
  undefined4 *puVar7;
  char *pcVar8;
  undefined4 uVar9;
  uint uVar10;
  CSoundEmitterSystem *this;
  undefined *puVar11;
  char local_3c [30];
  short local_1e [7];
  
  uVar4 = (**(code **)(*soundemitterbase + 0x1c))(soundemitterbase,param_1);
  cVar2 = (**(code **)(*soundemitterbase + 0x20))(soundemitterbase,uVar4);
  if (cVar2 == '\0') {
    iVar5 = V_stristr(param_1,".wav");
    if ((iVar5 != 0) || (iVar5 = _V_strstr(param_1,".mp3"), iVar5 != 0)) {
      g_bPermitDirectSoundPrecache = 1;
      PrecacheSound(param_1);
      g_bPermitDirectSoundPrecache = 0;
      return 0xffffffff;
    }
    if (*param_1 != '\0') {
      if ((CSoundEmitterSystem::PrecacheScriptSound(char_const*)::s_PrecacheScriptSoundFailures ==
           '\0') &&
         (iVar5 = __cxa_guard_acquire(&CSoundEmitterSystem::PrecacheScriptSound(char_const*)::
                                       s_PrecacheScriptSoundFailures), iVar5 != 0)) {
                    /* try { // try from 004b341f to 004b3423 has its CatchHandler @ 004b349e */
        CUtlSymbolTable::CUtlSymbolTable
                  ((CUtlSymbolTable *)
                   CSoundEmitterSystem::PrecacheScriptSound(char_const*)::
                   s_PrecacheScriptSoundFailures,0,0x10,false);
        __cxa_guard_release(&CSoundEmitterSystem::PrecacheScriptSound(char_const*)::
                             s_PrecacheScriptSoundFailures);
        __cxa_atexit(CUtlSymbolTable::~CUtlSymbolTable,
                     CSoundEmitterSystem::PrecacheScriptSound(char_const*)::
                     s_PrecacheScriptSoundFailures,&__dso_handle);
      }
      pcVar8 = param_1;
      CUtlSymbolTable::Find((char *)local_1e);
      if (local_1e[0] == -1) {
        DevMsg("PrecacheScriptSound \'%s\' failed, no such sound script entry\n",param_1,pcVar8);
        CUtlSymbolTable::AddString(local_3c);
      }
    }
  }
  else {
    if ((DAT_00f9ce64 != '\0') && (CUtlSymbolTable::Find((char *)local_1e), local_1e[0] == -1)) {
      if (DAT_00f9ce68 == 0) {
        this = (CSoundEmitterSystem *)&DAT_00f9ce6c;
        CUtlSymbolTable::RemoveAll((CUtlSymbolTable *)&DAT_00f9ce6c);
        if ((DAT_00f9ce64 != '\0') && (DAT_00f9ce68 == 0)) {
          CSoundEmitterSystem::StartLog(this);
        }
      }
      puVar11 = &DAT_00f9ce6c;
      pcVar8 = param_1;
      CUtlSymbolTable::AddString(local_3c);
      if (DAT_00f9ce68 == 0) {
        Warning("Disabling precache logging due to file i/o problem!!!\n",puVar11,pcVar8);
        DAT_00f9ce64 = '\0';
      }
      else {
        (**(code **)(*(int *)(filesystem + 4) + 4))(filesystem + 4,&DAT_00d539c6,1,DAT_00f9ce68);
        iVar5 = DAT_00f9ce68;
        pcVar1 = *(code **)(*(int *)(filesystem + 4) + 4);
        uVar9 = _V_strlen(param_1);
        (*pcVar1)(filesystem + 4,param_1,uVar9,iVar5);
        (**(code **)(*(int *)(filesystem + 4) + 4))(filesystem + 4,"\"\n",2,DAT_00f9ce68);
      }
    }
    puVar6 = (undefined4 *)(**(code **)(*soundemitterbase + 0x58))(soundemitterbase,uVar4);
    if (puVar6 != (undefined4 *)0x0) {
      uVar3 = *(ushort *)(puVar6 + 2);
      if (uVar3 == 0) {
        uVar9 = (**(code **)(*soundemitterbase + 0x28))(soundemitterbase,uVar4);
        DevMsg("CSoundEmitterSystem:  sounds.txt entry \'%s\' has no waves listed under \'wave\' or \'rndwave\' key!!!\n"
               ,uVar9);
      }
      else {
        uVar10 = (uint)uVar3;
        iVar5 = 0;
        g_bPermitDirectSoundPrecache = 1;
        while( true ) {
          puVar7 = puVar6;
          if (uVar3 != 1) {
            puVar7 = (undefined4 *)*puVar6;
          }
          pcVar8 = (char *)(**(code **)(*soundemitterbase + 0x30))(soundemitterbase,puVar7 + iVar5);
          PrecacheSound(pcVar8);
          if (iVar5 == uVar10 - 1) break;
          uVar3 = *(ushort *)(puVar6 + 2);
          iVar5 = iVar5 + 1;
        }
        g_bPermitDirectSoundPrecache = 0;
      }
    }
  }
  return uVar4;
}

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)