L L4D2node

CBaseCombatWeapon::DefaultReload

0x00409500 · 1000 bytes · __thiscall

_ZN17CBaseCombatWeapon13DefaultReloadEiii

Decompiled

undefined (4 params)

/* CBaseCombatWeapon::DefaultReload(int, int, int) */

CBaseCombatWeapon __thiscall
CBaseCombatWeapon::DefaultReload(CBaseCombatWeapon *this,int param_1,int param_2,int param_3)

{
  CBaseCombatWeapon CVar1;
  CBaseEdict *pCVar2;
  int *piVar3;
  char cVar4;
  CBaseCombatCharacter *this_00;
  int iVar5;
  CStudioHdr *pCVar6;
  int iVar7;
  CStudioHdr *pCVar8;
  float fVar9;
  bool bVar10;
  longdouble lVar11;
  longdouble lVar12;
  float fVar13;
  
  this_00 = (CBaseCombatCharacter *)GetOwner(this);
  if (this_00 == (CBaseCombatCharacter *)0x0) {
    return (CBaseCombatWeapon)0x0;
  }
  iVar5 = CBaseCombatCharacter::GetAmmoCount(this_00,*(int *)(this + 0x1418));
  if (iVar5 < 1) {
    return (CBaseCombatWeapon)0x0;
  }
  bVar10 = false;
  cVar4 = (**(code **)(*(int *)this + 0x548))(this);
  if (cVar4 != '\0') {
    iVar5 = *(int *)(this + 0x1420);
    iVar7 = CBaseCombatCharacter::GetAmmoCount(this_00,*(int *)(this + 0x1418));
    if (param_1 - iVar5 < iVar7) {
      iVar5 = param_1 - *(int *)(this + 0x1420);
    }
    else {
      iVar5 = CBaseCombatCharacter::GetAmmoCount(this_00,*(int *)(this + 0x1418));
    }
    bVar10 = iVar5 != 0;
  }
  cVar4 = (**(code **)(*(int *)this + 0x54c))(this);
  if (cVar4 == '\0') {
LAB_0040955c:
    if (!bVar10) {
      CVar1 = this[0x1428];
      if (CVar1 == (CBaseCombatWeapon)0x0) {
        return (CBaseCombatWeapon)0x0;
      }
      if (this[0x1459] != (CBaseCombatWeapon)0x1) {
        if (this[0x6c] == (CBaseCombatWeapon)0x0) {
          pCVar2 = *(CBaseEdict **)(this + 0x30);
          if (pCVar2 != (CBaseEdict *)0x0) {
            *(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
            iVar5 = CBaseEdict::GetChangeAccessor(pCVar2);
            *(undefined2 *)(iVar5 + 2) = 0;
          }
        }
        else {
          this[0x70] = (CBaseCombatWeapon)((byte)this[0x70] | 1);
        }
        this[0x1459] = (CBaseCombatWeapon)0x1;
        return CVar1;
      }
      return CVar1;
    }
  }
  else {
    iVar5 = *(int *)(this + 0x1424);
    iVar7 = CBaseCombatCharacter::GetAmmoCount(this_00,*(int *)(this + 0x141c));
    if (param_2 - iVar5 < iVar7) {
      iVar5 = param_2 - *(int *)(this + 0x1424);
    }
    else {
      iVar5 = CBaseCombatCharacter::GetAmmoCount(this_00,*(int *)(this + 0x141c));
    }
    if (iVar5 == 0) goto LAB_0040955c;
  }
  (**(code **)(*(int *)this + 0x3f0))(this,param_3);
  cVar4 = (**(code **)(*(int *)this_00 + 0x16c))(this_00);
  if (cVar4 != '\0') {
    (**(code **)(*(int *)this_00 + 0x620))(this_00,7);
  }
  piVar3 = mdlcache;
  (**(code **)(*mdlcache + 0x68))(mdlcache);
  fVar13 = *(float *)(gpGlobals + 0xc);
  iVar5 = *(int *)(this + 0x494);
  pCVar6 = *(CStudioHdr **)(this + 0x13e0);
  if (pCVar6 == (CStudioHdr *)0x0) {
    iVar7 = CBaseEntity::GetModel((CBaseEntity *)this);
    if (iVar7 != 0) {
      CBaseAnimating::LockStudioHdr((CBaseAnimating *)this);
    }
    pCVar6 = *(CStudioHdr **)(this + 0x13e0);
    pCVar8 = (CStudioHdr *)0x0;
    if (pCVar6 == (CStudioHdr *)0x0) goto LAB_0040966a;
  }
  pCVar8 = (CStudioHdr *)0x0;
  if (*(int *)pCVar6 != 0) {
    pCVar8 = pCVar6;
  }
LAB_0040966a:
                    /* try { // try from 00409678 to 00409737 has its CatchHandler @ 0040992a */
  lVar11 = (longdouble)CBaseAnimating::SequenceDuration((CBaseAnimating *)this,pCVar8,iVar5);
  lVar12 = (longdouble)(**(code **)(*(int *)this + 0x59c))(this);
  fVar13 = (float)lVar12 * (float)lVar11 + fVar13;
  lVar11 = (longdouble)(**(code **)(*(int *)this + 0x59c))(this);
  if (1.0 / (float)lVar11 != *(float *)(this + 0x468)) {
    if (this[0x6c] == (CBaseCombatWeapon)0x0) {
      pCVar2 = *(CBaseEdict **)(this + 0x30);
      if (pCVar2 != (CBaseEdict *)0x0) {
        *(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
        iVar5 = CBaseEdict::GetChangeAccessor(pCVar2);
        *(undefined2 *)(iVar5 + 2) = 0;
      }
    }
    else {
      this[0x70] = (CBaseCombatWeapon)((byte)this[0x70] | 1);
    }
    *(float *)(this + 0x468) = 1.0 / (float)lVar11;
  }
  if (fVar13 != *(float *)(this_00 + 0x17dc)) {
    if (this_00[0x6c] == (CBaseCombatCharacter)0x0) {
      pCVar2 = *(CBaseEdict **)(this_00 + 0x30);
      if (pCVar2 != (CBaseEdict *)0x0) {
        *(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
        iVar5 = CBaseEdict::GetChangeAccessor(pCVar2);
        *(undefined2 *)(iVar5 + 2) = 0;
      }
    }
    else {
      this_00[0x70] = (CBaseCombatCharacter)((byte)this_00[0x70] | 1);
    }
    *(float *)(this_00 + 0x17dc) = fVar13;
  }
  fVar9 = *(float *)(this + 0x1400);
  if (fVar13 != *(float *)(this + 0x1400)) {
    if (this[0x6c] == (CBaseCombatWeapon)0x0) {
      pCVar2 = *(CBaseEdict **)(this + 0x30);
      if (pCVar2 != (CBaseEdict *)0x0) {
        *(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
        iVar5 = CBaseEdict::GetChangeAccessor(pCVar2);
        *(undefined2 *)(iVar5 + 2) = 0;
      }
    }
    else {
      this[0x70] = (CBaseCombatWeapon)((byte)this[0x70] | 1);
    }
    *(float *)(this + 0x1400) = fVar13;
    fVar9 = fVar13;
  }
  if (fVar9 != *(float *)(this + 0x13fc)) {
    if (this[0x6c] == (CBaseCombatWeapon)0x0) {
      pCVar2 = *(CBaseEdict **)(this + 0x30);
      if (pCVar2 != (CBaseEdict *)0x0) {
        *(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
                    /* try { // try from 0040981b to 00409914 has its CatchHandler @ 0040992a */
        iVar5 = CBaseEdict::GetChangeAccessor(pCVar2);
        *(undefined2 *)(iVar5 + 2) = 0;
      }
    }
    else {
      this[0x70] = (CBaseCombatWeapon)((byte)this[0x70] | 1);
    }
    *(float *)(this + 0x13fc) = fVar9;
  }
  if (this[0x1459] != (CBaseCombatWeapon)0x1) {
    if (this[0x6c] == (CBaseCombatWeapon)0x0) {
      pCVar2 = *(CBaseEdict **)(this + 0x30);
      if (pCVar2 != (CBaseEdict *)0x0) {
        *(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
        iVar5 = CBaseEdict::GetChangeAccessor(pCVar2);
        *(undefined2 *)(iVar5 + 2) = 0;
      }
    }
    else {
      this[0x70] = (CBaseCombatWeapon)((byte)this[0x70] | 1);
    }
    this[0x1459] = (CBaseCombatWeapon)0x1;
  }
  (**(code **)(*piVar3 + 0x6c))(piVar3);
  return (CBaseCombatWeapon)0x1;
}

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)