L L4D2node

SavedTerrorGun::PostSpawn

0x00867d40 · 780 bytes · __thiscall

_ZN14SavedTerrorGun9PostSpawnEP11CBaseEntity

Decompiled

undefined (2 params)

/* SavedTerrorGun::PostSpawn(CBaseEntity*) */

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

{
  CBaseEdict *pCVar1;
  CTerrorGun *this_00;
  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) {
    this_00 = (CTerrorGun *)__dynamic_cast(param_1,&CBaseEntity::typeinfo,&CTerrorGun::typeinfo,0);
    if (this_00 != (CTerrorGun *)0x0) {
      iVar2 = KeyValues::GetInt(*(KeyValues **)(this + 4),"dual",0);
      if (iVar2 != 0) {
        (**(code **)(*(int *)this_00 + 0x71c))(this_00);
      }
      CTerrorGun::SetUpgradeBitVec(this_00,(CBitVec *)(this + 0xc));
      uVar5 = *(undefined4 *)(this + 8);
      if (SUB41(uVar5,0) != this_00[0x1790]) {
        if (this_00[0x6c] == (CTerrorGun)0x0) {
          pCVar1 = *(CBaseEdict **)(this_00 + 0x30);
          if (pCVar1 != (CBaseEdict *)0x0) {
            *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
            iVar2 = CBaseEdict::GetChangeAccessor(pCVar1);
            *(undefined2 *)(iVar2 + 2) = 0;
          }
        }
        else {
          this_00[0x70] = (CTerrorGun)((byte)this_00[0x70] | 1);
        }
        this_00[0x1790] = SUB41(uVar5,0);
      }
    }
    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_00867f0c;
    }
  }
  __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_00867f0c:
  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)