L L4D2node

CBaseEntity::Script_PrecacheScriptSound

0x004b2df0 · 793 bytes · __thiscall

_ZN11CBaseEntity26Script_PrecacheScriptSoundEPKc

Decompiled

undefined (2 params)

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

void __thiscall CBaseEntity::Script_PrecacheScriptSound(CBaseEntity *this,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_00;
  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)) {
      if (*param_1 == '\0') {
        return;
      }
      if ((CSoundEmitterSystem::PrecacheScriptSound(char_const*)::s_PrecacheScriptSoundFailures ==
           '\0') &&
         (iVar5 = __cxa_guard_acquire(&CSoundEmitterSystem::PrecacheScriptSound(char_const*)::
                                       s_PrecacheScriptSoundFailures), iVar5 != 0)) {
                    /* try { // try from 004b30a7 to 004b30ab has its CatchHandler @ 004b3126 */
        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) {
        return;
      }
      DevMsg("PrecacheScriptSound \'%s\' failed, no such sound script entry\n",param_1,pcVar8);
      CUtlSymbolTable::AddString(local_3c);
      return;
    }
    g_bPermitDirectSoundPrecache = 1;
    PrecacheSound(param_1);
  }
  else {
    if ((DAT_00f9ce64 != '\0') && (CUtlSymbolTable::Find((char *)local_1e), local_1e[0] == -1)) {
      if (DAT_00f9ce68 == 0) {
        this_00 = (CSoundEmitterSystem *)&DAT_00f9ce6c;
        CUtlSymbolTable::RemoveAll((CUtlSymbolTable *)&DAT_00f9ce6c);
        if ((DAT_00f9ce64 != '\0') && (DAT_00f9ce68 == 0)) {
          CSoundEmitterSystem::StartLog(this_00);
        }
      }
      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) {
      return;
    }
    uVar3 = *(ushort *)(puVar6 + 2);
    if (uVar3 == 0) {
      uVar4 = (**(code **)(*soundemitterbase + 0x28))(soundemitterbase,uVar4);
      DevMsg("CSoundEmitterSystem:  sounds.txt entry \'%s\' has no waves listed under \'wave\' or \'rndwave\' key!!!\n"
             ,uVar4);
      return;
    }
    uVar10 = (uint)uVar3;
    g_bPermitDirectSoundPrecache = 1;
    iVar5 = 0;
    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;
}

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)