//
// GameLevelManager::rateDemon from 0x140155350 to 0x140155776 (1062 bytes)
//
// 2 xrefs:
// > RateDemonLayer::onRate @ 0x1403c930a
// > ??> @ 0x1406ca938
//
// 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
bool GameLevelManager::rateDemon(GameLevelManager *a1, int a2, int a3, bool a4)
{
size_t v8; // rbx
cocos2d::CCString *v9; // rax
const char *CString; // rax
size_t v11; // r8
void *v12; // rcx
cocos2d::CCString *v13; // rax
const char *v14; // rax
const char *v15; // rdi
size_t v16; // r8
__int64 v17; // r14
void *v18; // rcx
size_t v20; // r8
__int64 v21; // rax
__int64 v22; // rcx
void *v23; // rcx
cocos2d::CCString *v24; // rax
const char *v25; // rax
cocos2d::CCString *v26; // rax
char *v27; // rax
size_t v28; // r8
size_t v29; // r8
_QWORD *v30; // rdx
__int128 v31; // [rsp+40h] [rbp-79h] BYREF
__int64 v32; // [rsp+50h] [rbp-69h]
__int64 v33; // [rsp+58h] [rbp-61h]
__int128 *v34; // [rsp+60h] [rbp-59h]
__int128 *v35; // [rsp+68h] [rbp-51h]
void *Block[2]; // [rsp+78h] [rbp-41h] BYREF
__int128 v37; // [rsp+88h] [rbp-31h]
__int128 v38; // [rsp+98h] [rbp-21h] BYREF
__int64 v39; // [rsp+A8h] [rbp-11h]
__int64 v40; // [rsp+B0h] [rbp-9h]
_QWORD Src[4]; // [rsp+B8h] [rbp-1h] BYREF
v8 = -1;
if ( !a4 )
{
if ( GameLevelManager::hasRatedDemon(a1, a2) )
return 0;
if ( cocos2d::CCDictionary::count(a1->m_ratedDemons) >= 0x3E8 )
{
cocos2d::CCDictionary::getFirstKey(a1->m_ratedDemons, &v38);
cocos2d::CCDictionary::removeObjectForKey(a1->m_ratedDemons, &v38);
sub_14003A830((__int64)&v38);
}
v9 = cocos2d::CCString::createWithFormat("%i", a2);
CString = cocos2d::CCString::getCString(v9);
*(_OWORD *)Block = 0;
v37 = 0;
v11 = -1;
do
++v11;
while ( CString[v11] );
sub_14003A930(Block, CString, v11);
cocos2d::CCDictionary::setObject(a1->m_ratedDemons, a1->m_trueString, Block);
if ( *((_QWORD *)&v37 + 1) > 0xFu )
{
v12 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v37 + 1) + 1LL) >= 0x1000 )
{
v12 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v12 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v12);
}
}
v13 = cocos2d::CCString::createWithFormat("rd_%i_%i", a2, a3);
v14 = cocos2d::CCString::getCString(v13);
v15 = v14;
*(_OWORD *)Block = 0;
v37 = 0;
v16 = -1;
do
++v16;
while ( v14[v16] );
sub_14003A930(Block, v14, v16);
v17 = cocos2d::CCDictionary::objectForKey(a1->m_friendReqAndUserBlocks, Block);
if ( *((_QWORD *)&v37 + 1) > 0xFu )
{
v18 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v37 + 1) + 1LL) >= 0x1000 )
{
v18 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v18 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v18);
}
if ( v17 )
return 0;
*(_OWORD *)Block = 0;
v37 = 0;
v20 = -1;
do
++v20;
while ( v15[v20] );
sub_14003A930(Block, v15, v20);
v21 = cocos2d::CCNode::create();
cocos2d::CCDictionary::setObject(a1->m_friendReqAndUserBlocks, v21, Block);
if ( *((_QWORD *)&v37 + 1) > 0xFu )
{
v23 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v37 + 1) + 1LL) >= 0x1000 )
{
v23 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v23 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v23);
}
GameLevelManager::getBasePostString(v22, Src);
v24 = cocos2d::CCString::createWithFormat("%c%s%s%c%c%s", 87, "mfp", "3879", 103, 99, (const char *)&word_140531E9C);
v25 = cocos2d::CCString::getCString(v24);
v26 = cocos2d::CCString::createWithFormat("&levelID=%i&rating=%i&secret=%s", a2, a3, v25);
v27 = (char *)cocos2d::CCString::getCString(v26);
v28 = -1;
do
++v28;
while ( v27[v28] );
sub_140041270(Src, v27, v28);
if ( a4 )
sub_140041270(Src, "&mode=1", 7u);
v34 = &v31;
v35 = &v38;
v31 = 0;
v32 = 0;
v33 = 0;
v29 = -1;
do
++v29;
while ( v15[v29] );
sub_14003A930(&v31, v15, v29);
v30 = Src;
if ( Src[3] > 0xFu )
v30 = (_QWORD *)Src[0];
v38 = 0;
v39 = 0;
v40 = 0;
do
++v8;
while ( *((_BYTE *)v30 + v8) );
sub_14003A930(&v38, v30, v8);
*(_OWORD *)Block = 0;
*(_QWORD *)&v37 = 0;
*((_QWORD *)&v37 + 1) = 15;
Block[0] = sub_14003AA10(0x40u);
*(_QWORD *)&v37 = 52;
*((_QWORD *)&v37 + 1) = 63;
strcpy((char *)Block[0], "https://www.boomlings.com/database/rateGJDemon21.php");
GameLevelManager::ProcessHttpRequest(a1, (__int64)Block, (const char *)&v38, (const char *)&v31, 50);
sub_14003A830((__int64)Src);
return 1;
}