L L4D2node

CTerrorPlayer::RestoreWeapons

0x0099ca40 · 644 bytes · __thiscall

_ZN13CTerrorPlayer14RestoreWeaponsEv

Decompiled

undefined (1 param)

/* CTerrorPlayer::RestoreWeapons() */

void __thiscall CTerrorPlayer::RestoreWeapons(CTerrorPlayer *this)

{
  code *pcVar1;
  CBaseEdict *this_00;
  char cVar2;
  undefined4 uVar3;
  int *piVar4;
  int iVar5;
  int iVar6;
  int iVar7;
  int iVar8;
  int iVar9;
  bool bVar10;
  
  if (this[0x4000] != (CTerrorPlayer)0x0) {
    return;
  }
  iVar9 = *(int *)(this + 0x3f94);
  iVar8 = *(int *)(survivor_respawn_with_guns._28_4_ + 0x30);
  cVar2 = CTerrorGameRules::IsScavengeMode();
  if ((cVar2 == '\0') && (cVar2 = CTerrorGameRules::IsSurvivalMode(), cVar2 == '\0')) {
    cVar2 = CDirector::IsFirstMapInScenario();
    if (cVar2 != '\0') goto LAB_0099ca80;
    iVar7 = *(int *)(this + 0x3f98);
    if (iVar8 == 2) {
      if (iVar7 == 1) {
        if (this[0x3f9c] == (CTerrorPlayer)0x0) goto LAB_0099cb99;
        (**(code **)(*(int *)this + 0x6c0))(this,"weapon_pistol",0,1,0);
      }
      else if (iVar7 != 0) {
LAB_0099cb99:
        pcVar1 = *(code **)(*(int *)this + 0x6c0);
        uVar3 = WeaponIDToClassname(iVar7);
        (*pcVar1)(this,uVar3,0,1,0);
      }
      goto LAB_0099ca82;
    }
    iVar7 = *(int *)(this + 0x3f90);
    if (iVar7 == 0) {
      return;
    }
    if (iVar8 != 1) goto LAB_0099ca90;
    iVar8 = GetWeaponInfo(iVar7);
    if ((iVar8 != 0) && ((*(int *)(iVar8 + 0xbe8) == 2 || (iVar7 == 0x15)))) {
      iVar8 = *(int *)(iVar8 + 0x894);
      if ((iVar8 == 4) || (iVar8 == 2)) {
        iVar8 = 1;
      }
      iVar5 = 3;
      if (iVar7 != 0x15) {
        iVar5 = iVar8;
      }
      iVar8 = 1;
      do {
        iVar6 = GetWeaponInfo(iVar8);
        if (((iVar6 != 0) && (*(int *)(iVar6 + 0x894) == iVar5)) && (*(int *)(iVar6 + 0xbe8) == 1))
        {
          bVar10 = false;
          iVar7 = iVar8;
          goto LAB_0099ca9b;
        }
        iVar8 = iVar8 + 1;
      } while (iVar8 != 0x2d);
      bVar10 = iVar9 != -1;
      goto LAB_0099ca9b;
    }
  }
  else {
    iVar9 = -1;
LAB_0099ca80:
    iVar8 = 0;
LAB_0099ca82:
    iVar7 = *(int *)(this + 0x3f90);
    if (iVar7 == 0) {
      return;
    }
LAB_0099ca90:
    if (iVar8 == 0) {
      return;
    }
  }
  bVar10 = iVar9 != -1;
LAB_0099ca9b:
  pcVar1 = *(code **)(*(int *)this + 0x6c0);
  uVar3 = WeaponIDToAlias(iVar7);
  uVar3 = UTIL_VarArgs("weapon_%s",uVar3);
  piVar4 = (int *)(*pcVar1)(this,uVar3,0,1,0);
  if ((piVar4 != (int *)0x0) && (bVar10)) {
    iVar9 = (**(code **)(*piVar4 + 0x55c))(piVar4);
    if (iVar9 != -1) {
      CBaseCombatCharacter::SetAmmoCount((CBaseCombatCharacter *)this,*(int *)(this + 0x3f94),iVar9)
      ;
    }
    if (*(char *)((int)piVar4 + 0x17e2) != '\0') {
      if ((char)piVar4[0x1b] == '\0') {
        this_00 = (CBaseEdict *)piVar4[0xc];
        if (this_00 != (CBaseEdict *)0x0) {
          *(uint *)this_00 = *(uint *)this_00 | 0x101;
          iVar9 = CBaseEdict::GetChangeAccessor(this_00);
          *(undefined2 *)(iVar9 + 2) = 0;
        }
      }
      else {
        *(byte *)(piVar4 + 0x1c) = *(byte *)(piVar4 + 0x1c) | 1;
      }
      *(undefined1 *)((int)piVar4 + 0x17e2) = 0;
    }
  }
  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)