// // GJBaseGameLayer::generateVisibilityGroups from 0x10011caf0 to 0x10011d7f7 (3335 bytes) // // 1 xrefs: // > GJBaseGameLayer::updateSpecialGroupData @ 0x1001173f9 // // 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::generateVisibilityGroups(GJBaseGameLayer *a1) { __int64 value; // rsi double v2; // xmm1_8 double v3; // xmm2_8 GJBaseGameLayer *v4; // r15 std::__hash_node_base>, void *> *>::__next_pointer next; // r14 __m128 v6; // xmm0 cocos2d::CCArray *m_objects; // rax cocos2d::ccArray *data; // rax __int64 num; // rcx cocos2d::CCObject **arr; // rbx unsigned __int64 v11; // r12 std::__hash_node_base>, void *> *> *v12; // rbx std::__hash_node_base>, void *> *> *v13; // rdi cocos2d::CCObject *v14; // rax void *v15; // rdi _QWORD *v16; // rbx void *v17; // rdi _QWORD *v18; // rdi _QWORD *v19; // rbx void *v20; // rdi _QWORD *v21; // r14 _QWORD *v22; // rdi _QWORD *v23; // r15 void *v24; // rdi _QWORD *v25; // rax GJBaseGameLayer *v26; // r15 GJBaseGameLayer *v27; // r12 intptr_t v28; // r14 cocos2d::CCObject *v29; // rbx __int64 v30; // rax cocos2d::CCObject_vtbl *v31; // rax void (__cdecl *v32)(cocos2d::CCObject *__hidden); // r14 unsigned __int64 v33; // r15 __int64 v34; // rax _DWORD *v35; // rbx _QWORD *v36; // rax __int64 *i; // rbx unsigned __int64 v38; // rdi unsigned __int64 v39; // rcx unsigned __int64 v40; // r8 _QWORD *v41; // r9 void **v42; // rax float *v43; // rdi intptr_t v44; // r14 cocos2d::CCObject *v45; // r15 cocos2d::CCObject_vtbl *v46; // rax __int64 copyWithZone_low; // rcx int **v48; // rax unsigned __int64 v49; // rcx int v50; // edx int *v51; // r14 unsigned __int64 v52; // r10 __int64 v53; // rax unsigned __int64 v54; // rax int *v55; // rax unsigned __int64 v56; // rax unsigned __int64 v57; // rax int *v58; // r11 unsigned __int64 v59; // rax _QWORD *v60; // rdi _QWORD *v61; // rbx void *v62; // rdi _QWORD *v63; // rdi _QWORD *v64; // rbx _DWORD *v65; // rbx int *v66; // rsi unsigned __int64 m_groupDict; // rdi _QWORD *v68; // r12 __int64 v69; // rax intptr_t v70; // r14 cocos2d::CCObject *v71; // r15 cocos2d::CCObject *v72; // rax GJBaseGameLayer *v73; // rbx cocos2d::CCObject_vtbl *v74; // rax void (__cdecl *v75)(cocos2d::CCObject *__hidden); // rbx unsigned __int64 v76; // r15 __int64 v77; // r14 unsigned int v78; // ecx unsigned __int64 v79; // r10 __int64 **v80; // rax __int64 *v81; // r9 unsigned __int64 v82; // rax __int64 v83; // rax char *v84; // r14 unsigned __int64 v85; // rax __int64 v86; // r12 int *v87; // r15 signed __int64 v88; // r14 __int64 v89; // r13 unsigned __int64 v90; // rcx __int64 v91; // rax unsigned __int64 v92; // r12 _QWORD *v93; // rbx _QWORD *v94; // rax _QWORD *v95; // rax _QWORD *v96; // rdi _QWORD *v97; // rbx char *v98; // [rsp+8h] [rbp-118h] __int64 *v99; // [rsp+10h] [rbp-110h] _QWORD *v100; // [rsp+18h] [rbp-108h] void *v101[2]; // [rsp+20h] [rbp-100h] BYREF void *v102[2]; // [rsp+30h] [rbp-F0h] int v103; // [rsp+40h] [rbp-E0h] void (__cdecl *v104)(cocos2d::CCObject *__hidden); // [rsp+48h] [rbp-D8h] unsigned __int64 v105; // [rsp+50h] [rbp-D0h] GJBaseGameLayer **p_m_visibilityGroups; // [rsp+58h] [rbp-C8h] void *__p[2]; // [rsp+60h] [rbp-C0h] BYREF void *v108[2]; // [rsp+70h] [rbp-B0h] BYREF int v109; // [rsp+80h] [rbp-A0h] _QWORD *v110; // [rsp+90h] [rbp-90h] _QWORD *v111; // [rsp+98h] [rbp-88h] void *v112[4]; // [rsp+A0h] [rbp-80h] BYREF int v113; // [rsp+C0h] [rbp-60h] unsigned int v114; // [rsp+CCh] [rbp-54h] BYREF GJBaseGameLayer *v115; // [rsp+D0h] [rbp-50h] char v116; // [rsp+DFh] [rbp-41h] BYREF int v117; // [rsp+E0h] [rbp-40h] BYREF unsigned int v118; // [rsp+E4h] [rbp-3Ch] BYREF int *v119; // [rsp+E8h] [rbp-38h] BYREF _DWORD v120[11]; // [rsp+F4h] [rbp-2Ch] BYREF v4 = a1; p_m_visibilityGroups = (GJBaseGameLayer **)&a1->m_visibilityGroups; if ( a1->m_visibilityGroups.__table_.__p2_.__value_ ) { next = a1->m_visibilityGroups.__table_.__p1_.__value_.__next_; if ( next ) { do { v12 = next->__next_; v13 = next[3].__next_; if ( v13 ) { next[4].__next_ = v13; operator delete(v13); } a1 = (GJBaseGameLayer *)next; operator delete(next); next = v12; } while ( v12 ); } v4->m_visibilityGroups.__table_.__p1_.__value_.__next_ = nullptr; value = v4->m_visibilityGroups.__table_.__bucket_list_.__ptr_.__value_.__data_.__value_; if ( value ) { a1 = *p_m_visibilityGroups; value *= 8; __bzero(*p_m_visibilityGroups, value); } v4->m_visibilityGroups.__table_.__p2_.__value_ = 0; } v6 = 0; *(_OWORD *)v102 = 0; *(_OWORD *)v101 = 0; v103 = 1065353216; m_objects = v4->m_objects; if ( !m_objects || (data = m_objects->data, (num = data->num) == 0) ) { v120[0] = 0; *(_OWORD *)v108 = 0; *(_OWORD *)__p = 0; v109 = 1065353216; LABEL_17: *(__m128 *)&v112[1] = v6; v112[3] = nullptr; v113 = 1065353216; v15 = nullptr; goto LABEL_18; } v115 = v4; arr = data->arr; v11 = (unsigned __int64)&arr[num - 1]; do { v14 = *arr; if ( !*arr ) break; v14[15].m_uUnknown = 0; if ( v14[18].m_uReference == 3662 ) { LODWORD(__p[0]) = v14[26].m_uID; a1 = (GJBaseGameLayer *)v101; value = (__int64)__p; sub_100056510((float *)v101, (int *)__p, __p, (__m128)0LL); } ++arr; } while ( (unsigned __int64)arr <= v11 ); v25 = v102[0]; v120[0] = 0; v6 = 0; *(_OWORD *)v108 = 0; *(_OWORD *)__p = 0; v109 = 1065353216; if ( !v102[0] ) goto LABEL_17; v26 = v115; v27 = v115; do { v111 = v25; v28 = *((unsigned int *)v25 + 4); v117 = v28; if ( (int)v28 >= 9999 ) v28 = 9999; if ( (int)v28 <= 0 ) v28 = 0; v29 = v26->m_groups.__begin_[v28]; if ( !v29 ) { v29 = (cocos2d::CCObject *)sub_10071F9E0(a1, value); cocos2d::CCDictionary::setObject(v26->m_groupDict, v29, v28); v26->m_groups.__begin_[v28] = (cocos2d::CCArray *)v29; } ++v120[0]; v112[0] = v120; v30 = sub_1001667C0(__p, v120, &unk_100816AE0, v112, &v119); value = (__int64)&v117; sub_100054F50((float *)(v30 + 24), &v117, &v117, v6, v2, v3); v6 = 0; memset(v112, 0, sizeof(v112)); v113 = 1065353216; if ( !v29 ) { a1 = nullptr; v112[0] = nullptr; goto LABEL_35; } v31 = v29[1].__vftable; if ( !LODWORD(v31->copyWithZone) ) goto LABEL_142; v32 = v31->~CCObject_0; v33 = (unsigned __int64)v32 + 8 * LODWORD(v31->copyWithZone) - 8; do { v34 = *(_QWORD *)v32; if ( !*(_QWORD *)v32 ) break; v35 = (_DWORD *)(v34 + 876); if ( *(int *)(v34 + 876) > 0 ) { value = v34 + 876; sub_100054F50((float *)v112, (int *)(v34 + 876), (_DWORD *)(v34 + 876), (__m128)0LL, v2, v3); } *v35 = v120[0]; v32 = (void (__cdecl *)(cocos2d::CCObject *__hidden))((char *)v32 + 8); } while ( (unsigned __int64)v32 <= v33 ); v36 = v112[2]; v26 = v115; if ( !v112[2] ) goto LABEL_142; while ( 2 ) { v110 = v36; v118 = *((_DWORD *)v36 + 4); value = (__int64)&v118; v119 = (int *)&v118; for ( i = *(__int64 **)(sub_1001667C0(__p, &v118, &unk_100816AE0, &v119, &v114) + 40); i; v26 = v115 ) { v114 = *((_DWORD *)i + 4); v119 = v120; v43 = (float *)(sub_1001667C0(__p, v120, &unk_100816AE0, &v119, &v116) + 24); value = (__int64)&v114; sub_100054F50(v43, (int *)&v114, &v114, (__m128)0LL, v2, v3); v44 = v114; if ( (int)v114 >= 9999 ) v44 = 9999; if ( (int)v44 <= 0 ) v44 = 0; v45 = v26->m_groups.__begin_[v44]; if ( v45 || (v45 = (cocos2d::CCObject *)sub_10071F9E0(v43, &v114), value = (__int64)v45, cocos2d::CCDictionary::setObject(v27->m_groupDict, v45, v44), (v27->m_groups.__begin_[v44] = (cocos2d::CCArray *)v45) != nullptr) ) { v46 = v45[1].__vftable; copyWithZone_low = LODWORD(v46->copyWithZone); if ( LODWORD(v46->copyWithZone) ) { v48 = (int **)v46->~CCObject_0; v49 = (unsigned __int64)&v48[copyWithZone_low - 1]; v50 = v120[0]; do { value = (__int64)*v48; if ( !*v48 ) break; *(_DWORD *)(value + 876) = v50; ++v48; } while ( (unsigned __int64)v48 <= v49 ); } } i = (__int64 *)*i; } v38 = (unsigned __int64)__p[1]; if ( !__p[1] ) goto LABEL_52; v39 = (int)v118; v40 = (0x101010101010101LL * (((((unsigned __int64)__p[1] - (((unsigned __int64)__p[1] >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL) + ((((unsigned __int64)__p[1] - (((unsigned __int64)__p[1] >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL) + (((((unsigned __int64)__p[1] - (((unsigned __int64)__p[1] >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL) + ((((unsigned __int64)__p[1] - (((unsigned __int64)__p[1] >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4)) & 0xF0F0F0F0F0F0F0FLL)) >> 56; if ( v40 > 1 ) { value = (int)v118; if ( __p[1] <= (void *)(int)v118 ) { if ( !(((unsigned __int64)__p[1] | (int)v118) >> 32) ) { value = v118 % LODWORD(__p[1]); v41 = __p[0]; v42 = *((void ***)__p[0] + value); if ( !v42 ) goto LABEL_52; goto LABEL_74; } value = (int)v118 % (unsigned __int64)__p[1]; } v41 = __p[0]; v42 = *((void ***)__p[0] + value); if ( !v42 ) goto LABEL_52; } else { value = (int)v118 & ((unsigned __int64)__p[1] - 1); v41 = __p[0]; v42 = *((void ***)__p[0] + value); if ( !v42 ) goto LABEL_52; } LABEL_74: v51 = (int *)*v42; if ( !*v42 ) goto LABEL_52; v52 = (unsigned __int64)__p[1] - 1; if ( (unsigned int)v40 < 2 ) { while ( 1 ) { v53 = *((_QWORD *)v51 + 1); if ( v53 == v118 ) { if ( v51[4] == v118 ) goto LABEL_92; } else if ( (v52 & v53) != value ) { goto LABEL_52; } v51 = *(int **)v51; if ( !v51 ) goto LABEL_52; } } while ( 1 ) { v54 = *((_QWORD *)v51 + 1); if ( v54 == v118 ) break; if ( (void *)v54 < __p[1] ) goto LABEL_88; if ( ((unsigned __int64)__p[1] | v54) >> 32 ) { v54 %= (unsigned __int64)__p[1]; LABEL_88: if ( v54 != value ) goto LABEL_52; goto LABEL_83; } if ( (unsigned int)v54 % LODWORD(__p[1]) != value ) goto LABEL_52; LABEL_83: v51 = *(int **)v51; if ( !v51 ) goto LABEL_52; } if ( v51[4] != v118 ) goto LABEL_83; LABEL_92: if ( (unsigned int)v40 > 1 ) { if ( __p[1] <= (void *)(int)v118 ) { if ( ((unsigned __int64)__p[1] | (int)v118) >> 32 ) v39 = (int)v118 % (unsigned __int64)__p[1]; else v39 = v118 % LODWORD(__p[1]); } } else { v39 = v52 & (int)v118; } v55 = (int *)v41[v39]; do { value = (__int64)v55; v55 = *(int **)v55; } while ( v55 != v51 ); if ( (void **)value == v108 ) goto LABEL_110; v56 = *(_QWORD *)(value + 8); if ( (unsigned int)v40 > 1 ) { if ( (void *)v56 >= __p[1] ) { if ( !(((unsigned __int64)__p[1] | v56) >> 32) ) { if ( (unsigned int)v56 % LODWORD(__p[1]) != v39 ) goto LABEL_110; goto LABEL_119; } v56 %= (unsigned __int64)__p[1]; } if ( v56 == v39 ) goto LABEL_119; goto LABEL_110; } if ( (v52 & v56) == v39 ) goto LABEL_119; LABEL_110: if ( !*(_QWORD *)v51 ) goto LABEL_118; v57 = *(_QWORD *)(*(_QWORD *)v51 + 8LL); if ( (unsigned int)v40 <= 1 ) { if ( (v52 & v57) == v39 ) goto LABEL_119; LABEL_118: v41[v39] = 0; goto LABEL_119; } if ( (void *)v57 < __p[1] ) { LABEL_117: if ( v57 == v39 ) goto LABEL_119; goto LABEL_118; } if ( ((unsigned __int64)__p[1] | v57) >> 32 ) { v57 %= (unsigned __int64)__p[1]; goto LABEL_117; } if ( (unsigned int)v57 % LODWORD(__p[1]) != v39 ) goto LABEL_118; LABEL_119: v58 = *(int **)v51; if ( !*(_QWORD *)v51 ) { v58 = nullptr; goto LABEL_129; } v59 = *((_QWORD *)v58 + 1); if ( (unsigned int)v40 <= 1 ) { v59 &= v52; if ( v59 == v39 ) goto LABEL_129; LABEL_128: v41[v59] = value; v58 = *(int **)v51; goto LABEL_129; } if ( v59 < v38 ) { LABEL_127: if ( v59 == v39 ) goto LABEL_129; goto LABEL_128; } if ( (v38 | v59) >> 32 ) { v59 %= v38; goto LABEL_127; } v59 = (unsigned int)v59 % (unsigned int)v38; if ( v59 != v39 ) goto LABEL_128; LABEL_129: *(_QWORD *)value = v58; *(_QWORD *)v51 = 0; --v108[1]; v60 = *((_QWORD **)v51 + 5); if ( v60 ) { do { v61 = (_QWORD *)*v60; operator delete(v60); v60 = v61; } while ( v61 ); } v62 = *((void **)v51 + 3); *((_QWORD *)v51 + 3) = 0; if ( v62 ) operator delete(v62); operator delete(v51); LABEL_52: v36 = (_QWORD *)*v110; if ( *v110 ) continue; break; } v63 = v112[2]; if ( v112[2] ) { do { v64 = (_QWORD *)*v63; operator delete(v63); v63 = v64; } while ( v64 ); } LABEL_142: a1 = (GJBaseGameLayer *)v112[0]; v112[0] = nullptr; if ( a1 ) operator delete(a1); LABEL_35: v25 = (_QWORD *)*v111; } while ( *v111 ); v65 = v108[0]; memset(v112, 0, sizeof(v112)); v113 = 1065353216; v15 = nullptr; if ( !v108[0] ) goto LABEL_18; while ( 2 ) { v117 = v65[4]; v66 = &v117; v119 = &v117; m_groupDict = (unsigned __int64)p_m_visibilityGroups; v68 = (_QWORD *)sub_100171070(p_m_visibilityGroups, &v117, &unk_100816AE0, &v119, &v118); v100 = v65; v69 = *((_QWORD *)v65 + 5); if ( v69 ) { v111 = v68; while ( 1 ) { v99 = (__int64 *)v69; v70 = *(unsigned int *)(v69 + 16); if ( (int)v70 >= 9999 ) v70 = 9999; if ( (int)v70 <= 0 ) v70 = 0; v71 = v26->m_groups.__begin_[v70]; if ( v71 || (v72 = (cocos2d::CCObject *)sub_10071F9E0(m_groupDict, v66), v73 = v115, v71 = v72, m_groupDict = (unsigned __int64)v115->m_groupDict, v66 = (int *)v72, cocos2d::CCDictionary::setObject((cocos2d::CCDictionary *)m_groupDict, v72, v70), (v73->m_groups.__begin_[v70] = (cocos2d::CCArray *)v71) != nullptr) ) { v74 = v71[1].__vftable; if ( LODWORD(v74->copyWithZone) ) break; } LABEL_149: v69 = *v99; v26 = v115; if ( !*v99 ) goto LABEL_146; } v75 = v74->~CCObject_0; v76 = (unsigned __int64)v75 + 8 * LODWORD(v74->copyWithZone) - 8; v105 = v76; while ( 2 ) { v77 = *(_QWORD *)v75; if ( !*(_QWORD *)v75 ) goto LABEL_149; v78 = *(_DWORD *)(v77 + 916); if ( !v112[1] ) goto LABEL_186; v66 = (int *)(int)v78; v79 = (0x101010101010101LL * (((((unsigned __int64)v112[1] - (((unsigned __int64)v112[1] >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL) + ((((unsigned __int64)v112[1] - (((unsigned __int64)v112[1] >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL) + (((((unsigned __int64)v112[1] - (((unsigned __int64)v112[1] >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL) + ((((unsigned __int64)v112[1] - (((unsigned __int64)v112[1] >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4)) & 0xF0F0F0F0F0F0F0FLL)) >> 56; if ( v79 <= 1 ) { m_groupDict = (int)v78 & ((unsigned __int64)v112[1] - 1); v80 = *((__int64 ***)v112[0] + m_groupDict); if ( !v80 ) goto LABEL_186; LABEL_167: v81 = *v80; if ( *v80 ) { if ( (unsigned int)v79 < 2 ) { while ( 1 ) { v83 = v81[1]; if ( v83 == v78 ) { if ( *((_DWORD *)v81 + 4) == v78 ) goto LABEL_201; } else if ( (((unsigned __int64)v112[1] - 1) & v83) != m_groupDict ) { goto LABEL_186; } v81 = (__int64 *)*v81; if ( !v81 ) goto LABEL_186; } } while ( 1 ) { v82 = v81[1]; if ( v82 == v78 ) { if ( *((_DWORD *)v81 + 4) == v78 ) goto LABEL_201; goto LABEL_171; } if ( (void *)v82 < v112[1] ) goto LABEL_176; if ( ((unsigned __int64)v112[1] | v82) >> 32 ) break; if ( (unsigned int)v82 % LODWORD(v112[1]) != m_groupDict ) goto LABEL_186; LABEL_171: v81 = (__int64 *)*v81; if ( !v81 ) goto LABEL_186; } v82 %= (unsigned __int64)v112[1]; LABEL_176: if ( v82 != m_groupDict ) goto LABEL_186; goto LABEL_171; } LABEL_186: LODWORD(v119) = *(_DWORD *)(v77 + 916); m_groupDict = (unsigned __int64)v112; v66 = (int *)&v119; sub_100056510((float *)v112, (int *)&v119, &v119, (__m128)0LL); v110 = (_QWORD *)v77; v84 = (char *)v68[4]; v85 = v68[5]; if ( (unsigned __int64)v84 >= v85 ) { v87 = (int *)v68[3]; v88 = v84 - (char *)v87; v89 = v88 >> 3; v90 = (v88 >> 3) + 1; if ( v90 > 0x1FFFFFFFFFFFFFFFLL ) sub_1000CACE0(); v91 = v85 - (_QWORD)v87; v92 = v91 >> 2; if ( v91 >> 2 <= v90 ) v92 = (v88 >> 3) + 1; if ( (unsigned __int64)v91 >= 0x7FFFFFFFFFFFFFF8LL ) v92 = 0x1FFFFFFFFFFFFFFFLL; v104 = v75; if ( v92 ) { if ( v92 > 0x1FFFFFFFFFFFFFFFLL ) sub_100054850(); v93 = operator new(8 * v92); } else { v93 = nullptr; } v98 = (char *)&v93[v92]; v93[v89] = v110; v86 = (__int64)&v93[v89 + 1]; m_groupDict = (unsigned __int64)v93; v66 = v87; memcpy(v93, v87, v88); v94 = v111; v111[3] = v93; v94[4] = v86; v94[5] = v98; if ( v87 ) { m_groupDict = (unsigned __int64)v87; operator delete(v87); } v75 = v104; v76 = v105; } else { *(_QWORD *)v84 = v110; v86 = (__int64)(v84 + 8); } v95 = v111; v111[4] = v86; v68 = v95; LABEL_201: v75 = (void (__cdecl *)(cocos2d::CCObject *__hidden))((char *)v75 + 8); if ( (unsigned __int64)v75 > v76 ) goto LABEL_149; continue; } break; } m_groupDict = (int)v78; if ( v112[1] <= (void *)(int)v78 ) { if ( !(((unsigned __int64)v112[1] | (int)v78) >> 32) ) { m_groupDict = v78 % LODWORD(v112[1]); v80 = *((__int64 ***)v112[0] + m_groupDict); if ( v80 ) goto LABEL_167; goto LABEL_186; } m_groupDict = (int)v78 % (unsigned __int64)v112[1]; } v80 = *((__int64 ***)v112[0] + m_groupDict); if ( v80 ) goto LABEL_167; goto LABEL_186; } LABEL_146: v65 = (_DWORD *)*v100; if ( *v100 ) continue; break; } v96 = v112[2]; if ( v112[2] ) { do { v97 = (_QWORD *)*v96; operator delete(v96); v96 = v97; } while ( v97 ); } v15 = v112[0]; LABEL_18: v112[0] = nullptr; if ( v15 ) operator delete(v15); v16 = v108[0]; if ( v108[0] ) { do { v21 = (_QWORD *)*v16; v22 = (_QWORD *)v16[5]; if ( v22 ) { do { v23 = (_QWORD *)*v22; operator delete(v22); v22 = v23; } while ( v23 ); } v24 = (void *)v16[3]; v16[3] = 0; if ( v24 ) operator delete(v24); operator delete(v16); v16 = v21; } while ( v21 ); } v17 = __p[0]; __p[0] = nullptr; if ( v17 ) operator delete(v17); v18 = v102[0]; if ( v102[0] ) { do { v19 = (_QWORD *)*v18; operator delete(v18); v18 = v19; } while ( v19 ); } v20 = v101[0]; v101[0] = nullptr; if ( v20 ) operator delete(v20); }