//
// PlayLayer::checkForEnd from 0x1403b4cf0 to 0x1403b4ea8 (440 bytes)
//
// 2 xrefs:
// > ??> @ 0x1405c9b90
// > ??> @ 0x1406d6f20
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// Hidden C++ exception states: #wind=3
void PlayLayer::checkForEnd(PlayLayer *a1)
{
EndPortalObject *m_endPortal; // rcx
float *SpawnPos; // rbx
EndPortalObject *v4; // rcx
float *v5; // rbx
EndPortalObject *v6; // rbx
EndPortalObject *v7; // rdi
__int64 v8; // rax
__int64 v9; // rdx
__int64 v10; // rbx
PlayLayer *v11; // rbx
cocos2d::CCPoint v12; // rax
void *v13; // [rsp+40h] [rbp+8h]
char v14; // [rsp+48h] [rbp+10h] BYREF
void *v15; // [rsp+50h] [rbp+18h]
m_endPortal = a1->m_endPortal;
if ( m_endPortal && !a1->m_endChecked )
{
if ( !m_endPortal->m_flippedX
&& (SpawnPos = (float *)EndPortalObject::getSpawnPos(m_endPortal),
a1->m_player1->getPosition_0(a1->m_player1)->x >= *SpawnPos)
|| (v4 = a1->m_endPortal, v4->m_flippedX)
&& (v5 = (float *)EndPortalObject::getSpawnPos(v4), *v5 >= a1->m_player1->getPosition_0(a1->m_player1)->x) )
{
a1->m_endChecked = 1;
if ( a1->m_sectionYFactor != 0.0 )
{
EndPortalObject::updateEndPos(a1->m_endPortal, 0);
v6 = a1->m_endPortal;
GJBaseGameLayer::removeObjectFromSection(a1, v6);
a1->addToSection(a1, v6);
}
v7 = a1->m_endPortal;
v8 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v15 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v15);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v8 = qword_1406C2ED8;
}
v9 = *(_QWORD *)(v8 + 520);
if ( !*(_BYTE *)(*(_QWORD *)(v9 + 3488) + 2496LL) )
{
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(*(_QWORD *)(v9 + 13632) + 568LL) + 920LL))(
*(_QWORD *)(*(_QWORD *)(v9 + 13632) + 568LL),
0);
v10 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v13 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v13);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v10 = qword_1406C2ED8;
}
v11 = *(PlayLayer **)(v10 + 520);
v12 = (cocos2d::CCPoint)((__int64 (__fastcall *)(EndPortalObject *, char *))v7->getStartPos)(v7, &v14);
PlayLayer::playEndAnimationToPos(v11, v12);
}
}
}
}