//
// PlayLayer::levelComplete from 0x407b64 to 0x408388 (2084 bytes)
//
// 1 xrefs:
// > PlayLayer::playPlatformerEndAnimationToPos @ 0x408550
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:47:29 +0000
//
void __fastcall PlayLayer::levelComplete(PlayLayer *this)
{
int v2; // r6
int v3; // r5
char v4; // r7
double *v5; // r3
double v6; // d7
_DWORD *v7; // r1
int v8; // r1
int v9; // r8
unsigned int v10; // r6
int v11; // r7
cocos2d::CCArray *v12; // r8
cocos2d::CCString *v13; // r0
const char *CString; // r0
int v15; // r11
size_t v16; // r0
_DWORD *v17; // r11
int v18; // r3
_DWORD *v19; // r10
int v20; // s15
_DWORD *v21; // r10
int v22; // s15
_DWORD *v23; // r10
int v24; // s15
GJGameLevel *v25; // r0
int v26; // r6
int v27; // s15
int v28; // r6
int v29; // r1
int v30; // r2
double TempMilliTime; // r0
GameManager *v32; // r0
int v33; // r7
GameManager *PlayTimerMilli; // r0
int v35; // r9
int *v36; // r10
GameManager *v37; // r0
GameManager *v38; // r0
int v39; // r11
GameManager *v40; // r0
int v41; // r0
int v42; // r3
int v43; // r11
int v44; // r10
int v45; // r10
int v46; // r11
GameManager *v47; // r0
_DWORD *v48; // r2
GameStatsManager *v49; // r0
GameStatsManager *hasCompletedStarLevel; // r0
GameStatsManager *v51; // r0
GameStatsManager *HasDiamonds; // r0
GameStatsManager *v53; // r0
GameStatsManager *v54; // r0
GameStatsManager *v55; // r0
GameStatsManager *v56; // r0
GameStatsManager *v57; // r0
GameStatsManager *v58; // r0
int v59; // r0
int v60; // r0
int v61; // r2
PlatformToolbox *v62; // r0
float v63; // r1
int v64; // r3
GameLevelManager *isNetworkAvailable; // r0
int v66; // r0
int v67; // r0
int v68; // s15
cocos2d::CCSequence *v69; // r7
cocos2d::CCFiniteTimeAction *v70; // r0
cocos2d::CCAction *v71; // r0
CCCircleWave *v72; // r0
CCCircleWave *v73; // r5
_BYTE *v74; // r3
char v75; // r2
char v76; // r1
void (__fastcall *v77)(CCCircleWave *, _DWORD *); // r7
cocos2d::CCSequence *v78; // r0
cocos2d::CCSequence *v79; // r6
cocos2d::CCFiniteTimeAction *v80; // r0
cocos2d::CCAction *v81; // r0
int v82; // r2
int v83; // r3
bool v84; // [sp+0h] [bp-6Ch]
const char *v85; // [sp+10h] [bp-5Ch]
int v86; // [sp+10h] [bp-5Ch]
int v87; // [sp+10h] [bp-5Ch]
int v88; // [sp+14h] [bp-58h]
int v89; // [sp+18h] [bp-54h]
_DWORD v90[2]; // [sp+2Ch] [bp-40h] BYREF
_BYTE v91[12]; // [sp+34h] [bp-38h] BYREF
int v92[3]; // [sp+40h] [bp-2Ch] BYREF
int v93[3]; // [sp+4Ch] [bp-20h] BYREF
int v94; // [sp+58h] [bp-14h] BYREF
int v95; // [sp+5Ch] [bp-10h]
int v96; // [sp+60h] [bp-Ch]
v2 = *((_DWORD *)this + 3074);
if ( v2 )
{
v3 = *(unsigned __int8 *)(v2 + 1648);
v4 = *(_BYTE *)(v2 + 1650);
}
else
{
v3 = 0;
v4 = 0;
}
if ( *((_BYTE *)this + 10614) || v2 )
{
PlayerObject::playCompleteEffect(*((PlayerObject **)this + 519), v3, v4);
PlayerObject::playCompleteEffect(*((PlayerObject **)this + 520), v3, v4);
}
v5 = (double *)((char *)this + 12168);
v6 = *((double *)this + 1520);
if ( v6 > *((double *)this + 1521) )
*v5 = v6;
v7 = *((_DWORD **)this + 352);
if ( v7[238] != 1
&& !*((_BYTE *)this + 10784)
&& !*((_BYTE *)this + 10836)
&& !*((_BYTE *)this + 11797)
&& v7[193] - v7[194] > 0
&& (!*((_BYTE *)this + 10614) || *((double *)this + 1407) < 10.0)
&& *v5 < 10.0 )
{
*((_BYTE *)this + 11705) = 1;
}
*((_BYTE *)this + 11272) = 1;
*((_BYTE *)this + 1438) = 1;
(*(void (__fastcall **)(PlayLayer *, int))(*(_DWORD *)this + 732))(this, 1065353216);
if ( !*((_BYTE *)this + 10836) && !*((_BYTE *)this + 11797) && *(_DWORD *)(*((_DWORD *)this + 352) + 952) == 2 )
{
GJBaseGameLayer::getCapacityString((GJBaseGameLayer *)v93);
v9 = *((_DWORD *)this + 352);
std::string::basic_string(&v94, (int)v93);
std::string::operator=((unsigned __int8 *)(v9 + 972), (unsigned __int8 *)&v94);
std::string::~string((int)&v94);
if ( !*((_BYTE *)this + 10784) )
{
v82 = *((_DWORD *)this + 521);
v83 = *((_DWORD *)this + 202) / 2;
if ( v82 )
*(_DWORD *)(v82 + 352) = v83;
*(_DWORD *)(*((_DWORD *)this + 352) + 1000) = v83;
}
std::string::~string((int)v93);
}
if ( *((_BYTE *)this + 11705) )
goto LABEL_22;
if ( !*((_BYTE *)this + 10836) && !*((_BYTE *)this + 11797) && !*((_BYTE *)this + 11798) )
{
v10 = *((unsigned __int8 *)this + 10784);
if ( !*((_BYTE *)this + 10784) )
{
v11 = *((unsigned __int8 *)this + 10784);
v12 = (cocos2d::CCArray *)cocos2d::CCDictionary::allKeys(*((cocos2d::CCDictionary **)this + 2704));
while ( v10 < cocos2d::CCArray::count(v12) )
{
v13 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v12, v10);
CString = (const char *)cocos2d::CCString::getCString(v13);
v94 = v11;
v95 = v11;
v96 = v11;
v15 = *((_DWORD *)this + 2704);
v85 = CString;
v16 = strlen(CString);
std::string::__init(&v94, v85, v16);
v17 = (_DWORD *)cocos2d::CCDictionary::objectForKey(v15, &v94);
std::string::~string((int)&v94);
if ( (*(int (__fastcall **)(_DWORD *))(*v17 + 900))(v17) == 31 )
{
v18 = v17[402];
switch ( v18 )
{
case 2:
v21 = *((_DWORD **)this + 352);
v21[213] = 1;
v22 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v21[212] = v22;
v21[211] = v22 + 1;
break;
case 3:
v23 = *((_DWORD **)this + 352);
v23[216] = 1;
v24 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v23[215] = v24;
v23[214] = v24 + 1;
break;
case 1:
v19 = *((_DWORD **)this + 352);
v19[210] = 1;
v20 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v19[209] = v20;
v19[208] = v20 + 1;
break;
}
}
++v10;
}
v25 = *((GJGameLevel **)this + 352);
if ( *((_DWORD *)v25 + 238) == 2 )
{
if ( GJGameLevel::areCoinsVerified(v25) )
{
v26 = *((_DWORD *)this + 352);
*(_BYTE *)(v26 + 608) = 1;
v27 = (int)(float)(vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0);
*(_DWORD *)(v26 + 604) = v27;
*(_DWORD *)(v26 + 600) = v27 + 1;
if ( *((_BYTE *)this + 10936) )
{
v28 = *((_DWORD *)this + 352);
GJBaseGameLayer::getRecordString((GJBaseGameLayer *)&v94, (bool)this);
if ( (*(_BYTE *)(v28 + 328) & 1) != 0 )
{
**(_BYTE **)(v28 + 336) = 0;
*(_DWORD *)(v28 + 332) = 0;
}
else
{
*(_BYTE *)(v28 + 329) = 0;
*(_BYTE *)(v28 + 328) = 0;
}
std::string::reserve((int *)(v28 + 328), 0);
v29 = v95;
v30 = v96;
*(_DWORD *)(v28 + 328) = v94;
*(_DWORD *)(v28 + 332) = v29;
*(_DWORD *)(v28 + 336) = v30;
v94 = 0;
v95 = 0;
v96 = 0;
std::string::~string((int)&v94);
}
}
}
}
}
if ( *((_BYTE *)this + 11705) )
{
LABEL_22:
PlayLayer::onQuit((GJGameLevel **)this);
}
else
{
if ( !*((_BYTE *)this + 10836) && !*((_BYTE *)this + 11797) )
{
TempMilliTime = PlayLayer::getTempMilliTime(this, v8);
v32 = (GameManager *)GJGameLevel::savePercentage(
*((GJGameLevel **)this + 352),
100,
*((_BYTE *)this + 10784),
*((_DWORD *)this + 2646),
(int)(TempMilliTime - *((double *)this + 1523) - *((double *)this + 1524)),
*((_BYTE *)this + 11708));
if ( !*((_BYTE *)this + 10784) )
{
GJBaseGameLayer::getRecordString((GJBaseGameLayer *)v91, (bool)this);
v33 = GJBaseGameLayer::countCollectedUserCoins(this);
PlayTimerMilli = (GameManager *)GJBaseGameLayer::getPlayTimerMilli(this);
v35 = (int)PlayTimerMilli;
v36 = (int *)((char *)this + 11264);
if ( *((_BYTE *)this + 10614) )
{
v37 = (GameManager *)GameManager::sharedState(PlayTimerMilli);
*((_DWORD *)v37 + 323) = *(_DWORD *)(*((_DWORD *)this + 352) + 956);
v38 = (GameManager *)GameManager::sharedState(v37);
*((_DWORD *)v38 + 324) = v35;
if ( *((_BYTE *)this + 1396) )
{
if ( !*(_BYTE *)(*((_DWORD *)this + 521) + 350) )
*((_DWORD *)this + 348) -= v35;
v39 = *((_DWORD *)this + 352);
v86 = *((_DWORD *)this + 348);
v88 = *v36;
v89 = *((_DWORD *)this + 2817);
std::string::basic_string(v92, (int)v91);
GJGameLevel::saveNewScore(v39, v86, 1, v88, v89, v33, (int)v92, 0);
v40 = (GameManager *)std::string::~string((int)v92);
v41 = GameManager::sharedState(v40);
v42 = *((_DWORD *)this + 348);
}
else
{
v41 = GameManager::sharedState(v38);
v42 = 0;
}
*(_DWORD *)(v41 + 1300) = v42;
v43 = *((_DWORD *)this + 352);
v44 = *v36;
v87 = *((_DWORD *)this + 2817);
std::string::basic_string(v93, (int)v91);
GJGameLevel::saveNewScore(v43, v35, 0, v44, v87, v33, (int)v93, 0);
std::string::~string((int)v93);
GJGameLevel::clearPlatformerSave(*((GJGameLevel **)this + 352));
PlayLayer::setLastSavedCheckpoint((CheckpointObject **)this, nullptr);
}
else
{
v45 = *v36;
v46 = *((_DWORD *)this + 2817);
std::string::basic_string(&v94, (int)v91);
GJGameLevel::saveNewScore(
*((_DWORD *)this + 352),
v35,
0,
v45,
v46,
v33,
(int)&v94,
v33 >= *(_DWORD *)(*((_DWORD *)this + 352) + 1052));
std::string::~string((int)&v94);
}
v32 = (GameManager *)std::string::~string((int)v91);
}
if ( *(_DWORD *)(*((_DWORD *)this + 352) + 952) == 1 )
{
v47 = (GameManager *)GameManager::sharedState(v32);
v32 = (GameManager *)GameManager::reportPercentageForLevel(
v47,
*(_DWORD *)(*((_DWORD *)this + 352) + 268) - *(_DWORD *)(*((_DWORD *)this + 352) + 272),
100,
*((_BYTE *)this + 10784));
}
if ( !*((_BYTE *)this + 10784) )
{
v48 = *((_DWORD **)this + 352);
if ( v48[238] != 2 )
{
if ( v48[193] - v48[194] > 0 )
{
v49 = (GameStatsManager *)GameStatsManager::sharedState(v32);
hasCompletedStarLevel = (GameStatsManager *)GameStatsManager::hasCompletedStarLevel(
v49,
*((GJGameLevel **)this + 352));
if ( !hasCompletedStarLevel )
*((_BYTE *)this + 12104) = 1;
v51 = (GameStatsManager *)GameStatsManager::sharedState(hasCompletedStarLevel);
*((_DWORD *)this + 3027) = GameStatsManager::awardCurrencyForLevel(v51, *((GJGameLevel **)this + 352));
HasDiamonds = (GameStatsManager *)GJGameLevel::levelHasDiamonds(*((GJGameLevel **)this + 352));
if ( HasDiamonds )
{
v53 = (GameStatsManager *)GameStatsManager::sharedState(HasDiamonds);
HasDiamonds = (GameStatsManager *)GameStatsManager::awardDiamondsForLevel(
v53,
*((GJGameLevel **)this + 352));
*((_DWORD *)this + 3028) = HasDiamonds;
}
if ( *((int *)this + 3027) > 0 )
{
v54 = (GameStatsManager *)GameStatsManager::sharedState(HasDiamonds);
*((_BYTE *)this + 12116) = GameStatsManager::awardSecretKey(v54);
}
}
v55 = (GameStatsManager *)GJBaseGameLayer::processItems(this);
v56 = (GameStatsManager *)GameStatsManager::sharedState(v55);
v57 = (GameStatsManager *)GameStatsManager::completedLevel(v56, *((GJGameLevel **)this + 352));
v58 = (GameStatsManager *)GameStatsManager::sharedState(v57);
GameStatsManager::checkCoinAchievement(v58, *((GJGameLevel **)this + 352));
}
}
if ( !*((_BYTE *)this + 10784)
&& !*((_BYTE *)this + 10836)
&& !*((_BYTE *)this + 10612)
&& !*((_BYTE *)this + 11797)
&& !*((_BYTE *)this + 11798) )
{
GJGameLevel::recordCompletion(*((GJGameLevel **)this + 352));
if ( PlayLayer::tracksPercent(this) )
{
GJGameLevel::dtAppendOrder(*((_DWORD *)this + 352), *((_DWORD *)this + 352) + 1216);
*((_DWORD *)this + 2996) = 100;
}
}
PlayLayer::dtCommitPlaytime(this);
PlayLayer::dtFlushCells(this);
if ( *((_BYTE *)this + 12032) )
{
v59 = *((_DWORD *)this + 353);
if ( v59 )
{
(*(void (__fastcall **)(int))(*(_DWORD *)v59 + 260))(v59);
*((_DWORD *)this + 353) = 0;
}
v60 = *((_DWORD *)this + 354);
if ( v60 )
{
(*(void (__fastcall **)(int))(*(_DWORD *)v60 + 260))(v60);
*((_DWORD *)this + 354) = 0;
}
}
if ( !*((_BYTE *)this + 10784) )
{
v61 = *((_DWORD *)this + 352);
if ( *(_DWORD *)(v61 + 952) == 2 )
*(_BYTE *)(v61 + 784) = *((_BYTE *)this + 12088) ^ 1;
}
}
v62 = (PlatformToolbox *)PlayLayer::commitJumps(this);
v64 = *((_DWORD *)this + 352);
if ( (*(_BYTE *)(v64 + 1124) || *(_BYTE *)(v64 + 1125))
&& *(_DWORD *)(v64 + 952) != 2
&& *(_DWORD *)(v64 + 756) - *(_DWORD *)(v64 + 760) == 1 )
{
isNetworkAvailable = (GameLevelManager *)PlatformToolbox::isNetworkAvailable(v62);
if ( isNetworkAvailable )
{
if ( *(_BYTE *)(*((_DWORD *)this + 352) + 1124) )
{
v66 = GameLevelManager::sharedState(isNetworkAvailable);
isNetworkAvailable = (GameLevelManager *)GameLevelManager::getLevelLeaderboard(
v66,
*((_DWORD *)this + 352),
4,
0);
}
if ( *(_BYTE *)(*((_DWORD *)this + 352) + 1125) )
{
v67 = GameLevelManager::sharedState(isNetworkAvailable);
GameLevelManager::getLevelLeaderboard(v67, *((_DWORD *)this + 352), 4, 1);
}
}
}
if ( !v3 )
{
do
{
v68 = v3++;
v69 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(COERCE_COCOS2D_CCDELAYTIME_((float)v68 * 0.05), v63);
v70 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(this, PlayLayer::spawnCircle, 0);
v71 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v69, v70, 0);
cocos2d::CCNode::runAction(this, v71);
}
while ( v3 != 5 );
v72 = CCCircleWave::create((CCCircleWave *)0x41200000, 1132068864, (cocos2d::CCActionTween *)0x3F000000, 0.0, v84);
*((_DWORD *)v72 + 74) = 4;
v73 = v72;
v74 = *((_BYTE **)this + 519);
v75 = v74[2107];
v76 = v74[2106];
LOBYTE(v74) = v74[2108];
*((_BYTE *)v72 + 281) = v75;
*((_BYTE *)v72 + 280) = v76;
*((_BYTE *)v72 + 282) = (_BYTE)v74;
v77 = *(void (__fastcall **)(CCCircleWave *, _DWORD *))(*(_DWORD *)v72 + 92);
PlayLayer::getEndPosition((PlayLayer *)v90, (int)this);
v77(v73, v90);
(*(void (__fastcall **)(_DWORD, CCCircleWave *, _DWORD))(**((_DWORD **)this + 609) + 232))(
*((_DWORD *)this + 609),
v73,
0);
}
if ( *((_BYTE *)this + 10784) )
{
v78 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create((cocos2d::CCDelayTime *)0x3DCCCCCD, v63);
v90[1] = 0;
v90[0] = PlayLayer::showCompleteText;
v79 = v78;
v80 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(this, PlayLayer::showCompleteText, 0);
v81 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v79, v80, 0);
cocos2d::CCNode::runAction(this, v81);
}
else
{
PlayLayer::showCompleteEffect((unsigned __int8 **)this, v63);
}
}
}