//
// GameLevelManager::downloadUserMessage from 0x7227d4 to 0x722b48 (884 bytes)
//
// 2 xrefs:
// > GJMessagePopup::init @ 0x8cebf8
// > ??> @ 0x4e090
//
// 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 GameLevelManager::downloadUserMessage(GameLevelManager *a1, int a2, bool a3)
{
_BOOL4 v4; // w22
char *MessageKey; // x21
cocos2d::CCString *v7; // x0
const char *CString; // x0
cocos2d::CCString *v9; // x0
size_t v10; // x0
int *p_m_unknown2; // x0
char *v12; // x0
char *v13; // x0
char *v14; // x0
unsigned int *v15; // x1
int v16; // w2
unsigned int *p_timeoutForConnect; // x1
int timeoutForConnect; // w2
unsigned int *v19; // x1
int v20; // w2
unsigned int *v21; // x1
int v22; // w2
const char *v23; // [xsp+48h] [xbp+48h]
char *v24; // [xsp+78h] [xbp+78h] BYREF
const char *v25; // [xsp+80h] [xbp+80h] BYREF
const char *v26; // [xsp+88h] [xbp+88h] BYREF
cocos2d::extension::CCHttpClient *v27; // [xsp+90h] [xbp+90h] BYREF
v4 = a3;
MessageKey = (char *)GameLevelManager::getMessageKey(a1, a2);
if ( !GameLevelManager::isDLActive(a1, MessageKey) )
{
GameLevelManager::addDLToActive(a1, MessageKey);
GameLevelManager::getBasePostString(a1, (__int64)&v24);
v7 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)off_50 + 7,
"mfd",
"2893",
103,
98,
"7");
CString = cocos2d::CCString::getCString(v7);
v9 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"&messageID=%i&secret=%s",
(const char *)(unsigned int)a2,
CString);
v23 = cocos2d::CCString::getCString(v9);
v10 = strlen(v23);
sub_D15FD4(&v24, v23, v10);
if ( v4 )
sub_D15FD4(&v24, "&isSender=1", 11);
sub_D153B8((int)&v25, "https://www.boomlings.com/database/downloadGJMessage20.php");
sub_D153B8((int)&v26, v24);
sub_D153B8((int)&v27, MessageKey);
GameLevelManager::ProcessHttpRequest(a1, &v25, &v26, &v27, 38);
p_m_unknown2 = &v27[-1].m_unknown2;
if ( &v27[-1].m_unknown2 != (int *)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_timeoutForConnect = (unsigned int *)&v27[-1]._timeoutForConnect;
do
timeoutForConnect = __ldaxr(p_timeoutForConnect);
while ( __stlxr(timeoutForConnect - 1, p_timeoutForConnect) );
}
else
{
timeoutForConnect = v27[-1]._timeoutForConnect;
v27[-1]._timeoutForConnect = timeoutForConnect - 1;
}
if ( timeoutForConnect <= 0 )
operator delete(p_m_unknown2);
}
v12 = (char *)(v26 - 24);
if ( v26 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v19 = (unsigned int *)(v26 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *((_DWORD *)v26 - 2);
*((_DWORD *)v26 - 2) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v12);
}
v13 = (char *)(v25 - 24);
if ( v25 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)(v25 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *((_DWORD *)v25 - 2);
*((_DWORD *)v25 - 2) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v13);
}
v14 = v24 - 24;
if ( v24 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v15 = (unsigned int *)(v24 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *((_DWORD *)v24 - 2);
*((_DWORD *)v24 - 2) = v16 - 1;
}
if ( v16 <= 0 )
operator delete(v14);
}
}
}