L L4D2node

CTerrorGun::AddUpgrade

0x00564680 · 367 bytes · __thiscall

_ZN10CTerrorGun10AddUpgradeE19SurvivorUpgradeType

Decompiled

undefined (2 params)

/* CTerrorGun::AddUpgrade(SurvivorUpgradeType) */

undefined4 __thiscall CTerrorGun::AddUpgrade(CTerrorGun *this,int param_2)

{
  CTerrorGun *pCVar1;
  CBaseEdict *this_00;
  char cVar2;
  int *piVar3;
  undefined4 uVar4;
  int iVar5;
  uint uVar6;
  int *piVar7;
  uint uVar8;
  
  piVar3 = (int *)GetUpgradeInfo(param_2);
  if (piVar3 == (int *)0x0) {
LAB_00564786:
    uVar4 = 0;
  }
  else {
    if ((code *)piVar3[3] != (code *)0x0) {
      cVar2 = (*(code *)piVar3[3])(this);
      if (cVar2 == '\0') goto LAB_00564786;
    }
    cVar2 = (**(code **)(*(int *)this + 0x6b4))(this,param_2);
    if (cVar2 != '\0') {
      if ((char)piVar3[7] == '\0') goto LAB_00564786;
      (**(code **)(*(int *)this + 0x6ac))(this,param_2);
      if ((code *)piVar3[5] != (code *)0x0) {
        (*(code *)piVar3[5])(this);
      }
    }
    if (piVar3[6] != 0) {
      piVar7 = &UpgradeDatabase;
      do {
        if (*piVar7 != *piVar3) {
          cVar2 = (**(code **)(*(int *)this + 0x6b4))(this,*piVar7);
          if ((cVar2 != '\0') && (piVar7[6] == piVar3[6])) {
            (**(code **)(*(int *)this + 0x6ac))(this,*piVar7);
            if ((code *)piVar7[5] != (code *)0x0) {
              (*(code *)piVar7[5])(this);
            }
          }
        }
        piVar7 = piVar7 + 9;
      } while (piVar7 != (int *)&DAT_00f1c30c);
    }
    if ((code *)piVar3[4] != (code *)0x0) {
      (*(code *)piVar3[4])(this);
    }
    uVar8 = 1 << ((byte)param_2 & 0x1f);
    pCVar1 = this + (param_2 >> 5) * 4 + 0x17e4;
    uVar6 = *(uint *)pCVar1;
    uVar4 = 1;
    if ((uVar6 & uVar8) == 0) {
      if (this[0x6c] == (CTerrorGun)0x0) {
        this_00 = *(CBaseEdict **)(this + 0x30);
        if (this_00 != (CBaseEdict *)0x0) {
          *(uint *)this_00 = *(uint *)this_00 | 0x101;
          iVar5 = CBaseEdict::GetChangeAccessor(this_00);
          *(undefined2 *)(iVar5 + 2) = 0;
          uVar6 = *(uint *)pCVar1;
        }
      }
      else {
        this[0x70] = (CTerrorGun)((byte)this[0x70] | 1);
        uVar6 = *(uint *)pCVar1;
      }
      *(uint *)pCVar1 = uVar8 | uVar6;
      return 1;
    }
  }
  return uVar4;
}

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)