//
// LevelInfoLayer::downloadLevel from 0x14041f070 to 0x14041f39e (814 bytes)
//
// 5 xrefs:
// > LevelInfoLayer::init @ 0x14041cdb2
// > LevelInfoLayer::onPlay @ 0x140421500
// > LevelInfoLayer::onEdit @ 0x140422a66
// > LevelInfoLayer::onUpdate @ 0x1404243fa
// > ??> @ 0x1409267a4
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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:32:08 +0000
//
// Hidden C++ exception states: #wind=8
__int64 __fastcall LevelInfoLayer::downloadLevel(__int64 a1)
{
__int64 v2; // rdx
__int64 v3; // r9
int v4; // eax
__int64 v5; // rcx
bool GameVariable; // al
int v7; // edx
__int64 v8; // rax
__int64 v9; // rax
__int64 i; // r8
int v11; // ecx
int v12; // edx
__int64 v13; // rax
__int64 v14; // rax
__int64 j; // r8
int v16; // ecx
_DWORD *v17; // rax
int v18; // edi
unsigned int v19; // esi
cocos2d::CCActionManager **v20; // rcx
__int64 v21; // rbx
__int64 result; // rax
void *v23; // [rsp+30h] [rbp+8h]
void *v24; // [rsp+30h] [rbp+8h]
void *v25; // [rsp+30h] [rbp+8h]
void *v26; // [rsp+30h] [rbp+8h]
void *v27; // [rsp+30h] [rbp+8h]
void *v28; // [rsp+30h] [rbp+8h]
void *v29; // [rsp+30h] [rbp+8h]
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 496) + 336LL))(*(_QWORD *)(a1 + 496), 0);
LOBYTE(v2) = 1;
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 648) + 336LL))(*(_QWORD *)(a1 + 648), v2);
v3 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v23 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v23);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v3 = *(_QWORD *)&qword_14090BFB0;
}
v4 = *(_DWORD *)(v3 + 1608);
if ( v4 != 99 && v4 != 100 )
{
v5 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v24 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v24);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v5 = qword_14090BFD0;
}
GameVariable = GameManager::getGameVariable(v5, "0084");
v3 = *(_QWORD *)&qword_14090BFB0;
if ( GameVariable )
{
if ( !*(_DWORD *)(*(_QWORD *)(a1 + 504) + 704LL) )
{
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v25 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v25);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v3 = *(_QWORD *)&qword_14090BFB0;
}
v7 = 0;
v8 = *(_QWORD *)(v3 + 856);
if ( v8 )
{
v9 = *(_QWORD *)(v8 + 56);
if ( v9 )
{
for ( i = *(_QWORD *)(v9 + 288); ; i = *(_QWORD *)(i + 288) )
{
v11 = v7;
v7 = *(_DWORD *)(*(_QWORD *)(v9 + 264) + 704LL);
if ( v7 >= v11 )
v7 = v11;
v9 = i;
if ( !i )
break;
}
}
}
*(_DWORD *)(*(_QWORD *)(a1 + 504) + 704LL) = v7;
}
}
else
{
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v26 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v26);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v3 = *(_QWORD *)&qword_14090BFB0;
}
v12 = 0;
v13 = *(_QWORD *)(v3 + 856);
if ( v13 )
{
v14 = *(_QWORD *)(v13 + 56);
if ( v14 )
{
for ( j = *(_QWORD *)(v14 + 288); ; j = *(_QWORD *)(j + 288) )
{
v16 = v12;
v12 = *(_DWORD *)(*(_QWORD *)(v14 + 264) + 704LL);
if ( v12 <= v16 )
v12 = v16;
v14 = j;
if ( !j )
break;
}
}
}
*(_DWORD *)(*(_QWORD *)(a1 + 504) + 704LL) = v12 + 1;
}
}
if ( !v3 )
{
v27 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v27);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v3 = *(_QWORD *)&qword_14090BFB0;
}
GameLevelManager::saveLevel((_QWORD *)v3, *(_QWORD *)(a1 + 504));
v17 = *(_DWORD **)(a1 + 504);
v18 = v17[248] - v17[249];
v19 = v17[82] - v17[83];
v20 = *(cocos2d::CCActionManager ***)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v28 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v28);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v20 = *(cocos2d::CCActionManager ***)&qword_14090BFB0;
}
GameLevelManager::downloadLevel(v20, v19, *(_BYTE *)(*(_QWORD *)(a1 + 504) + 721LL), v18);
v21 = a1 + 408;
result = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v29 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v29);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
result = *(_QWORD *)&qword_14090BFB0;
}
*(_QWORD *)(result + 1360) = v21;
return result;
}