L L4D2node

SavedMeleeWeaponSpawn::PreSpawn

0x00868070 · 1051 bytes · __thiscall

_ZN21SavedMeleeWeaponSpawn8PreSpawnEP11CBaseEntity

Decompiled

undefined (2 params)

/* SavedMeleeWeaponSpawn::PreSpawn(CBaseEntity*) */

void __thiscall SavedMeleeWeaponSpawn::PreSpawn(SavedMeleeWeaponSpawn *this,CBaseEntity *param_1)

{
  CBaseEdict *this_00;
  code *pcVar1;
  char *pcVar2;
  CBaseEntity *this_01;
  undefined4 uVar3;
  int iVar4;
  int iVar5;
  int iVar6;
  int in_GS_OFFSET;
  double dVar7;
  double dVar8;
  double dVar9;
  undefined1 *puVar10;
  undefined1 *local_40 [4];
  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);
  pcVar2 = (char *)KeyValues::GetString(*(KeyValues **)(this + 4),"pos","");
  local_30 = vec3_origin;
  local_2c = DAT_01053d4c;
  local_28 = DAT_01053d50;
  sscanf(pcVar2,"%f %f %f",(Vector *)&local_30,&local_2c,&local_28);
  CBaseEntity::SetAbsOrigin(param_1,(Vector *)&local_30);
  pcVar2 = (char *)KeyValues::GetString(*(KeyValues **)(this + 4),"angles","");
  local_30 = (float)vec3_angle;
  local_2c = DAT_01053d40;
  local_28 = DAT_01053d44;
  sscanf(pcVar2,"%f %f %f",(Vector *)&local_30,&local_2c,&local_28);
  CBaseEntity::SetAbsAngles(param_1,(QAngle *)&local_30);
  pcVar2 = (char *)KeyValues::GetString(*(KeyValues **)(this + 4),"vel","");
  local_30 = vec3_origin;
  local_2c = DAT_01053d4c;
  local_28 = DAT_01053d50;
  sscanf(pcVar2,"%f %f %f",(Vector *)&local_30,&local_2c,&local_28);
  CBaseEntity::SetAbsVelocity(param_1,(Vector *)&local_30);
  if ((param_1 == (CBaseEntity *)0x0) ||
     (this_01 = (CBaseEntity *)
                __dynamic_cast(param_1,&CBaseEntity::typeinfo,&CWeaponSpawn::typeinfo,0),
     this_01 == (CBaseEntity *)0x0)) {
    pcVar2 = (char *)KeyValues::GetString(*(KeyValues **)(this + 4),"pos","");
    local_30 = vec3_origin;
    local_2c = DAT_01053d4c;
    local_28 = DAT_01053d50;
    sscanf(pcVar2,"%f %f %f",(Vector *)&local_30,&local_2c,&local_28);
    dVar9 = (double)local_28;
    dVar8 = (double)local_2c;
    dVar7 = (double)local_30;
    uVar3 = KeyValues::GetString(*(KeyValues **)(this + 4),"classname","");
    local_24 = 0;
    local_23 = 0xff;
    local_22 = 0xc0;
    local_21 = 0xff;
    ConColorMsg(&local_24,"Removing bad weapon spawn %s at %.0f, %.0f, %.0f\n",uVar3,dVar7,dVar8,
                dVar9);
    UTIL_Remove(param_1);
    puVar10 = *(undefined1 **)(this + 4);
    iVar4 = KeyValues::GetInt((KeyValues *)puVar10,"melee_weapon",0);
    if (param_1 == (CBaseEntity *)0x0) goto LAB_0086834e;
  }
  else {
    uVar3 = KeyValues::GetInt(*(KeyValues **)(this + 4),"itemCount",0);
    *(undefined4 *)(this_01 + 0x144c) = uVar3;
    KeyValues::GetString(*(KeyValues **)(this + 4),"model","");
    AllocPooledString((char *)local_40);
    *(undefined1 **)(this_01 + 0x260) = local_40[0];
    CBaseEntity::DispatchUpdateTransmitState(this_01);
    puVar10 = &DAT_00d539c2;
    if (local_40[0] != (undefined1 *)0x0) {
      puVar10 = local_40[0];
    }
    iVar4 = (**(code **)(*soundemitterbase + 0x88))(soundemitterbase,puVar10);
    if (iVar4 != *(int *)(this_01 + 0xf4)) {
      if (this_01[0x6c] == (CBaseEntity)0x0) {
        this_00 = *(CBaseEdict **)(this_01 + 0x30);
        if (this_00 != (CBaseEdict *)0x0) {
          *(uint *)this_00 = *(uint *)this_00 | 0x101;
          iVar5 = CBaseEdict::GetChangeAccessor(this_00);
          *(undefined2 *)(iVar5 + 2) = 0;
        }
      }
      else {
        this_01[0x70] = (CBaseEntity)((byte)this_01[0x70] | 1);
      }
      *(int *)(this_01 + 0xf4) = iVar4;
    }
    pcVar1 = *(code **)(*(int *)this_01 + 0x3d8);
    uVar3 = KeyValues::GetInt(*(KeyValues **)(this + 4),"weaponID",0);
    (*pcVar1)(this_01,uVar3);
    uVar3 = KeyValues::GetInt(*(KeyValues **)(this + 4),"weaponskin",0);
    *(undefined4 *)(this_01 + 0x1450) = uVar3;
    iVar4 = KeyValues::GetInt(*(KeyValues **)(this + 4),"melee_weapon",0);
  }
  iVar5 = __dynamic_cast(param_1,&CBaseEntity::typeinfo,&CWeaponMeleeSpawn::typeinfo,0);
  puVar10 = param_1;
  if (iVar5 != 0) {
    puVar10 = g_MeleeWeaponInfoStore;
    iVar6 = CMeleeWeaponInfoStore::GetInvalidHandle();
    if (iVar6 != iVar4) {
      *(int *)(iVar5 + 0x1468) = iVar4;
    }
  }
LAB_0086834e:
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail(puVar10);
  }
  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)