//
// GJBaseGameLayer::generateTargetGroups from 0x1001e0c74 to 0x1001e16a0 (2604 bytes)
//
// 1 xrefs:
// > GJBaseGameLayer::updateSpecialGroupData @ 0x1001dfbfc
//
// 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 __fastcall GJBaseGameLayer::generateTargetGroups(GJBaseGameLayer *a1)
{
cocos2d::CCArray *m_targetGroupsArray; // x0
cocos2d::CCArray *v3; // x0
cocos2d::CCArray *m_objects; // x9
cocos2d::ccArray *v5; // x10
__int64 v6; // x9
cocos2d::CCObject **arr; // x19
unsigned __int64 v8; // x23
cocos2d::CCObject *v9; // x21
_QWORD *v10; // x0
int m_unknown2_low; // w9
int v12; // w8
_BYTE *v13; // x8
int v14; // w10
__int64 v15; // x22
cocos2d::CCObject_vtbl *v16; // x26
__int64 v17; // x0
int v18; // w9
_BYTE *v19; // x21
__int64 *i; // x24
_BYTE *v21; // x0
__int64 v22; // x8
GJBaseGameLayer *v23; // x19
int v24; // w9
int v25; // w20
int v26; // w8
int v27; // w19
int v28; // w10
cocos2d::CCDictionary *v29; // x24
cocos2d::CCDictionary *v30; // x25
unsigned int v31; // w0
cocos2d::ccArray *data; // x9
__int64 num; // x8
cocos2d::CCObject **v34; // x20
unsigned __int64 v35; // x21
cocos2d::CCObject *v36; // x8
int m_uIndexInArray; // w22
cocos2d::ccArray *v38; // x9
__int64 v39; // x8
cocos2d::CCObject **v40; // x19
cocos2d::CCObject *v41; // x22
cocos2d::CCObject *v42; // x21
__int64 j; // x26
__int64 v44; // x20
cocos2d::CCArray *v45; // x28
__int64 v46; // x23
intptr_t v47; // x27
__int64 v48; // x20
cocos2d::CCObject *v49; // x0
cocos2d::CCObject *v50; // x0
cocos2d::CCObject *v51; // x0
cocos2d::ccArray *v52; // x9
__int64 v53; // x8
cocos2d::CCObject **v54; // x19
unsigned __int64 v55; // x22
cocos2d::CCObject *v56; // x20
intptr_t v57; // x21
cocos2d::CCObject *v58; // x0
cocos2d::CCObject *v59; // x0
__int64 v60; // x0
__int64 v61; // x26
__int64 v62; // x21
cocos2d::CCDictionary *v63; // x28
cocos2d::CCDictionary *v64; // x27
cocos2d::ccArray *v65; // x9
__int64 v66; // x8
cocos2d::CCObject **v67; // x19
unsigned __int64 v68; // x22
cocos2d::CCObject *v69; // x23
intptr_t v70; // x20
cocos2d::CCObject *v71; // x0
cocos2d::CCArray *v72; // x1
cocos2d::CCObject *v73; // x0
int v74; // w20
int v75; // w23
int v76; // w24
__int64 v77; // x0
int v78; // w20
__int64 v79; // x0
__int64 *v80; // [xsp+8h] [xbp-1A8h]
char v81; // [xsp+14h] [xbp-19Ch]
_BYTE *v82; // [xsp+18h] [xbp-198h]
int v83; // [xsp+24h] [xbp-18Ch]
unsigned __int64 v84; // [xsp+28h] [xbp-188h]
cocos2d::CCArray *Group; // [xsp+30h] [xbp-180h]
GJBaseGameLayer *v86; // [xsp+38h] [xbp-178h]
cocos2d::CCObject *v87; // [xsp+40h] [xbp-170h]
unsigned int v88; // [xsp+48h] [xbp-168h] BYREF
unsigned int m_uReference; // [xsp+4Ch] [xbp-164h] BYREF
int v90[8]; // [xsp+50h] [xbp-160h] BYREF
float v91; // [xsp+70h] [xbp-140h]
int v92; // [xsp+78h] [xbp-138h] BYREF
int v93; // [xsp+7Ch] [xbp-134h] BYREF
__int128 v94; // [xsp+80h] [xbp-130h] BYREF
__int128 v95; // [xsp+90h] [xbp-120h]
int v96; // [xsp+A0h] [xbp-110h]
_QWORD v97[4]; // [xsp+B0h] [xbp-100h] BYREF
int v98; // [xsp+D0h] [xbp-E0h]
__int128 v99; // [xsp+E0h] [xbp-D0h] BYREF
__int128 v100; // [xsp+F0h] [xbp-C0h]
int v101; // [xsp+100h] [xbp-B0h]
_BYTE v102[32]; // [xsp+110h] [xbp-A0h] BYREF
int v103; // [xsp+130h] [xbp-80h]
int v104[6]; // [xsp+148h] [xbp-68h] BYREF
m_targetGroupsArray = a1->m_targetGroupsArray;
if ( m_targetGroupsArray )
{
sub_10024A45C(m_targetGroupsArray);
}
else
{
v3 = (cocos2d::CCArray *)sub_10024A15C(0);
a1->m_targetGroupsArray = v3;
cocos2d::CCObject::retain(v3);
}
sub_100018054(&a1->m_targetGroups.__table_.__bucket_list_.__ptr_.__value_);
memset(v102, 0, sizeof(v102));
v103 = 1065353216;
v99 = 0u;
v100 = 0u;
v101 = 1065353216;
memset(v97, 0, sizeof(v97));
v98 = 1065353216;
m_objects = a1->m_objects;
if ( m_objects && (v5 = m_objects->data, v6 = v5->num, (_DWORD)v6) )
{
v86 = a1;
arr = v5->arr;
v8 = (unsigned __int64)&arr[v6 - 1];
do
{
v9 = *arr;
if ( !*arr )
break;
if ( v9[18].m_uReference != 3016
&& ((unsigned int (__fastcall *)(cocos2d::CCObject *))v9->__vftable[22].isEqual)(*arr) != 45 )
{
if ( v9[18].m_uReference == 1268 )
{
v15 = *(_QWORD *)&v9[32].m_uOrderOfArrival;
v16 = v9[33].__vftable;
while ( (cocos2d::CCObject_vtbl *)v15 != v16 )
{
*(_QWORD *)&v94 = v15;
v17 = sub_100209DB0(v97, v15, &unk_10063A31C, &v94, v90);
sub_10001C1B0(v17 + 24, (int *)(v15 + 8), (_DWORD *)(v15 + 8));
v15 += 16;
}
}
goto LABEL_27;
}
v90[0] = v9[26].m_uID;
*(_QWORD *)&v94 = v90;
v10 = sub_10001D150((unsigned __int64)v102, v90, (__int64)&unk_10063A31C, (_DWORD **)&v94);
m_unknown2_low = LOBYTE(v9[32].m_unknown2);
v12 = BYTE1(v9[32].m_unknown2);
if ( (m_unknown2_low & 1) == 0 && !BYTE1(v9[32].m_unknown2) )
{
v13 = (char *)v10 + 20;
LABEL_25:
*v13 = 1;
goto LABEL_26;
}
v14 = v12 ^ 1;
if ( (m_unknown2_low & 1) == 0 && (v14 & 1) == 0 )
{
v13 = (char *)v10 + 21;
goto LABEL_25;
}
v18 = m_unknown2_low ^ 1;
if ( (v18 & 1) == 0 && (v12 & 1) == 0 )
{
v13 = (char *)v10 + 22;
goto LABEL_25;
}
if ( ((v18 | v14) & 1) == 0 )
{
v13 = (char *)v10 + 23;
goto LABEL_25;
}
LABEL_26:
LODWORD(v94) = v9[26].m_uID;
sub_10001C1B0((unsigned __int64)&v99, (int *)&v94, &v94);
LABEL_27:
++arr;
}
while ( (unsigned __int64)arr <= v8 );
v94 = 0u;
v95 = 0u;
v96 = 1065353216;
if ( *((_QWORD *)&v100 + 1) )
{
do
{
v104[0] = *(_DWORD *)(v100 + 16);
sub_10001C1B0((unsigned __int64)&v94, v104, v104);
sub_100018AE0(&v99, (__int64 *)v100);
*(_QWORD *)v90 = v104;
v19 = sub_10001D150((unsigned __int64)v102, v104, (__int64)&unk_10063A31C, (_DWORD **)v90);
if ( sub_100018814(v97, v104) )
{
*(_QWORD *)v90 = v104;
for ( i = *(__int64 **)(sub_100209DB0(v97, v104, &unk_10063A31C, v90, &v93) + 40); i; i = (__int64 *)*i )
{
v93 = *((_DWORD *)i + 4);
if ( !sub_100018814(&v94, &v93) )
sub_10001C1B0((unsigned __int64)&v99, &v93, &v93);
*(_QWORD *)v90 = &v93;
v21 = sub_10001D150((unsigned __int64)v102, &v93, (__int64)&unk_10063A31C, (_DWORD **)v90);
if ( v19[20] == 1 )
v21[20] = 1;
if ( v19[21] == 1 )
v21[21] = 1;
if ( v19[22] == 1 )
v21[22] = 1;
if ( v19[23] == 1 )
v21[23] = 1;
}
sub_10020C740(v97, v104);
}
}
while ( *((_QWORD *)&v100 + 1) );
v22 = v95;
v23 = a1;
if ( (_QWORD)v95 )
{
LABEL_45:
v80 = (__int64 *)v22;
v93 = *(_DWORD *)(v22 + 16);
*(_QWORD *)v90 = &v93;
v82 = sub_10001D150((unsigned __int64)v102, &v93, (__int64)&unk_10063A31C, (_DWORD **)v90);
v87 = cocos2d::CCDictionary::objectForKey(v23->m_parentGroupsDict, v93);
Group = GJBaseGameLayer::getGroup(v23, v93);
v24 = 0;
while ( 1 )
{
if ( v24 > 1 )
{
if ( v24 != 2 )
{
if ( (v82[23] & 1) == 0 )
goto LABEL_137;
v25 = 1;
goto LABEL_58;
}
if ( (v82[22] & 1) != 0 )
{
v25 = 0;
LABEL_58:
v83 = v24;
v27 = 0;
v26 = 110000000;
goto LABEL_59;
}
}
else if ( v24 )
{
if ( (v82[21] & 1) != 0 )
{
v25 = 1;
LABEL_55:
v83 = v24;
v26 = 100000000;
v27 = 1;
LABEL_59:
if ( v25 )
v28 = 1000000;
else
v28 = 0;
v92 = v26 + v28 + v93;
v29 = cocos2d::CCDictionary::create();
v30 = cocos2d::CCDictionary::create();
memset(v90, 0, sizeof(v90));
v91 = 1.0;
v31 = sub_10024A36C(Group);
sub_100018D40((unsigned __int64)v90, vcvtps_u32_f32((float)v31 / v91));
if ( Group )
{
v81 = v25;
data = Group->data;
num = data->num;
if ( (_DWORD)num )
{
v34 = data->arr;
v35 = (unsigned __int64)&v34[num - 1];
do
{
v36 = *v34;
if ( !*v34 )
break;
m_uIndexInArray = v36[15].m_uIndexInArray;
m_uReference = v36[16].m_uReference;
*(_QWORD *)v104 = &m_uReference;
*((_DWORD *)sub_10001D150(
(unsigned __int64)v90,
(int *)&m_uReference,
(__int64)&unk_10063A31C,
(_DWORD **)v104)
+ 5) = m_uIndexInArray;
++v34;
}
while ( (unsigned __int64)v34 <= v35 );
}
if ( v27 )
{
v38 = Group->data;
v39 = v38->num;
if ( (_DWORD)v39 )
{
v40 = v38->arr;
v84 = (unsigned __int64)&v40[v39 - 1];
do
{
v41 = *v40;
if ( !*v40 )
break;
if ( BYTE2(v41[20].m_uOrderOfArrival) == 1 )
{
v42 = cocos2d::CCDictionary::objectForKey(v86->m_parentGroupIDs, v41[16].m_uReference);
if ( v42 )
{
for ( j = 0; (unsigned int)j < (unsigned int)sub_10024A36C(v42); j = (unsigned int)(j + 1) )
{
v44 = *(int *)(sub_10024A388(v42, j) + 56);
if ( !v87 || v41 == v87 && (_DWORD)v44 == v93 )
{
v45 = GJBaseGameLayer::getGroup(v86, v44);
v46 = 0;
v47 = -v44;
while ( (unsigned int)v46 < (unsigned int)sub_10024A36C(v45) )
{
v48 = sub_10024A388(v45, v46);
v104[0] = *(_DWORD *)(v48 + 916);
if ( sub_100018814(v90, v104) )
{
v104[0] = *(_DWORD *)(v48 + 916);
sub_10001B104(v90, v104);
}
if ( (*(_BYTE *)(v48 + 1150) & 1) != 0
|| (*(_BYTE *)(v48 + 1151) & 1) != 0
|| (cocos2d::CCObject *)v48 == v41 )
{
v49 = cocos2d::CCDictionary::objectForKey(v29, v47);
if ( !v49
|| (HIBYTE(v49[20].m_eObjType) != 1 || (cocos2d::CCObject *)v48 == v41)
&& *(_BYTE *)(v48 + 1151) == 1 )
{
cocos2d::CCDictionary::setObject(v29, (cocos2d::CCObject *)v48, v47);
}
v50 = cocos2d::CCDictionary::objectForKey(v30, v47);
if ( !v50
|| (BYTE2(v50[20].m_eObjType) != 1 || (cocos2d::CCObject *)v48 == v41)
&& *(_BYTE *)(v48 + 1150) == 1 )
{
cocos2d::CCDictionary::setObject(v30, (cocos2d::CCObject *)v48, v47);
}
}
v46 = (unsigned int)(v46 + 1);
}
v51 = cocos2d::CCDictionary::objectForKey(v29, v47);
if ( v51 )
{
m_uReference = v51[16].m_uReference;
*(_QWORD *)v104 = &m_uReference;
*((_DWORD *)sub_10001D150(
(unsigned __int64)v90,
(int *)&m_uReference,
(__int64)&unk_10063A31C,
(_DWORD **)v104)
+ 5) = v47;
}
}
}
}
}
++v40;
}
while ( (unsigned __int64)v40 <= v84 );
}
}
if ( (v81 & 1) == 0 )
{
v52 = Group->data;
v53 = v52->num;
if ( (_DWORD)v53 )
{
v54 = v52->arr;
v55 = (unsigned __int64)&v54[v53 - 1];
do
{
v56 = *v54;
if ( !*v54 )
break;
m_uReference = v56[16].m_uReference;
if ( sub_100018814(v90, (int *)&m_uReference) )
{
v88 = v56[16].m_uReference;
*(_QWORD *)v104 = &v88;
v57 = *((unsigned int *)sub_10001D150(
(unsigned __int64)v90,
(int *)&v88,
(__int64)&unk_10063A31C,
(_DWORD **)v104)
+ 5);
if ( (int)v57 >= 1 && ((BYTE2(v56[20].m_eObjType) & 1) != 0 || HIBYTE(v56[20].m_eObjType) == 1) )
{
v58 = cocos2d::CCDictionary::objectForKey(v29, v57);
if ( !v58 || (HIBYTE(v58[20].m_eObjType) & 1) == 0 && HIBYTE(v56[20].m_eObjType) == 1 )
cocos2d::CCDictionary::setObject(v29, v56, v57);
v59 = cocos2d::CCDictionary::objectForKey(v30, v57);
if ( !v59 || (BYTE2(v59[20].m_eObjType) & 1) == 0 && BYTE2(v56[20].m_eObjType) == 1 )
cocos2d::CCDictionary::setObject(v30, v56, v57);
}
}
++v54;
}
while ( (unsigned __int64)v54 <= v55 );
}
}
}
v60 = cocos2d::CCDictionary::count(v29);
v23 = v86;
if ( (_DWORD)v60 )
{
v61 = sub_10024A15C(v60);
v62 = sub_10024A15C(v61);
v63 = cocos2d::CCDictionary::create();
v64 = cocos2d::CCDictionary::create();
if ( Group )
{
v65 = Group->data;
v66 = v65->num;
if ( (_DWORD)v66 )
{
v67 = v65->arr;
v68 = (unsigned __int64)&v67[v66 - 1];
do
{
v69 = *v67;
if ( !*v67 )
break;
v104[0] = v69[16].m_uReference;
if ( sub_100018814(v90, v104) )
{
m_uReference = v69[16].m_uReference;
*(_QWORD *)v104 = &m_uReference;
v70 = *((int *)sub_10001D150(
(unsigned __int64)v90,
(int *)&m_uReference,
(__int64)&unk_10063A31C,
(_DWORD **)v104)
+ 5);
if ( !(_DWORD)v70 )
goto LABEL_126;
v71 = cocos2d::CCDictionary::objectForKey(v29, v70);
if ( v69 == v71 )
{
sub_10024A2D0(v61, v69);
if ( (v70 & 0x80000000) != 0 )
v72 = GJBaseGameLayer::getGroup(v86, -(int)v70);
else
v72 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v86->m_linkedGroupDict, v70);
cocos2d::CCDictionary::setObject(v63, v72, v69[16].m_uReference);
v73 = cocos2d::CCDictionary::objectForKey(v30, v70);
cocos2d::CCDictionary::setObject(v64, v73, v69[16].m_uReference);
goto LABEL_132;
}
if ( !v71 )
LABEL_126:
sub_10024A2D0(v62, v69);
}
LABEL_132:
++v67;
}
while ( (unsigned __int64)v67 <= v68 );
}
}
v74 = sub_10024A36C(v62);
v75 = sub_10024A36C(v61);
v23 = v86;
v76 = sub_10024A36C(v86->m_targetGroupsArray);
*(_QWORD *)v104 = &v92;
v77 = sub_10020A390(&v86->m_targetGroups, &v92, &unk_10063A31C, v104, &m_uReference);
*(_DWORD *)(v77 + 20) = v76 + 1;
*(_DWORD *)(v77 + 24) = v75 + v74;
sub_10024A2D0(v86->m_targetGroupsArray, v62);
sub_10024A2D0(v86->m_targetGroupsArray, v61);
sub_10024A2D0(v86->m_targetGroupsArray, v63);
sub_10024A2D0(v86->m_targetGroupsArray, v64);
}
else
{
v78 = sub_10024A36C(Group);
*(_QWORD *)v104 = &v92;
v79 = sub_10020A390(&v86->m_targetGroups, &v92, &unk_10063A31C, v104, &m_uReference);
*(_DWORD *)(v79 + 20) = 0;
*(_DWORD *)(v79 + 24) = v78;
}
sub_100017A98((__int64)v90);
v24 = v83;
}
}
else if ( v82[20] == 1 )
{
v25 = 0;
goto LABEL_55;
}
if ( ++v24 == 4 )
{
LABEL_137:
v22 = *v80;
if ( !*v80 )
break;
goto LABEL_45;
}
}
}
}
}
else
{
v94 = 0u;
v95 = 0u;
v96 = 1065353216;
}
sub_100017A98((__int64)&v94);
sub_100209D3C(v97);
sub_100017A98((__int64)&v99);
sub_100017A98((__int64)v102);
}