//
// GameLevelManager::onGetGJDailyLevelStateCompleted from 0x3c416c to 0x3c4502 (918 bytes)
//
// 1 xrefs:
// > GameLevelManager::handleIt @ 0x3d7564
//
// 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
//
int __fastcall GameLevelManager::onGetGJDailyLevelStateCompleted(
GameLevelManager *a1,
cocos2d::CCArray *a2,
const char **a3)
{
_BOOL4 v6; // r8
_BOOL4 v7; // r4
GJTimedLevelType v8; // r4
_BOOL4 v9; // r7
_BOOL4 v10; // r7
int result; // r0
int (*v12)(void); // r3
cocos2d::CCArray *v13; // r0
cocos2d::CCArray *v14; // r7
cocos2d::CCString *v16; // r0
cocos2d::CCString *v17; // r0
int v18; // r0
cocos2d::CCString *v19; // r0
char *CString; // r0
cocos2d::CCString *v21; // r0
char *v22; // r0
cocos2d::CCString *v23; // r0
char *v24; // r0
const void *v25; // r0
unsigned __int8 *v26; // r3
char *v27; // r2
_BOOL4 v28; // r9
GJDailyLevelDelegate *m_GJDailyLevelDelegate; // r0
cocos2d::CCArray *v30; // r9
cocos2d::CCString *v31; // r0
int v32; // r10
GameManager *v33; // r0
GJDailyLevelDelegate *v34; // r0
cocos2d::CCString *v35; // r0
cocos2d::CCString *v36; // r0
cocos2d::CCString *v37; // r0
char *v38; // r0
GameStatsManager *v39; // r11
GJRewardItem *Reward; // r11
GJDailyLevelDelegate *v41; // r0
GameStatsManager *v42; // r0
int v43; // [sp+18h] [bp-30h]
int v44; // [sp+1Ch] [bp-2Ch]
GJRewardType v45; // [sp+20h] [bp-28h]
std::string v46; // [sp+28h] [bp-20h] BYREF
char v47[4]; // [sp+2Ch] [bp-1Ch] BYREF
char v48[4]; // [sp+30h] [bp-18h] BYREF
char *v49; // [sp+34h] [bp-14h] BYREF
char v50[4]; // [sp+38h] [bp-10h] BYREF
cocos2d::CCArray v51; // [sp+3Ch] [bp-Ch] BYREF
GameLevelManager::removeDLFromActive(a1, *a3);
sub_776584((int)&v51.m_nTag, "weekly_state");
v6 = sub_3BE0D8((int)a3, (int)&v51.m_nTag);
sub_774008(&v51.m_nTag);
if ( v6 )
{
v8 = 1;
}
else
{
sub_776584((int)&v51.m_nTag, "event_state");
v7 = sub_3BE0D8((int)a3, (int)&v51.m_nTag);
sub_774008(&v51.m_nTag);
if ( v7 )
v8 = Event;
else
v8 = Daily;
}
sub_776584((int)&v51.m_nTag, "-1");
v9 = sub_3BE0D8((int)a2, (int)&v51.m_nTag);
sub_774008(&v51.m_nTag);
if ( !v9 )
{
sub_776584((int)&v51.m_nTag, "-2");
v10 = sub_3BE0D8((int)a2, (int)&v51.m_nTag);
sub_774008(&v51.m_nTag);
if ( v10 )
{
result = (int)a1->m_GJDailyLevelDelegate;
if ( !result )
return result;
v12 = *(int (**)(void))(*(_DWORD *)result + 4);
return v12();
}
v13 = sub_3BE530(a2, "|");
v14 = v13;
if ( v8 == Event ? cocos2d::CCArray::count(v13) > 3u : cocos2d::CCArray::count(v13) > 1u )
{
v16 = cocos2d::CCArray::stringAtIndex(v14, 0);
v43 = cocos2d::CCString::intValue(v16);
v17 = cocos2d::CCArray::stringAtIndex(v14, 1u);
v18 = cocos2d::CCString::intValue(v17);
GameLevelManager::storeDailyLevelState(a1, v43, v18, v8);
if ( v8 == Event )
{
v19 = cocos2d::CCArray::stringAtIndex(v14, 2u);
CString = (char *)cocos2d::CCString::getCString(v19);
sub_776584((int)&v46, CString);
v21 = cocos2d::CCArray::stringAtIndex(v14, 3u);
v22 = (char *)cocos2d::CCString::getCString(v21);
sub_776584((int)v47, v22);
sub_776158(v48, &v46, 5, -1);
sub_774794(&v46, v48);
sub_774008(v48);
sub_775C20(&v49, &v46);
v23 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_70,
"C26",
"fpYa",
81,
67,
"tg");
v24 = (char *)cocos2d::CCString::getCString(v23);
sub_774544((int)&v49, v24);
v25 = (const void *)strlen(v49);
rtsha1::calc((rtsha1 *)v49, v25, (int)&v51.m_uReference, v26);
rtsha1::toHexString((rtsha1 *)&v51.m_uReference, (const unsigned __int8 *)&v51.m_unknown2, v27);
sub_776584((int)v50, (char *)&v51.m_unknown2);
v28 = sub_3BE0D8((int)v50, (int)v47);
sub_774008(v50);
if ( !v28 )
{
m_GJDailyLevelDelegate = a1->m_GJDailyLevelDelegate;
if ( m_GJDailyLevelDelegate )
m_GJDailyLevelDelegate->dailyStatusFailed(m_GJDailyLevelDelegate, Event, (GJErrorCode)-1);
goto LABEL_31;
}
sub_776584((int)&v51.m_uID, "59182");
cocos2d::ZipUtils::base64DecodeEnc((cocos2d::ZipUtils *)&v51, &v46, (std::string)&v51.m_uID);
sub_774008(&v51.m_uID);
v30 = sub_3BE530(&v51, ":");
if ( cocos2d::CCArray::count(v30) <= 4u
|| (v31 = cocos2d::CCArray::stringAtIndex(v30, 1u),
v32 = cocos2d::CCString::intValue(v31),
v33 = GameManager::sharedState(),
v32 != v33->m_chk.random - v33->m_chk.seed) )
{
v34 = a1->m_GJDailyLevelDelegate;
if ( v34 )
v34->dailyStatusFailed(v34, Event, (GJErrorCode)-1);
LABEL_30:
sub_774008(&v51);
LABEL_31:
sub_774008(&v49);
sub_774008(v47);
return sub_774008(&v46);
}
v35 = cocos2d::CCArray::stringAtIndex(v30, 2u);
v44 = cocos2d::CCString::intValue(v35);
v36 = cocos2d::CCArray::stringAtIndex(v30, 3u);
v45 = cocos2d::CCString::intValue(v36);
v37 = cocos2d::CCArray::stringAtIndex(v30, 4u);
v38 = (char *)cocos2d::CCString::getCString(v37);
sub_776584((int)&v51.m_nLuaID, v38);
v39 = GameStatsManager::sharedState();
sub_775C20(&v51.m_nTag, &v51.m_nLuaID);
Reward = (GJRewardItem *)GameStatsManager::createReward(v39, v45, v44, (std::string)&v51.m_nTag);
sub_774008(&v51.m_nTag);
if ( !Reward )
{
v41 = a1->m_GJDailyLevelDelegate;
if ( v41 )
v41->dailyStatusFailed(v41, Event, (GJErrorCode)-1);
sub_774008(&v51.m_nLuaID);
goto LABEL_30;
}
v42 = GameStatsManager::sharedState();
GameStatsManager::storeEventChest(v42, v43, Reward);
sub_774008(&v51.m_nLuaID);
sub_774008(&v51);
sub_774008(&v49);
sub_774008(v47);
sub_774008(&v46);
}
result = (int)a1->m_GJDailyLevelDelegate;
if ( result )
return (**(int (__fastcall ***)(int, GJTimedLevelType))result)(result, v8);
return result;
}
}
result = (int)a1->m_GJDailyLevelDelegate;
if ( result )
{
v12 = *(int (**)(void))(*(_DWORD *)result + 4);
return v12();
}
return result;
}