L L4D2node

SavedWeaponSpawn::PreSpawn

0x00867990 · 919 bytes · __thiscall

_ZN16SavedWeaponSpawn8PreSpawnEP11CBaseEntity

Decompiled

undefined (2 params)

/* SavedWeaponSpawn::PreSpawn(CBaseEntity*) */

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

{
  CBaseEdict *this_00;
  code *pcVar1;
  char *pcVar2;
  CBaseEntity *this_01;
  undefined4 uVar3;
  undefined1 *puVar4;
  int iVar5;
  int iVar6;
  int in_GS_OFFSET;
  double dVar7;
  double dVar8;
  double dVar9;
  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);
    if (this_01 != (CBaseEntity *)0x0) {
      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);
      puVar4 = &DAT_00d539c2;
      if (local_40[0] != (undefined1 *)0x0) {
        puVar4 = local_40[0];
      }
      iVar5 = (**(code **)(*soundemitterbase + 0x88))(soundemitterbase,puVar4);
      if (iVar5 != *(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;
            iVar6 = CBaseEdict::GetChangeAccessor(this_00);
            *(undefined2 *)(iVar6 + 2) = 0;
          }
        }
        else {
          this_01[0x70] = (CBaseEntity)((byte)this_01[0x70] | 1);
        }
        *(int *)(this_01 + 0xf4) = iVar5;
      }
      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;
      goto LAB_00867c12;
    }
  }
  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);
LAB_00867c12:
  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)