L L4D2node

CMultiplayRules::LoadVoiceCommandScript

0x0046f7d0 · 560 bytes · __thiscall

_ZN15CMultiplayRules22LoadVoiceCommandScriptEv

Decompiled

undefined (1 param)

/* CMultiplayRules::LoadVoiceCommandScript() */

void __thiscall CMultiplayRules::LoadVoiceCommandScript(CMultiplayRules *this)

{
  char cVar1;
  KeyValues *this_00;
  IBaseFileSystem *pIVar2;
  int iVar3;
  KeyValues *this_01;
  char *pcVar4;
  int iVar5;
  CUtlVector<VoiceCommandMenuItem_t,CUtlMemory<VoiceCommandMenuItem_t,int>> *this_02;
  undefined4 uVar6;
  int iVar7;
  int in_GS_OFFSET;
  uint in_stack_ffffff68;
  KeyValues *local_74;
  int local_68;
  undefined1 local_64;
  undefined1 local_63;
  char local_62 [66];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  this_00 = KeyValues::operator_new((KeyValues *)0x2c,in_stack_ffffff68);
                    /* try { // try from 0046f80e to 0046f812 has its CatchHandler @ 0046fa03 */
  KeyValues::KeyValues(this_00,"VoiceCommands",0);
  pIVar2 = (IBaseFileSystem *)0x0;
  if (filesystem != 0) {
    pIVar2 = (IBaseFileSystem *)(filesystem + 4);
  }
  cVar1 = KeyValues::LoadFromFile(this_00,pIVar2,"scripts/voicecommands.txt","GAME");
  if ((cVar1 != '\0') &&
     (local_74 = (KeyValues *)KeyValues::GetFirstSubKey(this_00), local_74 != (KeyValues *)0x0)) {
    do {
      iVar3 = CUtlVector<CUtlVector<VoiceCommandMenuItem_t,CUtlMemory<VoiceCommandMenuItem_t,int>>,CUtlMemory<CUtlVector<VoiceCommandMenuItem_t,CUtlMemory<VoiceCommandMenuItem_t,int>>,int>>
              ::InsertBefore((CUtlVector<CUtlVector<VoiceCommandMenuItem_t,CUtlMemory<VoiceCommandMenuItem_t,int>>,CUtlMemory<CUtlVector<VoiceCommandMenuItem_t,CUtlMemory<VoiceCommandMenuItem_t,int>>,int>>
                              *)(this + 0x24),*(int *)(this + 0x30));
      this_01 = (KeyValues *)KeyValues::GetFirstSubKey(local_74);
      if (this_01 != (KeyValues *)0x0) {
        iVar7 = 0;
        do {
          while (iVar7 = iVar7 + 1, 9 < iVar7) {
            Warning("Trying to load more than 9 menu items in voicecommands.txt, extras ignored");
            this_01 = (KeyValues *)KeyValues::GetNextKey(this_01);
            if (this_01 == (KeyValues *)0x0) goto LAB_0046f9af;
          }
          pcVar4 = (char *)KeyValues::GetString(this_01,"concept","");
          iVar5 = GetMPConceptIndexFromString(pcVar4);
          if (iVar5 == -1) {
            uVar6 = KeyValues::GetString(this_01,"concept","");
            Warning("Voicecommand script attempting to use unknown concept. Need to define new concepts in code. ( %s )\n"
                    ,uVar6);
          }
          local_68 = iVar5;
          iVar5 = KeyValues::GetInt(this_01,"show_subtitle",0);
          local_64 = 0 < iVar5;
          iVar5 = KeyValues::GetInt(this_01,"distance_check_subtitle",0);
          local_63 = 0 < iVar5;
          pcVar4 = (char *)KeyValues::GetString(this_01,"activity","");
          V_strncpy(local_62,pcVar4,0x40);
          this_02 = (CUtlVector<VoiceCommandMenuItem_t,CUtlMemory<VoiceCommandMenuItem_t,int>> *)
                    (*(int *)(this + 0x24) + iVar3 * 0x14);
          CUtlVector<VoiceCommandMenuItem_t,CUtlMemory<VoiceCommandMenuItem_t,int>>::InsertBefore
                    (this_02,*(int *)(this_02 + 0xc),(VoiceCommandMenuItem_t *)&local_68);
          this_01 = (KeyValues *)KeyValues::GetNextKey(this_01);
        } while (this_01 != (KeyValues *)0x0);
      }
LAB_0046f9af:
      local_74 = (KeyValues *)KeyValues::GetNextKey(local_74);
    } while (local_74 != (KeyValues *)0x0);
  }
  KeyValues::deleteThis();
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail(this_00);
  }
  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)