//
// GameLevelManager::onUploadLevelCompleted from 0x14014d2a0 to 0x14014d4a8 (520 bytes)
//
// 3 xrefs:
// > GameLevelManager::handleIt @ 0x14014307b
// > ??> @ 0x1406ca7a0
// > ??> @ 0x1406ca7ac
//
// 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
//
// Hidden C++ exception states: #wind=3
void __fastcall GameLevelManager::onUploadLevelCompleted(__int64 a1, const void **a2, _QWORD *a3)
{
_BYTE *v6; // rbx
size_t v7; // r8
void *v8; // rcx
int v9; // r15d
const void *v10; // rcx
unsigned __int64 v11; // r14
unsigned __int64 v12; // rbx
size_t v13; // r8
GameLevelManager *v14; // rcx
__int64 *v15; // rbx
__int64 v16; // rbx
GJGameLevel *LocalLevel; // rax
const char *v18; // rcx
int v19; // r14d
GameLevelManager *v20; // rcx
GJGameLevel *v21; // rax
GJGameLevel *v22; // rbx
float v23; // xmm0_4
void (__fastcall ***v24)(_QWORD, GJGameLevel *); // rcx
void *Block[2]; // [rsp+30h] [rbp-58h] BYREF
__int128 v26; // [rsp+40h] [rbp-48h]
v6 = a3;
if ( a3[3] > 0xFu )
v6 = (_BYTE *)*a3;
*(_OWORD *)Block = 0;
v26 = 0;
v7 = -1;
do
++v7;
while ( v6[v7] );
sub_14003A930(Block, v6, v7);
cocos2d::CCDictionary::removeObjectForKey(*(_QWORD *)(a1 + 592), Block);
if ( *((_QWORD *)&v26 + 1) > 0xFu )
{
v8 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v26 + 1) + 1LL) >= 0x1000 )
{
v8 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v8 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v8);
}
v9 = atoi(v6);
*(_OWORD *)Block = 0;
*(_QWORD *)&v26 = 2;
*((_QWORD *)&v26 + 1) = 15;
strcpy((char *)Block, "-1");
v10 = a2;
v11 = (unsigned __int64)a2[3];
if ( v11 > 0xF )
v10 = *a2;
v12 = (unsigned __int64)a2[2];
v13 = v12;
if ( v12 > 2 )
v13 = 2;
if ( !memcmp(v10, Block, v13) && v12 == 2 )
{
v15 = *(__int64 **)(a1 + 752);
if ( v15 )
{
v16 = *v15;
LocalLevel = GameLevelManager::getLocalLevel(v14, v9);
(*(void (__fastcall **)(_QWORD, GJGameLevel *))(v16 + 8))(*(_QWORD *)(a1 + 752), LocalLevel);
}
}
else
{
v18 = (const char *)a2;
if ( v11 > 0xF )
v18 = (const char *)*a2;
v19 = atoi(v18);
v21 = GameLevelManager::getLocalLevel(v20, v9);
v22 = v21;
if ( v21 )
{
v21->m_levelID.value = v19;
v23 = (float)((float)rand() / 32767.0) * 1000.0;
v22->m_levelID.seed = (int)v23;
v22->m_levelID.random = (int)v23 + v19;
v22->m_isUploaded = 1;
}
v24 = *(void (__fastcall ****)(_QWORD, GJGameLevel *))(a1 + 752);
if ( v24 )
(**v24)(v24, v22);
}
sub_14003A830((__int64)a2);
sub_14003A830((__int64)a3);
}