//
// SetupSpawnPopup::updateRemapButtons from 0x8ea574 to 0x8eae18 (2212 bytes)
//
// 5 xrefs:
// > SetupSpawnPopup::init @ 0x8eb6a0
// > ??> @ 0x903f0
// > SetupSpawnPopup::queueUpdateButtons @ 0x8ea2a0
// > SetupSpawnPopup::updateRemapButtons @ 0x8ea5a0
// > ??> @ 0x122ceb8
//
// 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 SetupSpawnPopup::updateRemapButtons(SetupSpawnPopup *a1, float a2)
{
unsigned int v3; // w19
unsigned int v4; // w1
cocos2d::CCObject *v5; // x20
bool v6; // cf
cocos2d::CCArray *m_remapButtons; // x0
int *m_start; // x1
EffectGameObject *m_gameObject; // x0
cocos2d::ccArray *data; // x0
unsigned int num; // w20
cocos2d::CCObject **arr; // x0
cocos2d::CCObject *v13; // x19
int *v14; // x21
int *v15; // x23
__int64 v16; // x0
int v17; // w19
int v18; // w20
__int64 v19; // x1
int *v20; // x3
int v21; // w2
int v22; // w1
int *v23; // x28
int v24; // w1
int v25; // w0
__int64 v26; // x27
__int64 v27; // x0
int *v28; // x1
int *v29; // x3
int *v30; // x2
int v31; // w3
_BOOL8 v32; // x0
int v33; // w1
float v34; // s8
int v35; // w22
float v36; // s10
float v37; // s9
cocos2d::CCDirector *v38; // x0
cocos2d::CCMenu *m_buttonMenu; // x19
int v40; // w0
int *v41; // x19
int v42; // w20
char *v43; // x1
cocos2d::CCString *v44; // x0
ButtonSprite *CString; // x0
const char *v46; // x6
cocos2d::CCNode *v47; // x0
CCMenuItemSpriteExtra *v48; // x25
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x27
int *m_finish; // x1
char *v51; // x0
unsigned int v52; // w25
unsigned int v53; // w27
int *v54; // x28
int v55; // w1
int v56; // w0
__int64 v57; // x27
__int64 insert_hint_unique_pos; // x0
int *v59; // x1
int *v60; // x3
int *v61; // x2
int v62; // w3
_BOOL8 v63; // x0
int v64; // w1
int *v65; // x0
int *v66; // x0
unsigned int *v67; // x1
int v68; // w2
char *v69; // x0
__int64 v70; // x19
void *v71; // x0
int *v72; // x0
signed __int64 v73; // x4
unsigned __int64 v74; // x2
unsigned __int64 v75; // x3
unsigned __int64 v76; // x27
int *v77; // x3
int *v78; // x2
int *v79; // x4
int *v80; // x2
unsigned int *v81; // x3
int v82; // w1
__int64 v83; // [xsp+0h] [xbp+0h] BYREF
int *v84; // [xsp+88h] [xbp+88h]
int *v85; // [xsp+90h] [xbp+90h]
cocos2d::CCObject **v86; // [xsp+98h] [xbp+98h]
cocos2d::CCArray *m_gameObjects; // [xsp+A0h] [xbp+A0h]
cocos2d::CCObject **v88; // [xsp+A8h] [xbp+A8h]
float v89; // [xsp+B0h] [xbp+B0h]
float v90; // [xsp+B4h] [xbp+B4h]
char v91; // [xsp+B8h] [xbp+B8h] BYREF
const char *v92; // [xsp+C0h] [xbp+C0h]
cocos2d::CCPoint v93; // [xsp+C8h] [xbp+C8h] BYREF
cocos2d::CCPoint v94; // [xsp+D0h] [xbp+D0h] BYREF
__int64 v95; // [xsp+D8h] [xbp+D8h] BYREF
int v96; // [xsp+E0h] [xbp+E0h] BYREF
__int64 v97; // [xsp+E8h] [xbp+E8h]
int *v98; // [xsp+F0h] [xbp+F0h]
int *v99; // [xsp+F8h] [xbp+F8h]
cocos2d::CCDirector *v100; // [xsp+100h] [xbp+100h]
cocos2d::SEL_SCHEDULE v101; // 0:x1.16
cocos2d::SEL_MenuHandler v102; // 0:x2.16
v101.adj = 0;
v101.ptr = (void (__cdecl *)(float))SetupSpawnPopup::updateRemapButtons;
v3 = 0;
cocos2d::CCNode::unschedule(a1, v101);
a1->m_isBusy = 0;
while ( 1 )
{
v6 = v3 >= (unsigned int)cocos2d::CCArray::count(a1->m_remapButtons);
m_remapButtons = a1->m_remapButtons;
if ( v6 )
break;
v4 = v3++;
v5 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(m_remapButtons, v4);
SetupTriggerPopup::removeObjectFromPage(a1, v5, 1);
((void (__fastcall *)(cocos2d::CCObject *))v5->__vftable[6].isEqual)(v5);
}
cocos2d::CCArray::removeAllObjects(m_remapButtons);
m_start = a1->m_remapGroups.m_start;
m_gameObject = a1->m_gameObject;
a1->m_remapGroups.m_finish = m_start;
if ( m_gameObject )
m_gameObjects = (cocos2d::CCArray *)cocos2d::CCArray::createWithObject(
(cocos2d::CCArray *)m_gameObject,
(cocos2d::CCObject *)m_start);
else
m_gameObjects = a1->m_gameObjects;
v96 = 0;
v97 = 0;
v100 = nullptr;
v98 = &v96;
v99 = &v96;
if ( !m_gameObjects )
goto LABEL_109;
data = m_gameObjects->data;
num = data->num;
if ( !data->num )
goto LABEL_109;
arr = data->arr;
v88 = arr;
v86 = &arr[num - 1];
if ( arr > v86 )
goto LABEL_109;
v13 = *arr;
if ( !*arr )
goto LABEL_109;
do
{
v14 = *(int **)&v13[32].m_uIndexInArray;
v15 = *(int **)&v13[32].m_unknown2;
if ( v14 != v15 )
{
while ( 1 )
{
v16 = v97;
v17 = *v14;
v18 = v14[2];
if ( !v97 )
break;
v19 = v97;
v20 = &v96;
do
{
while ( 1 )
{
v21 = *(_DWORD *)(v19 + 32);
if ( v17 > v21 || v17 >= v21 && v18 > *(_DWORD *)(v19 + 36) )
break;
v20 = (int *)v19;
v19 = *(_QWORD *)(v19 + 16);
if ( !v19 )
goto LABEL_17;
}
v19 = *(_QWORD *)(v19 + 24);
}
while ( v19 );
LABEL_17:
if ( v20 != &v96 )
{
v22 = v20[8];
if ( v17 >= v22 && (v17 > v22 || v18 >= v20[9]) )
{
v54 = &v96;
do
{
while ( 1 )
{
v55 = *(_DWORD *)(v16 + 32);
if ( v17 > v55 || v17 >= v55 && v18 > *(_DWORD *)(v16 + 36) )
break;
v54 = (int *)v16;
v16 = *(_QWORD *)(v16 + 16);
if ( !v16 )
goto LABEL_62;
}
v16 = *(_QWORD *)(v16 + 24);
}
while ( v16 );
LABEL_62:
if ( v54 == &v96 || (v56 = v54[8], v17 < v56) || v17 <= v56 && v18 < v54[9] )
{
v57 = (__int64)v54;
v54 = (int *)operator new(0x30u);
v54[8] = v17;
v54[9] = v18;
v54[10] = 0;
insert_hint_unique_pos = std::_Rb_tree,std::pair const,int>,std::_Select1st const,int>>,std::less>,std::allocator const,int>>>::_M_get_insert_hint_unique_pos(
&v95,
v57,
v54 + 8);
v60 = (int *)insert_hint_unique_pos;
v61 = v59;
if ( v59 )
{
if ( insert_hint_unique_pos || &v96 == v59 )
{
v63 = 1;
}
else
{
v62 = v54[8];
v63 = 1;
v64 = v59[8];
if ( v62 >= v64 )
{
v63 = 0;
if ( v62 <= v64 )
v63 = v54[9] < v61[9];
}
}
sub_CFAD74(v63, v54, v61, &v96);
v100 = (cocos2d::CCDirector *)((char *)v100 + 1);
}
else
{
v66 = v54;
v54 = v60;
operator delete(v66);
}
}
++v54[10];
goto LABEL_38;
}
}
v23 = &v96;
do
{
while ( 1 )
{
v24 = *(_DWORD *)(v16 + 32);
if ( v17 > v24 || v17 >= v24 && v18 > *(_DWORD *)(v16 + 36) )
break;
v23 = (int *)v16;
v16 = *(_QWORD *)(v16 + 16);
if ( !v16 )
goto LABEL_26;
}
v16 = *(_QWORD *)(v16 + 24);
}
while ( v16 );
LABEL_26:
if ( v23 == &v96 )
goto LABEL_30;
v25 = v23[8];
if ( v17 < v25 || v17 <= v25 && v18 < v23[9] )
goto LABEL_30;
LABEL_37:
v23[10] = 1;
LABEL_38:
v14 += 4;
if ( v15 == v14 )
goto LABEL_39;
}
v23 = &v96;
LABEL_30:
v26 = (__int64)v23;
v23 = (int *)operator new(0x30u);
v23[8] = v17;
v23[9] = v18;
v23[10] = 0;
v27 = std::_Rb_tree,std::pair const,int>,std::_Select1st const,int>>,std::less>,std::allocator const,int>>>::_M_get_insert_hint_unique_pos(
&v95,
v26,
v23 + 8);
v29 = (int *)v27;
v30 = v28;
if ( v28 )
{
if ( v27 || &v96 == v28 )
{
v32 = 1;
}
else
{
v31 = v23[8];
v32 = 1;
v33 = v28[8];
if ( v31 >= v33 )
{
v32 = 0;
if ( v31 <= v33 )
v32 = v23[9] < v30[9];
}
}
sub_CFAD74(v32, v23, v30, &v96);
v100 = (cocos2d::CCDirector *)((char *)v100 + 1);
}
else
{
v65 = v23;
v23 = v29;
operator delete(v65);
}
goto LABEL_37;
}
LABEL_39:
if ( v86 < ++v88 )
break;
v13 = *v88;
}
while ( *v88 );
if ( (unsigned __int64)v100 > 0xA )
{
v34 = 35.0;
v35 = 10;
v36 = 4.5;
v37 = 15.0;
}
else
{
LABEL_109:
v34 = 66.0;
v35 = 5;
v36 = 2.0;
v37 = 40.0;
}
v38 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v38);
m_buttonMenu = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(
&v94,
-(float)((float)(v36 * v34) - (float)(v89 * 0.5)),
(float)((float)(v90 * 0.5) + 45.0) - 25.0);
v86 = (cocos2d::CCObject **)&v91;
cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, &v94);
v40 = cocos2d::CCArray::count(m_gameObjects);
v41 = v98;
LODWORD(v88) = v40;
if ( v98 == &v96 )
goto LABEL_92;
v42 = 0;
m_gameObjects = (cocos2d::CCArray *)"GJ_button_05.png";
while ( 1 )
{
v52 = v41[8];
v53 = v41[9];
if ( a1->m_remapOriginalID == v52 && a1->m_remapNewID == v53 )
{
v43 = "GJ_button_03.png";
}
else if ( (_DWORD)v88 == v41[10] )
{
v43 = "GJ_button_04.png";
}
else
{
v43 = (char *)m_gameObjects;
}
sub_D153B8((unsigned int)&v83 + 192, v43);
v44 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i\n%i",
(const char *)v52,
v53);
CString = (ButtonSprite *)cocos2d::CCString::getCString(v44);
v47 = (cocos2d::CCNode *)ButtonSprite::create(
CString,
(const char *)(unsigned int)(int)v37,
0,
1,
0.35,
"bigFont.fnt",
v92,
v46,
30.0);
v102.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v102.adj = (size_t)SetupSpawnPopup::onSelectRemap;
v48 = CCMenuItemSpriteExtra::create(v47, nullptr, v102);
v48->setTag(v48, v42);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v48);
SetupTriggerPopup::addObjectToPage(a1, v48, 1);
setPosition = v48->setPosition;
cocos2d::CCPoint::CCPoint(&v93, v34 * (float)(v42 % v35), floorf((float)(v42 / v35)) * -38.0);
cocos2d::CCPoint::operator+(&v94, v86, &v93);
setPosition(v48, &v94);
cocos2d::CCArray::addObject(a1->m_remapButtons, v48);
m_finish = a1->m_remapGroups.m_finish;
if ( m_finish != a1->m_remapGroups.m_reserveEnd )
{
if ( m_finish )
*(_QWORD *)m_finish = *((_QWORD *)v41 + 4);
a1->m_remapGroups.m_finish = m_finish + 2;
goto LABEL_51;
}
v72 = a1->m_remapGroups.m_start;
v73 = (char *)m_finish - (char *)v72;
v74 = ((char *)m_finish - (char *)v72) >> 3;
if ( v74 )
{
v75 = 2 * v74;
v76 = 0x3FFFFFFFFFFFFFFELL;
if ( v74 <= 2 * v74 && v75 <= 0x1FFFFFFFFFFFFFFFLL )
{
v76 = 4 * v74;
if ( !v75 )
{
v78 = (_DWORD *)byte_8;
v77 = nullptr;
goto LABEL_98;
}
}
}
else
{
v76 = 2;
}
v77 = (int *)operator new(v76 * 4);
m_finish = a1->m_remapGroups.m_finish;
v78 = v77 + 2;
v72 = a1->m_remapGroups.m_start;
v73 = (char *)m_finish - (char *)v72;
LABEL_98:
if ( (char *)v77 + v73 )
*(_QWORD *)((char *)v77 + v73) = *((_QWORD *)v41 + 4);
if ( v72 != m_finish )
{
v79 = v72;
v80 = v77;
do
{
if ( v80 )
*(_QWORD *)v80 = *(_QWORD *)v79;
v79 += 2;
v80 += 2;
}
while ( m_finish != v79 );
v78 = (int *)((char *)v77 + (((char *)m_finish - (char *)(v72 + 2)) & 0xFFFFFFFFFFFFFFF8LL) + 16);
}
if ( v72 )
{
v84 = v77;
v85 = v78;
operator delete(v72);
v77 = v84;
v78 = v85;
}
a1->m_remapGroups.m_start = v77;
a1->m_remapGroups.m_finish = v78;
a1->m_remapGroups.m_reserveEnd = &v77[v76];
LABEL_51:
if ( ++v42 == 20 )
break;
v51 = (char *)(v92 - 24);
if ( v92 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v67 = (unsigned int *)(v92 - 8);
do
v68 = __ldaxr(v67);
while ( __stlxr(v68 - 1, v67) );
}
else
{
v68 = *((_DWORD *)v92 - 2);
*((_DWORD *)v92 - 2) = v68 - 1;
}
if ( v68 <= 0 )
operator delete(v51);
}
v41 = (int *)sub_CFAB14(v41);
if ( v41 == &v96 )
goto LABEL_92;
}
v69 = (char *)(v92 - 24);
if ( v92 - 24 != (const char *)&qword_124B6B0 )
{
v81 = (unsigned int *)(v92 - 8);
if ( &pthread_create )
{
do
v82 = __ldaxr(v81);
while ( __stlxr(v82 - 1, v81) );
}
else
{
v82 = *((_DWORD *)v92 - 2);
*((_DWORD *)v92 - 2) = v82 - 1;
}
if ( v82 <= 0 )
operator delete(v69);
}
LABEL_92:
v70 = v97;
while ( v70 )
{
std::_Rb_tree,std::pair const,int>,std::_Select1st const,int>>,std::less>,std::allocator const,int>>>::_M_erase(
(__int64)&v95,
*(_QWORD **)(v70 + 24));
v71 = (void *)v70;
v70 = *(_QWORD *)(v70 + 16);
operator delete(v71);
}
}