//
// GameLevelManager::onLikeItemCompleted from 0x140164270 to 0x1401646b8 (1096 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x1401434ad
// > ??> @ 0x1406cac74
//
// 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=5
void __fastcall GameLevelManager::onLikeItemCompleted(GameLevelManager *a1, const void **a2, _QWORD *a3)
{
_BYTE *v5; // rbx
size_t v6; // rdi
size_t v7; // r8
cocos2d::CCArray *v8; // rsi
void *v9; // rcx
cocos2d::CCString *v10; // rax
const char *CString; // rax
size_t v12; // r8
cocos2d::CCArray *v13; // rsi
void *v14; // rcx
cocos2d::CCString *v15; // rax
const char *v16; // rax
size_t v17; // r8
cocos2d::CCArray *v18; // rsi
void *v19; // rcx
cocos2d::CCString *v20; // rax
const char *v21; // rax
const void *v22; // rcx
unsigned __int64 v23; // r15
size_t v24; // r8
int v25; // esi
void *v26; // rcx
GJGameLevel *SavedLevel; // rax
GameStatsManager *v28; // rcx
int v29; // [rsp+20h] [rbp-59h]
int v30; // [rsp+24h] [rbp-55h]
int v31; // [rsp+28h] [rbp-51h]
void *v33; // [rsp+30h] [rbp-49h]
void *Block[2]; // [rsp+50h] [rbp-29h] BYREF
__int64 v36; // [rsp+60h] [rbp-19h]
unsigned __int64 v37; // [rsp+68h] [rbp-11h]
__int128 Buf2; // [rsp+70h] [rbp-9h] BYREF
__int64 v39; // [rsp+80h] [rbp+7h]
unsigned __int64 v40; // [rsp+88h] [rbp+Fh]
v5 = a3;
if ( a3[3] > 0xFu )
v5 = (_BYTE *)*a3;
*(_OWORD *)Block = 0;
v36 = 0;
v37 = 0;
v6 = -1;
v7 = -1;
do
++v7;
while ( v5[v7] );
sub_14003A930(Block, v5, v7);
v8 = sub_140140F70((__int64 *)Block, "_");
if ( v37 > 0xF )
{
v9 = Block[0];
if ( v37 + 1 >= 0x1000 )
{
v9 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v9 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v9);
}
v36 = 0;
v37 = 15;
LOBYTE(Block[0]) = 0;
if ( cocos2d::CCArray::count(v8) < 5 )
{
v29 = 0;
}
else
{
v10 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v8, 1u);
CString = cocos2d::CCString::getCString(v10);
v29 = atoi(CString);
}
*(_OWORD *)Block = 0;
v36 = 0;
v37 = 0;
v12 = -1;
do
++v12;
while ( v5[v12] );
sub_14003A930(Block, v5, v12);
v13 = sub_140140F70((__int64 *)Block, "_");
if ( v37 > 0xF )
{
v14 = Block[0];
if ( v37 + 1 >= 0x1000 )
{
v14 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v14 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v14);
}
v36 = 0;
v37 = 15;
LOBYTE(Block[0]) = 0;
if ( cocos2d::CCArray::count(v13) < 5 )
{
v30 = 0;
}
else
{
v15 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v13, 2u);
v16 = cocos2d::CCString::getCString(v15);
v30 = atoi(v16);
}
*(_OWORD *)Block = 0;
v36 = 0;
v37 = 0;
v17 = -1;
do
++v17;
while ( v5[v17] );
sub_14003A930(Block, v5, v17);
v18 = sub_140140F70((__int64 *)Block, "_");
if ( v37 > 0xF )
{
v19 = Block[0];
if ( v37 + 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);
}
v36 = 0;
v37 = 15;
LOBYTE(Block[0]) = 0;
if ( cocos2d::CCArray::count(v18) < 5 )
{
v31 = 0;
}
else
{
v20 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v18, 3u);
v21 = cocos2d::CCString::getCString(v20);
v31 = atoi(v21);
}
Buf2 = 0;
v39 = 2;
v40 = 15;
strcpy((char *)&Buf2, "-1");
v22 = a2;
if ( (unsigned __int64)a2[3] > 0xF )
v22 = *a2;
v23 = (unsigned __int64)a2[2];
v24 = v23;
if ( v23 > 2 )
v24 = 2;
v25 = memcmp(v22, &Buf2, v24);
if ( !v25 )
{
if ( v23 >= 2 )
v25 = v23 > 2;
else
v25 = -1;
}
if ( v25 )
{
if ( v29 == 1 )
{
v28 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v33 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0(v33);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v28 = (GameStatsManager *)qword_1406C2EE8;
}
GameStatsManager::incrementStat(v28, "10", 1);
}
}
else
{
Buf2 = 0;
v39 = 0;
v40 = 0;
do
++v6;
while ( v5[v6] );
sub_14003A930(&Buf2, v5, v6);
cocos2d::CCDictionary::removeObjectForKey(a1->m_likedLevels, &Buf2);
if ( v40 > 0xF )
{
v26 = (void *)Buf2;
if ( v40 + 1 >= 0x1000 )
{
v26 = *(void **)(Buf2 - 8);
if ( (unsigned __int64)(Buf2 - (_QWORD)v26 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v26);
}
if ( v29 == 1 )
{
SavedLevel = GameLevelManager::getSavedLevel(a1, v30);
if ( SavedLevel )
{
if ( v31 )
--SavedLevel->m_likes;
else
--SavedLevel->m_dislikes;
}
}
}
sub_14003A830((__int64)a2);
sub_14003A830((__int64)a3);
}