Skip to content

Instantly share code, notes, and snippets.

@leoetlino
Created October 27, 2020 20:25
Show Gist options
  • Save leoetlino/c6b2803cde88e5f577fd065422a32930 to your computer and use it in GitHub Desktop.
Save leoetlino/c6b2803cde88e5f577fd065422a32930 to your computer and use it in GitHub Desktop.
bool __fastcall needToFreezeSceneForActorCreate(BaseProcEvent *event, Vec3 *playerPos)
{
// [COLLAPSED LOCAL DECLARATIONS. PRESS KEYPAD CTRL-"+" TO EXPAND]
v2 = __ldar((unsigned __int8 *)&unk_71026003D8);
if...
if ( !event || !event->_.vptr->_.rtti1((ksys::util::ManagedTask *)event, &BaseProcEvent::rttiInfo) )
return 0;
obj = event->placementObj;
if ( !obj )
return 0;
linkData = obj->linkData;
if ( linkData )
{
v7 = linkData->genGroup;
if ( v7 )
{
if ( v7->counter3 == PlacementGlobal::sInstance->frameCounter )
{
result = 0;
}
else
{
v16 = PlacementLinkData::x_4(obj->linkData, playerPos);
v7 = linkData->genGroup;
result = v16 != 0LL;
}
distanceToLoadSphere = v7->field_30;
if ( distanceToLoadSphere >= 1000.0 )
distanceToLoadSphere = -1.0;
end:
event->distanceToLoadSphere = distanceToLoadSphere;
return result;
}
}
if ( !(obj->hardModeFlags & 1) )
{
v9 = obj->actorDataIdx;
if ( (unsigned int)v9 >> 4 >= 0x177 )
v9 = 0LL;
if ( !(PlacementMgr::sInstance->pa->actorData[v9].flags4 & 0x40000)
&& obj->actorDataFlags8 & 2
&& !PlacementObj::shouldSkipSpawn(event->placementObj) )
{
v10 = PlacementObj::getUnitConfigName(obj);
for ( i = 0LL; aTrunk[i] != sead::SafeStringBase<char>::cNullChar; i += 2LL )
{
if ( i >= 0x80000 )
goto endFalse;
if ( aTrunk[i + 1] == sead::SafeStringBase<char>::cNullChar )
{
LODWORD(i) = i + 1;
break;
}
}
if ( (_DWORD)i )
{
v12 = 0LL;
v13 = (signed __int64)(v10 + 1);
while ( v10[v12] != sead::SafeStringBase<char>::cNullChar )
{
if ( *(unsigned __int8 *)(v13 + v12) == (unsigned __int8)sead::SafeStringBase<char>::cNullChar )
{
v18 = v12 + 1;
v15 = v18 - i;
if ( v18 < (signed int)i )
goto LABEL_47;
goto LABEL_42;
}
if ( *(unsigned __int8 *)(v13 + v12 + 1) == (unsigned __int8)sead::SafeStringBase<char>::cNullChar )
{
LODWORD(v12) = v12 + 2;
break;
}
v14 = v12 + 2;
v12 += 3LL;
if ( v14 >= 0x80000 )
{
v15 = -(signed int)i;
if ( (signed int)i > 0 )
goto LABEL_47;
goto LABEL_42;
}
}
v15 = v12 - i;
if ( (signed int)v12 < (signed int)i )
goto LABEL_47;
LABEL_42:
if ( (signed int)i < 1 )
goto endFalse;
v19 = 0LL;
i = (signed int)i;
v20 = &v10[v15];
while ( v20[v19] == aTrunk[v19] )
{
if ( ++v19 >= i )
goto endFalse;
}
LABEL_47:
v21 = PlacementObj::getUnitConfigName(obj);
for ( j = 0LL; aStump[j] != sead::SafeStringBase<char>::cNullChar; j += 2LL )
{
if ( j >= 0x80000 )
goto endFalse;
if ( aStump[j + 1] == sead::SafeStringBase<char>::cNullChar )
{
LODWORD(j) = j + 1;
break;
}
}
if ( (_DWORD)j )
{
v23 = 0LL;
v24 = (signed __int64)(v21 + 1);
while ( v21[v23] != sead::SafeStringBase<char>::cNullChar )
{
if ( *(unsigned __int8 *)(v24 + v23) == (unsigned __int8)sead::SafeStringBase<char>::cNullChar )
{
v27 = v23 + 1;
v26 = v27 - j;
if ( v27 < (signed int)j )
goto LABEL_70;
goto LABEL_65;
}
if ( *(unsigned __int8 *)(v24 + v23 + 1) == (unsigned __int8)sead::SafeStringBase<char>::cNullChar )
{
LODWORD(v23) = v23 + 2;
break;
}
v25 = v23 + 2;
v23 += 3LL;
if ( v25 >= 0x80000 )
{
v26 = -(signed int)j;
if ( (signed int)j > 0 )
goto LABEL_70;
goto LABEL_65;
}
}
v26 = v23 - j;
if ( (signed int)v23 < (signed int)j )
goto LABEL_70;
LABEL_65:
if ( (signed int)j < 1 )
goto endFalse;
v28 = 0LL;
j = (signed int)j;
v29 = &v21[v26];
while ( v29[v28] == aStump[v28] )
{
if ( ++v28 >= j )
goto endFalse;
}
LABEL_70:
v30 = PlacementObj::getUnitConfigName(obj);
if ( sead::SafeStringBase<char>::cNullChar != 0x57 )
{
v31 = "eapon_";
v32 = 0x57;
while ( (unsigned __int8)*v30 == v32 )
{
v33 = (unsigned __int8)*v31++;
v32 = v33;
++v30;
if ( v33 == (unsigned __int8)sead::SafeStringBase<char>::cNullChar )
goto endFalse;
}
v34 = PlacementObj::getUnitConfigName(obj);
if ( sead::SafeStringBase<char>::cNullChar != 0x41 )
{
v35 = "nimal_";
v36 = 0x41;
while ( (unsigned __int8)*v34 == v36 )
{
v37 = (unsigned __int8)*v35++;
v36 = v37;
++v34;
if ( v37 == (unsigned __int8)sead::SafeStringBase<char>::cNullChar )
goto endFalse;
}
v38 = obj->actorDataIdx;
v39 = PlacementMgr::sInstance->pa;
if ( (unsigned int)v38 >> 4 >= 0x177 )
v38 = 0LL;
v40 = (signed __int64)v39 + 0x1A0 * v38;
if ( !(*(_DWORD *)(v40 + 0x53C) & PlacementActorFlags4_IgnoreBoundingAtAreaCulling)
|| *(_DWORD *)(v40 + 0x53C) & PlacementActorFlags4_NpcOrNonGanonAndNonGuardianEnemy )
{
v41 = obj->translate.z;
ps1 = v39->placementStruct1;
*(_QWORD *)&a2.x = *(_QWORD *)&obj->translate.x;
a2.z = v41;
v43 = obj->actorDataIdx;
if ( (unsigned int)v43 >> 4 >= 0x177 )
v43 = 0LL;
v44 = v39->actorData[v43].boundingForTraverse;
a3 = v44 * PlacementObj::getScale(obj);
if ( !PlacementStruct1::x_9(ps1, &a2, &a3, obj, 0)
&& PlacementObj::getDispDistance(obj, 0, 0, v45) <= 1000.0 )
{
v46.n64_f32[0] = (float)((float)(playerPos->x - obj->translate.x)
* (float)(playerPos->x - obj->translate.x))
+ (float)((float)(playerPos->z - obj->translate.z)
* (float)(playerPos->z - obj->translate.z));
dist = sqrtf(v46.n64_f32[0]);
v46.n64_u16[0] = obj->traverseDistInt;
distanceToLoadSphere = dist - (float)(signed int)*(_OWORD *)&vmovl_s16(v46);
v49 = distanceToLoadSphere == 0.0;
v48 = distanceToLoadSphere >= 0.0;
if ( distanceToLoadSphere <= 0.0 )
distanceToLoadSphere = 0.0;
if ( !v49 && v48 )
result = 0;
else
result = 1;
goto end;
}
}
}
}
}
}
}
}
endFalse:
result = 0;
event->distanceToLoadSphere = -1.0;
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment