//
// AchievementManager::achievementForUnlock from 0x56a424 to 0x56a7d4 (944 bytes)
//
// 7 xrefs:
// > GJGarageLayer::titleForUnlock @ 0x7911f0
// > GJGarageLayer::descriptionForUnlock @ 0x7913c0
// > GJGarageLayer::achievementForUnlock @ 0x791598
// > ItemInfoPopup::init @ 0x794e98
// > GameStatsManager::getItemUnlockStateLite @ 0x7bc634
// > GameStatsManager::generateItemUnlockableData @ 0x7bc980
// > ??> @ 0xab570
//
// 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
//
__int64 __usercall AchievementManager::achievementForUnlock@(
__int64 a1@,
signed int a2@,
int a3@,
__int64 a4@)
{
size_t v7; // x24
size_t v8; // x21
size_t v9; // x24
cocos2d::CCDictionary *v10; // x25
cocos2d::CCString *v11; // x0
char *CString; // x0
char *v13; // x0
int *v15; // x0
int *v16; // x0
int *v17; // x0
__int16 v18; // w2
char v19; // w0
unsigned int *v20; // x2
int v21; // w1
std::string v22; // [xsp+60h] [xbp+60h] BYREF
size_t v23; // [xsp+68h] [xbp+68h] BYREF
unsigned __int64 v24; // [xsp+70h] [xbp+70h]
char *v25; // [xsp+78h] [xbp+78h]
_QWORD v26[63]; // [xsp+80h] [xbp+80h] BYREF
v24 = 500;
v23 = 0;
v25 = (char *)v26;
switch ( a3 )
{
case 1:
v15 = (int *)"icon_";
goto LABEL_17;
case 2:
v16 = (int *)"color_";
goto LABEL_19;
case 3:
v17 = (int *)"color2_";
goto LABEL_21;
case 4:
v15 = &dword_E9EBC8;
goto LABEL_17;
case 5:
v15 = &dword_E9EBD0;
goto LABEL_17;
case 6:
v15 = &dword_E9EBD8;
goto LABEL_17;
case 7:
v15 = &dword_E9EBE0;
goto LABEL_17;
case 8:
v16 = &dword_E9EBE8;
goto LABEL_19;
case 9:
v17 = &dword_E9EBF0;
LABEL_21:
v23 = 7;
LODWORD(v26[0]) = *v17;
v18 = *((_WORD *)v17 + 2);
v19 = *((_BYTE *)v17 + 6);
WORD2(v26[0]) = v18;
BYTE6(v26[0]) = v19;
break;
case 10:
v23 = 8;
v26[0] = *(_QWORD *)"special_";
break;
case 11:
v16 = &dword_E9EC08;
goto LABEL_19;
case 12:
v15 = &dword_E9EC28;
LABEL_17:
v23 = 5;
LODWORD(v26[0]) = *v15;
BYTE4(v26[0]) = *((_BYTE *)v15 + 4);
break;
case 13:
v16 = &dword_E9EC10;
LABEL_19:
v23 = 6;
LODWORD(v26[0]) = *v16;
WORD2(v26[0]) = *((_WORD *)v16 + 2);
break;
case 14:
v23 = 8;
v26[0] = *(_QWORD *)"jetpack_";
break;
case 15:
v23 = 11;
qmemcpy(v26, "shipstreak_", 11);
break;
default:
v23 = 2;
LOWORD(v26[0]) = 24352;
break;
}
if ( a2 <= 9 )
{
v7 = v23;
v8 = v23 + 1;
if ( v23 + 1 > v24 )
fmt::internal::Array::grow(&v23, v23 + 1);
v23 = v8;
v25[v7] = aAssertionFaile_0[72];
}
fmt::BasicWriter::FormatInt,char>>(&v23, a2);
v9 = v23;
v10 = *(cocos2d::CCDictionary **)(a1 + 336);
if ( v24 < v23 + 1 )
fmt::internal::Array::grow(&v23, v23 + 1);
v25[v9] = 0;
sub_D153B8((int)&v22, v25);
v11 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v10, &v22);
CString = (char *)cocos2d::CCString::getCString(v11);
sub_D153B8(a4, CString);
v13 = (char *)v22.m_data.m_data - 24;
if ( (__int64 *)v22.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)((char *)v22.m_data.m_data - 8);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *((_DWORD *)v22.m_data.m_data - 2);
*((_DWORD *)v22.m_data.m_data - 2) = v21 - 1;
}
if ( v21 <= 0 )
operator delete(v13);
}
if ( v25 != (char *)v26 && v25 )
operator delete[](v25);
return a4;
}