CBaseEntity::SetParent
0x00608750 · 1107 bytes · __thiscall
_ZN11CBaseEntity9SetParentEPS_i
Decompiled
undefined (3 params)
/* CBaseEntity::SetParent(CBaseEntity*, int) */
void __thiscall CBaseEntity::SetParent(CBaseEntity *this,CBaseEntity *param_1,int param_2)
{
CCollisionProperty *this_00;
uint uVar1;
CBaseEdict *this_01;
int *piVar2;
char cVar3;
uint *puVar4;
int iVar5;
undefined4 uVar6;
CBaseEntity *pCVar7;
undefined *puVar8;
undefined1 *puVar9;
CBaseEntity *local_100;
float local_f4;
float local_f0;
float local_ec;
QAngle local_e8 [12];
float local_dc;
float local_d8;
float local_d4;
float local_d0;
float local_cc;
float local_c8;
float local_c4;
float local_c0;
float local_bc;
float local_b8;
float local_b4;
float local_b0;
EntityMatrix local_9c [64];
VMatrix local_5c [76];
if (param_2 == -1) {
param_2 = (int)(byte)this[0x185];
}
uVar1 = *(uint *)(this + 0x180);
if (((uVar1 == 0xffffffff) ||
(puVar8 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar8 == (undefined *)0xfffffffc)) ||
(*(uint *)(puVar8 + 8) != uVar1 >> 0xc)) {
local_100 = (CBaseEntity *)0x0;
}
else {
local_100 = *(CBaseEntity **)(puVar8 + 4);
}
UnlinkFromParent(this);
if (param_1 != (CBaseEntity *)0x0) {
puVar4 = (uint *)(**(code **)(*(int *)param_1 + 0xc))(param_1);
puVar8 = g_pEntityList;
uVar1 = *puVar4;
*(uint *)(this + 0x180) = uVar1;
if (((uVar1 == 0xffffffff) ||
(puVar8 = puVar8 + (uVar1 & 0xfff) * 0x10, puVar8 == (undefined *)0xfffffffc)) ||
(*(uint *)(puVar8 + 8) != uVar1 >> 0xc)) goto LAB_006087f4;
if (this != *(CBaseEntity **)(puVar8 + 4)) {
if (*(int *)(puVar8 + 4) != 0) {
this_00 = (CCollisionProperty *)(this + 0x194);
*(undefined4 *)(this + 0x84) = *(undefined4 *)(*(int *)(puVar8 + 4) + 0x154);
CCollisionProperty::SetSolidFlags(this_00,(uint)(*(ushort *)(this + 0x1b4) & 0xfeff));
iVar5 = GetRootMoveParent(param_1);
iVar5 = (**(code **)(*(int *)(iVar5 + 0x194) + 0x2c))(iVar5 + 0x194);
if (iVar5 == 1) {
CCollisionProperty::SetSolidFlags(this_00,(uint)(*(ushort *)(this + 0x1b4) | 0x100));
}
else {
iVar5 = (**(code **)(*(int *)(this + 0x194) + 0x2c))(this_00);
if (iVar5 == 1) {
CCollisionProperty::SetSolid(this_00,6);
}
}
if (*(int *)(this + 0x30) != 0) {
uVar1 = *(uint *)(this + 0x180);
pCVar7 = (CBaseEntity *)0x0;
if (((uVar1 != 0xffffffff) &&
(puVar8 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar8 != (undefined *)0xfffffffc))
&& (*(uint *)(puVar8 + 8) == uVar1 >> 0xc)) {
pCVar7 = *(CBaseEntity **)(puVar8 + 4);
}
LinkChild(pCVar7,this);
if (this[0x185] != param_2._0_1_) {
if (this[0x6c] == (CBaseEntity)0x0) {
this_01 = *(CBaseEdict **)(this + 0x30);
if (this_01 != (CBaseEdict *)0x0) {
*(uint *)this_01 = *(uint *)this_01 | 0x101;
iVar5 = CBaseEdict::GetChangeAccessor(this_01);
*(undefined2 *)(iVar5 + 2) = 0;
}
}
else {
this[0x70] = (CBaseEntity)((byte)this[0x70] | 1);
}
this[0x185] = param_2._0_1_;
}
EntityMatrix::InitFromEntity((EntityMatrix *)&local_dc,param_1,param_2 & 0xff);
EntityMatrix::InitFromEntityLocal(local_9c,this);
local_d0 = *(float *)(this + 0x39c) - local_d0;
local_c0 = *(float *)(this + 0x3a0) - local_c0;
local_b0 = *(float *)(this + 0x3a4) - local_b0;
local_ec = local_c4 * local_c0 + local_d4 * local_d0 + local_b4 * local_b0;
local_f0 = local_c8 * local_c0 + local_d8 * local_d0 + local_b8 * local_b0;
local_f4 = local_c0 * local_cc + local_d0 * local_dc + local_b0 * local_bc;
VMatrix::Transpose();
VMatrix::MatrixMul(local_5c,(VMatrix *)local_9c,(VMatrix *)&local_dc);
MatrixToAngles((VMatrix *)&local_dc,local_e8);
SetLocalAngles(this,local_e8);
UTIL_SetOrigin(this,(Vector *)&local_f4,false);
if (local_100 == (CBaseEntity *)0x0) {
TransformStepData_WorldToParent(this,this);
}
else {
TransformStepData_ParentToParent(this,local_100,this);
}
}
piVar2 = *(int **)(this + 0x238);
if (piVar2 != (int *)0x0) {
cVar3 = (**(code **)(*piVar2 + 8))(piVar2);
if (cVar3 != '\0') {
cVar3 = (**(code **)(**(int **)(this + 0x238) + 0x30))(*(int **)(this + 0x238),0);
if (cVar3 != '\0') {
puVar9 = &DAT_00d539c2;
if (*(undefined1 **)(this + 0x7c) != (undefined1 *)0x0) {
puVar9 = *(undefined1 **)(this + 0x7c);
}
uVar6 = GetDebugName(this);
Warning("SetParent on static object, all constraints attached to %s (%s)will now be broken!\n"
,uVar6,puVar9);
}
(**(code **)(*(int *)this + 0x298))(this);
VPhysicsInitShadow(this,false,false,(solid_t *)0x0);
}
}
CollisionRulesChanged(SUB41(this,0));
return;
}
goto LAB_006087f4;
}
}
*(undefined4 *)(this + 0x180) = 0xffffffff;
LAB_006087f4:
*(undefined4 *)(this + 0x84) = 0;
TransformStepData_ParentToWorld(this,local_100);
return;
}
SourceMod gamedata
paste intoaddons/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.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.