//
// GameLevelManager::onUploadLevelCompleted from 0x7018f4 to 0x701b7c (648 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x732f84
// > ??> @ 0x5ac48
//
// 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
//
__int64 __fastcall GameLevelManager::onUploadLevelCompleted(GameLevelManager *a1, const void **a2, char **a3)
{
const char *v4; // x25
cocos2d::CCDictionary *m_friendReqAndUserBlocks; // x22
char *v7; // x0
int v8; // w25
_DWORD *v9; // x26
unsigned __int64 v10; // x27
unsigned __int64 v11; // x20
size_t v12; // x2
int v13; // w19
__int64 v14; // x20
__int64 *v15; // x0
LevelUploadDelegate *v16; // x19
void (__fastcall *levelUploadFailed)(LevelUploadDelegate *__hidden, GJGameLevel *); // x20
GJGameLevel *v18; // x0
int v20; // w20
GJGameLevel *LocalLevel; // x0
GJGameLevel *v22; // x19
int v23; // w25
LevelUploadDelegate *m_levelUploadDelegate; // x0
unsigned int *v25; // x26
int v26; // w1
unsigned int *v27; // x1
int v28; // w2
void *v29; // [xsp+70h] [xbp+70h] BYREF
v4 = *a3;
m_friendReqAndUserBlocks = a1->m_friendReqAndUserBlocks;
sub_D153B8((int)&v29, *a3);
cocos2d::CCDictionary::removeObjectForKey(m_friendReqAndUserBlocks, (const std::string *)&v29);
v7 = (char *)v29 - 24;
if ( (char *)v29 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = (unsigned int *)((char *)v29 - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *((_DWORD *)v29 - 2);
*((_DWORD *)v29 - 2) = v28 - 1;
}
if ( v28 <= 0 )
operator delete(v7);
}
v8 = atoi(v4);
sub_D153B8((int)&v29, "-1");
v9 = v29;
v10 = *((_QWORD *)v29 - 3);
v11 = *((_QWORD *)*a2 - 3);
if ( v10 > v11 )
v12 = *((_QWORD *)*a2 - 3);
else
v12 = *((_QWORD *)v29 - 3);
v13 = memcmp(*a2, v29, v12);
if ( v13 || (v13 = 0x7FFFFFFF, v14 = v11 - v10, v14 > 0x7FFFFFFF) )
{
v15 = (__int64 *)(v9 - 6);
if ( v9 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_8;
}
else
{
v15 = (__int64 *)(v9 - 6);
if ( v14 >= (__int64)0xFFFFFFFF80000000LL )
v13 = v14;
else
v13 = 0x80000000;
if ( v15 == &qword_124B6B0 )
goto LABEL_8;
}
if ( &pthread_create )
{
v25 = v9 - 2;
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *(v9 - 2);
*(v9 - 2) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v15);
LABEL_8:
if ( v13 )
{
v20 = atoi((const char *)*a2);
LocalLevel = GameLevelManager::getLocalLevel(a1, v8);
v22 = LocalLevel;
if ( LocalLevel )
{
LocalLevel->m_levelID.value = v20;
v23 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v22->m_levelID.seed = v23;
v22->m_levelID.random = v20 + v23;
GJGameLevel::levelWasSubmitted(v22);
}
m_levelUploadDelegate = a1->m_levelUploadDelegate;
if ( m_levelUploadDelegate )
m_levelUploadDelegate->levelUploadFinished(m_levelUploadDelegate, v22);
}
else
{
v16 = a1->m_levelUploadDelegate;
if ( v16 )
{
levelUploadFailed = v16->levelUploadFailed;
v18 = GameLevelManager::getLocalLevel(a1, v8);
levelUploadFailed(v16, v18);
}
}
return _stack_chk_guard;
}