//
// MapPackCell::loadFromMapPack from 0x10022a5e0 to 0x10022b126 (2886 bytes)
//
// 3 xrefs:
// > CustomListView::loadCell @ 0x100228049
// > CustomListView::reloadAll @ 0x1002360c2
// > MapPackCell::reloadCell @ 0x10023626c
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:27:06 +0000
//
__int64 __fastcall MapPackCell::loadFromMapPack(__int64 a1, __int64 a2)
{
int v3; // r14d
__int64 v4; // rax
__int64 CString; // rax
const std::string::value_type *v6; // rdi
__int64 v7; // r14
__int64 v8; // rax
__int128 *v9; // rax
char *v10; // rdi
__int64 v11; // r14
__int64 v12; // rax
__int16 v13; // cx
float *v14; // rax
double v15; // xmm0_8
char *v16; // r14
__int64 v17; // rax
int v18; // edx
int v19; // ecx
int v20; // r8d
int v21; // r9d
__int64 v22; // r15
float *v23; // rax
__int64 v24; // rax
__int64 v25; // rsi
int v26; // r12d
__int64 v27; // rax
__int64 v28; // rax
__int64 v29; // r15
__int64 v30; // rax
__int64 v31; // r15
__int64 v32; // r12
__int64 v33; // rax
__int16 v34; // cx
__int64 v35; // rax
int v36; // eax
double v37; // xmm2_8
__int64 v38; // rax
__int64 v39; // rax
__int64 v40; // r12
__int64 v41; // rax
__int64 v42; // rax
int v43; // ecx
__int64 result; // rax
unsigned int v45; // r14d
__int64 v46; // r12
float v47; // xmm0_4
__int64 v48; // rax
__int64 v49; // rax
__int64 v50; // r13
__int64 v51; // r14
__int64 v52; // r12
float v53; // xmm0_4
__int64 v54; // rax
__int64 v55; // rax
__int64 v56; // r13
__int64 v57; // r14
__int64 v58; // r14
__int64 v59; // rbx
char v60; // [rsp+0h] [rbp-70h]
char v61; // [rsp+0h] [rbp-70h]
char v62; // [rsp+0h] [rbp-70h]
_BYTE v63[8]; // [rsp+10h] [rbp-60h] BYREF
unsigned int v64; // [rsp+18h] [rbp-58h]
__int16 v65; // [rsp+1Ch] [rbp-54h] BYREF
char v66; // [rsp+1Eh] [rbp-52h]
__int128 v67; // [rsp+20h] [rbp-50h] BYREF
void *__p; // [rsp+30h] [rbp-40h]
__int64 v69; // [rsp+38h] [rbp-38h]
bool hasCompletedMapPack; // [rsp+47h] [rbp-29h]
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 536) + 584LL))(*(_QWORD *)(a1 + 536), 1);
sub_1007FF190(*(_QWORD *)(a1 + 584));
sub_1007FF190(*(_QWORD *)(a1 + 576));
*(_QWORD *)(a1 + 552) = a2;
v3 = *(_DWORD *)(a2 + 332);
v4 = sub_10088E820("difficulty_%02d_btn_001.png", v60);
CString = cocos2d::CCString::getCString(v4);
v6 = "difficulty_auto_btn_001.png";
if ( v3 )
v6 = (const std::string::value_type *)CString;
v7 = cocos2d::CCSprite::createWithSpriteFrameName(v6);
sub_100278250(&v67, 31.0, *(float *)(a1 + 524) * 0.5);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v7 + 184LL))(v7, &v67);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v7 + 160LL))(v7, 1.1);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v7, 2);
v8 = *(_QWORD *)(a1 + 552);
if ( (*(_BYTE *)(v8 + 344) & 1) != 0 )
{
sub_10001AD30(&v67, *(const void **)(v8 + 360), *(_QWORD *)(v8 + 352));
if ( (v67 & 1) == 0 )
goto LABEL_5;
}
else
{
v9 = (__int128 *)(v8 + 344);
__p = *((void **)v9 + 2);
v67 = *v9;
if ( (v67 & 1) == 0 )
{
LABEL_5:
v10 = (char *)&v67 + 1;
goto LABEL_8;
}
}
v10 = (char *)__p;
LABEL_8:
v11 = cocos2d::CCLabelBMFont::create_3(v10, "bigFont.fnt");
if ( (v67 & 1) != 0 )
operator delete(__p);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 536) + 456LL))(*(_QWORD *)(a1 + 536), v11);
v12 = *(_QWORD *)(a1 + 552);
v13 = *(_WORD *)(v12 + 395);
BYTE2(v67) = *(_BYTE *)(v12 + 397);
LOWORD(v67) = v13;
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v11 + 1072LL))(v11, &v67);
sub_100278250(
&v67,
(float)((float)(*(float *)(a1 + 520) * 0.5) + -14.0) + -2.0,
(float)(*(float *)(a1 + 524) * 0.5) + 30.0);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v11 + 184LL))(v11, &v67);
if ( *(float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v11 + 328LL))(v11) > 205.0 )
{
v14 = (float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v11 + 328LL))(v11);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v11 + 160LL))(v11, 205.0 / *v14);
}
v15 = (*(double (__fastcall **)(__int64))(*(_QWORD *)v11 + 168LL))(v11);
if ( *(float *)&v15 <= 0.89999998 )
(*(void (__fastcall **)(__int64))(*(_QWORD *)v11 + 168LL))(v11);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v11 + 160LL))(v11);
v16 = ButtonSprite::create_1(
(__int64)"View",
0x32u,
0,
0,
(__int64)"bigFont.fnt",
(__int64)"GJ_button_01.png",
0.60000002,
50.0);
v17 = CCMenuItemSpriteExtra::create(v16, 0, a1, MapPackCell::onClick, 0);
*(_QWORD *)(a1 + 560) = v17;
CCMenuItemSpriteExtra::setSizeMult(v17, 1.5);
v22 = sub_1008735E0(*(_QWORD *)(a1 + 560), 0, v18, v19, v20, v21);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 536) + 456LL))(*(_QWORD *)(a1 + 536), v22);
LODWORD(v69) = *(_DWORD *)(a1 + 520);
v23 = (float *)(*(__int64 (__fastcall **)(char *))(*(_QWORD *)v16 + 328LL))(v16);
sub_100278250(&v67, (float)(*(float *)&v69 - (float)(*v23 * 0.5)) + -9.0, *(float *)(a1 + 524) * 0.5);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v22 + 184LL))(v22, &v67);
v24 = GameStatsManager::sharedState();
v25 = *(unsigned int *)(*(_QWORD *)(a1 + 552) + 328LL);
hasCompletedMapPack = GameStatsManager::hasCompletedMapPack(v24);
if ( !hasCompletedMapPack )
{
v26 = GJMapPack::completedMaps(*(_QWORD *)(a1 + 552), v25);
if ( v26 >= (int)GJMapPack::totalMaps(*(_QWORD *)(a1 + 552)) )
{
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 560) + 344LL))(*(_QWORD *)(a1 + 560), 0);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 560) + 1056LL))(*(_QWORD *)(a1 + 560), 0);
v27 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_rewardBtn_001.png");
v28 = CCMenuItemSpriteExtra::create(v27, 0, a1, MapPackCell::onClaimReward, 0);
*(_QWORD *)(a1 + 568) = v28;
CCMenuItemSpriteExtra::setSizeMult(v28, 1.5);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v22 + 456LL))(v22, *(_QWORD *)(a1 + 568));
v29 = *(_QWORD *)(a1 + 568);
v30 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 560) + 192LL))(*(_QWORD *)(a1 + 560));
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v29 + 184LL))(v29, v30);
}
}
v66 = 0;
v65 = 0;
v31 = cocos2d::CCSprite::create_1("GJ_progressBar_001.png");
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v31 + 960LL))(v31, &v65);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v31 + 912LL))(v31, 125);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v31 + 144LL))(v31, 0.80000001);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v31 + 128LL))(v31, 0.60000002);
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 536) + 464LL))(*(_QWORD *)(a1 + 536), v31, 3);
sub_100278250(&v67, (float)(*(float *)(a1 + 520) * 0.5) + -14.0, (float)(*(float *)(a1 + 524) * 0.5) + -2.0);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v31 + 184LL))(v31, &v67);
v32 = cocos2d::CCSprite::create_1("GJ_progressBar_001.png");
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v32 + 128LL))(v32, 0.98500001);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v32 + 144LL))(v32, 0.82999998);
v33 = *(_QWORD *)(a1 + 552);
v34 = *(_WORD *)(v33 + 392);
BYTE2(v67) = *(_BYTE *)(v33 + 394);
LOWORD(v67) = v34;
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v32 + 960LL))(v32, &v67);
*(float *)&v69 = *(float *)(v32 + 432) - (float)(0.98500001 * *(float *)(v32 + 432));
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v31 + 464LL))(v31, v32, 1);
sub_100278250(&v67, 0.0, 0.5);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v32 + 296LL))(v32, &v67);
*(float *)&v69 = *(float *)&v69 * 0.5;
v35 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v31 + 328LL))(v31);
sub_100278250(&v67, *(float *)&v69, *(float *)(v35 + 4) * 0.5);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v32 + 184LL))(v32, &v67);
*(float *)&v69 = (float)(int)GJMapPack::completedMaps(*(_QWORD *)(a1 + 552), &v67);
v36 = GJMapPack::totalMaps(*(_QWORD *)(a1 + 552));
*(_QWORD *)&v37 = (unsigned int)v69;
*(float *)&v37 = fminf((float)(*(float *)&v69 / (float)v36) * *(float *)(v32 + 432), *(float *)(v32 + 432));
sub_100278270(&v67, 0.0, 0.0, v37, COERCE_DOUBLE((unsigned __int64)*(_DWORD *)(v32 + 436)));
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v32 + 1136LL))(v32, &v67);
GJMapPack::completedMaps(*(_QWORD *)(a1 + 552), &v67);
GJMapPack::totalMaps(*(_QWORD *)(a1 + 552));
v38 = sub_10088E820("%i/%i", v61);
v39 = cocos2d::CCString::getCString(v38);
v40 = cocos2d::CCLabelBMFont::create_3(v39, "bigFont.fnt");
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 536) + 464LL))(*(_QWORD *)(a1 + 536), v40, 4);
v41 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v31 + 192LL))(v31);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v40 + 184LL))(v40, v41);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v40 + 160LL))(v40, 0.5);
v42 = *(_QWORD *)(a1 + 552);
v43 = *(_DWORD *)(v42 + 336);
result = *(unsigned int *)(v42 + 340);
v45 = (v43 > 0) + ((int)result > 0);
*(float *)&v69 = (float)(0.5 * *(float *)(a1 + 524)) + -30.0;
if ( v43 > 0 )
{
v46 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_starsIcon_001.png");
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 536) + 464LL))(*(_QWORD *)(a1 + 536), v46, 2);
v64 = v45;
if ( v45 > 1 )
v47 = (float)((float)(*(float *)(a1 + 520) * 0.5) + -4.0) + -40.0;
else
v47 = (float)(*(float *)(a1 + 520) * 0.5) + -4.0;
sub_100278250(&v67, v47, *(float *)&v69);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v46 + 184LL))(v46, &v67);
v48 = sub_10088E820("%i", v62);
v49 = cocos2d::CCString::getCString(v48);
v50 = cocos2d::CCLabelBMFont::create_3(v49, "bigFont.fnt");
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 536) + 464LL))(*(_QWORD *)(a1 + 536), v50, 1);
sub_100278250(&v67, 1.0, 0.5);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v50 + 296LL))(v50, &v67);
v51 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v46 + 192LL))(v46);
sub_100278250(v63, -17.0, 0.0);
sub_100278350(&v67, v51, v63);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v50 + 184LL))(v50, &v67);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v50 + 160LL))(v50, 0.69999999);
sub_1007FEBF0(*(_QWORD *)(a1 + 584), v46);
sub_1007FEBF0(*(_QWORD *)(a1 + 576), v50);
if ( hasCompletedMapPack )
{
BYTE2(v67) = 50;
LOWORD(v67) = -1;
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v50 + 1072LL))(v50, &v67);
v45 = v64;
if ( *(int *)(*(_QWORD *)(a1 + 552) + 340LL) <= 0 )
goto LABEL_33;
}
else
{
result = *(_QWORD *)(a1 + 552);
v45 = v64;
if ( *(int *)(result + 340) <= 0 )
return result;
}
LABEL_28:
v52 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_coinsIcon_001.png");
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 536) + 464LL))(*(_QWORD *)(a1 + 536), v52, 2);
if ( v45 > 1 )
v53 = (float)((float)(*(float *)(a1 + 520) * 0.5) + -4.0) + 40.0;
else
v53 = (float)(*(float *)(a1 + 520) * 0.5) + -4.0;
sub_100278250(&v67, v53, *(float *)&v69);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v52 + 184LL))(v52, &v67);
v54 = sub_10088E820("%i", v62);
v55 = cocos2d::CCString::getCString(v54);
v56 = cocos2d::CCLabelBMFont::create_3(v55, "bigFont.fnt");
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 536) + 464LL))(*(_QWORD *)(a1 + 536), v56, 1);
sub_100278250(&v67, 1.0, 0.5);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v56 + 296LL))(v56, &v67);
v57 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v52 + 192LL))(v52);
sub_100278250(v63, -19.0, 0.0);
v69 = v52;
sub_100278350(&v67, v57, v63);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v56 + 184LL))(v56, &v67);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 160LL))(v56, 0.69999999);
sub_1007FEBF0(*(_QWORD *)(a1 + 584), v69);
result = sub_1007FEBF0(*(_QWORD *)(a1 + 576), v56);
if ( hasCompletedMapPack )
{
BYTE2(v67) = 50;
LOWORD(v67) = -1;
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v56 + 1072LL))(v56, &v67);
goto LABEL_33;
}
return result;
}
if ( (int)result > 0 )
goto LABEL_28;
if ( hasCompletedMapPack )
{
LABEL_33:
v58 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_completesIcon_001.png");
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 536) + 464LL))(*(_QWORD *)(a1 + 536), v58, 5);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v58 + 160LL))(v58, 1.0);
v59 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v31 + 192LL))(v31);
sub_100278250(v63, 86.0, 1.0);
sub_100278350(&v67, v59, v63);
return (*(__int64 (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v58 + 184LL))(v58, &v67);
}
return result;
}