//
// GameLevelManager::markLevelAsRatedDemon from 0x6f6554 to 0x6f6714 (448 bytes)
//
// 2 xrefs:
// > GameLevelManager::rateDemon @ 0x71fdcc
// > ??> @ 0xbc718
//
// 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
//
void GameLevelManager::markLevelAsRatedDemon(GameLevelManager *a1, int a2)
{
char *v4; // x0
const char *v5; // x1
cocos2d::CCDictionary *m_ratedDemons; // x23
cocos2d::CCString *m_trueString; // x20
cocos2d::CCString *v8; // x0
char *CString; // x0
char *v10; // x0
unsigned int *v11; // x1
int v12; // w2
unsigned int *v13; // x20
int v14; // w1
std::string v15; // [xsp+50h] [xbp+50h] BYREF
if ( cocos2d::CCDictionary::count(a1->m_ratedDemons) > 0x3E7 )
{
cocos2d::CCDictionary::getFirstKey((__int64 *)&v15, a1->m_ratedDemons);
cocos2d::CCDictionary::removeObjectForKey(a1->m_ratedDemons, &v15);
v4 = (char *)v15.m_data.m_data - 24;
if ( (__int64 *)v15.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)((char *)v15.m_data.m_data - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *((_DWORD *)v15.m_data.m_data - 2);
*((_DWORD *)v15.m_data.m_data - 2) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v4);
}
}
v5 = (const char *)(unsigned int)a2;
m_ratedDemons = a1->m_ratedDemons;
m_trueString = a1->m_trueString;
v8 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v5);
CString = (char *)cocos2d::CCString::getCString(v8);
sub_D153B8((int)&v15, CString);
cocos2d::CCDictionary::setObject((int)m_ratedDemons, m_trueString);
v10 = (char *)v15.m_data.m_data - 24;
if ( (__int64 *)v15.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)((char *)v15.m_data.m_data - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v15.m_data.m_data - 2);
*((_DWORD *)v15.m_data.m_data - 2) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v10);
}
}