//
// GJBaseGameLayer::checkCollisions from 0x1001e72e8 to 0x1001e7f38 (3152 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::update @ 0x1001fec20
// > GJBaseGameLayer::update @ 0x1001feca8
//
// 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
//
int __fastcall GJBaseGameLayer::checkCollisions(GJBaseGameLayer *a1, PlayerObject *a2, float a3, bool a4)
{
bool *p_m_isPlatformer; // x28
bool m_wasTeleported; // w24
bool v10; // w26
__n128 v11; // q0
float m_unkAngle1; // s1
float v13; // s13
float v14; // s12
float v15; // s9
unsigned __int32 v16; // s9
_BOOL4 m_isOutOfBounds; // w22
__n128 v18; // q1
__n128 v19; // q0
int v20; // w23
float MaxPortalY; // s9
float MinPortalY; // s10
_BOOL4 v23; // w24
__n128 v24; // q0
__n128 v25; // q1
float v27; // s11
float v28; // s9
_BOOL4 v29; // w27
double v30; // d10
_BOOL4 v31; // w0
_BOOL4 v32; // w21
float v33; // s10
__n128 v34; // q0
__n128 v35; // q1
bool *p_m_wasOnSlope; // x26
__n128 v37; // q0
__n128 v38; // q1
float v39; // s10
double v40; // d9
double YVelocity; // d9
_BOOL4 v42; // w21
_BOOL4 canStickToGround; // w0
float v44; // s12
__n128 v45; // q0
__n128 v46; // q1
float *v47; // x0
float v48; // s9
float v49; // s0
float v50; // s1
int v51; // w21
int v52; // w9
__int64 v53; // x8
std::__vector_base *, std::allocator *>> *, std::allocator *, std::allocator *>> *>>::pointer end; // x12
std::__vector_base *, std::allocator *>> *, std::allocator *, std::allocator *>> *>>::pointer begin; // x13
__int64 v56; // x11
unsigned __int64 v57; // x14
int v58; // w11
int v59; // w10
__int64 v60; // x11
__int64 v61; // x21
std::vector *, std::allocator *>> *v62; // x8
__int64 v63; // x8
unsigned __int64 v64; // x9
int v65; // w8
__int64 v66; // x26
unsigned __int64 v67; // x25
std::vector *v68; // x22
unsigned __int64 v69; // x23
std::__vector_base::pointer v70; // x0
__int64 v71; // x1
unsigned __int64 v72; // x8
unsigned __int64 v73; // x3
__int64 v74; // x8
std::__vector_base::pointer v75; // x9
std::__vector_base::pointer v76; // x8
int m_calcNonEffectObjectsSize; // w3
bool m_isCollidingWithSlope; // w26
float *v79; // x22
float v80; // s9
float v81; // s10
float v82; // s11
__n128 v83; // q0
int m_solidCollisionObjectsCount; // w8
float v85; // s12
int v86; // w27
int v87; // w28
GameObject *v88; // x23
cocos2d::CCRect *ObjectRectPointer; // x24
__int64 v90; // x0
PlayerObject *m_player1; // x0
__int64 v92; // x0
float v93; // s9
float v94; // s10
float v95; // s11
float v96; // s12
__int64 v97; // x21
GameObject *v98; // x22
cocos2d::CCRect *v99; // x0
OBB2D *v100; // x23
OBB2D *v101; // x24
float *p_origin; // x23
bool *v103; // [xsp+0h] [xbp-C0h]
bool v104; // [xsp+Ch] [xbp-B4h]
__int64 v105; // [xsp+10h] [xbp-B0h]
int v106; // [xsp+20h] [xbp-A0h]
int v107; // [xsp+2Ch] [xbp-94h]
__int64 v108; // [xsp+30h] [xbp-90h]
bool (__fastcall *v109)(__int64, __int64); // [xsp+38h] [xbp-88h] BYREF
p_m_isPlatformer = &a1->m_isPlatformer;
m_wasTeleported = a2->m_wasTeleported;
a2->m_wasTeleported = 0;
PlayerObject::preCollision(a2);
v10 = 0;
v11.n128_u32[0] = LODWORD(a2->m_vehicleSize);
m_unkAngle1 = a2->m_unkAngle1;
if ( v11.n128_f32[0] == 1.0 )
v13 = 0.0;
else
v13 = (float)(m_unkAngle1 * (float)(1.0 - v11.n128_f32[0])) * 0.5;
v14 = m_unkAngle1 * 0.5;
v11.n128_u32[0] = 1119092736;
v15 = (float)(m_unkAngle1 * 0.5) + 90.0;
if ( !a1->m_gameState.m_isFreeMode )
v10 = PlayerObject::isFlying(a2) || a2->m_isBall || a2->m_isSpider || a1->m_gameState.m_isDualMode;
*(float *)&v16 = v15 - v13;
m_isOutOfBounds = a2->m_isOutOfBounds;
a2->m_isOutOfBounds = 0;
if ( *p_m_isPlatformer )
{
v11.n128_u32[0] = *(_DWORD *)((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2);
if ( v11.n128_f32[0] < -30.0 )
{
a2->m_platformerXVelocity = 0.0;
v18.n128_u32[0] = *(_DWORD *)(((__int64 (__fastcall *)(PlayerObject *, float))a2->getPosition)(
a2,
v11.n128_f32[0])
+ 4);
v19.n128_u32[0] = -30.0;
sub_100022980(v19, v18, &v109);
((void (__fastcall *)(PlayerObject *, bool (__fastcall **)(__int64, __int64)))a2->setPosition)(a2, &v109);
}
goto LABEL_15;
}
if ( !a2->m_isGoingLeft
|| (v11.n128_u32[0] = *(_DWORD *)((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2),
v11.n128_f32[0] >= -30.0) )
{
LABEL_15:
v20 = 0;
goto LABEL_16;
}
v20 = 1;
LABEL_16:
if ( *(float *)(((__int64 (__fastcall *)(PlayerObject *, __n128))a2->getPosition)(a2, v11) + 4) >= *(float *)&v16
|| v10 && (PlayerObject::isFlying(a2) || a2->m_isBall || a1->m_gameState.m_isDualMode || a2->m_isSpider) )
{
if ( *(float *)(((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2) + 4) > (float)(v13 + a1->m_maxGameplayY) )
LABEL_23:
v20 = 1;
}
else
{
if ( a2->m_isUpsideDown )
{
if ( PlayerObject::isSafeFlip(a2, 0.1) )
{
v24.n128_u32[0] = *(_DWORD *)((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2);
v25.n128_u32[0] = v16;
sub_100022980(v24, v25, &v109);
((void (__fastcall *)(PlayerObject *, bool (__fastcall **)(__int64, __int64)))a2->setPosition)(a2, &v109);
PlayerObject::hitGround(a2, nullptr, 1);
PlayerObject::updateCollide(a2, (PlayerCollisionDirection)0, nullptr);
a2->m_isOnGround2 = 0;
return 0;
}
goto LABEL_23;
}
if ( !a2->m_maybeIsBoosted )
{
v34.n128_u32[0] = *(_DWORD *)((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2);
v35.n128_u32[0] = v16;
sub_100022980(v34, v35, &v109);
((void (__fastcall *)(PlayerObject *, bool (__fastcall **)(__int64, __int64)))a2->setPosition)(a2, &v109);
PlayerObject::hitGround(a2, nullptr, 0);
PlayerObject::updateCollide(a2, (PlayerCollisionDirection)1, nullptr);
}
}
if ( !v10 || m_wasTeleported )
goto LABEL_88;
MaxPortalY = GJBaseGameLayer::getMaxPortalY(a1);
MinPortalY = GJBaseGameLayer::getMinPortalY(a1);
v23 = a2->m_isShip && a2->m_jumpBuffered;
v27 = MaxPortalY - a1->m_gameState.m_unkUint17;
v28 = v13 + (float)(MaxPortalY - v14);
if ( *(float *)(((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2) + 4) <= v28 )
{
v33 = (float)(v14 + MinPortalY) - v13;
if ( *(float *)(((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2) + 4) >= v33 )
{
LABEL_88:
v29 = v20;
goto LABEL_89;
}
if ( !a2->m_wasOnSlope
|| *(float *)(((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2) + 4) >= (float)(v33 - v14) )
{
if ( PlayerObject::destroyFromHitHead(a2) && a2->m_isUpsideDown )
{
v29 = 1;
if ( !PlayerObject::isSafeHeadTest(a2) )
goto LABEL_89;
}
else
{
v29 = 0;
}
YVelocity = PlayerObject::getYVelocity(a2);
if ( a2->m_isUpsideDown )
{
v42 = 0;
}
else
{
canStickToGround = PlayerObject::canStickToGround(a2);
v42 = v27 != 0.0 && canStickToGround;
}
v44 = 0.0;
if ( !v29
&& !PlayerObject::canStickToGround(a2)
&& a1->m_gameState.m_cameraZoom != a1->m_gameState.m_targetCameraZoom )
{
v44 = 1.0;
}
p_m_wasOnSlope = &a2->m_wasOnSlope;
v45.n128_u32[0] = *(_DWORD *)((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2);
v46.n128_f32[0] = v33 + v44;
sub_100022980(v45, v46, &v109);
((void (__fastcall *)(PlayerObject *, bool (__fastcall **)(__int64, __int64)))a2->setPosition)(a2, &v109);
if ( v29 )
{
PlayerObject::pushDown(a2);
}
else if ( !a2->m_isShip && !a2->m_isSwing || PlayerObject::getYVelocity(a2) < 0.0 )
{
PlayerObject::hitGround(a2, nullptr, a2->m_isUpsideDown);
}
v39 = YVelocity;
PlayerObject::updateCollide(a2, (PlayerCollisionDirection)!a2->m_isUpsideDown, nullptr);
if ( v42 )
{
v40 = v39;
if ( PlayerObject::getYVelocity(a2) > v39 )
goto LABEL_86;
}
if ( !a2->m_isUpsideDown || !v23 || v27 >= 0.0 )
goto LABEL_87;
goto LABEL_85;
}
LABEL_45:
v29 = 1;
goto LABEL_89;
}
if ( a2->m_wasOnSlope
&& *(float *)(((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2) + 4) > (float)(v14 + v28) )
{
goto LABEL_45;
}
if ( !PlayerObject::destroyFromHitHead(a2) || a2->m_isUpsideDown )
{
v29 = 0;
LABEL_38:
v30 = PlayerObject::getYVelocity(a2);
if ( a2->m_isUpsideDown )
{
v31 = PlayerObject::canStickToGround(a2);
v32 = v27 != 0.0 && v31;
}
else
{
v32 = 0;
}
p_m_wasOnSlope = &a2->m_wasOnSlope;
v37.n128_u32[0] = *(_DWORD *)((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2);
v38.n128_f32[0] = v28;
sub_100022980(v37, v38, &v109);
((void (__fastcall *)(PlayerObject *, bool (__fastcall **)(__int64, __int64)))a2->setPosition)(a2, &v109);
if ( v29 )
{
PlayerObject::pushDown(a2);
}
else if ( PlayerObject::getYVelocity(a2) > 0.0 )
{
PlayerObject::hitGround(a2, nullptr, !a2->m_isUpsideDown);
}
v39 = v30;
PlayerObject::updateCollide(a2, (PlayerCollisionDirection)a2->m_isUpsideDown, nullptr);
if ( v32 )
{
v40 = v39;
if ( PlayerObject::getYVelocity(a2) < v39 )
goto LABEL_86;
}
if ( (v23 & ~a2->m_isUpsideDown & 1) == 0 || v27 <= 0.0 )
goto LABEL_87;
LABEL_85:
v40 = v39;
LABEL_86:
PlayerObject::setYVelocity(a2, v40, 0);
LABEL_87:
*p_m_wasOnSlope = 0;
goto LABEL_88;
}
v29 = 1;
if ( PlayerObject::isSafeHeadTest(a2) )
goto LABEL_38;
LABEL_89:
if ( v29 && m_isOutOfBounds )
{
if ( !a4 )
((void (__fastcall *)(GJBaseGameLayer *, PlayerObject *, _QWORD))a1->destroyPlayer)(a1, a2, 0);
return 1;
}
a2->m_isOutOfBounds = v29;
v47 = (float *)((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2);
v48 = 0.0;
v49 = 0.0;
if ( *v47 > 0.0 )
{
v50 = *(float *)((__int64 (__fastcall *)(PlayerObject *, float))a2->getPosition)(a2, 0.0);
if ( v50 >= 10000000.0 )
v49 = a1->m_sectionXFactor * 10000000.0;
else
v49 = *(float *)((__int64 (__fastcall *)(PlayerObject *, float, float))a2->getPosition)(a2, 10000000.0, v50)
* a1->m_sectionXFactor;
}
v51 = (int)v49;
if ( *(float *)(((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2) + 4) > 0.0 )
{
if ( *(float *)(((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2) + 4) >= 10000000.0 )
v48 = a1->m_sectionYFactor * 10000000.0;
else
v48 = *(float *)(((__int64 (__fastcall *)(PlayerObject *))a2->getPosition)(a2) + 4) * a1->m_sectionYFactor;
}
v103 = p_m_isPlatformer;
v104 = a4;
v52 = (int)v48;
if ( v51 <= 1 )
v53 = 1;
else
v53 = (unsigned int)v51;
end = a1->m_nonEffectObjects.__end_;
begin = a1->m_nonEffectObjects.__begin_;
v56 = end - begin;
v57 = v56 - 1;
v58 = v56 - 1;
if ( v57 >= v51 + 1 )
v59 = v51 + 1;
else
v59 = v58;
if ( v52 <= 1 )
v60 = 1;
else
v60 = (unsigned int)v52;
a1->m_solidCollisionObjectsCount = 0;
a1->m_hazardCollisionObjectsCount = 0;
if ( end != begin && (int)v53 - 1 <= v59 )
{
v107 = v60 - 1;
v106 = v52 + 1;
v105 = v60 - 1;
v61 = v53 - 1;
v108 = (unsigned int)(v59 + 1);
do
{
v62 = a1->m_nonEffectObjects.__begin_[v61];
if ( v62 )
{
v63 = v62->__end_ - v62->__begin_;
v64 = v63 - 1;
v65 = v63 - 1;
if ( v64 >= v106 )
v65 = v106;
if ( v107 <= v65 )
{
v66 = (unsigned int)(v65 + 1);
v67 = v105;
do
{
v68 = a1->m_nonEffectObjects.__begin_[v61]->__begin_[v67];
if ( v68 )
{
v69 = a1->m_nonEffectObjectsSizes.__begin_[v61]->__begin_[v67];
if ( (*(_QWORD *)&a1->m_nonEffectObjectsFlags.__begin_[v61]->__begin_[8 * (v67 >> 6)] & (1LL << v67)) != 0 )
{
v70 = v68->__begin_;
v71 = (__int64)&v68->__begin_[v69];
v109 = sub_1001D9AD0;
v72 = 126 - 2 * __clz(v69);
if ( (_DWORD)v69 )
v73 = v72;
else
v73 = 0;
sub_10020AA24(v70, v71, &v109, v73, 1);
if ( (int)v69 >= 1 )
{
v74 = 0;
v75 = v68->__begin_;
do
{
v75[v74]->m_innerSectionIndex = v74;
++v74;
}
while ( v69 != v74 );
}
v76 = a1->m_nonEffectObjectsFlags.__begin_[v61]->__begin_;
*(_QWORD *)&v76[8 * (v67 >> 6)] &= ~(1LL << v67);
}
GJBaseGameLayer::collisionCheckObjects(a1, a2, v68, v69, a3);
}
++v67;
}
while ( v67 != v66 );
}
}
++v61;
}
while ( v61 != v108 );
}
m_calcNonEffectObjectsSize = a1->m_calcNonEffectObjectsSize;
if ( m_calcNonEffectObjectsSize >= 1 )
GJBaseGameLayer::collisionCheckObjects(a1, a2, &a1->m_calcNonEffectObjects, m_calcNonEffectObjectsSize, a3);
if ( a2->m_lastGroundObject )
m_isCollidingWithSlope = a2->m_isCollidingWithSlope;
else
m_isCollidingWithSlope = 0;
v79 = (float *)((__int64 (__fastcall *)(PlayerObject *))a2->getObjectRect)(a2);
v80 = sub_100022C30(v79);
v81 = sub_100022C40((__int64)v79);
v82 = sub_100022C48((__int64)v79);
v83.n128_f32[0] = sub_100022C58((__int64)v79);
m_solidCollisionObjectsCount = a1->m_solidCollisionObjectsCount;
if ( m_solidCollisionObjectsCount >= 1 )
{
v85 = v83.n128_f32[0];
v86 = 0;
v87 = -1;
do
{
v88 = *(&a1->m_solidCollisionObjects.__begin_[m_solidCollisionObjectsCount] + v87);
if ( !GameObject::getGroupDisabled(v88) )
{
ObjectRectPointer = GameObject::getObjectRectPointer(v88);
m_isCollidingWithSlope = m_isCollidingWithSlope
&& (v88->m_groupCount < 1 || !PlayerObject::testForMoving(a2, a3, v88));
v83.n128_f32[0] = sub_100022C40((__int64)ObjectRectPointer);
if ( v80 >= v83.n128_f32[0] )
{
v83.n128_f32[0] = sub_100022C30((float *)&ObjectRectPointer->origin);
if ( v83.n128_f32[0] >= v81 )
{
v83.n128_f32[0] = sub_100022C58((__int64)ObjectRectPointer);
if ( v82 >= v83.n128_f32[0] )
{
v83.n128_f32[0] = sub_100022C48((__int64)ObjectRectPointer);
if ( v83.n128_f32[0] >= v85 )
{
PlayerObject::collidedWithObject_1(a2, a3, v88);
v90 = ((__int64 (__fastcall *)(PlayerObject *))a2->getObjectRect)(a2);
sub_100022BB0(v79, v90);
v80 = sub_100022C30(v79);
v81 = sub_100022C40((__int64)v79);
v82 = sub_100022C48((__int64)v79);
v83.n128_f32[0] = sub_100022C58((__int64)v79);
v85 = v83.n128_f32[0];
}
}
}
}
}
++v86;
m_solidCollisionObjectsCount = a1->m_solidCollisionObjectsCount;
--v87;
}
while ( v86 < m_solidCollisionObjectsCount );
}
m_player1 = a1->m_player1;
if ( m_player1->m_isDead )
PlayerObject::removePlacedCheckpoint(m_player1);
v92 = ((__int64 (__fastcall *)(PlayerObject *, __n128))a2->getObjectRect)(a2, v83);
sub_100022BB0(v79, v92);
v93 = sub_100022C30(v79);
v94 = sub_100022C40((__int64)v79);
v95 = sub_100022C48((__int64)v79);
v96 = sub_100022C58((__int64)v79);
((void (__fastcall *)(PlayerObject *))a2->updateOrientedBox)(a2);
if ( a1->m_hazardCollisionObjectsCount < 1 )
{
LABEL_170:
PlayerObject::postCollision(a2, a3, v103[1594]);
return 0;
}
v97 = 0;
while ( 1 )
{
v98 = a1->m_hazardCollisionObjects.__begin_[v97];
if ( GameObject::getGroupDisabled(v98) )
goto LABEL_155;
v99 = GameObject::getObjectRectPointer(v98);
if ( v98->m_objectRadius <= 0.0 )
break;
if ( GJBaseGameLayer::playerCircleCollision(a1, a2, v98) )
goto LABEL_159;
LABEL_155:
if ( ++v97 >= a1->m_hazardCollisionObjectsCount )
goto LABEL_170;
}
p_origin = (float *)&v99->origin;
if ( v93 < sub_100022C40((__int64)v99)
|| sub_100022C30(p_origin) < v94
|| v95 < sub_100022C58((__int64)p_origin)
|| sub_100022C48((__int64)p_origin) < v96 )
{
goto LABEL_155;
}
LABEL_159:
if ( v98->m_shouldUseOuterOb && (!a1->m_levelSettings->m_fixRadiusCollision || v98->m_objectRadius <= 0.0) )
{
v100 = (OBB2D *)((__int64 (__fastcall *)(GameObject *))v98->getOrientedBox)(v98);
v101 = (OBB2D *)((__int64 (__fastcall *)(PlayerObject *))a2->getOrientedBox)(a2);
if ( !OBB2D::overlaps1Way(v100) || !OBB2D::overlaps1Way(v101) )
goto LABEL_155;
}
if ( !v104 )
((void (__fastcall *)(GJBaseGameLayer *, PlayerObject *, GameObject *))a1->destroyPlayer)(a1, a2, v98);
return 1;
}