//
// GameLevelManager::onDownloadUserMessageCompleted from 0x100525660 to 0x10052582a (458 bytes)
//
// 1 xrefs:
// > GameLevelManager::handleIt @ 0x10051c342
//
// 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
//
void __fastcall GameLevelManager::onDownloadUserMessageCompleted(
GameLevelManager *a1,
unsigned __int8 *a2,
__int64 a3,
double a4)
{
const char *v4; // r15
unsigned int SplitIntFromKey; // r13d
const void *v6; // r15
unsigned __int64 v7; // rcx
size_t v8; // rdx
DownloadMessageDelegate *m_downloadMessageDelegate; // rdi
size_t v10; // rax
size_t v11; // r12
char *v12; // r13
size_t v13; // r14
cocos2d::CCDictionary *v14; // rax
GJUserMessage *v15; // r15
unsigned int v16; // r14d
DownloadMessageDelegate *v17; // rdi
DownloadMessageDelegate *v18; // rdi
_WORD __s2[11]; // [rsp+1h] [rbp-5Fh] BYREF
_QWORD __dst[2]; // [rsp+18h] [rbp-48h] BYREF
void *__p; // [rsp+28h] [rbp-38h]
unsigned int v22; // [rsp+34h] [rbp-2Ch]
if ( (*(_BYTE *)a3 & 1) != 0 )
v4 = *(const char **)(a3 + 16);
else
v4 = (const char *)(a3 + 1);
SplitIntFromKey = GameLevelManager::getSplitIntFromKey(a1, v4, 1);
GameLevelManager::removeDLFromActive(a1, v4);
strcpy((char *)__s2, "-1");
v6 = a2 + 1;
v7 = *a2 >> 1;
if ( (*a2 & 1) != 0 )
{
v6 = *((const void **)a2 + 2);
v7 = *((_QWORD *)a2 + 1);
}
v8 = 2;
if ( v7 < 2 )
v8 = v7;
if ( !((v7 != 2) | (memcmp(v6, __s2, v8) != 0)) )
{
m_downloadMessageDelegate = a1->m_downloadMessageDelegate;
if ( m_downloadMessageDelegate )
((void (__fastcall *)(DownloadMessageDelegate *, _QWORD))m_downloadMessageDelegate->downloadMessageFailed)(
m_downloadMessageDelegate,
SplitIntFromKey);
return;
}
v10 = strlen((const char *)v6);
if ( v10 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a4);
v11 = v10;
v22 = SplitIntFromKey;
if ( v10 >= 0x17 )
{
v13 = 26;
if ( (v10 | 7) != 0x17 )
v13 = (v10 | 7) + 1;
v12 = (char *)operator new(v13);
__p = v12;
__dst[0] = v13 + 1;
__dst[1] = v11;
}
else
{
LOBYTE(__dst[0]) = 2 * v10;
v12 = (char *)__dst + 1;
if ( !v10 )
goto LABEL_19;
}
memmove(v12, v6, v11);
LABEL_19:
v12[v11] = 0;
v14 = (cocos2d::CCDictionary *)GameLevelManager::responseToDict(__dst, 0);
v15 = GJUserMessage::create(v14);
v16 = v22;
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
if ( v15 )
{
cocos2d::CCDictionary::setObject(a1->m_userMessages, v15, v15->m_messageID);
v17 = a1->m_downloadMessageDelegate;
if ( v17 )
((void (__fastcall *)(DownloadMessageDelegate *, GJUserMessage *))v17->downloadMessageFinished)(v17, v15);
}
else
{
v18 = a1->m_downloadMessageDelegate;
if ( v18 )
((void (__fastcall *)(DownloadMessageDelegate *, _QWORD))v18->downloadMessageFailed)(v18, v16);
}
}