L L4D2node

CBaseCombatWeapon::Precache

0x00405570 · 1283 bytes · __thiscall

_ZN17CBaseCombatWeapon8PrecacheEv

Decompiled

undefined (1 param)

/* CBaseCombatWeapon::Precache() */

void __thiscall CBaseCombatWeapon::Precache(CBaseCombatWeapon *this)

{
  CBaseEdict *pCVar1;
  char cVar2;
  undefined1 uVar3;
  int iVar4;
  uchar *puVar5;
  int iVar6;
  CAmmoDef *pCVar7;
  undefined1 *puVar8;
  char *pcVar9;
  
  if (*(int *)(this + 0x141c) != -1) {
    if (this[0x6c] == (CBaseCombatWeapon)0x0) {
      pCVar1 = *(CBaseEdict **)(this + 0x30);
      if (pCVar1 != (CBaseEdict *)0x0) {
        *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
        iVar4 = CBaseEdict::GetChangeAccessor(pCVar1);
        *(undefined2 *)(iVar4 + 2) = 0;
      }
    }
    else {
      this[0x70] = (CBaseCombatWeapon)((byte)this[0x70] | 1);
    }
    *(undefined4 *)(this + 0x141c) = 0xffffffff;
  }
  if (*(int *)(this + 0x1418) != -1) {
    if (this[0x6c] == (CBaseCombatWeapon)0x0) {
      pCVar1 = *(CBaseEdict **)(this + 0x30);
      if (pCVar1 != (CBaseEdict *)0x0) {
        *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
        iVar4 = CBaseEdict::GetChangeAccessor(pCVar1);
        *(undefined2 *)(iVar4 + 2) = 0;
      }
    }
    else {
      this[0x70] = (CBaseCombatWeapon)((byte)this[0x70] | 1);
    }
    *(undefined4 *)(this + 0x1418) = 0xffffffff;
  }
  puVar5 = (uchar *)(**(code **)(*(int *)this + 0x558))(this);
  pcVar9 = *(char **)(this + 0x7c);
  if (pcVar9 == (char *)0x0) {
    pcVar9 = "";
  }
  cVar2 = ReadWeaponDataFromFileForSlot(filesystem,pcVar9,(ushort *)(this + 0x1474),puVar5);
  if (cVar2 == '\0') {
    puVar8 = &DAT_00d539c2;
    if (*(undefined1 **)(this + 0x7c) != (undefined1 *)0x0) {
      puVar8 = *(undefined1 **)(this + 0x7c);
    }
    Warning("Error reading weapon data file for: %s\n",puVar8);
  }
  else {
    iVar4 = GetFileWeaponInfoFromHandle(*(ushort *)(this + 0x1474));
    if (*(char *)(iVar4 + 0x180) != '\0') {
      iVar4 = GetFileWeaponInfoFromHandle(*(ushort *)(this + 0x1474));
      pCVar7 = (CAmmoDef *)GetAmmoDef();
      iVar4 = CAmmoDef::Index(pCVar7,(char *)(iVar4 + 0x180));
      if (iVar4 != *(int *)(this + 0x1418)) {
        if (this[0x6c] == (CBaseCombatWeapon)0x0) {
          pCVar1 = *(CBaseEdict **)(this + 0x30);
          if (pCVar1 != (CBaseEdict *)0x0) {
            *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
            iVar6 = CBaseEdict::GetChangeAccessor(pCVar1);
            *(undefined2 *)(iVar6 + 2) = 0;
          }
        }
        else {
          this[0x70] = (CBaseCombatWeapon)((byte)this[0x70] | 1);
        }
        *(int *)(this + 0x1418) = iVar4;
      }
      if (iVar4 == -1) {
        iVar4 = GetFileWeaponInfoFromHandle(*(ushort *)(this + 0x1474));
        puVar8 = &DAT_00d539c2;
        if (*(undefined1 **)(this + 0x7c) != (undefined1 *)0x0) {
          puVar8 = *(undefined1 **)(this + 0x7c);
        }
        Msg("ERROR: Weapon (%s) using undefined primary ammo type (%s)\n",puVar8,iVar4 + 0x180);
      }
    }
    iVar4 = GetFileWeaponInfoFromHandle(*(ushort *)(this + 0x1474));
    if (*(char *)(iVar4 + 0x1a0) != '\0') {
      iVar4 = GetFileWeaponInfoFromHandle(*(ushort *)(this + 0x1474));
      pCVar7 = (CAmmoDef *)GetAmmoDef();
      iVar4 = CAmmoDef::Index(pCVar7,(char *)(iVar4 + 0x1a0));
      if (iVar4 != *(int *)(this + 0x141c)) {
        if (this[0x6c] == (CBaseCombatWeapon)0x0) {
          pCVar1 = *(CBaseEdict **)(this + 0x30);
          if (pCVar1 != (CBaseEdict *)0x0) {
            *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
            iVar6 = CBaseEdict::GetChangeAccessor(pCVar1);
            *(undefined2 *)(iVar6 + 2) = 0;
          }
        }
        else {
          this[0x70] = (CBaseCombatWeapon)((byte)this[0x70] | 1);
        }
        *(int *)(this + 0x141c) = iVar4;
      }
      if (iVar4 == -1) {
        iVar4 = GetFileWeaponInfoFromHandle(*(ushort *)(this + 0x1474));
        puVar8 = &DAT_00d539c2;
        if (*(undefined1 **)(this + 0x7c) != (undefined1 *)0x0) {
          puVar8 = *(undefined1 **)(this + 0x7c);
        }
        Msg("ERROR: Weapon (%s) using undefined secondary ammo type (%s)\n",puVar8,iVar4 + 0x1a0);
      }
    }
    uVar3 = (**(code **)(*engine + 0xd8))(engine,0);
    if (*(int *)(this + 0x140c) != 0) {
      if (this[0x6c] == (CBaseCombatWeapon)0x0) {
        pCVar1 = *(CBaseEdict **)(this + 0x30);
        if (pCVar1 != (CBaseEdict *)0x0) {
          *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
          iVar4 = CBaseEdict::GetChangeAccessor(pCVar1);
          *(undefined2 *)(iVar4 + 2) = 0;
        }
      }
      else {
        this[0x70] = (CBaseCombatWeapon)((byte)this[0x70] | 1);
      }
      *(undefined4 *)(this + 0x140c) = 0;
    }
    if (*(int *)(this + 0x1410) != 0) {
      if (this[0x6c] == (CBaseCombatWeapon)0x0) {
        pCVar1 = *(CBaseEdict **)(this + 0x30);
        if (pCVar1 != (CBaseEdict *)0x0) {
          *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
          iVar4 = CBaseEdict::GetChangeAccessor(pCVar1);
          *(undefined2 *)(iVar4 + 2) = 0;
        }
      }
      else {
        this[0x70] = (CBaseCombatWeapon)((byte)this[0x70] | 1);
      }
      *(undefined4 *)(this + 0x1410) = 0;
    }
    iVar4 = (**(code **)(*(int *)this + 0x504))(this,0);
    if (iVar4 != 0) {
      pcVar9 = (char *)(**(code **)(*(int *)this + 0x504))(this,0);
      if (*pcVar9 != '\0') {
        pcVar9 = (char *)(**(code **)(*(int *)this + 0x504))(this,0);
        iVar4 = CBaseEntity::PrecacheModel(pcVar9);
        if (iVar4 != *(int *)(this + 0x140c)) {
          if (this[0x6c] == (CBaseCombatWeapon)0x0) {
            pCVar1 = *(CBaseEdict **)(this + 0x30);
            if (pCVar1 != (CBaseEdict *)0x0) {
              *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
              iVar6 = CBaseEdict::GetChangeAccessor(pCVar1);
              *(undefined2 *)(iVar6 + 2) = 0;
            }
          }
          else {
            this[0x70] = (CBaseCombatWeapon)((byte)this[0x70] | 1);
          }
          *(int *)(this + 0x140c) = iVar4;
        }
      }
    }
    iVar4 = (**(code **)(*(int *)this + 0x508))(this);
    if (iVar4 != 0) {
      pcVar9 = (char *)(**(code **)(*(int *)this + 0x508))(this);
      if (*pcVar9 != '\0') {
        pcVar9 = (char *)(**(code **)(*(int *)this + 0x508))(this);
        iVar4 = CBaseEntity::PrecacheModel(pcVar9);
        if (iVar4 != *(int *)(this + 0x1410)) {
          if (this[0x6c] == (CBaseCombatWeapon)0x0) {
            pCVar1 = *(CBaseEdict **)(this + 0x30);
            if (pCVar1 != (CBaseEdict *)0x0) {
              *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
              iVar6 = CBaseEdict::GetChangeAccessor(pCVar1);
              *(undefined2 *)(iVar6 + 2) = 0;
            }
          }
          else {
            this[0x70] = (CBaseCombatWeapon)((byte)this[0x70] | 1);
          }
          *(int *)(this + 0x1410) = iVar4;
        }
      }
    }
    iVar4 = 0;
    do {
      while( true ) {
        pcVar9 = (char *)(**(code **)(*(int *)this + 0x540))(this,iVar4);
        if ((pcVar9 == (char *)0x0) || (*pcVar9 == '\0')) break;
        iVar4 = iVar4 + 1;
        CBaseEntity::PrecacheScriptSound(pcVar9);
        if (iVar4 == 0x14) goto LAB_00405848;
      }
      iVar4 = iVar4 + 1;
    } while (iVar4 != 0x14);
LAB_00405848:
    (**(code **)(*engine + 0xd8))(engine,uVar3);
  }
  pcVar9 = (char *)(**(code **)(*(int *)this + 0x60))(this);
  if (pcVar9 != (char *)0x0) {
    PrecacheEffect(pcVar9);
  }
  PrecacheEffect("ParticleTracer");
  PrecacheParticleSystem("weapon_tracers");
  PrecacheParticleSystem("impact_ricochet");
  PrecacheParticleSystem("weapon_tracers_incendiary");
  PrecacheParticleSystem("impact_incendiary_generic");
  PrecacheParticleSystem("weapon_tracers_explosive");
  PrecacheParticleSystem("impact_explosive_ammo_large");
  PrecacheParticleSystem("impact_explosive_ammo_small");
  PrecacheParticleSystem("impact_explosive_ammo_world");
  PrecacheParticleSystem("impact_armor");
  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)