//
// GameLevelManager::onUpdateUserScoreCompleted from 0x72cf70 to 0x72d210 (672 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x732c74
// > ??> @ 0x4af88
//
// 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::onUpdateUserScoreCompleted(GameLevelManager *a1, const void **a2)
{
_DWORD *v4; // x26
unsigned __int64 v5; // x27
unsigned __int64 v6; // x20
size_t v7; // x2
int v8; // w19
__int64 v9; // x20
__int64 *v10; // x0
LeaderboardManagerDelegate *m_leaderboardManagerDelegate; // x0
_DWORD *v13; // x25
unsigned __int64 v14; // x26
unsigned __int64 v15; // x24
size_t v16; // x2
int v17; // w19
__int64 v18; // x24
char *v19; // x0
int v20; // w19
GameManager *v21; // x0
GameManager *v22; // x20
int v23; // w0
GameManager *v24; // x0
LeaderboardManagerDelegate *v25; // x1
LevelCommentDelegate *m_levelCommentDelegate; // x0
GameLevelManager *v27; // x0
unsigned int *v28; // x26
int v29; // w1
unsigned int *v30; // x25
int v31; // w1
void *v32; // [xsp+70h] [xbp+70h] BYREF
GameLevelManager::removeDLFromActive(a1, "user_score");
sub_D153B8((int)&v32, "-1");
v4 = v32;
v5 = *((_QWORD *)v32 - 3);
v6 = *((_QWORD *)*a2 - 3);
if ( v5 > v6 )
v7 = *((_QWORD *)*a2 - 3);
else
v7 = *((_QWORD *)v32 - 3);
v8 = memcmp(*a2, v32, v7);
if ( v8 || (v8 = 0x7FFFFFFF, v9 = v6 - v5, v9 > 0x7FFFFFFF) )
{
v10 = (__int64 *)(v4 - 6);
if ( v4 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_7;
}
else
{
v10 = (__int64 *)(v4 - 6);
if ( v9 >= (__int64)0xFFFFFFFF80000000LL )
v8 = v9;
else
v8 = 0x80000000;
if ( v10 == &qword_124B6B0 )
goto LABEL_7;
}
if ( &pthread_create )
{
v28 = v4 - 2;
do
v29 = __ldaxr(v28);
while ( __stlxr(v29 - 1, v28) );
}
else
{
v29 = *(v4 - 2);
*(v4 - 2) = v29 - 1;
}
if ( v29 <= 0 )
operator delete(v10);
LABEL_7:
if ( !v8 )
{
m_leaderboardManagerDelegate = a1->m_leaderboardManagerDelegate;
if ( m_leaderboardManagerDelegate )
m_leaderboardManagerDelegate->updateUserScoreFailed(m_leaderboardManagerDelegate);
return _stack_chk_guard;
}
sub_D153B8((int)&v32, "-9");
v13 = v32;
v14 = *((_QWORD *)v32 - 3);
v15 = *((_QWORD *)*a2 - 3);
if ( v14 > v15 )
v16 = *((_QWORD *)*a2 - 3);
else
v16 = *((_QWORD *)v32 - 3);
v17 = memcmp(*a2, v32, v16);
if ( !v17 )
{
v17 = 0x7FFFFFFF;
v18 = v15 - v14;
if ( v18 <= 0x7FFFFFFF )
{
if ( v18 >= (__int64)0xFFFFFFFF80000000LL )
v17 = v18;
else
v17 = 0x80000000;
}
}
v19 = (char *)(v13 - 6);
if ( v13 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_25;
if ( &pthread_create )
{
v30 = v13 - 2;
do
v31 = __ldaxr(v30);
while ( __stlxr(v31 - 1, v30) );
}
else
{
v31 = *(v13 - 2);
*(v13 - 2) = v31 - 1;
}
if ( v31 > 0 )
{
LABEL_25:
if ( !v17 )
{
LABEL_31:
v27 = GameLevelManager::sharedState();
GameLevelManager::submitUserInfo(v27);
goto LABEL_27;
}
}
else
{
operator delete(v19);
if ( !v17 )
goto LABEL_31;
}
v20 = atoi((const char *)*a2);
v21 = GameManager::sharedState();
v21->m_playerUserID.value = v20;
v22 = v21;
v23 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v22->m_playerUserID.seed = v23;
v22->m_playerUserID.random = v20 + v23;
LABEL_27:
v24 = GameManager::sharedState();
v25 = a1->m_leaderboardManagerDelegate;
v24->m_scoreValid = 1;
if ( v25 )
v25->updateUserScoreFinished(v25);
m_levelCommentDelegate = a1->m_levelCommentDelegate;
if ( m_levelCommentDelegate )
m_levelCommentDelegate->updateUserScoreFinished(m_levelCommentDelegate);
return _stack_chk_guard;
}