//
// GameManager::checkSteamAchievementUnlock from 0x14017e1c0 to 0x14017e5a0 (992 bytes)
//
// 3 xrefs:
// > GameManager::reportPercentageForLevel @ 0x14017dec4
// > GameManager::dataLoaded @ 0x140188607
// > ??> @ 0x1406cb3f4
//
// 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
//
// Hidden C++ exception states: #wind=3
void GameManager::checkSteamAchievementUnlock(GameManager *a1)
{
AchievementManager *v1; // rbx
cocos2d::CCString *v2; // rax
int v3; // ebx
void *v4; // rcx
AchievementManager *v5; // rbx
cocos2d::CCString *v6; // rax
int v7; // ebx
void *v8; // rcx
AchievementManager *v9; // rbx
cocos2d::CCString *v10; // rax
int v11; // ebx
bool v12; // r9
void *v13; // rcx
GameManager *v14; // rcx
AchievementManager *v15; // rbx
cocos2d::CCString *v16; // rax
int v17; // ebx
bool v18; // r9
void *v19; // rcx
GameManager *v20; // rcx
void *v21; // [rsp+20h] [rbp-30h]
void *v22; // [rsp+20h] [rbp-30h]
void *Block[2]; // [rsp+28h] [rbp-28h] BYREF
__int64 v24; // [rsp+38h] [rbp-18h]
unsigned __int64 v25; // [rsp+40h] [rbp-10h]
v1 = AchievementManager::sharedState();
*(_OWORD *)Block = 0;
Block[0] = sub_14003AA10(0x20u);
v24 = 21;
v25 = 31;
strcpy((char *)Block[0], "geometry.ach.level01b");
v2 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v1->m_reportedAchievements, Block);
v3 = cocos2d::CCString::intValue(v2);
if ( v25 > 0xF )
{
v4 = Block[0];
if ( v25 + 1 >= 0x1000 )
{
v4 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v4 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v4);
}
if ( v3 >= 100 )
{
v5 = AchievementManager::sharedState();
*(_OWORD *)Block = 0;
v24 = 0;
v25 = 15;
Block[0] = sub_14003AA10(0x20u);
v24 = 21;
v25 = 31;
strcpy((char *)Block[0], "geometry.ach.level02b");
v6 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v5->m_reportedAchievements, Block);
v7 = cocos2d::CCString::intValue(v6);
if ( v25 > 0xF )
{
v8 = Block[0];
if ( v25 + 1 >= 0x1000 )
{
v8 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v8 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v8);
}
if ( v7 >= 100 )
{
v9 = AchievementManager::sharedState();
*(_OWORD *)Block = 0;
v24 = 0;
v25 = 15;
Block[0] = sub_14003AA10(0x20u);
v24 = 21;
v25 = 31;
strcpy((char *)Block[0], "geometry.ach.level03b");
v10 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v9->m_reportedAchievements, Block);
v11 = cocos2d::CCString::intValue(v10);
if ( v25 > 0xF )
{
v13 = Block[0];
if ( v25 + 1 >= 0x1000 )
{
v13 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v13 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v13);
}
v24 = 0;
v25 = 15;
LOBYTE(Block[0]) = 0;
if ( v11 >= 100 )
{
v14 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v21 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v21);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v14 = (GameManager *)qword_1406C2ED8;
}
GameManager::reportAchievementWithID(v14, "geometry.ach.steam01", 100, v12);
}
}
}
v15 = AchievementManager::sharedState();
*(_OWORD *)Block = 0;
v24 = 0;
v25 = 15;
Block[0] = sub_14003AA10(0x20u);
v24 = 21;
v25 = 31;
strcpy((char *)Block[0], "geometry.ach.level14b");
v16 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v15->m_reportedAchievements, Block);
v17 = cocos2d::CCString::intValue(v16);
if ( v25 > 0xF )
{
v19 = Block[0];
if ( v25 + 1 >= 0x1000 )
{
v19 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v19 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v19);
}
v24 = 0;
v25 = 15;
LOBYTE(Block[0]) = 0;
if ( v17 >= 100 )
{
v20 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v22 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v22);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v20 = (GameManager *)qword_1406C2ED8;
}
GameManager::reportAchievementWithID(v20, "geometry.ach.steam02", 100, v18);
}
}