//
// LevelInfoLayer::downloadLevel from 0x1002acf30 to 0x1002ad02a (250 bytes)
//
// 4 xrefs:
// > LevelInfoLayer::init @ 0x1002aac1e
// > LevelInfoLayer::onPlay @ 0x1002ac594
// > LevelInfoLayer::onEdit @ 0x1002acf02
// > LevelInfoLayer::onUpdate @ 0x1002ae4e2
//
// 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 12:28:00 +0000
//
__int64 __fastcall LevelInfoLayer::downloadLevel(__int64 a1)
{
__int64 v2; // rdi
double v3; // xmm0_8
__int64 v4; // rdx
__int64 v5; // rax
char GameVariable; // al
__int64 v7; // r14
__int64 v8; // rax
int LowestLevelOrder; // eax
__int64 v10; // rax
__int64 v11; // rax
double v12; // xmm0_8
__int64 v13; // rax
__int64 v14; // rdi
__int64 result; // rax
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 496) + 344LL))(*(_QWORD *)(a1 + 496), 0);
v2 = *(_QWORD *)(a1 + 648);
v3 = (*(double (__fastcall **)(__int64, __int64))(*(_QWORD *)v2 + 344LL))(v2, 1);
if ( *(_DWORD *)(GameLevelManager::sharedState(v3) + 1480) != 99
&& *(_DWORD *)(GameLevelManager::sharedState(v3) + 1480) != 100 )
{
*(_QWORD *)&v3 = GameManager::sharedState(v2, 1, v4).u64[0];
GameVariable = GameManager::getGameVariable(v5, "0084");
v7 = *(_QWORD *)(a1 + 504);
if ( !GameVariable )
{
v10 = GameLevelManager::sharedState(v3);
LowestLevelOrder = GameLevelManager::getHighestLevelOrder(v10) + 1;
goto LABEL_7;
}
if ( !*(_DWORD *)(v7 + 632) )
{
v8 = GameLevelManager::sharedState(v3);
LowestLevelOrder = GameLevelManager::getLowestLevelOrder(v8);
LABEL_7:
*(_DWORD *)(v7 + 632) = LowestLevelOrder;
}
}
v11 = GameLevelManager::sharedState(v3);
v12 = GameLevelManager::saveLevel(v11, *(_QWORD *)(a1 + 504));
v13 = GameLevelManager::sharedState(v12);
v14 = *(_QWORD *)(a1 + 504);
GameLevelManager::downloadLevel(
v13,
(unsigned int)(*(_DWORD *)(v14 + 328) - *(_DWORD *)(v14 + 332)),
*(unsigned __int8 *)(v14 + 649),
(unsigned int)(*(_DWORD *)(v14 + 920) - *(_DWORD *)(v14 + 924)));
result = GameLevelManager::sharedState(v12);
*(_QWORD *)(result + 1232) = a1 + 408;
return result;
}