//
// GameStatsManager::completedDailyLevel from 0x7c5ab8 to 0x7c6064 (1452 bytes)
//
// 2 xrefs:
// > DailyLevelPage::claimLevelReward @ 0x9156c4
// > ??> @ 0x61458
//
// 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
//
GJRewardItem *GameStatsManager::completedDailyLevel(GameStatsManager *a1, GJGameLevel *a2)
{
int v4; // w1
unsigned int BonusDiamonds; // w20
const char *v7; // x1
cocos2d::CCArray *v8; // x23
GJRewardObject *v9; // x0
GJRewardObject *v10; // x0
GJRewardObject *v11; // x0
SpecialRewardItem RandomNonMaxShardType; // w20
GJRewardItem *v13; // x20
char *v14; // x0
void *v15; // x0
char *v16; // x0
char *v17; // x0
unsigned int *v18; // x22
int v19; // w1
GameStatsManager *v20; // x24
int Stat; // w24
char *v22; // x0
int v23; // w1
GJRewardObject *v24; // x0
unsigned int *v25; // x2
int v26; // w1
cocos2d::CCDictionary *m_challengeDiamonds; // x25
cocos2d::CCObject *v28; // x24
char *v29; // x0
unsigned int *v30; // x1
int v31; // w2
unsigned int *v32; // x1
int v33; // w2
unsigned int *v34; // x2
int v35; // w1
unsigned int *v36; // x2
int v37; // w1
std::string v38; // [xsp+70h] [xbp+70h] BYREF
__int64 v39; // [xsp+78h] [xbp+78h] BYREF
char *v40; // [xsp+80h] [xbp+80h] BYREF
if ( !a2 )
return nullptr;
v4 = a2->m_dailyID.random - a2->m_dailyID.seed;
if ( v4 <= 0
|| a2->m_stars.random - a2->m_stars.seed <= 0
|| a2->m_orbCompletion.random - a2->m_orbCompletion.seed <= 99
|| GameStatsManager::hasCompletedDailyLevel(a1, v4) )
{
return nullptr;
}
BonusDiamonds = GameStatsManager::getBonusDiamonds(a1, a2->m_stars.random - a2->m_stars.seed);
v7 = (const char *)(unsigned int)(a2->m_dailyID.random - a2->m_dailyID.seed);
if ( (int)v7 <= 99999 )
{
m_challengeDiamonds = a1->m_challengeDiamonds;
v28 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)BonusDiamonds);
GameStatsManager::getDailyLevelKey(
a1,
(const char *)(unsigned int)(a2->m_dailyID.random - a2->m_dailyID.seed),
(__int64)&v40);
cocos2d::CCDictionary::setObject((int)m_challengeDiamonds, v28);
v29 = v40 - 24;
if ( v40 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v36 = (unsigned int *)(v40 - 8);
do
v37 = __ldaxr(v36);
while ( __stlxr(v37 - 1, v36) );
}
else
{
v37 = *((_DWORD *)v40 - 2);
*((_DWORD *)v40 - 2) = v37 - 1;
}
if ( v37 <= 0 )
operator delete(v29);
}
GameStatsManager::incrementStat(a1, "13", BonusDiamonds);
return nullptr;
}
if ( (int)v7 > (int)&stru_30D38.st_shndx + 1 )
{
GameStatsManager::getDailyLevelKey(a1, v7, (__int64)&v38);
v13 = (GJRewardItem *)cocos2d::CCDictionary::objectForKey(a1->m_eventChest, &v38);
if ( v13 )
{
sub_D18D28(&v39);
GameStatsManager::storeOnlineChest((__int64)a1, (int)&v39, v13);
v15 = (void *)(v39 - 24);
if ( (__int64 *)(v39 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v30 = (unsigned int *)(v39 - 8);
do
v31 = __ldaxr(v30);
while ( __stlxr(v31 - 1, v30) );
}
else
{
v31 = *(_DWORD *)(v39 - 8);
*(_DWORD *)(v39 - 8) = v31 - 1;
}
if ( v31 <= 0 )
operator delete(v15);
}
sub_D18D28(&v40);
v13 = GameStatsManager::unlockOnlineChest(a1);
v16 = v40 - 24;
if ( v40 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v32 = (unsigned int *)(v40 - 8);
do
v33 = __ldaxr(v32);
while ( __stlxr(v33 - 1, v32) );
}
else
{
v33 = *((_DWORD *)v40 - 2);
*((_DWORD *)v40 - 2) = v33 - 1;
}
if ( v33 <= 0 )
operator delete(v16);
}
}
v17 = (char *)v38.m_data.m_data - 24;
if ( (__int64 *)v38.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)((char *)v38.m_data.m_data - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *((_DWORD *)v38.m_data.m_data - 2);
*((_DWORD *)v38.m_data.m_data - 2) = v19 - 1;
}
if ( v19 <= 0 )
{
operator delete(v17);
return v13;
}
}
return v13;
}
v8 = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)((char *)&stru_30D38.st_shndx + 1));
v9 = GJRewardObject::create(Diamonds, BonusDiamonds, 0);
cocos2d::CCArray::addObject(v8, v9);
v10 = GJRewardObject::create(BonusKey|FireShard, 500, 0);
cocos2d::CCArray::addObject(v8, v10);
v11 = GJRewardObject::create(BonusKey, 1, 0);
cocos2d::CCArray::addObject(v8, v11);
RandomNonMaxShardType = GJRewardItem::getRandomNonMaxShardType();
if ( RandomNonMaxShardType )
{
v20 = GameStatsManager::sharedState();
GJRewardItem::rewardItemToStat(RandomNonMaxShardType, (__int64)&v40);
Stat = GameStatsManager::getStat(v20, v40);
v22 = v40 - 24;
if ( v40 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v34 = (unsigned int *)(v40 - 8);
do
v35 = __ldaxr(v34);
while ( __stlxr(v35 - 1, v34) );
}
else
{
v35 = *((_DWORD *)v40 - 2);
*((_DWORD *)v40 - 2) = v35 - 1;
}
if ( v35 <= 0 )
operator delete(v22);
}
if ( Stat > 98 )
v23 = 1;
else
v23 = 2;
v24 = GJRewardObject::create(RandomNonMaxShardType, v23, 0);
cocos2d::CCArray::addObject(v8, v24);
}
v13 = GJRewardItem::createWithObjects(SmallTreasure, v8);
if ( !v13 )
return nullptr;
GameStatsManager::getDailyLevelKey(
a1,
(const char *)(unsigned int)(a2->m_dailyID.random - a2->m_dailyID.seed),
(__int64)&v40);
if ( !cocos2d::CCDictionary::objectForKey(a1->m_weeklyChest, (const std::string *)&v40) )
{
GameStatsManager::registerRewardsFromItem(a1, v13);
cocos2d::CCDictionary::setObject((int)a1->m_weeklyChest, v13);
}
v14 = v40 - 24;
if ( v40 - 24 == (char *)&qword_124B6B0 )
return v13;
if ( &pthread_create )
{
v25 = (unsigned int *)(v40 - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *((_DWORD *)v40 - 2);
*((_DWORD *)v40 - 2) = v26 - 1;
}
if ( v26 > 0 )
return v13;
operator delete(v14);
return v13;
}