//
// GJBaseGameLayer::updateCollisionBlocks from 0x860e4c to 0x8614c4 (1656 bytes)
//
// 3 xrefs:
// > GJBaseGameLayer::loadUpToPosition @ 0x89d5a0
// > GJBaseGameLayer::update @ 0x89e220
// > ??> @ 0xb2050
//
// 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
//
void GJBaseGameLayer::updateCollisionBlocks(GJBaseGameLayer *a1)
{
cocos2d::CCArray *m_collisionBlocks; // x0
cocos2d::ccArray *data; // x21
unsigned int num; // w19
EffectGameObject **arr; // x0
EffectGameObject *v6; // x20
int m_outerSectionIndex; // w23
int m_middleSectionIndex; // w25
int v9; // w21
int v10; // w23
signed __int64 v11; // x19
unsigned __int64 v12; // x0
int v13; // w19
int v14; // w22
__int64 v15; // x27
std::vector *v16; // x0
__int64 v17; // x19
unsigned __int64 v18; // x1
int v19; // w19
__int64 v20; // x24
int v21; // w26
__int64 v22; // x25
std::vector *v23; // x3
int m_calcCollisionBlockObjectsSize; // w3
GameObject **v25; // x1
int v26; // w0
int v27; // w2
int v28; // w0
GameObject *v29; // x1
EffectGameObject **v30; // x0
cocos2d::CCArray *v31; // x0
GameObject **v32; // x1
GameObject **i; // x3
int v34; // w2
GameObject *v35; // x0
int v36; // w2
int m_calcCollisionBlockObjects2Size; // w3
GameObject **m_start; // x0
int v39; // w3
int m_innerSectionIndex; // w1
int v41; // w5
int v42; // w2
int *v43; // x6
int v44; // w5
int v45; // w0
int v46; // w1
int v47; // w6
int *v48; // x5
GameObject *v49; // x2
GameObject_vtbl *v50; // x3
int v51; // w0
cocos2d::CCRect *ObjectRectPointer; // x19
float v53; // s0
float v54; // s0
float v55; // s0
float v56; // s0
float v57; // s0
float v58; // s0
float v59; // s0
float v60; // s1
float v61; // s0
float v62; // s0
float v63; // s0
float v64; // s0
float v65; // s0
float v66; // s0
float v67; // s0
float v68; // s0
float v69; // s0
float v70; // s0
float v71; // s0
float v72; // s0
float v73; // s0
float v74; // s0
float v75; // s0
EffectGameObject **v76; // [xsp+A0h] [xbp+A0h]
EffectGameObject **v77; // [xsp+C0h] [xbp+C0h]
int v78; // [xsp+CCh] [xbp+CCh]
if ( !(unsigned int)cocos2d::CCArray::count(a1->m_collisionBlocks) )
return;
GJBaseGameLayer::updatePlayerCollisionBlocks(a1);
m_collisionBlocks = a1->m_collisionBlocks;
if ( !m_collisionBlocks )
return;
data = m_collisionBlocks->data;
num = data->num;
if ( !data->num )
return;
arr = (EffectGameObject **)data->arr;
v77 = arr;
v76 = &arr[num - 1];
if ( arr > v76 )
goto LABEL_38;
v6 = *arr;
if ( !*arr )
goto LABEL_38;
do
{
if ( v6->m_isGroupDisabled )
goto LABEL_31;
if ( !v6->m_isUIObject )
{
m_outerSectionIndex = v6->m_outerSectionIndex;
m_middleSectionIndex = v6->m_middleSectionIndex;
if ( m_outerSectionIndex <= 1 )
v9 = 0;
else
v9 = m_outerSectionIndex - 1;
v10 = m_outerSectionIndex + 1;
v11 = a1->m_collisionBlockSections.m_finish - a1->m_collisionBlockSections.m_start;
v12 = v11 - 1;
v13 = v11 - 1;
if ( v12 < v10 )
v10 = v13;
if ( m_middleSectionIndex <= 1 )
v14 = 0;
else
v14 = m_middleSectionIndex - 1;
if ( !v6->m_hasExtendedCollision )
{
v78 = m_middleSectionIndex + 1;
LABEL_17:
if ( v10 >= v9 )
{
v15 = v9;
do
{
v16 = a1->m_collisionBlockSections.m_start[v15];
if ( v16 )
{
v17 = v16->m_finish - v16->m_start;
v18 = v17 - 1;
v19 = v17 - 1;
if ( v78 <= v18 )
v19 = v78;
}
else
{
v19 = -1;
}
if ( v19 >= v14 )
{
v20 = v14;
v21 = v14;
v22 = v14;
while ( 1 )
{
++v21;
v23 = (std::vector *)v16->m_start[v22++];
if ( v23 )
GJBaseGameLayer::checkCollisionBlocks(
a1,
v6,
v23,
a1->m_collisionBlockSectionSizes.m_start[v15]->m_start[v20]);
++v20;
if ( v21 > v19 )
break;
v16 = a1->m_collisionBlockSections.m_start[v15];
}
}
++v9;
++v15;
}
while ( v9 <= v10 );
}
m_calcCollisionBlockObjectsSize = a1->m_calcCollisionBlockObjectsSize;
if ( m_calcCollisionBlockObjectsSize > 0 )
GJBaseGameLayer::checkCollisionBlocks(
a1,
v6,
(std::vector *)&a1->m_calcCollisionBlockObjects,
m_calcCollisionBlockObjectsSize);
goto LABEL_31;
}
ObjectRectPointer = GameObject::getObjectRectPointer(v6);
cocos2d::CCRect::getMinX(ObjectRectPointer);
if ( v53 > 0.0 )
{
cocos2d::CCRect::getMinX(ObjectRectPointer);
if ( v54 < 10000000.0 )
{
cocos2d::CCRect::getMinX(ObjectRectPointer);
if ( (float)((float)(v70 * a1->m_sectionXFactor) + -1.0) > 0.0 )
{
LABEL_58:
v9 = -1;
cocos2d::CCRect::getMinX(ObjectRectPointer);
if ( v55 > 0.0 )
{
cocos2d::CCRect::getMinX(ObjectRectPointer);
if ( v56 < 10000000.0 )
{
cocos2d::CCRect::getMinX(ObjectRectPointer);
v9 = (int)(float)((float)(v74 * a1->m_sectionXFactor) + -1.0);
}
else
{
v9 = (int)(float)((float)(a1->m_sectionXFactor * 10000000.0) + -1.0);
}
}
LABEL_62:
cocos2d::CCRect::getMaxX(ObjectRectPointer);
if ( v57 <= 0.0 )
{
v59 = 1.0;
}
else
{
cocos2d::CCRect::getMaxX(ObjectRectPointer);
if ( v58 < 10000000.0 )
{
cocos2d::CCRect::getMaxX(ObjectRectPointer);
v59 = (float)(v72 * a1->m_sectionXFactor) + 1.0;
}
else
{
v59 = (float)(a1->m_sectionXFactor * 10000000.0) + 1.0;
}
}
v60 = (float)(unsigned __int64)(a1->m_collisionBlockSections.m_finish
- a1->m_collisionBlockSections.m_start
- 1);
if ( v60 >= v59 )
{
v10 = 1;
cocos2d::CCRect::getMaxX(ObjectRectPointer);
if ( v67 > 0.0 )
{
cocos2d::CCRect::getMaxX(ObjectRectPointer);
if ( v68 < 10000000.0 )
{
cocos2d::CCRect::getMaxX(ObjectRectPointer);
v10 = (int)(float)((float)(v75 * a1->m_sectionXFactor) + 1.0);
}
else
{
v10 = (int)(float)((float)(a1->m_sectionXFactor * 10000000.0) + 1.0);
}
}
}
else
{
v10 = (int)v60;
}
cocos2d::CCRect::getMinY(ObjectRectPointer);
if ( v61 > 0.0 )
{
cocos2d::CCRect::getMinY(ObjectRectPointer);
if ( v62 < 10000000.0 )
{
cocos2d::CCRect::getMinY(ObjectRectPointer);
if ( (float)((float)(v69 * a1->m_sectionYFactor) + -1.0) > 0.0 )
{
LABEL_70:
v14 = -1;
cocos2d::CCRect::getMinY(ObjectRectPointer);
if ( v63 > 0.0 )
{
cocos2d::CCRect::getMinY(ObjectRectPointer);
if ( v64 < 10000000.0 )
{
cocos2d::CCRect::getMinY(ObjectRectPointer);
v14 = (int)(float)((float)(v73 * a1->m_sectionYFactor) + -1.0);
}
else
{
v14 = (int)(float)((float)(a1->m_sectionYFactor * 10000000.0) + -1.0);
}
}
goto LABEL_74;
}
}
else if ( (float)((float)(a1->m_sectionYFactor * 10000000.0) + -1.0) > 0.0 )
{
goto LABEL_70;
}
}
v14 = 0;
LABEL_74:
v78 = 1;
cocos2d::CCRect::getMaxY(ObjectRectPointer);
if ( v65 > 0.0 )
{
cocos2d::CCRect::getMaxY(ObjectRectPointer);
if ( v66 < 10000000.0 )
{
cocos2d::CCRect::getMaxY(ObjectRectPointer);
v78 = (int)(float)((float)(v71 * a1->m_sectionYFactor) + 1.0);
}
else
{
v78 = (int)(float)((float)(a1->m_sectionYFactor * 10000000.0) + 1.0);
}
}
goto LABEL_17;
}
}
else if ( (float)((float)(a1->m_sectionXFactor * 10000000.0) + -1.0) > 0.0 )
{
goto LABEL_58;
}
}
v9 = 0;
goto LABEL_62;
}
m_calcCollisionBlockObjects2Size = a1->m_calcCollisionBlockObjects2Size;
if ( m_calcCollisionBlockObjects2Size <= 0 )
goto LABEL_49;
GJBaseGameLayer::checkCollisionBlocks(
a1,
v6,
(std::vector *)&a1->m_calcCollisionBlockObjects2,
m_calcCollisionBlockObjects2Size);
LABEL_31:
if ( v6->m_isUIObject )
{
m_calcCollisionBlockObjects2Size = a1->m_calcCollisionBlockObjects2Size;
LABEL_49:
m_start = a1->m_calcCollisionBlockObjects2.m_start;
v39 = m_calcCollisionBlockObjects2Size - 1;
m_innerSectionIndex = v6->m_innerSectionIndex;
a1->m_calcCollisionBlockObjects2Size = v39;
m_start[m_innerSectionIndex] = m_start[v39];
a1->m_calcCollisionBlockObjects2.m_start[v6->m_innerSectionIndex]->m_innerSectionIndex = v6->m_innerSectionIndex;
goto LABEL_35;
}
if ( v6->m_hasExtendedCollision )
{
v25 = a1->m_calcCollisionBlockObjects.m_start;
v26 = a1->m_calcCollisionBlockObjectsSize - 1;
v27 = v6->m_innerSectionIndex;
a1->m_calcCollisionBlockObjectsSize = v26;
v25[v27] = v25[v26];
v28 = v6->m_innerSectionIndex;
v29 = a1->m_calcCollisionBlockObjects.m_start[v28];
}
else
{
v45 = v6->m_outerSectionIndex;
v46 = v6->m_middleSectionIndex;
v47 = v6->m_innerSectionIndex;
v48 = a1->m_collisionBlockSectionSizes.m_start[v45]->m_start;
v49 = a1->m_collisionBlockSections.m_start[v45]->m_start[v46];
v50 = v49->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v51 = v48[v46] - 1;
v48[v46] = v51;
*((_QWORD *)&v50->copyWithZone + v47) = *((_QWORD *)&v50->copyWithZone + v51);
v28 = v6->m_innerSectionIndex;
v29 = *((GameObject **)&v49->copyWithZone + v28);
}
v29->m_innerSectionIndex = v28;
LABEL_35:
v30 = v77 + 1;
v77 = v30;
if ( v76 < v30 )
break;
v6 = *v30;
}
while ( *v30 );
v31 = a1->m_collisionBlocks;
if ( v31 )
{
data = v31->data;
num = data->num;
if ( data->num )
{
LABEL_38:
v32 = (GameObject **)data->arr;
for ( i = &v32[num - 1]; i >= v32; ++v32 )
{
v35 = *v32;
if ( !*v32 )
break;
if ( v35->m_isUIObject )
{
v34 = a1->m_calcCollisionBlockObjects2Size;
a1->m_calcCollisionBlockObjects2.m_start[v34] = v35;
a1->m_calcCollisionBlockObjects2Size = v34 + 1;
v35->m_innerSectionIndex = v34;
}
else if ( v35->m_hasExtendedCollision )
{
v36 = a1->m_calcCollisionBlockObjectsSize;
a1->m_calcCollisionBlockObjects.m_start[v36] = v35;
a1->m_calcCollisionBlockObjectsSize = v36 + 1;
v35->m_innerSectionIndex = v36;
}
else
{
v41 = v35->m_outerSectionIndex;
v42 = v35->m_middleSectionIndex;
*((_QWORD *)&a1->m_collisionBlockSections.m_start[v41]->m_start[v42]->copyWithZone
+ a1->m_collisionBlockSectionSizes.m_start[v41]->m_start[v42]) = v35;
v43 = a1->m_collisionBlockSectionSizes.m_start[v41]->m_start;
v44 = v43[v42];
v43[v42] = v44 + 1;
v35->m_innerSectionIndex = v44;
}
}
}
}
}