L L4D2node

SavedWeapon::PostSpawn

0x008674c0 · 604 bytes · __thiscall

_ZN11SavedWeapon9PostSpawnEP11CBaseEntity

Decompiled

undefined (2 params)

/* SavedWeapon::PostSpawn(CBaseEntity*) */

void __thiscall SavedWeapon::PostSpawn(SavedWeapon *this,CBaseEntity *param_1)

{
  CBaseEdict *pCVar1;
  int iVar2;
  int iVar3;
  int iVar4;
  char *__s;
  undefined4 uVar5;
  int in_GS_OFFSET;
  double dVar6;
  double dVar7;
  double dVar8;
  float local_30;
  float local_2c;
  float local_28;
  Color local_24;
  undefined1 local_23;
  undefined1 local_22;
  undefined1 local_21;
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  if (param_1 != (CBaseEntity *)0x0) {
    iVar2 = __dynamic_cast(param_1,&CBaseEntity::typeinfo,&CWeaponCSBase::typeinfo,0);
    if (iVar2 != 0) {
      iVar3 = KeyValues::GetInt(*(KeyValues **)(this + 4),"currentMagazine",0);
      if (iVar3 != *(int *)(iVar2 + 0x1420)) {
        if (*(char *)(iVar2 + 0x6c) == '\0') {
          pCVar1 = *(CBaseEdict **)(iVar2 + 0x30);
          if (pCVar1 != (CBaseEdict *)0x0) {
            *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
            iVar4 = CBaseEdict::GetChangeAccessor(pCVar1);
            *(undefined2 *)(iVar4 + 2) = 0;
          }
        }
        else {
          *(byte *)(iVar2 + 0x70) = *(byte *)(iVar2 + 0x70) | 1;
        }
        *(int *)(iVar2 + 0x1420) = iVar3;
      }
      iVar3 = KeyValues::GetInt(*(KeyValues **)(this + 4),"extraAmmo",0);
      if (iVar3 != *(int *)(iVar2 + 0x14fc)) {
        if (*(char *)(iVar2 + 0x6c) == '\0') {
          pCVar1 = *(CBaseEdict **)(iVar2 + 0x30);
          if (pCVar1 != (CBaseEdict *)0x0) {
            *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
            iVar4 = CBaseEdict::GetChangeAccessor(pCVar1);
            *(undefined2 *)(iVar4 + 2) = 0;
          }
        }
        else {
          *(byte *)(iVar2 + 0x70) = *(byte *)(iVar2 + 0x70) | 1;
        }
        *(int *)(iVar2 + 0x14fc) = iVar3;
      }
      iVar3 = KeyValues::GetInt(*(KeyValues **)(this + 4),"weaponskin",0);
      if (iVar3 != *(int *)(iVar2 + 0x458)) {
        if (*(char *)(iVar2 + 0x6c) == '\0') {
          pCVar1 = *(CBaseEdict **)(iVar2 + 0x30);
          if (pCVar1 != (CBaseEdict *)0x0) {
            *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
            iVar4 = CBaseEdict::GetChangeAccessor(pCVar1);
            *(undefined2 *)(iVar4 + 2) = 0;
          }
        }
        else {
          *(byte *)(iVar2 + 0x70) = *(byte *)(iVar2 + 0x70) | 1;
        }
        *(int *)(iVar2 + 0x458) = iVar3;
      }
      goto LAB_008675f8;
    }
  }
  __s = (char *)KeyValues::GetString(*(KeyValues **)(this + 4),"pos","");
  local_30 = vec3_origin;
  local_2c = DAT_01053d4c;
  local_28 = DAT_01053d50;
  sscanf(__s,"%f %f %f",&local_30,&local_2c,&local_28);
  dVar8 = (double)local_28;
  dVar7 = (double)local_2c;
  dVar6 = (double)local_30;
  uVar5 = KeyValues::GetString(*(KeyValues **)(this + 4),"classname","");
  local_24 = 0;
  local_23 = 0xff;
  local_22 = 0xc0;
  local_21 = 0xff;
  ConColorMsg(&local_24,"Removing bad weapon %s at %.0f, %.0f, %.0f\n",uVar5,dVar6,dVar7,dVar8);
  UTIL_Remove(param_1);
LAB_008675f8:
  if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
    return;
  }
                    /* WARNING: Subroutine does not return */
  __stack_chk_fail();
}

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)