L L4D2node

KeyValues::RecursiveSaveToFile

0x0024c420 · 2239 bytes · __thiscall

_ZN9KeyValues19RecursiveSaveToFileEP15IBaseFileSystemPvP10CUtlBufferi

Decompiled

undefined (5 params)

/* KeyValues::RecursiveSaveToFile(IBaseFileSystem*, void*, CUtlBuffer*, int) */

void __thiscall
KeyValues::RecursiveSaveToFile
          (KeyValues *this,IBaseFileSystem *param_1,void *param_2,CUtlBuffer *param_3,int param_4)

{
  KeyValues *this_00;
  char *pcVar1;
  void *pvVar2;
  int iVar3;
  int in_GS_OFFSET;
  char local_50 [48];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  if (param_4 < 1) {
    InternalWrite(this,param_1,param_2,param_3,&DAT_002cc2b5,1);
    pcVar1 = (char *)GetName(this);
    WriteConvertedString(this,param_1,param_2,param_3,pcVar1);
    InternalWrite(this,param_1,param_2,param_3,&DAT_002af868,2);
  }
  else {
    iVar3 = 0;
    do {
      iVar3 = iVar3 + 1;
      InternalWrite(this,param_1,param_2,param_3,&DAT_002c79d3,1);
    } while (iVar3 != param_4);
    InternalWrite(this,param_1,param_2,param_3,&DAT_002cc2b5,1);
    pcVar1 = (char *)GetName(this);
    WriteConvertedString(this,param_1,param_2,param_3,pcVar1);
    InternalWrite(this,param_1,param_2,param_3,&DAT_002af868,2);
    iVar3 = 0;
    do {
      iVar3 = iVar3 + 1;
      InternalWrite(this,param_1,param_2,param_3,&DAT_002c79d3,1);
    } while (iVar3 != param_4);
  }
  InternalWrite(this,param_1,param_2,param_3,&DAT_002cc281,2);
  this_00 = *(KeyValues **)(this + 0x20);
  do {
    if (this_00 == (KeyValues *)0x0) {
      if (0 < param_4) {
        iVar3 = 0;
        do {
          iVar3 = iVar3 + 1;
          InternalWrite(this,param_1,param_2,param_3,&DAT_002c79d3,1);
        } while (iVar3 != param_4);
      }
      InternalWrite(this,param_1,param_2,param_3,&DAT_002a4aed,2);
      if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
        return;
      }
                    /* WARNING: Subroutine does not return */
      __stack_chk_fail();
    }
    if (*(int *)(this_00 + 0x20) != 0) {
      RecursiveSaveToFile(this_00,param_1,param_2,param_3,param_4 + 1);
      goto switchD_0024c5c6_caseD_0;
    }
    switch(this_00[0x10]) {
    case (KeyValues)0x1:
      if ((*(char **)(this_00 + 4) != (char *)0x0) && (**(char **)(this_00 + 4) != '\0')) {
        if (-1 < param_4) {
          iVar3 = 0;
          do {
            iVar3 = iVar3 + 1;
            InternalWrite(this,param_1,param_2,param_3,&DAT_002c79d3,1);
          } while (iVar3 <= param_4);
        }
        InternalWrite(this,param_1,param_2,param_3,&DAT_002cc2b5,1);
        pcVar1 = (char *)GetName(this_00);
        WriteConvertedString(this,param_1,param_2,param_3,pcVar1);
        InternalWrite(this,param_1,param_2,param_3,&DAT_002cc2b2,4);
        WriteConvertedString(this,param_1,param_2,param_3,*(char **)(this_00 + 4));
        goto LAB_0024c9f2;
      }
      break;
    case (KeyValues)0x2:
      if (-1 < param_4) {
        iVar3 = 0;
        do {
          iVar3 = iVar3 + 1;
          InternalWrite(this,param_1,param_2,param_3,&DAT_002c79d3,1);
        } while (iVar3 <= param_4);
      }
      InternalWrite(this,param_1,param_2,param_3,&DAT_002cc2b5,1);
      pcVar1 = (char *)GetName(this_00);
      iVar3 = _V_strlen(pcVar1);
      pvVar2 = (void *)GetName(this_00);
      InternalWrite(this,param_1,param_2,param_3,pvVar2,iVar3);
      InternalWrite(this,param_1,param_2,param_3,&DAT_002cc2b2,4);
      V_snprintf(local_50,0x20,"%d",*(undefined4 *)(this_00 + 0xc));
      goto LAB_0024cb2b;
    case (KeyValues)0x3:
      if (-1 < param_4) {
        iVar3 = 0;
        do {
          iVar3 = iVar3 + 1;
          InternalWrite(this,param_1,param_2,param_3,&DAT_002c79d3,1);
        } while (iVar3 <= param_4);
      }
      InternalWrite(this,param_1,param_2,param_3,&DAT_002cc2b5,1);
      pcVar1 = (char *)GetName(this_00);
      iVar3 = _V_strlen(pcVar1);
      pvVar2 = (void *)GetName(this_00);
      InternalWrite(this,param_1,param_2,param_3,pvVar2,iVar3);
      InternalWrite(this,param_1,param_2,param_3,&DAT_002cc2b2,4);
      V_snprintf(local_50,0x30,"%f",(double)*(float *)(this_00 + 0xc));
      iVar3 = _V_strlen(local_50);
      InternalWrite(this,param_1,param_2,param_3,local_50,iVar3);
LAB_0024c9f2:
      InternalWrite(this,param_1,param_2,param_3,&DAT_002af868,2);
      break;
    case (KeyValues)0x5:
      if ((*(wchar_t **)(this_00 + 8) == (wchar_t *)0x0) ||
         (iVar3 = V_UnicodeToUTF8(*(wchar_t **)(this_00 + 8),
                                  RecursiveSaveToFile(IBaseFileSystem*,void*,CUtlBuffer*,int)::buf,
                                  0x400), iVar3 == 0)) break;
      if (-1 < param_4) {
        iVar3 = 0;
        do {
          iVar3 = iVar3 + 1;
          InternalWrite(this,param_1,param_2,param_3,&DAT_002c79d3,1);
        } while (iVar3 <= param_4);
      }
      InternalWrite(this,param_1,param_2,param_3,&DAT_002cc2b5,1);
      pcVar1 = (char *)GetName(this_00);
      iVar3 = _V_strlen(pcVar1);
      pvVar2 = (void *)GetName(this_00);
      InternalWrite(this,param_1,param_2,param_3,pvVar2,iVar3);
      InternalWrite(this,param_1,param_2,param_3,&DAT_002cc2b2,4);
      WriteConvertedString
                (this,param_1,param_2,param_3,
                 RecursiveSaveToFile(IBaseFileSystem*,void*,CUtlBuffer*,int)::buf);
      goto LAB_0024cb5b;
    case (KeyValues)0x6:
      DevMsg(1,"KeyValues::RecursiveSaveToFile: TODO, missing code for TYPE_COLOR.\n");
      break;
    case (KeyValues)0x7:
      if (-1 < param_4) {
        iVar3 = 0;
        do {
          iVar3 = iVar3 + 1;
          InternalWrite(this,param_1,param_2,param_3,&DAT_002c79d3,1);
        } while (iVar3 <= param_4);
      }
      InternalWrite(this,param_1,param_2,param_3,&DAT_002cc2b5,1);
      pcVar1 = (char *)GetName(this_00);
      iVar3 = _V_strlen(pcVar1);
      pvVar2 = (void *)GetName(this_00);
      InternalWrite(this,param_1,param_2,param_3,pvVar2,iVar3);
      InternalWrite(this,param_1,param_2,param_3,&DAT_002cc2b2,4);
      V_snprintf(local_50,0x20,"0x%016llX",**(undefined4 **)(this_00 + 4));
LAB_0024cb2b:
      iVar3 = _V_strlen(local_50);
      InternalWrite(this,param_1,param_2,param_3,local_50,iVar3);
LAB_0024cb5b:
      InternalWrite(this,param_1,param_2,param_3,&DAT_002af868,2);
    }
switchD_0024c5c6_caseD_0:
    this_00 = *(KeyValues **)(this_00 + 0x1c);
  } while( true );
}

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)