//
// PlayLayer::levelComplete from 0x1000b33c0 to 0x1000b4072 (3250 bytes)
//
// 3 xrefs:
// > PlayLayer::playPlatformerEndAnimationToPos @ 0x1000b6941
// > PlayLayer::playEndAnimationToPos @ 0x1000b6215
// > PlayLayer::playPlatformerEndAnimationToPos @ 0x1000b6726
//
// 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 __fastcall PlayLayer::levelComplete(PlayLayer *a1)
{
PlayLayer *v1; // rbx
EndTriggerGameObject *m_platformerEndTrigger; // rax
_BOOL4 m_noEffects; // r12d
bool *p_m_isPlatformer; // r15
bool v5; // r14
double m_attemptTime; // xmm1_8
double m_bestAttemptTime; // xmm0_8
GJGameLevel *m_level; // rax
double v9; // xmm0_8
GJGameLevel *v10; // r14
cocos2d::CCArray *v11; // r15
unsigned int v12; // r14d
GJGameLevel *v13; // rbx
unsigned int v14; // eax
cocos2d::CCString *v15; // rax
const char *CString; // r14
cocos2d::CCDictionary *m_collectedItems; // r13
size_t v18; // rax
size_t v19; // r12
char *v20; // rbx
size_t v21; // r15
_DWORD *v22; // rbx
int v23; // r14d
int v24; // eax
GJGameLevel *v25; // rbx
GJGameLevel *v26; // rbx
int v27; // eax
LevelSettingsObject *m_levelSettings; // rcx
GJGameLevel *v29; // rdi
GJGameLevel *v30; // rbx
float v31; // xmm0_4
GJGameLevel *v32; // rax
timeb *p_m_recordString; // rbx
double v34; // xmm0_8
int PlayTimerMilli; // r15d
GJGameLevel *v36; // r12
int m_M_ID; // ebx
PlayLayer *v38; // rcx
int m_points; // r12d
GJGameLevel *v40; // r14
int m_tickIndex; // ebx
int m_clickIndex; // r13d
int v43; // r13d
int v44; // r14d
GJGameLevel *v45; // rax
void **p_data; // rax
GameManager *v47; // rax
int v48; // ebx
PlayLayer *v49; // rbx
GJGameLevel *v50; // r13
int v51; // r14d
int v52; // r12d
GameManager *v53; // rax
bool m_isPracticeMode; // al
GJGameLevel *v55; // rcx
GameStatsManager *v56; // rax
GameStatsManager *v57; // rax
int m_orbs; // eax
GJGameLevel *v59; // rcx
GameStatsManager *v60; // rax
int v61; // eax
GameStatsManager *v62; // rax
GameStatsManager *v63; // rax
GameStatsManager *v64; // rax
GJGameLevel *v65; // rax
GameStatsManager *v66; // rax
GJGameLevel *v67; // rax
GJGameLevel *v68; // rax
GameLevelManager *v69; // rax
GameLevelManager *v70; // rax
unsigned int v71; // ebx
unsigned int v72; // eax
int v73; // ecx
int v74; // r8d
int v75; // r9d
cocos2d::CCAction *v76; // rax
unsigned int v77; // ebx
unsigned int v78; // eax
int v79; // ecx
int v80; // r8d
int v81; // r9d
cocos2d::CCAction *v82; // rax
unsigned int v83; // ebx
unsigned int v84; // eax
int v85; // ecx
int v86; // r8d
int v87; // r9d
cocos2d::CCAction *v88; // rax
unsigned int v89; // ebx
unsigned int v90; // eax
int v91; // ecx
int v92; // r8d
int v93; // r9d
cocos2d::CCAction *v94; // rax
unsigned int v95; // ebx
unsigned int v96; // eax
unsigned int v97; // edi
int v98; // ecx
int v99; // r8d
int v100; // r9d
cocos2d::CCAction *v101; // rsi
CCCircleWave *v102; // r14
PlayerObject *m_player1; // rax
__int16 v104; // cx
EndPortalObject *m_endPortal; // rdi
double v106; // xmm0_8
cocos2d::CCNode *v107; // r14
unsigned int v108; // ebx
unsigned int v109; // eax
int v110; // ecx
int v111; // r8d
int v112; // r9d
cocos2d::CCAction *v113; // rax
cocos2d::CCArray *v114; // [rsp+18h] [rbp-D8h]
std::string __str; // [rsp+20h] [rbp-D0h] BYREF
std::string v116; // [rsp+40h] [rbp-B0h] BYREF
std::string v117; // [rsp+60h] [rbp-90h] BYREF
std::string v118; // [rsp+80h] [rbp-70h] BYREF
int v119; // [rsp+A0h] [rbp-50h]
int v120; // [rsp+A4h] [rbp-4Ch]
timeb __dst; // [rsp+A8h] [rbp-48h] BYREF
void *__p; // [rsp+B8h] [rbp-38h]
PlayLayer *v123; // [rsp+C0h] [rbp-30h]
v1 = a1;
m_platformerEndTrigger = a1->m_platformerEndTrigger;
v123 = a1;
if ( m_platformerEndTrigger )
{
m_noEffects = m_platformerEndTrigger->m_noEffects;
LOBYTE(m_platformerEndTrigger) = m_platformerEndTrigger->m_instant;
p_m_isPlatformer = &a1->m_isPlatformer;
}
else
{
p_m_isPlatformer = &a1->m_isPlatformer;
LODWORD(m_platformerEndTrigger) = 0;
m_noEffects = 0;
if ( !a1->m_isPlatformer )
goto LABEL_5;
}
v5 = (char)m_platformerEndTrigger;
PlayerObject::playCompleteEffect(a1->m_player1, m_noEffects, (bool)m_platformerEndTrigger);
v1 = v123;
PlayerObject::playCompleteEffect(v123->m_player2, m_noEffects, v5);
LODWORD(m_platformerEndTrigger) = m_noEffects;
LABEL_5:
v119 = (int)m_platformerEndTrigger;
m_attemptTime = v1->m_attemptTime;
m_bestAttemptTime = v1->m_bestAttemptTime;
if ( m_attemptTime > m_bestAttemptTime )
{
v1->m_bestAttemptTime = m_attemptTime;
m_bestAttemptTime = m_attemptTime;
}
m_level = v1->m_level;
if ( m_level->m_levelType != Main
&& !v1->m_isPracticeMode
&& !v1->m_isTestMode
&& !v1->m_isIgnoreDamageEnabled
&& m_level->m_stars.random > m_level->m_stars.seed
&& (!*p_m_isPlatformer || v1->m_timePlayed < 10.0)
&& m_bestAttemptTime < 10.0 )
{
v1->m_unk36cd = 1;
}
v1->m_levelEndAnimationStarted = 1;
*(_QWORD *)&v9 = 1065353216;
((void (__fastcall *)(PlayLayer *, float))v1->updateTimeWarp)(v1, 1.0);
if ( v1->m_isTestMode || v1->m_isIgnoreDamageEnabled || v1->m_level->m_levelType != Editor )
goto LABEL_26;
GJBaseGameLayer::getCapacityString(&__dst, v1);
v10 = v1->m_level;
if ( (__dst.time & 1) != 0 )
{
sub_100006B70(&__str, __p, *(unsigned __int64 *)&__dst.millitm, COERCE_DOUBLE(1065353216));
}
else
{
__str.__r_.__value_.__r.__words[2] = (std::string::size_type)__p;
v9 = *(double *)&__dst.time;
*(timeb *)&__str.__r_.__value_.__l.0 = __dst;
}
std::string::operator=((std::string *)&v10->m_capacityString, &__str);
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) == 0 )
{
if ( v1->m_isPracticeMode )
goto LABEL_24;
LABEL_51:
v27 = (signed int)v1->m_gameState.m_commandIndex / 2;
m_levelSettings = v1->m_levelSettings;
if ( m_levelSettings )
m_levelSettings->m_propertykA44 = v27;
v1->m_level->GJBaseGameLayer::m_timestamp = v27;
if ( (__dst.time & 1) == 0 )
goto LABEL_26;
goto LABEL_25;
}
operator delete(__str.__r_.__value_.__l.__data_);
if ( !v1->m_isPracticeMode )
goto LABEL_51;
LABEL_24:
if ( (__dst.time & 1) != 0 )
LABEL_25:
operator delete(__p);
LABEL_26:
if ( v1->m_unk36cd )
goto LABEL_62;
if ( !v1->m_isTestMode && !v1->m_isIgnoreDamageEnabled && !v1->m_isPracticeMode )
{
v11 = cocos2d::CCDictionary::allKeys(v1->m_collectedItems);
if ( (unsigned int)sub_100720070(v11) )
{
v12 = 0;
v114 = v11;
do
{
v120 = v12;
v15 = (cocos2d::CCString *)sub_1007200C0(v11, v12);
CString = cocos2d::CCString::getCString(v15);
m_collectedItems = v1->m_collectedItems;
v18 = strlen(CString);
if ( v18 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v9);
v19 = v18;
if ( v18 >= 0x17 )
{
v21 = (v18 | 7) + 1;
if ( (v18 | 7) == 0x17 )
v21 = 26;
v20 = (char *)operator new(v21);
__p = v20;
__dst.time = v21 + 1;
v11 = v114;
*(_QWORD *)&__dst.millitm = v19;
}
else
{
LOBYTE(__dst.time) = 2 * v18;
v20 = (char *)&__dst.time + 1;
if ( !v18 )
goto LABEL_42;
}
memmove(v20, CString, v19);
LABEL_42:
v20[v19] = 0;
v22 = (_DWORD *)cocos2d::CCDictionary::objectForKey_1(m_collectedItems, &__dst);
v23 = v120;
if ( (__dst.time & 1) != 0 )
operator delete(__p);
if ( (*(unsigned int (__fastcall **)(_DWORD *))(*(_QWORD *)v22 + 1784LL))(v22) == 31 )
{
v24 = v22[448];
switch ( v24 )
{
case 1:
v26 = v123->m_level;
v26->m_firstCoinVerified.value = 1;
HIDWORD(v9) = 0;
*(float *)&v9 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
v26->m_firstCoinVerified.seed = (int)*(float *)&v9;
v26->m_firstCoinVerified.random = (int)*(float *)&v9 + 1;
break;
case 2:
v13 = v123->m_level;
v13->m_secondCoinVerified.value = 1;
HIDWORD(v9) = 0;
*(float *)&v9 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
v13->m_secondCoinVerified.seed = (int)*(float *)&v9;
v13->m_secondCoinVerified.random = (int)*(float *)&v9 + 1;
break;
case 3:
v25 = v123->m_level;
v25->m_thirdCoinVerified.value = 1;
HIDWORD(v9) = 0;
*(float *)&v9 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
v25->m_thirdCoinVerified.seed = (int)*(float *)&v9;
v25->m_thirdCoinVerified.random = (int)*(float *)&v9 + 1;
break;
}
}
v12 = v23 + 1;
v14 = sub_100720070(v11);
v1 = v123;
}
while ( v12 < v14 );
}
v29 = v1->m_level;
if ( v29->m_levelType == Editor && GJGameLevel::areCoinsVerified(v29) )
{
v30 = v123->m_level;
v30->m_isVerifiedRaw = 1;
v31 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
v30->m_isVerified.seed = (int)v31;
v30->m_isVerified.random = (int)v31 + 1;
v1 = v123;
if ( v123->m_recordInputs )
{
GJBaseGameLayer::getRecordString(&__dst, v123, 1);
v32 = v1->m_level;
p_m_recordString = (timeb *)&v32->m_recordString;
if ( (v32->m_recordString.m_data.m_short.sizex2 & 1) != 0 )
operator delete(v32->m_recordString.m_data.m_long.longStorage);
p_m_recordString[1].time = (time_t)__p;
*p_m_recordString = __dst;
v1 = v123;
}
}
}
if ( v1->m_unk36cd )
{
LABEL_62:
PlayLayer::onQuit(v1);
return;
}
if ( !v1->m_isTestMode && !v1->m_isIgnoreDamageEnabled )
{
ftime(&__dst);
v34 = (double)(__dst.millitm + 1000 * (__dst.time & 0xFFFFF)) / 1000.0 - v1->m_currentTime - v1->m_pauseDelta;
GJGameLevel::savePercentage(v1->m_level, 100, v1->m_isPracticeMode, v1->m_clicks, (int)v34, v1->m_damageVerified);
if ( v1->m_isPracticeMode )
{
LABEL_90:
if ( v1->m_level->m_levelType == Main )
{
v53 = GameManager::sharedState();
GameManager::reportPercentageForLevel(
v53,
v1->m_level->m_levelID.random - v1->m_level->m_levelID.seed,
100,
v1->m_isPracticeMode);
}
m_isPracticeMode = v1->m_isPracticeMode;
if ( !m_isPracticeMode )
{
v55 = v1->m_level;
if ( v55->m_levelType != Editor )
{
if ( v55->m_stars.random > v55->m_stars.seed )
{
v56 = GameStatsManager::sharedState();
if ( !GameStatsManager::hasCompletedStarLevel(v56, v1->m_level) )
v1->m_endLayerStars = 1;
v57 = GameStatsManager::sharedState();
GameStatsManager::awardCurrencyForLevel(v57, v1->m_level);
v1->m_orbs = m_orbs;
v59 = v1->m_level;
if ( v59->m_dailyID.random > v59->m_dailyID.seed || v59->m_gauntletLevel )
{
v60 = GameStatsManager::sharedState();
GameStatsManager::awardDiamondsForLevel(v60, v1->m_level);
v1->m_diamonds = v61;
m_orbs = v1->m_orbs;
}
if ( m_orbs > 0 )
{
v62 = GameStatsManager::sharedState();
v1->m_secretKey = GameStatsManager::awardSecretKey(v62);
}
}
GJBaseGameLayer::processItems(v1);
v63 = GameStatsManager::sharedState();
GameStatsManager::completedLevel(v63, v1->m_level);
v64 = GameStatsManager::sharedState();
GameStatsManager::checkCoinAchievement(v64, v1->m_level);
m_isPracticeMode = v1->m_isPracticeMode;
}
}
if ( !m_isPracticeMode )
{
v65 = v1->m_level;
if ( v65->m_levelType == Editor )
v65->m_autoLevel = !v1->m_hasJumped;
}
goto LABEL_106;
}
GJBaseGameLayer::getRecordString(&__dst, v1, 1);
v120 = GJBaseGameLayer::countCollectedUserCoins(v1);
PlayTimerMilli = GJBaseGameLayer::getPlayTimerMilli(v1);
v1 = v123;
v36 = v123->m_level;
if ( v123->m_isPlatformer )
{
m_M_ID = v36->m_M_ID;
GameManager::sharedState()->m_leaderboardLevelID = m_M_ID;
GameManager::sharedState()->m_leaderboardLevelTime = PlayTimerMilli;
v38 = v123;
if ( v123->m_gameState.m_unkBool32 )
{
m_points = v123->m_gameState.m_points;
if ( !v123->m_levelSettings->m_noTimePenalty )
{
m_points -= PlayTimerMilli;
v123->m_gameState.m_points = m_points;
}
v40 = v38->m_level;
m_tickIndex = v38->m_tickIndex;
m_clickIndex = v38->m_clickIndex;
if ( (__dst.time & 1) != 0 )
{
sub_100006B70(&v116, __p, *(unsigned __int64 *)&__dst.millitm, v34);
}
else
{
v116.__r_.__value_.__r.__words[2] = (std::string::size_type)__p;
v34 = *(double *)&__dst.time;
*(timeb *)&v116.__r_.__value_.__l.0 = __dst;
}
GJGameLevel::saveNewScore((int)v40, m_points, 1, m_tickIndex, m_clickIndex, v120, &v116, 0);
v49 = v123;
if ( (*(_BYTE *)&v116.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v116.__r_.__value_.__l.__data_);
v48 = v49->m_gameState.m_points;
v47 = GameManager::sharedState();
}
else
{
v47 = GameManager::sharedState();
v48 = 0;
}
v47->m_leaderboardLevelPoints = v48;
v50 = v123->m_level;
v51 = v123->m_tickIndex;
v52 = v123->m_clickIndex;
if ( (__dst.time & 1) != 0 )
{
sub_100006B70(&v117, __p, *(unsigned __int64 *)&__dst.millitm, v34);
}
else
{
v117.__r_.__value_.__r.__words[2] = (std::string::size_type)__p;
*(timeb *)&v117.__r_.__value_.__l.0 = __dst;
}
GJGameLevel::saveNewScore((int)v50, PlayTimerMilli, 0, v51, v52, v120, &v117, 0);
v1 = v123;
if ( (*(_BYTE *)&v117.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_88;
p_data = (void **)&v117.__r_.__value_.__l.__data_;
}
else
{
v43 = v123->m_tickIndex;
v44 = v123->m_clickIndex;
if ( (__dst.time & 1) != 0 )
{
sub_100006B70(&v118, __p, *(unsigned __int64 *)&__dst.millitm, v34);
v1 = v123;
v45 = v123->m_level;
}
else
{
v118.__r_.__value_.__r.__words[2] = (std::string::size_type)__p;
*(timeb *)&v118.__r_.__value_.__l.0 = __dst;
v45 = v36;
}
GJGameLevel::saveNewScore((int)v36, PlayTimerMilli, 0, v43, v44, v120, &v118, v120 >= v45->m_coinsTime);
if ( (*(_BYTE *)&v118.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_88:
if ( (__dst.time & 1) != 0 )
operator delete(__p);
goto LABEL_90;
}
p_data = (void **)&v118.__r_.__value_.__l.__data_;
}
operator delete(*p_data);
goto LABEL_88;
}
LABEL_106:
v66 = GameStatsManager::sharedState();
GameStatsManager::incrementStat(v66, "1", v1->m_uncommittedJumps);
v1->m_uncommittedJumps = 0;
v67 = v1->m_level;
if ( (v67->m_savedTime || v67->m_savedPoints)
&& v67->m_levelType != Editor
&& v67->m_demon.random - v67->m_demon.seed == 1
&& PlatformToolbox::isNetworkAvailable() )
{
v68 = v1->m_level;
if ( v68->m_savedTime )
{
v69 = GameLevelManager::sharedState();
GameLevelManager::getLevelLeaderboard(v69, v1->m_level, (LevelLeaderboardType)4, Time);
v68 = v1->m_level;
}
if ( v68->m_savedPoints )
{
v70 = GameLevelManager::sharedState();
GameLevelManager::getLevelLeaderboard(v70, v1->m_level, (LevelLeaderboardType)4, Points);
}
}
if ( !(_BYTE)v119 )
{
v71 = (unsigned int)cocos2d::CCDelayTime::create(0.0);
v72 = (unsigned int)cocos2d::CCCallFunc::create(
v123,
(cocos2d::SEL_CallFunc)(unsigned __int64)PlayLayer::spawnCircle);
v76 = (cocos2d::CCAction *)sub_1003B5760(v71, v72, 0, v73, v74, v75);
cocos2d::CCNode::runAction(v123, v76);
v77 = (unsigned int)cocos2d::CCDelayTime::create(0.050000001);
v78 = (unsigned int)cocos2d::CCCallFunc::create(
v123,
(cocos2d::SEL_CallFunc)(unsigned __int64)PlayLayer::spawnCircle);
v82 = (cocos2d::CCAction *)sub_1003B5760(v77, v78, 0, v79, v80, v81);
cocos2d::CCNode::runAction(v123, v82);
v83 = (unsigned int)cocos2d::CCDelayTime::create(0.1);
v84 = (unsigned int)cocos2d::CCCallFunc::create(
v123,
(cocos2d::SEL_CallFunc)(unsigned __int64)PlayLayer::spawnCircle);
v88 = (cocos2d::CCAction *)sub_1003B5760(v83, v84, 0, v85, v86, v87);
cocos2d::CCNode::runAction(v123, v88);
v89 = (unsigned int)cocos2d::CCDelayTime::create(0.15000001);
v90 = (unsigned int)cocos2d::CCCallFunc::create(
v123,
(cocos2d::SEL_CallFunc)(unsigned __int64)PlayLayer::spawnCircle);
v94 = (cocos2d::CCAction *)sub_1003B5760(v89, v90, 0, v91, v92, v93);
cocos2d::CCNode::runAction(v123, v94);
v95 = (unsigned int)cocos2d::CCDelayTime::create(0.2);
v96 = (unsigned int)cocos2d::CCCallFunc::create(
v123,
(cocos2d::SEL_CallFunc)(unsigned __int64)PlayLayer::spawnCircle);
v97 = v95;
v1 = v123;
v101 = (cocos2d::CCAction *)sub_1003B5760(v97, v96, 0, v98, v99, v100);
cocos2d::CCNode::runAction(v1, v101);
v102 = CCCircleWave::create_1(10.0, 250.0, 0.5, 0);
v102->m_lineWidth = 4;
m_player1 = v1->m_player1;
v104 = *(_WORD *)&m_player1->m_playerColor1.r;
v102->m_color.b = m_player1->m_playerColor1.b;
*(_WORD *)&v102->m_color.r = v104;
if ( !v1->m_isPlatformer )
{
m_endPortal = v1->m_endPortal;
if ( m_endPortal )
{
if ( !v1->m_platformerEndTrigger )
((void (__fastcall *)(EndPortalObject *))m_endPortal->getPosition)(m_endPortal);
}
}
v106 = sub_10028CC60(&__dst);
((void (__fastcall *)(CCCircleWave *, timeb *, double))v102->setPosition)(v102, &__dst, v106);
((void (__fastcall *)(cocos2d::CCLayer *, CCCircleWave *, _QWORD))v1->m_objectLayer->addChild_0)(
v1->m_objectLayer,
v102,
0);
}
if ( v1->m_isPracticeMode )
{
v107 = v1;
v108 = (unsigned int)cocos2d::CCDelayTime::create(0.1);
v109 = (unsigned int)cocos2d::CCCallFunc::create(
v107,
(cocos2d::SEL_CallFunc)(unsigned __int64)PlayLayer::showCompleteText);
v113 = (cocos2d::CCAction *)sub_1003B5760(v108, v109, 0, v110, v111, v112);
cocos2d::CCNode::runAction(v107, v113);
}
else
{
PlayLayer::showCompleteEffect(v1);
}
}