L L4D2node

ScriptTableFromKeyValues

0x008a1960 · 977 bytes · __cdecl

_Z24ScriptTableFromKeyValuesP9IScriptVMP9KeyValuesP9HSCRIPT__

Decompiled

undefined (3 params)

/* ScriptTableFromKeyValues(IScriptVM*, KeyValues*, HSCRIPT__*) */

HSCRIPT__ * ScriptTableFromKeyValues(IScriptVM *param_1,KeyValues *param_2,HSCRIPT__ *param_3)

{
  KeyValues *this;
  undefined4 uVar1;
  HSCRIPT__ *pHVar2;
  undefined4 uVar3;
  int in_GS_OFFSET;
  longdouble lVar4;
  undefined8 uVar5;
  HSCRIPT__ *local_b0;
  HSCRIPT__ *local_ac;
  undefined4 local_a8;
  undefined2 local_a4;
  ushort local_a2;
  HSCRIPT__ local_a0 [128];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  local_b0 = param_3;
  if ((param_2 == (KeyValues *)0x0) || (param_1 == (IScriptVM *)0x0)) {
    local_b0 = (HSCRIPT__ *)0x0;
  }
  else {
    if (param_3 == (HSCRIPT__ *)&DAT_ffffffff) {
      local_ac = (HSCRIPT__ *)0x0;
      local_a4 = 0;
      local_a2 = 0;
                    /* try { // try from 008a1d0e to 008a1d13 has its CatchHandler @ 008a1d41 */
      (**(code **)(*(int *)param_1 + 0x80))(param_1,&local_ac);
      local_b0 = local_ac;
      if ((local_a2 & 1) != 0) {
        free(local_ac);
      }
    }
    for (this = (KeyValues *)KeyValues::GetFirstSubKey(param_2); this != (KeyValues *)0x0;
        this = (KeyValues *)KeyValues::GetNextKey(this)) {
      local_a4 = 0;
      local_a2 = 0;
      local_ac = (HSCRIPT__ *)0x0;
                    /* try { // try from 008a19e5 to 008a1ab4 has its CatchHandler @ 008a1d58 */
      uVar1 = KeyValues::GetDataType(this,(char *)0x0);
      switch(uVar1) {
      case 0:
        pHVar2 = (HSCRIPT__ *)ScriptTableFromKeyValues(param_1,this,(HSCRIPT__ *)&DAT_ffffffff);
        if ((local_a2 & 1) != 0) {
          free(local_ac);
          local_a2 = local_a2 & 0xfffe;
        }
        local_a4 = 0x20;
        local_ac = pHVar2;
        break;
      case 1:
        pHVar2 = (HSCRIPT__ *)KeyValues::GetString(this,(char *)0x0,"");
        if ((local_a2 & 1) != 0) {
          free(local_ac);
          local_a2 = local_a2 & 0xfffe;
        }
        local_a4 = 0x1f;
        local_ac = pHVar2;
        break;
      case 2:
        pHVar2 = (HSCRIPT__ *)KeyValues::GetInt(this,(char *)0x0,0);
        if ((local_a2 & 1) != 0) {
          free(local_ac);
          local_a2 = local_a2 & 0xfffe;
        }
        local_a4 = 5;
        local_ac = pHVar2;
        break;
      case 3:
                    /* try { // try from 008a1b19 to 008a1cdd has its CatchHandler @ 008a1d58 */
        lVar4 = (longdouble)KeyValues::GetFloat(this,(char *)0x0,0.0);
        if ((local_a2 & 1) != 0) {
          free(local_ac);
          local_a2 = local_a2 & 0xfffe;
        }
        local_a4 = 1;
        local_ac = (HSCRIPT__ *)(float)lVar4;
        break;
      default:
        uVar1 = KeyValues::GetDataType(this,(char *)0x0);
        uVar3 = KeyValues::GetName(this);
        Warning("ScriptVmKeyValueToVariant failed to package parameter %s (type %d)\n",uVar3,uVar1);
        goto LAB_008a1ab5;
      case 7:
        uVar5 = KeyValues::GetUint64((char *)this,0);
        V_snprintf((char *)local_a0,0x80,"%llu",(int)uVar5,(int)((ulonglong)uVar5 >> 0x20));
        if ((local_a2 & 1) != 0) {
          free(local_ac);
          local_a2 = local_a2 & 0xfffe;
        }
        local_a4 = 0x1f;
        local_ac = local_a0;
      }
      local_a8 = 0;
      uVar1 = KeyValues::GetName(this);
      (**(code **)(*(int *)param_1 + 0x78))(param_1,local_b0,uVar1,&local_ac);
LAB_008a1ab5:
      if ((local_a2 & 1) != 0) {
        free(local_ac);
      }
    }
  }
  if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
    return local_b0;
  }
                    /* WARNING: Subroutine does not return */
  __stack_chk_fail();
}

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)