//
// GameLevelManager::uploadFriendRequest from 0x725f6c to 0x726534 (1480 bytes)
//
// 2 xrefs:
// > ShareCommentLayer::onShare @ 0x7e6528
// > ??> @ 0xba5e8
//
// 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::uploadFriendRequest(GameLevelManager *a1, unsigned int a2, __int64 *a3)
{
char *v6; // x0
char *v7; // x0
cocos2d::CCString *v8; // x0
char *CString; // x26
cocos2d::CCDictionary *m_friendReqAndUserBlocks; // x28
__int64 v11; // x28
char *v12; // x0
__int64 result; // x0
cocos2d::CCNode *v14; // x28
char *v15; // x0
__int64 v16; // x23
cocos2d::CCString *v17; // x0
const char *v18; // x0
cocos2d::CCString *v19; // x0
size_t v20; // x0
char *v21; // x0
char *v22; // x0
char *v23; // x0
char *v24; // x0
unsigned int *v25; // x1
int v26; // w2
unsigned int *v27; // x1
int v28; // w2
unsigned int *v29; // x1
int v30; // w2
unsigned int *v31; // x1
int v32; // w2
unsigned int *v33; // x1
int v34; // w2
unsigned int *v35; // x1
int v36; // w2
unsigned int *v37; // x1
int v38; // w2
unsigned int *v39; // x1
int v40; // w2
int v41[2]; // [xsp+68h] [xbp+68h]
const char *v42; // [xsp+68h] [xbp+68h]
char *v43; // [xsp+98h] [xbp+98h] BYREF
const char *v44; // [xsp+A0h] [xbp+A0h] BYREF
const char *v45; // [xsp+A8h] [xbp+A8h] BYREF
std::string v46; // [xsp+B0h] [xbp+B0h] BYREF
sub_D18D28(&v45);
LevelTools::base64EncodeString((cocos2d::ZipUtils *)&v45, &v46);
sub_D163D4(a3, &v46);
v6 = (char *)v46.m_data.m_data - 24;
if ( (__int64 *)v46.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v25 = (unsigned int *)((char *)v46.m_data.m_data - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *((_DWORD *)v46.m_data.m_data - 2);
*((_DWORD *)v46.m_data.m_data - 2) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v6);
}
v7 = (char *)(v45 - 24);
if ( v45 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = (unsigned int *)(v45 - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *((_DWORD *)v45 - 2);
*((_DWORD *)v45 - 2) = v28 - 1;
}
if ( v28 <= 0 )
operator delete(v7);
}
v8 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"friendReq_%i", (const char *)a2);
CString = (char *)cocos2d::CCString::getCString(v8);
m_friendReqAndUserBlocks = a1->m_friendReqAndUserBlocks;
sub_D153B8((int)&v46, CString);
v11 = cocos2d::CCDictionary::objectForKey(m_friendReqAndUserBlocks, &v46);
v12 = (char *)v46.m_data.m_data - 24;
if ( (__int64 *)v46.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v29 = (unsigned int *)((char *)v46.m_data.m_data - 8);
do
v30 = __ldaxr(v29);
while ( __stlxr(v30 - 1, v29) );
}
else
{
v30 = *((_DWORD *)v46.m_data.m_data - 2);
*((_DWORD *)v46.m_data.m_data - 2) = v30 - 1;
}
if ( v30 <= 0 )
operator delete(v12);
}
result = 0;
if ( !v11 )
{
*(_QWORD *)v41 = a1->m_friendReqAndUserBlocks;
v14 = cocos2d::CCNode::create();
sub_D153B8((int)&v46, CString);
cocos2d::CCDictionary::setObject(v41[0], v14);
v15 = (char *)v46.m_data.m_data - 24;
if ( (__int64 *)v46.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v39 = (unsigned int *)((char *)v46.m_data.m_data - 8);
do
v40 = __ldaxr(v39);
while ( __stlxr(v40 - 1, v39) );
}
else
{
v40 = *((_DWORD *)v46.m_data.m_data - 2);
*((_DWORD *)v46.m_data.m_data - 2) = v40 - 1;
}
if ( v40 <= 0 )
operator delete(v15);
}
GameLevelManager::makeTimeStamp(a1, CString);
GameLevelManager::getBasePostString(a1, (__int64)&v43);
v16 = *a3;
v17 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)off_50 + 7,
"mfd",
"2893",
103,
98,
"7");
v18 = cocos2d::CCString::getCString(v17);
v19 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"&toAccountID=%i&comment=%s&secret=%s",
(const char *)a2,
v16,
v18);
v42 = cocos2d::CCString::getCString(v19);
v20 = strlen(v42);
sub_D15FD4(&v43, v42, v20);
sub_D153B8((int)&v44, "https://www.boomlings.com/database/uploadFriendRequest20.php");
sub_D153B8((int)&v45, v43);
sub_D153B8((int)&v46, CString);
GameLevelManager::ProcessHttpRequest(a1, &v44, &v45, (cocos2d::extension::CCHttpClient **)&v46, 29);
v21 = (char *)v46.m_data.m_data - 24;
if ( (__int64 *)v46.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v37 = (unsigned int *)((char *)v46.m_data.m_data - 8);
do
v38 = __ldaxr(v37);
while ( __stlxr(v38 - 1, v37) );
}
else
{
v38 = *((_DWORD *)v46.m_data.m_data - 2);
*((_DWORD *)v46.m_data.m_data - 2) = v38 - 1;
}
if ( v38 <= 0 )
operator delete(v21);
}
v22 = (char *)(v45 - 24);
if ( v45 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v35 = (unsigned int *)(v45 - 8);
do
v36 = __ldaxr(v35);
while ( __stlxr(v36 - 1, v35) );
}
else
{
v36 = *((_DWORD *)v45 - 2);
*((_DWORD *)v45 - 2) = v36 - 1;
}
if ( v36 <= 0 )
operator delete(v22);
}
v23 = (char *)(v44 - 24);
if ( v44 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v33 = (unsigned int *)(v44 - 8);
do
v34 = __ldaxr(v33);
while ( __stlxr(v34 - 1, v33) );
}
else
{
v34 = *((_DWORD *)v44 - 2);
*((_DWORD *)v44 - 2) = v34 - 1;
}
if ( v34 <= 0 )
operator delete(v23);
}
v24 = v43 - 24;
if ( v43 - 24 == (char *)&qword_124B6B0 )
return 1;
if ( &pthread_create )
{
v31 = (unsigned int *)(v43 - 8);
do
v32 = __ldaxr(v31);
while ( __stlxr(v32 - 1, v31) );
}
else
{
v32 = *((_DWORD *)v43 - 2);
*((_DWORD *)v43 - 2) = v32 - 1;
}
if ( v32 > 0 )
{
return 1;
}
else
{
operator delete(v24);
return 1;
}
}
return result;
}