//
// GameLevelManager::markItemAsLiked from 0x6fc014 to 0x6fc218 (516 bytes)
//
// 2 xrefs:
// > GameLevelManager::likeItem @ 0x728b74
// > ??> @ 0x410e8
//
// 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::markItemAsLiked(GameLevelManager *a1, LikeItemType a2, int a3, bool a4, int a5)
{
const char *LikeAccountItemKey; // x0
size_t v11; // x0
char *v12; // x0
char *v13; // x0
unsigned int *v14; // x1
int v15; // w2
unsigned int *v16; // x1
int v17; // w2
const char *v18; // [xsp+58h] [xbp+58h]
std::string v19; // [xsp+70h] [xbp+70h] BYREF
if ( cocos2d::CCDictionary::count(a1->m_likedLevels) > 0x3E7 )
{
cocos2d::CCDictionary::getFirstKey((__int64 *)&v19, a1->m_likedLevels);
cocos2d::CCDictionary::removeObjectForKey(a1->m_likedLevels, &v19);
v13 = (char *)v19.m_data.m_data - 24;
if ( (__int64 *)v19.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v14 = (unsigned int *)((char *)v19.m_data.m_data - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *((_DWORD *)v19.m_data.m_data - 2);
*((_DWORD *)v19.m_data.m_data - 2) = v15 - 1;
}
if ( v15 <= 0 )
operator delete(v13);
}
}
v19.m_data.m_data = (stl::StringData::Internal *)&byte_124B6C8;
if ( a2 == AccountComment )
LikeAccountItemKey = GameLevelManager::getLikeAccountItemKey(a1, AccountComment, a3, a4, a5);
else
LikeAccountItemKey = GameLevelManager::getLikeItemKey(a1, a2, a3, a4, a5);
v18 = LikeAccountItemKey;
v11 = strlen(LikeAccountItemKey);
sub_D1798C(&v19, v18, v11);
cocos2d::CCDictionary::setObject((int)a1->m_likedLevels, a1->m_trueString);
v12 = (char *)v19.m_data.m_data - 24;
if ( (__int64 *)v19.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)((char *)v19.m_data.m_data - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v19.m_data.m_data - 2);
*((_DWORD *)v19.m_data.m_data - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v12);
}
}