//
// PlayLayer::levelComplete from 0x100119948 to 0x10011a23c (2292 bytes)
//
// 3 xrefs:
// > PlayLayer::playPlatformerEndAnimationToPos @ 0x10011befc
// > PlayLayer::playEndAnimationToPos @ 0x10011ba4c
// > PlayLayer::playPlatformerEndAnimationToPos @ 0x10011be94
//
// 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)
{
bool *p_m_isPlatformer; // x26
EndTriggerGameObject *m_platformerEndTrigger; // x8
bool m_noEffects; // w20
bool m_instant; // w21
bool v6; // w27
double m_attemptTime; // d1
double m_bestAttemptTime; // d0
GJGameLevel *m_level; // x8
double v10; // d1
GJGameLevel *v11; // x20
int v12; // w8
LevelSettingsObject *m_levelSettings; // x9
cocos2d::CCArray *v14; // x20
__int64 v15; // x21
cocos2d::CCString *v16; // x0
char *CString; // x0
cocos2d::CCDictionary *m_collectedItems; // x22
_DWORD *v19; // x22
int v20; // w8
GJGameLevel *v21; // x22
float v22; // s0
GJGameLevel *v23; // x22
float v24; // s0
GJGameLevel *v25; // x22
float v26; // s0
GJGameLevel *v27; // x0
GJGameLevel *v28; // x20
float v29; // s0
GJGameLevel *v30; // x8
void **p_m_recordString; // x20
int PlayTimerMilli; // w21
GJGameLevel *v33; // x22
int m_M_ID; // w22
int m_points; // w22
GJGameLevel *v36; // x25
GameManager *v37; // x0
int v38; // w22
std::string *p_dst; // x8
GJGameLevel *v40; // x24
GameManager *v41; // x0
GJGameLevel *v42; // x8
GameStatsManager *v43; // x0
GameStatsManager *v44; // x0
int m_orbs; // w0
GJGameLevel *v46; // x8
GameStatsManager *v47; // x0
int v48; // w0
GameStatsManager *v49; // x0
GameStatsManager *v50; // x0
GameStatsManager *v51; // x0
GJGameLevel *v52; // x8
GameStatsManager *v53; // x0
GJGameLevel *v54; // x8
GJGameLevel *v55; // x8
GameLevelManager *v56; // x0
GameLevelManager *v57; // x0
unsigned int i; // w22
cocos2d::CCDelayTime *v59; // x21
cocos2d::CCAction *v60; // x0
CCCircleWave *v61; // x20
PlayerObject *m_player1; // x8
__int16 v63; // w9
cocos2d::CCDelayTime *v64; // x20
cocos2d::CCAction *v65; // x0
std::string __dst; // [xsp+10h] [xbp-F0h] BYREF
std::string v67; // [xsp+30h] [xbp-D0h] BYREF
std::string __p; // [xsp+50h] [xbp-B0h] BYREF
std::string __str; // [xsp+70h] [xbp-90h] BYREF
std::string v70; // [xsp+88h] [xbp-78h] BYREF
cocos2d::CCPoint EndPosition; // 0:kr00_8.8
cocos2d::SEL_CallFunc v72; // 0:x1.16
cocos2d::SEL_CallFunc v73; // 0:x1.16
p_m_isPlatformer = &a1->m_isPlatformer;
m_platformerEndTrigger = a1->m_platformerEndTrigger;
if ( m_platformerEndTrigger )
{
m_noEffects = m_platformerEndTrigger->m_noEffects;
m_instant = m_platformerEndTrigger->m_instant;
}
else
{
m_instant = 0;
m_noEffects = 0;
v6 = 0;
if ( !*p_m_isPlatformer )
goto LABEL_5;
}
PlayerObject::playCompleteEffect(a1->m_player1, m_noEffects, m_instant);
PlayerObject::playCompleteEffect(a1->m_player2, m_noEffects, m_instant);
v6 = m_noEffects;
LABEL_5:
m_attemptTime = a1->m_attemptTime;
m_bestAttemptTime = a1->m_bestAttemptTime;
if ( m_attemptTime > m_bestAttemptTime )
{
a1->m_bestAttemptTime = m_attemptTime;
m_bestAttemptTime = m_attemptTime;
}
m_level = a1->m_level;
if ( m_level->m_levelType != Main
&& !p_m_isPlatformer[290]
&& !p_m_isPlatformer[354]
&& !p_m_isPlatformer[1784]
&& m_level->m_stars.random > m_level->m_stars.seed )
{
if ( *p_m_isPlatformer )
{
v10 = 10.0;
if ( a1->m_timePlayed >= 10.0 )
goto LABEL_18;
}
else
{
v10 = 10.0;
}
if ( m_bestAttemptTime < v10 )
p_m_isPlatformer[1631] = 1;
}
LABEL_18:
p_m_isPlatformer[1074] = 1;
((void (__fastcall *)(PlayLayer *, float))a1->updateTimeWarp)(a1, 1.0);
if ( !p_m_isPlatformer[354] && !p_m_isPlatformer[1784] && a1->m_level->m_levelType == Editor )
{
GJBaseGameLayer::getCapacityString(&v70, a1);
v11 = a1->m_level;
if ( SHIBYTE(v70.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__str, v70.__r_.__value_.__l.__data_, v70.__r_.__value_.__l.__size_);
else
__str = v70;
std::string::operator=((std::string *)&v11->m_capacityString, &__str);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
if ( !p_m_isPlatformer[290] )
{
v12 = (signed int)a1->m_gameState.m_commandIndex / 2;
m_levelSettings = a1->m_levelSettings;
if ( m_levelSettings )
m_levelSettings->m_propertykA44 = v12;
a1->m_level->GJBaseGameLayer::m_timestamp = v12;
}
if ( SHIBYTE(v70.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v70.__r_.__value_.__l.__data_);
}
if ( p_m_isPlatformer[1631] )
goto LABEL_55;
if ( !p_m_isPlatformer[354] && !p_m_isPlatformer[1784] && !p_m_isPlatformer[290] )
{
v14 = cocos2d::CCDictionary::allKeys(a1->m_collectedItems);
if ( (unsigned int)sub_10024A36C(v14) )
{
v15 = 0;
do
{
v16 = (cocos2d::CCString *)sub_10024A388(v14, v15);
CString = (char *)cocos2d::CCString::getCString(v16);
m_collectedItems = a1->m_collectedItems;
sub_100009900(&v70, CString);
v19 = (_DWORD *)cocos2d::CCDictionary::objectForKey_1(m_collectedItems, &v70);
if ( SHIBYTE(v70.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v70.__r_.__value_.__l.__data_);
if ( (*(unsigned int (__fastcall **)(_DWORD *))(*(_QWORD *)v19 + 1784LL))(v19) == 31 )
{
v20 = v19[448];
switch ( v20 )
{
case 1:
v25 = a1->m_level;
v25->m_firstCoinVerified.value = 1;
v26 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v25->m_firstCoinVerified.seed = (int)v26;
v25->m_firstCoinVerified.random = (int)v26 + 1;
break;
case 2:
v23 = a1->m_level;
v23->m_secondCoinVerified.value = 1;
v24 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v23->m_secondCoinVerified.seed = (int)v24;
v23->m_secondCoinVerified.random = (int)v24 + 1;
break;
case 3:
v21 = a1->m_level;
v21->m_thirdCoinVerified.value = 1;
v22 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v21->m_thirdCoinVerified.seed = (int)v22;
v21->m_thirdCoinVerified.random = (int)v22 + 1;
break;
}
}
v15 = (unsigned int)(v15 + 1);
}
while ( (unsigned int)v15 < (unsigned int)sub_10024A36C(v14) );
}
v27 = a1->m_level;
if ( v27->m_levelType == Editor && GJGameLevel::areCoinsVerified(v27) )
{
v28 = a1->m_level;
v28->m_isVerifiedRaw = 1;
v29 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v28->m_isVerified.seed = (int)v29;
v28->m_isVerified.random = (int)v29 + 1;
if ( p_m_isPlatformer[474] )
{
GJBaseGameLayer::getRecordString(&v70, a1, 1);
v30 = a1->m_level;
p_m_recordString = (void **)&v30->m_recordString;
if ( v30->m_recordString.m_data.m_short.shortStorage.__elems_[22] < 0 )
operator delete(*p_m_recordString);
*(std::string *)p_m_recordString = v70;
}
}
}
if ( p_m_isPlatformer[1631] )
{
LABEL_55:
PlayLayer::onQuit(a1);
return;
}
if ( !p_m_isPlatformer[354] && !p_m_isPlatformer[1784] )
{
ftime((timeb *)&v70);
GJGameLevel::savePercentage(
a1->m_level,
100,
p_m_isPlatformer[290],
a1->m_clicks,
(int)((double)(LOWORD(v70.__r_.__value_.__r.__words[1])
+ 1000 * (unsigned __int64)((__int64)v70.__r_.__value_.__l.__data_ & 0xFFFFF))
/ 1000.0
- a1->m_currentTime
- a1->m_pauseDelta),
p_m_isPlatformer[1634]);
if ( p_m_isPlatformer[290] )
{
LABEL_83:
if ( a1->m_level->m_levelType == Main )
{
v41 = GameManager::sharedState();
GameManager::reportPercentageForLevel(
v41,
a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed,
100,
p_m_isPlatformer[290]);
}
if ( !p_m_isPlatformer[290] )
{
v42 = a1->m_level;
if ( v42->m_levelType == Editor )
goto LABEL_96;
if ( v42->m_stars.random > v42->m_stars.seed )
{
v43 = GameStatsManager::sharedState();
if ( !GameStatsManager::hasCompletedStarLevel(v43, a1->m_level) )
p_m_isPlatformer[2062] = 1;
v44 = GameStatsManager::sharedState();
GameStatsManager::awardCurrencyForLevel(v44, a1->m_level);
a1->m_orbs = m_orbs;
v46 = a1->m_level;
if ( v46->m_dailyID.random > v46->m_dailyID.seed || v46->m_gauntletLevel )
{
v47 = GameStatsManager::sharedState();
GameStatsManager::awardDiamondsForLevel(v47, a1->m_level);
a1->m_diamonds = v48;
m_orbs = a1->m_orbs;
}
if ( m_orbs >= 1 )
{
v49 = GameStatsManager::sharedState();
p_m_isPlatformer[2074] = GameStatsManager::awardSecretKey(v49);
}
}
GJBaseGameLayer::processItems(a1);
v50 = GameStatsManager::sharedState();
GameStatsManager::completedLevel(v50, a1->m_level);
v51 = GameStatsManager::sharedState();
GameStatsManager::checkCoinAchievement(v51, a1->m_level);
if ( !p_m_isPlatformer[290] )
{
LABEL_96:
v52 = a1->m_level;
if ( v52->m_levelType == Editor )
v52->m_autoLevel = !p_m_isPlatformer[2046];
}
}
goto LABEL_98;
}
GJBaseGameLayer::getRecordString(&v70, a1, 1);
GJBaseGameLayer::countCollectedUserCoins(a1);
PlayTimerMilli = GJBaseGameLayer::getPlayTimerMilli(a1);
v33 = a1->m_level;
if ( *p_m_isPlatformer )
{
m_M_ID = v33->m_M_ID;
GameManager::sharedState()->m_leaderboardLevelID = m_M_ID;
GameManager::sharedState()->m_leaderboardLevelTime = PlayTimerMilli;
if ( a1->m_gameState.m_unkBool32 )
{
m_points = a1->m_gameState.m_points;
if ( !a1->m_levelSettings->m_noTimePenalty )
{
m_points -= PlayTimerMilli;
a1->m_gameState.m_points = m_points;
}
v36 = a1->m_level;
if ( SHIBYTE(v70.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__p, v70.__r_.__value_.__l.__data_, v70.__r_.__value_.__l.__size_);
else
__p = v70;
GJGameLevel::storeNewLocalScore(v36, m_points, 1);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
v38 = a1->m_gameState.m_points;
v37 = GameManager::sharedState();
}
else
{
v37 = GameManager::sharedState();
v38 = 0;
}
v37->m_leaderboardLevelPoints = v38;
v40 = a1->m_level;
if ( SHIBYTE(v70.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&v67, v70.__r_.__value_.__l.__data_, v70.__r_.__value_.__l.__size_);
else
v67 = v70;
GJGameLevel::storeNewLocalScore(v40, PlayTimerMilli, 0);
if ( (SHIBYTE(v67.__r_.__value_.__r.__words[2]) & 0x80000000) == 0 )
goto LABEL_81;
p_dst = &v67;
}
else
{
if ( SHIBYTE(v70.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__dst, v70.__r_.__value_.__l.__data_, v70.__r_.__value_.__l.__size_);
else
__dst = v70;
GJGameLevel::storeNewLocalScore(v33, PlayTimerMilli, 0);
if ( (SHIBYTE(__dst.__r_.__value_.__r.__words[2]) & 0x80000000) == 0 )
{
LABEL_81:
if ( SHIBYTE(v70.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v70.__r_.__value_.__l.__data_);
goto LABEL_83;
}
p_dst = &__dst;
}
operator delete(p_dst->__r_.__value_.__l.__data_);
goto LABEL_81;
}
LABEL_98:
v53 = GameStatsManager::sharedState();
GameStatsManager::incrementStat(v53, "1", a1->m_uncommittedJumps);
a1->m_uncommittedJumps = 0;
v54 = a1->m_level;
if ( (v54->m_savedTime || v54->m_savedPoints)
&& v54->m_levelType != Editor
&& v54->m_demon.random - v54->m_demon.seed == 1
&& PlatformToolbox::isNetworkAvailable() )
{
v55 = a1->m_level;
if ( v55->m_savedTime )
{
v56 = GameLevelManager::sharedState();
GameLevelManager::getLevelLeaderboard(v56, a1->m_level, (LevelLeaderboardType)4, Time);
v55 = a1->m_level;
}
if ( v55->m_savedPoints )
{
v57 = GameLevelManager::sharedState();
GameLevelManager::getLevelLeaderboard(v57, a1->m_level, (LevelLeaderboardType)4, Points);
}
}
if ( !v6 )
{
for ( i = 0; i != 5; ++i )
{
v59 = cocos2d::CCDelayTime::create((float)i * 0.05);
v72.ptr = (void (*)(void))PlayLayer::spawnCircle;
v72.adj = 0;
cocos2d::CCCallFunc::create(a1, v72);
v60 = (cocos2d::CCAction *)sub_10018A494(v59);
cocos2d::CCNode::runAction(a1, v60);
}
v61 = CCCircleWave::create_1(10.0, 250.0, 0.5, 0);
v61->m_lineWidth = 4;
m_player1 = a1->m_player1;
v63 = *(_WORD *)&m_player1->m_playerColor1.r;
v61->m_color.b = m_player1->m_playerColor1.b;
*(_WORD *)&v61->m_color.r = v63;
EndPosition = PlayLayer::getEndPosition(a1);
((void (__fastcall *)(CCCircleWave *, std::string *, float, float))v61->setPosition)(
v61,
&v70,
EndPosition.x,
EndPosition.y);
((void (__fastcall *)(cocos2d::CCLayer *, CCCircleWave *, _QWORD))a1->m_objectLayer->addChild_0)(
a1->m_objectLayer,
v61,
0);
}
if ( p_m_isPlatformer[290] )
{
v64 = cocos2d::CCDelayTime::create(0.1);
v73.ptr = (void (*)(void))PlayLayer::showCompleteText;
v73.adj = 0;
cocos2d::CCCallFunc::create(a1, v73);
v65 = (cocos2d::CCAction *)sub_10018A494(v64);
cocos2d::CCNode::runAction(a1, v65);
}
else
{
PlayLayer::showCompleteEffect(a1);
}
}