L L4D2node

OnRunCommand_Avatar

0x0003b910 · 1072 bytes · __regparm3

_ZL19OnRunCommand_AvatarP9KeyValuesS0_PS0_

Decompiled

undefined (3 params)

/* OnRunCommand_Avatar(KeyValues*, KeyValues*, KeyValues**) */

void __regparm3 OnRunCommand_Avatar(KeyValues *param_1,KeyValues *param_2,KeyValues **param_3)

{
  char *pcVar1;
  KeyValues *this;
  KeyValues *pKVar2;
  int iVar3;
  KeyValues *pKVar4;
  int iVar5;
  KeyValues *this_00;
  char *pcVar6;
  int iVar7;
  int iVar8;
  int iVar9;
  int in_GS_OFFSET;
  longlong lVar10;
  longlong lVar11;
  undefined4 uVar12;
  int local_140;
  int local_134;
  CFmtStrN<256> local_12c [5];
  char local_127 [263];
  int local_20;
  
  uVar12 = 0;
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  lVar10 = KeyValues::GetUint64((char *)param_1,0xb4d28);
  pcVar1 = (char *)KeyValues::GetString(param_1,"avatar","");
  this = (KeyValues *)KeyValues::FindKey(param_2,"Members",false);
  if ((((this != (KeyValues *)0x0) && (param_2 != (KeyValues *)0x0)) &&
      (pKVar2 = (KeyValues *)KeyValues::FindKey(param_2,"Members",false), pKVar2 != (KeyValues *)0x0
      )) && (iVar3 = KeyValues::GetInt(pKVar2,"numMachines",0), 0 < iVar3)) {
    local_140 = 0;
    do {
      CFmtStrN<256>::CFmtStrN(local_12c,"machine%d",local_140,uVar12);
      pKVar4 = (KeyValues *)KeyValues::FindKey(pKVar2,local_127,false);
      if ((pKVar4 != (KeyValues *)0x0) &&
         (iVar5 = KeyValues::GetInt(pKVar4,"numPlayers",0), 0 < iVar5)) {
        iVar8 = 0;
        do {
          CFmtStrN<256>::CFmtStrN(local_12c,"player%d",iVar8,uVar12);
          this_00 = (KeyValues *)KeyValues::FindKey(pKVar4,local_127,false);
          if (this_00 != (KeyValues *)0x0) {
            uVar12 = 0;
            lVar11 = KeyValues::GetUint64((char *)this_00,0xb4d28);
            if (lVar10 == lVar11) {
              pcVar6 = (char *)KeyValues::GetString(this_00,"Game/avatar","");
              iVar3 = _V_stricmp(pcVar1,pcVar6);
              if ((iVar3 != 0) &&
                 (pKVar2 = (KeyValues *)KeyValues::FindKey(this_00,"Game",true),
                 pKVar2 != (KeyValues *)0x0)) {
                if (*pcVar1 == '\0') {
                  KeyValues::SetString(pKVar2,"avatar","");
                }
                else {
                  iVar3 = KeyValues::GetInt(this,"numMachines",0);
                  if (iVar3 < 1) {
                    _V_stricmp(pcVar1,"Infected");
                  }
                  else {
                    local_134 = 0;
                    iVar5 = 0;
                    do {
                      CFmtStrN<256>::CFmtStrN(local_12c,"machine%d",local_134);
                      pKVar4 = (KeyValues *)KeyValues::FindKey(this,local_127,false);
                      if ((pKVar4 != (KeyValues *)0x0) &&
                         (iVar8 = KeyValues::GetInt(pKVar4,"numPlayers",0), 0 < iVar8)) {
                        iVar9 = 0;
                        do {
                          CFmtStrN<256>::CFmtStrN(local_12c,"player%d/Game/avatar",iVar9);
                          pcVar6 = (char *)KeyValues::GetString(pKVar4,local_127,"");
                          iVar7 = _V_stricmp(pcVar6,pcVar1);
                          iVar5 = iVar5 + (uint)(iVar7 == 0);
                          iVar9 = iVar9 + 1;
                        } while (iVar9 != iVar8);
                      }
                      local_134 = local_134 + 1;
                    } while (local_134 != iVar3);
                    iVar3 = _V_stricmp(pcVar1,"Infected");
                    if (iVar3 == 0) {
                      if (3 < iVar5) goto LAB_0003bb00;
                    }
                    else if (iVar5 != 0) goto LAB_0003bb00;
                  }
                  KeyValues::SetString(pKVar2,"avatar",pcVar1);
                }
                *param_3 = this_00;
              }
              goto LAB_0003bb00;
            }
          }
          iVar8 = iVar8 + 1;
        } while (iVar8 != iVar5);
      }
      local_140 = local_140 + 1;
    } while (local_140 != iVar3);
  }
LAB_0003bb00:
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail();
  }
  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)