//
// GameLevelManager::restoreItems from 0x72b280 to 0x72b5bc (828 bytes)
//
// 1 xrefs:
// > ??> @ 0x37f68
//
// 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::restoreItems(GameLevelManager *a1)
{
double v2; // d0
const char *v3; // x21
cocos2d::CCString *v4; // x0
const char *CString; // x0
cocos2d::CCString *v6; // x0
char *v7; // x21
int *p_m_unknown2; // x0
char *v9; // x0
char *v10; // x0
char *v11; // x0
unsigned int *v12; // x1
int v13; // w2
unsigned int *p_timeoutForConnect; // x1
int timeoutForConnect; // w2
unsigned int *v16; // x1
int v17; // w2
unsigned int *v18; // x1
int v19; // w2
const char *v20; // [xsp+68h] [xbp+68h] BYREF
const char *v21; // [xsp+70h] [xbp+70h] BYREF
const char *v22; // [xsp+78h] [xbp+78h] BYREF
cocos2d::extension::CCHttpClient *v23; // [xsp+80h] [xbp+80h] BYREF
if ( !GameLevelManager::isDLActive(a1, "restoreKey") )
{
GameLevelManager::addDLToActive(a1, "restoreKey");
GameManager::sharedState();
*(_QWORD *)&v2 = sub_D18D28(&v20).n128_u64[0];
v3 = v20;
v4 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)off_50 + 7,
"mfd",
"2893",
103,
98,
"7",
v2);
CString = cocos2d::CCString::getCString(v4);
v6 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"udid=%s&secret=%s", v3, CString);
v7 = (char *)cocos2d::CCString::getCString(v6);
sub_D153B8((int)&v21, "https://www.boomlings.com/database/restoreGJItems.php");
sub_D153B8((int)&v22, v7);
sub_D153B8((int)&v23, "restoreKey");
GameLevelManager::ProcessHttpRequest(a1, &v21, &v22, &v23, 16);
p_m_unknown2 = &v23[-1].m_unknown2;
if ( &v23[-1].m_unknown2 != (int *)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_timeoutForConnect = (unsigned int *)&v23[-1]._timeoutForConnect;
do
timeoutForConnect = __ldaxr(p_timeoutForConnect);
while ( __stlxr(timeoutForConnect - 1, p_timeoutForConnect) );
}
else
{
timeoutForConnect = v23[-1]._timeoutForConnect;
v23[-1]._timeoutForConnect = timeoutForConnect - 1;
}
if ( timeoutForConnect <= 0 )
operator delete(p_m_unknown2);
}
v9 = (char *)(v22 - 24);
if ( v22 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)(v22 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v22 - 2);
*((_DWORD *)v22 - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v9);
}
v10 = (char *)(v21 - 24);
if ( v21 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(v21 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *((_DWORD *)v21 - 2);
*((_DWORD *)v21 - 2) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v10);
}
v11 = (char *)(v20 - 24);
if ( v20 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v12 = (unsigned int *)(v20 - 8);
do
v13 = __ldaxr(v12);
while ( __stlxr(v13 - 1, v12) );
}
else
{
v13 = *((_DWORD *)v20 - 2);
*((_DWORD *)v20 - 2) = v13 - 1;
}
if ( v13 <= 0 )
operator delete(v11);
}
}
}