Skip to content

Instantly share code, notes, and snippets.

@leoetlino
Created September 21, 2020 23:09
Show Gist options
  • Save leoetlino/cfdd93cbf3aceea00d75c8fafee5c2fc to your computer and use it in GitHub Desktop.
Save leoetlino/cfdd93cbf3aceea00d75c8fafee5c2fc to your computer and use it in GitHub Desktop.
void __fastcall act::EnemyHinox::attachPlayer(act::EnemyHinox *this)
{
// [COLLAPSED LOCAL DECLARATIONS. PRESS KEYPAD CTRL-"+" TO EXPAND]
pMessedWithPlayerPosition = &this->attachedPlayer;
if ( this->attachedPlayer || !this->caughtPlayer )
return;
frm = Framework::sInstance;
if ( !Framework::sInstance )
{
frm = (Framework *)operator new(0x6C0uLL);
Framework::ctor(frm);
v43 = Framework::sInstance;
Framework::sInstance = frm;
if ( v43 )
{
Framework::sInstanceDeleter(v43);
frm = Framework::sInstance;
}
v1 = (unsigned __int64 *)Framework::deleteInstance;
Framework::sInstanceDeleter = (__int64 (__cdecl *)(_QWORD))Framework::deleteInstance;
}
player = frm->player.ptr;
v6 = frm->player.ctrl;
if ( v6 )
{
v7 = (unsigned __int64 *)&v6->__shared_owners_;
do
{
v8 = __ldxr(v1);
v1 = (unsigned __int64 *)((char *)v1 + 1);
}
while ( __stxr((unsigned __int64)v1, v7) );
do
{
v9 = __ldxr(v1);
v1 = (unsigned __int64 *)((char *)v1 + 1);
}
while ( __stxr((unsigned __int64)v1, v7) );
}
if ( player )
{
v10 = (player->_._.flags & 0x40000000) == 0;
if ( !v6 )
goto LABEL_13;
}
else
{
v10 = 0;
if ( !v6 )
goto LABEL_13;
}
do
v11 = __ldaxr(v1);
while ( __stlxr((unsigned __int64)v1 + 0xFFFFFFFF, (unsigned __int64 *)&v6->__shared_owners_) );
if ( v1 )
{
LABEL_13:
if ( v10 )
goto LABEL_14;
goto LABEL_43;
}
v6->vtable->__on_zero_shared(v6);
std::__1::__shared_weak_count::__release_weak((std::__1::__shared_weak_count *)v6);
if ( v10 )
{
LABEL_14:
v44 = Attacher::getCoords(this->attach_L.ptr)->pos;
v13 = Attacher::getCoords(this->attach_R.ptr)->pos;
playerRootComp = player->_.rootComp.ptr;
v15 = player->_.rootComp.ctrl;
if...
if ( playerRootComp->needCoordUpdate )
act::RootComp::updateCoords(playerRootComp);
attachL = &this->attach_L;
attachR = &this->attach_R;
if ( v15 )
{
do
v19 = __ldaxr((unsigned __int64 *)0x1688);
while ( __stlxr(0x1687uLL, (unsigned __int64 *)&v15->__shared_owners_) );
}
v20 = (float32x4_t)playerRootComp->coords.pos;
v21 = vsubq_f32(v20, (float32x4_t)v44);
v22 = vsubq_f32(v20, (float32x4_t)v13);
v23 = vmulq_f32(v21, v21);
v24 = vmulq_f32(v22, v22);
v23.n128_u64[0] = vadd_f32((float32x2_t)*(_OWORD *)&vextq_s8(v23, v23, 8uLL), (float32x2_t)v23.n128_u64[0]).n64_u64[0];
v24.n128_u64[0] = vadd_f32((float32x2_t)*(_OWORD *)&vextq_s8(v24, v24, 8uLL), (float32x2_t)v24.n128_u64[0]).n64_u64[0];
v23.n128_u64[0] = vpadd_f32((float32x2_t)v23.n128_u64[0], (float32x2_t)v23.n128_u64[0]).n64_u64[0];
v24.n128_u64[0] = vpadd_f32((float32x2_t)v24.n128_u64[0], (float32x2_t)v24.n128_u64[0]).n64_u64[0];
v23.n128_u64[1] = v23.n128_u64[0];
v24.n128_u64[1] = v24.n128_u64[0];
if ( COERCE_FLOAT(vsqrtq_f32(v23)) >= COERCE_FLOAT(vsqrtq_f32(v24)) )
attach = attachR;
else
attach = attachL;
attacherP = attach->ptr;
attacherC = attach->ctrl;
attacher.ptr = attacherP;
attacher.ctrl = attacherC;
if...
playerRootComp_1 = player->_.rootComp.ptr;
v31 = player->_.rootComp.ctrl;
if...
if ( playerRootComp_1 )
{
a4 = 3;
act::RootComp::attachCoords(playerRootComp_1, &attacher, 1, &a4);
}
if ( !v31 )
goto LABEL_60;
do
v33 = __ldaxr((unsigned __int64 *)attacherP);
while ( __stlxr(
(unsigned __int64)(&attacherP[0xFFFFFFFF].field_150 + 7),
(unsigned __int64 *)&v31->__shared_owners_) );
if ( !attacherP )
{
v31->vtable->__on_zero_shared(v31);
std::__1::__shared_weak_count::__release_weak((std::__1::__shared_weak_count *)v31);
v34 = attacher.ctrl;
if ( !attacher.ctrl )
goto LABEL_36;
}
else
{
LABEL_60:
v34 = attacher.ctrl;
if ( !attacher.ctrl )
goto LABEL_36;
}
do
v35 = __ldaxr((unsigned __int64 *)attacherP);
while ( __stlxr(
(unsigned __int64)(&attacherP[0xFFFFFFFF].field_150 + 7),
(unsigned __int64 *)&v34->__shared_owners_) );
if ( !attacherP )
{
v34->vtable->__on_zero_shared(v34);
std::__1::__shared_weak_count::__release_weak((std::__1::__shared_weak_count *)v34);
playerRootComp_2 = player->_.rootComp.ptr;
v37 = player->_.rootComp.ctrl;
if ( !v37 )
goto LABEL_38;
goto LABEL_37;
}
LABEL_36:
playerRootComp_2 = player->_.rootComp.ptr;
v37 = player->_.rootComp.ctrl;
if ( !v37 )
goto LABEL_38;
do
{
LABEL_37:
v38 = __ldxr((unsigned __int64 *)attacherP);
attacherP = (Attacher *)((char *)attacherP + 1);
}
while ( __stxr((unsigned __int64)attacherP, (unsigned __int64 *)&v37->__shared_owners_) );
LABEL_38:
v39 = *(_QWORD *)&nn::util::Vector3f::ConstantZero._.z;
*(_QWORD *)&playerRootComp_2->coordsNew.pos._.x = *(_QWORD *)&nn::util::Vector3f::ConstantZero._.x;
*(_QWORD *)&playerRootComp_2->coordsNew.pos._.z = v39;
act::RootComp::afterCoordUpdate(playerRootComp_2);
if...
*pMessedWithPlayerPosition = 1;
}
LABEL_43:
if ( v6 )
{
do
v41 = __ldaxr(v1);
while ( __stlxr((unsigned __int64)v1 + 0xFFFFFFFF, (unsigned __int64 *)&v6->__shared_owners_) );
if ( !v1 )
{
v6->vtable->__on_zero_shared(v6);
std::__1::__shared_weak_count::__release_weak((std::__1::__shared_weak_count *)v6);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment