//
// GJBaseGameLayer::checkCollisions from 0x493408 to 0x493e6c (2660 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::update @ 0x4978f0
// > GJBaseGameLayer::update @ 0x497954
//
// 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 GJBaseGameLayer::checkCollisions(GJBaseGameLayer *a1, PlayerObject *a2, float a3, bool a4)
{
_BOOL4 m_wasTeleported; // r9
cocos2d::CCPoint *v7; // r10
float m_vehicleSize; // s16
float m_unkAngle1; // s17
bool v10; // zf
float v11; // s16
float v12; // s17
float v13; // s18
_BOOL4 v14; // r6
_BOOL4 m_isOutOfBounds; // r8
_BOOL4 m_isPlatformer; // r2
int v17; // r5
PlayerObject_vtbl *v18; // r3
void (__fastcall *setPosition)(PlayerObject *__hidden, const cocos2d::CCPoint *); // r7
const cocos2d::CCPoint *v20; // r0
float MaxPortalY; // s18
float MinPortalY; // r0
float v23; // s20
float v24; // s19
_BOOL4 v25; // r7
float v26; // s18
float v27; // s16
int v28; // r6
float YVelocity; // s16
_BOOL4 v30; // r9
const cocos2d::CCPoint *v31; // r0
PlayerObject_vtbl *v33; // r3
float *p_m_sectionXFactor; // r5
float v35; // s14
float x; // s15
const cocos2d::CCPoint *v37; // r0
int v38; // r5
float *p_m_sectionYFactor; // r6
float v40; // s14
float y; // s15
const cocos2d::CCPoint *v42; // r0
int v43; // r2
std::vector *, std::allocator *>> *, std::allocator *, std::allocator *>> *>> *p_m_nonEffectObjects; // r6
std::vector *, std::allocator *>> **m_finish; // r1
std::vector *, std::allocator *>> **m_start; // r0
bool v47; // cc
int v48; // r5
bool v49; // cc
int v50; // r2
int m_calcNonEffectObjectsSize; // r3
unsigned int v52; // r5
std::vector *, std::allocator *>> *p_m_nonEffectObjectsFlags; // r8
std::vector *, std::allocator *>> *v54; // r2
unsigned int v55; // r3
unsigned int v56; // r7
char **v57; // r9
int i; // r2
std::uintptr_t *m_bitptr; // r2
GameObject *m_lastGroundObject; // r6
int v61; // r8
cocos2d::CCRect *v62; // r5
float v63; // s19
float v64; // s18
float v65; // s17
float v66; // s16
GameObject *v67; // r7
cocos2d::CCRect *ObjectRectPointer; // r9
PlayerObject *m_player1; // r0
int v70; // r6
const cocos2d::CCRect *v71; // r0
float v72; // s16
float v73; // s17
float v74; // s18
float v75; // s19
GameObject *v76; // r5
cocos2d::CCRect *v77; // r0
cocos2d::CCRect *v78; // r9
OBB2D *v79; // r9
OBB2D *v80; // r10
void (__fastcall *v81)(PlayerObject *__hidden, const cocos2d::CCPoint *); // r6
const cocos2d::CCPoint *v82; // r0
_BOOL4 m_maybeIsBoosted; // r7
const cocos2d::CCPoint *v84; // r0
_BOOL4 m_isUpsideDown; // r6
float v86; // s17
_BOOL4 v87; // r9
float v88; // s18
const cocos2d::CCPoint *v89; // r0
const cocos2d::CCRect *v90; // r0
void (__fastcall *v92)(PlayerObject *__hidden, const cocos2d::CCPoint *); // [sp+10h] [bp-44h]
int v93; // [sp+10h] [bp-44h]
int *p_m_solidCollisionObjectsCount; // [sp+10h] [bp-44h]
void (__fastcall *v95)(PlayerObject *__hidden, const cocos2d::CCPoint *); // [sp+10h] [bp-44h]
void (__fastcall *v96)(PlayerObject *__hidden, const cocos2d::CCPoint *); // [sp+10h] [bp-44h]
unsigned int v97; // [sp+14h] [bp-40h]
int v98; // [sp+14h] [bp-40h]
int v99; // [sp+18h] [bp-3Ch]
int v100; // [sp+1Ch] [bp-38h]
_BOOL4 v101; // [sp+20h] [bp-34h]
signed int v102; // [sp+28h] [bp-2Ch]
unsigned int v103; // [sp+30h] [bp-24h]
cocos2d::CCPoint v104; // [sp+44h] [bp-10h] BYREF
m_wasTeleported = a2->m_wasTeleported;
v7 = (cocos2d::CCPoint *)&_stack_chk_guard;
v101 = a4;
a2->m_wasTeleported = 0;
PlayerObject::preCollision(a2);
m_vehicleSize = a2->m_vehicleSize;
m_unkAngle1 = a2->m_unkAngle1;
v10 = m_vehicleSize == 1.0;
if ( m_vehicleSize == 1.0 )
v11 = 0.0;
else
v11 = 1.0 - m_vehicleSize;
if ( !v10 )
v11 = m_unkAngle1 * v11;
v12 = m_unkAngle1 * 0.5;
if ( !v10 )
v11 = v11 * 0.5;
v13 = (float)(v12 + 90.0) - v11;
if ( a1->m_gameState.m_isFreeMode )
v14 = 0;
else
v14 = PlayerObject::isFlying(a2) || a2->m_isBall || a2->m_isSpider || a1->m_gameState.m_isDualMode;
m_isOutOfBounds = a2->m_isOutOfBounds;
m_isPlatformer = a1->m_isPlatformer;
v17 = 0;
v18 = a2->GameObject::CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a2->m_isOutOfBounds = 0;
if ( m_isPlatformer )
{
if ( v18->getPosition(a2)->x < -30.0 )
{
v7 = &v104;
a2->m_platformerXVelocity = 0.0;
setPosition = a2->setPosition;
v20 = a2->getPosition(a2);
cocos2d::CCPoint::CCPoint(&v104, -30.0, v20->y);
setPosition(a2, &v104);
goto LABEL_21;
}
}
else if ( a2->m_isGoingLeft )
{
v17 = v18->getPosition(a2)->x < -30.0;
goto LABEL_21;
}
v17 = 0;
LABEL_21:
if ( a2->getPosition(a2)->y >= v13
|| v14 && (PlayerObject::isFlying(a2) || a2->m_isBall || a1->m_gameState.m_isDualMode || a2->m_isSpider) )
{
if ( a2->getPosition(a2)->y > (float)(v11 + a1->m_maxGameplayY) )
v17 = 1;
}
else if ( a2->m_isUpsideDown )
{
if ( PlayerObject::isSafeFlip(a2, 0.1) )
{
v81 = a2->setPosition;
v82 = a2->getPosition(a2);
cocos2d::CCPoint::CCPoint(&v104, v82->x, v13);
v81(a2, &v104);
PlayerObject::hitGround(a2, nullptr, 1);
PlayerObject::updateCollide(a2, (PlayerCollisionDirection)0, nullptr);
a2->m_isOnGround2 = 0;
return 0;
}
v17 = 1;
}
else
{
m_maybeIsBoosted = a2->m_maybeIsBoosted;
if ( !a2->m_maybeIsBoosted )
{
v7 = &v104;
v95 = a2->setPosition;
v84 = a2->getPosition(a2);
cocos2d::CCPoint::CCPoint(&v104, v84->x, v13);
v95(a2, &v104);
PlayerObject::hitGround(a2, (GameObject *)m_maybeIsBoosted, m_maybeIsBoosted);
PlayerObject::updateCollide(a2, (PlayerCollisionDirection)1, (GameObject *)m_maybeIsBoosted);
}
}
if ( v14 && !m_wasTeleported )
{
MaxPortalY = GJBaseGameLayer::getMaxPortalY(a1);
MinPortalY = GJBaseGameLayer::getMinPortalY(a1);
v23 = MaxPortalY - a1->m_gameState.m_unkUint17;
v24 = MinPortalY;
v25 = a2->m_isShip && a2->m_jumpBuffered;
v26 = (float)(MaxPortalY - v12) + v11;
if ( a2->getPosition(a2)->y > v26 )
{
if ( !a2->m_wasOnSlope || a2->getPosition(a2)->y <= (float)(v26 + v12) )
{
if ( !PlayerObject::destroyFromHitHead(a2) || a2->m_isUpsideDown )
{
v28 = 0;
LABEL_46:
YVelocity = PlayerObject::getYVelocity(a2);
v30 = a2->m_isUpsideDown && PlayerObject::canStickToGround(a2) && v23 != 0.0;
v7 = &v104;
v92 = a2->setPosition;
v31 = a2->getPosition(a2);
cocos2d::CCPoint::CCPoint(&v104, v31->x, v26);
v92(a2, &v104);
if ( v28 )
{
PlayerObject::pushDown(a2);
}
else if ( PlayerObject::getYVelocity(a2) > 0.0 )
{
PlayerObject::hitGround(a2, nullptr, !a2->m_isUpsideDown);
}
PlayerObject::updateCollide(a2, (PlayerCollisionDirection)a2->m_isUpsideDown, nullptr);
if ( v30 && YVelocity > PlayerObject::getYVelocity(a2) || !a2->m_isUpsideDown && v25 && v23 > 0.0 )
PlayerObject::setYVelocity(a2, YVelocity, 0);
LABEL_53:
a2->m_wasOnSlope = 0;
goto LABEL_54;
}
if ( PlayerObject::isSafeHeadTest(a2) )
{
v28 = 1;
goto LABEL_46;
}
}
LABEL_59:
if ( m_isOutOfBounds )
{
LABEL_56:
if ( !v101 )
a1->destroyPlayer(a1, a2, nullptr);
return 1;
}
LOBYTE(v17) = 1;
goto LABEL_61;
}
v27 = (float)(v24 + v12) - v11;
if ( a2->getPosition(a2)->y < v27 )
{
if ( a2->m_wasOnSlope && a2->getPosition(a2)->y < (float)(v27 - v12) )
goto LABEL_59;
if ( PlayerObject::destroyFromHitHead(a2) )
{
m_isUpsideDown = a2->m_isUpsideDown;
if ( a2->m_isUpsideDown )
{
if ( !PlayerObject::isSafeHeadTest(a2) )
goto LABEL_59;
m_isUpsideDown = 1;
}
}
else
{
m_isUpsideDown = 0;
}
v86 = PlayerObject::getYVelocity(a2);
v87 = !a2->m_isUpsideDown && PlayerObject::canStickToGround(a2) && v23 != 0.0;
if ( m_isUpsideDown
|| PlayerObject::canStickToGround(a2)
|| a1->m_gameState.m_cameraZoom == a1->m_gameState.m_targetCameraZoom )
{
v88 = 0.0;
}
else
{
v88 = 1.0;
}
v7 = &v104;
v96 = a2->setPosition;
v89 = a2->getPosition(a2);
cocos2d::CCPoint::CCPoint(&v104, v89->x, v27 + v88);
v96(a2, &v104);
if ( m_isUpsideDown )
{
PlayerObject::pushDown(a2);
}
else if ( !a2->m_isShip && !a2->m_isSwing || PlayerObject::getYVelocity(a2) < 0.0 )
{
PlayerObject::hitGround(a2, nullptr, a2->m_isUpsideDown);
}
PlayerObject::updateCollide(a2, (PlayerCollisionDirection)!a2->m_isUpsideDown, nullptr);
if ( v87 && v86 < PlayerObject::getYVelocity(a2) || a2->m_isUpsideDown && v25 && v23 < 0.0 )
PlayerObject::setYVelocity(a2, v86, 0);
goto LABEL_53;
}
}
LABEL_54:
if ( m_isOutOfBounds && v17 )
goto LABEL_56;
LABEL_61:
v33 = a2->GameObject::CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a2->m_isOutOfBounds = v17;
if ( v33->getPosition(a2)->x <= 0.0 )
{
v38 = 0;
}
else
{
p_m_sectionXFactor = &a1->m_sectionXFactor;
v35 = 10000000.0;
if ( a2->getPosition(a2)->x < 10000000.0 )
{
v37 = a2->getPosition(a2);
v35 = *p_m_sectionXFactor;
x = v37->x;
}
else
{
x = *p_m_sectionXFactor;
}
v38 = (int)(float)(x * v35);
}
if ( a2->getPosition(a2)->y <= 0.0 )
{
v43 = 0;
}
else
{
p_m_sectionYFactor = &a1->m_sectionYFactor;
v40 = 10000000.0;
if ( a2->getPosition(a2)->y < 10000000.0 )
{
v42 = a2->getPosition(a2);
v40 = *p_m_sectionYFactor;
y = v42->y;
}
else
{
y = *p_m_sectionYFactor;
}
v43 = (int)(float)(y * v40);
}
p_m_nonEffectObjects = &a1->m_nonEffectObjects;
v97 = v38 + 1;
m_finish = a1->m_nonEffectObjects.m_finish;
m_start = a1->m_nonEffectObjects.m_start;
v47 = v38 <= 1;
if ( v38 > 1 )
v7 = (cocos2d::CCPoint *)(v38 - 1);
v48 = v38 + 1;
if ( v47 )
v7 = nullptr;
if ( v97 >= m_finish - m_start - 1 )
v48 = m_finish - m_start - 1;
v49 = v43 <= 1;
v98 = v48;
if ( v43 > 1 )
v48 = v43 - 1;
else
v99 = 0;
v50 = v43 + 1;
if ( !v49 )
v99 = v48;
v103 = v50;
a1->m_solidCollisionObjectsCount = 0;
a1->m_hazardCollisionObjectsCount = 0;
if ( m_start != m_finish )
{
v52 = (unsigned int)v7;
p_m_nonEffectObjectsFlags = &a1->m_nonEffectObjectsFlags;
while ( (int)v7 <= v98 )
{
v54 = p_m_nonEffectObjects->m_start[v52];
if ( v54 )
{
v55 = v54->m_finish - v54->m_start - 1;
if ( v55 >= v103 )
v55 = v103;
}
else
{
v55 = -1;
}
v102 = v55;
v56 = v99;
v93 = v99;
while ( (int)v56 <= v102 )
{
v57 = (char **)p_m_nonEffectObjects->m_start[v52]->m_start[v93];
if ( v57 )
{
v100 = a1->m_nonEffectObjectsSizes.m_start[v52]->m_start[v93];
if ( ((1 << (v56 & 0x1F)) & p_m_nonEffectObjectsFlags->m_start[v52]->m_start.m_bitptr[v56 >> 5]) != 0 )
{
std::__sort<__gnu_cxx::__normal_iterator>,__gnu_cxx::__ops::_Iter_comp_iter>(
*v57,
&(*v57)[4 * v100],
(int (__fastcall *)(int, int))mIDCompSort);
for ( i = 0; i < v100; ++i )
*(_DWORD *)(*(_DWORD *)&(*v57)[4 * i] + 524) = i;
m_bitptr = p_m_nonEffectObjectsFlags->m_start[v52]->m_start.m_bitptr;
LODWORD(v104.y) = 1 << (v56 & 0x1F);
LODWORD(v104.x) = &m_bitptr[v56 >> 5];
std::_Bit_reference::operator=((int)&v104, 0);
}
GJBaseGameLayer::collisionCheckObjects(a1, a2, (std::vector *)v57, v100, a3);
}
++v56;
++v93;
}
v7 = (cocos2d::CCPoint *)((char *)v7 + 1);
++v52;
}
}
m_calcNonEffectObjectsSize = a1->m_calcNonEffectObjectsSize;
if ( m_calcNonEffectObjectsSize > 0 )
GJBaseGameLayer::collisionCheckObjects(a1, a2, &a1->m_calcNonEffectObjects, m_calcNonEffectObjectsSize, a3);
m_lastGroundObject = a2->m_lastGroundObject;
if ( m_lastGroundObject )
m_lastGroundObject = (GameObject *)a2->m_isCollidingWithSlope;
v61 = 0;
v62 = (cocos2d::CCRect *)a2->getObjectRect(a2);
v63 = COERCE_FLOAT(cocos2d::CCRect::getMaxX(v62));
v64 = COERCE_FLOAT(cocos2d::CCRect::getMinX(v62));
v65 = COERCE_FLOAT(cocos2d::CCRect::getMaxY(v62));
p_m_solidCollisionObjectsCount = &a1->m_solidCollisionObjectsCount;
v66 = COERCE_FLOAT(cocos2d::CCRect::getMinY(v62));
while ( v61 < *p_m_solidCollisionObjectsCount )
{
v67 = a1->m_solidCollisionObjects.m_start[*p_m_solidCollisionObjectsCount - 1 - v61];
if ( !GameObject::getGroupDisabled(v67) )
{
ObjectRectPointer = GameObject::getObjectRectPointer(v67);
if ( m_lastGroundObject && v67->m_groupCount > 0 )
m_lastGroundObject = (GameObject *)!PlayerObject::testForMoving(a2, a3, v67);
if ( v63 >= COERCE_FLOAT(cocos2d::CCRect::getMinX(ObjectRectPointer))
&& COERCE_FLOAT(cocos2d::CCRect::getMaxX(ObjectRectPointer)) >= v64
&& v65 >= COERCE_FLOAT(cocos2d::CCRect::getMinY(ObjectRectPointer))
&& COERCE_FLOAT(cocos2d::CCRect::getMaxY(ObjectRectPointer)) >= v66 )
{
PlayerObject::collidedWithObject(a2, a3, v67);
v90 = a2->getObjectRect(a2);
cocos2d::CCRect::operator=(v62, v90);
v63 = COERCE_FLOAT(cocos2d::CCRect::getMaxX(v62));
v64 = COERCE_FLOAT(cocos2d::CCRect::getMinX(v62));
v65 = COERCE_FLOAT(cocos2d::CCRect::getMaxY(v62));
v66 = COERCE_FLOAT(cocos2d::CCRect::getMinY(v62));
}
}
++v61;
}
m_player1 = a1->m_player1;
if ( m_player1->m_isDead )
PlayerObject::removePlacedCheckpoint(m_player1);
v70 = 0;
v71 = a2->getObjectRect(a2);
cocos2d::CCRect::operator=(v62, v71);
v72 = COERCE_FLOAT(cocos2d::CCRect::getMaxX(v62));
v73 = COERCE_FLOAT(cocos2d::CCRect::getMinX(v62));
v74 = COERCE_FLOAT(cocos2d::CCRect::getMaxY(v62));
v75 = COERCE_FLOAT(cocos2d::CCRect::getMinY(v62));
a2->updateOrientedBox(a2);
while ( 1 )
{
if ( v70 >= a1->m_hazardCollisionObjectsCount )
{
PlayerObject::postCollision(a2, a3, a1->m_isBetweenSteps);
return 0;
}
v76 = a1->m_hazardCollisionObjects.m_start[v70];
if ( !GameObject::getGroupDisabled(v76) )
{
v77 = GameObject::getObjectRectPointer(v76);
v78 = v77;
if ( v76->m_objectRadius <= 0.0 )
{
if ( v72 < COERCE_FLOAT(cocos2d::CCRect::getMinX(v77))
|| COERCE_FLOAT(cocos2d::CCRect::getMaxX(v78)) < v73
|| v74 < COERCE_FLOAT(cocos2d::CCRect::getMinY(v78))
|| COERCE_FLOAT(cocos2d::CCRect::getMaxY(v78)) < v75 )
{
goto LABEL_139;
}
}
else if ( !GJBaseGameLayer::playerCircleCollision(a1, a2, v76) )
{
goto LABEL_139;
}
if ( !v76->m_shouldUseOuterOb || a1->m_levelSettings->m_fixRadiusCollision && v76->m_objectRadius > 0.0 )
break;
v79 = v76->getOrientedBox(v76);
v80 = a2->getOrientedBox(a2);
if ( OBB2D::overlaps1Way(v79) && OBB2D::overlaps1Way(v80) )
break;
}
LABEL_139:
++v70;
}
if ( !v101 )
a1->destroyPlayer(a1, a2, v76);
return 1;
}