//
// GameLevelManager::onDownloadUserMessageCompleted from 0x714fe0 to 0x71522c (588 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x732184
// > ??> @ 0x34470
//
// 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::onDownloadUserMessageCompleted(
GameLevelManager *a1,
const void **a2,
const char **a3)
{
const char *v4; // x19
unsigned int SplitIntFromKey; // w26
_DWORD *v7; // x27
unsigned __int64 v8; // x28
unsigned __int64 v9; // x20
size_t v10; // x2
int v11; // w19
__int64 v12; // x20
__int64 *v13; // x0
DownloadMessageDelegate *v14; // x0
GJUserMessage *v16; // x27
char *v17; // x23
DownloadMessageDelegate *m_downloadMessageDelegate; // x0
unsigned int *v19; // x27
int v20; // w1
unsigned int *v21; // x19
int v22; // w0
void *v23[2]; // [xsp+0h] [xbp+0h] BYREF
void *v24; // [xsp+70h] [xbp+70h] BYREF
v4 = *a3;
SplitIntFromKey = GameLevelManager::getSplitIntFromKey(a1, *a3, 1);
GameLevelManager::removeDLFromActive(a1, v4);
sub_D153B8((unsigned int)v23 + 112, "-1");
v7 = v24;
v8 = *((_QWORD *)v24 - 3);
v9 = *((_QWORD *)*a2 - 3);
if ( v8 > v9 )
v10 = *((_QWORD *)*a2 - 3);
else
v10 = *((_QWORD *)v24 - 3);
v11 = memcmp(*a2, v24, v10);
if ( v11 || (v11 = 0x7FFFFFFF, v12 = v9 - v8, v12 > 0x7FFFFFFF) )
{
v13 = (__int64 *)(v7 - 6);
if ( v7 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_7;
}
else
{
v13 = (__int64 *)(v7 - 6);
if ( v12 >= (__int64)0xFFFFFFFF80000000LL )
v11 = v12;
else
v11 = 0x80000000;
if ( v13 == &qword_124B6B0 )
goto LABEL_7;
}
if ( &pthread_create )
{
v19 = v7 - 2;
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *(v7 - 2);
*(v7 - 2) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v13);
LABEL_7:
if ( !v11 )
goto LABEL_8;
sub_D153B8((unsigned int)v23 + 112, (char *)*a2);
GameLevelManager::responseToDict((char **)&v24, 0);
v16 = GJUserMessage::create();
v17 = (char *)v24 - 24;
if ( (char *)v24 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)((char *)v24 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *((_DWORD *)v24 - 2);
*((_DWORD *)v24 - 2) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v17);
}
if ( v16 )
{
GameLevelManager::storeUserMessage(a1, v16);
m_downloadMessageDelegate = a1->m_downloadMessageDelegate;
if ( m_downloadMessageDelegate )
m_downloadMessageDelegate->downloadMessageFinished(m_downloadMessageDelegate, v16);
}
else
{
LABEL_8:
v14 = a1->m_downloadMessageDelegate;
if ( v14 )
v14->downloadMessageFailed(v14, SplitIntFromKey);
}
return _stack_chk_guard;
}