//
// MessagesProfilePage::deleteSelected from 0x8f2664 to 0x8f28b0 (588 bytes)
//
// 2 xrefs:
// > MessagesProfilePage::FLAlert_Clicked @ 0x8f28f8
// > ??> @ 0xa25b8
//
// 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 MessagesProfilePage::deleteSelected(MessagesProfilePage *a1)
{
GameLevelManager *v2; // x0
cocos2d::CCArray *StoredOnlineLevels; // x0
cocos2d::CCArray *v4; // x19
cocos2d::CCArray *v5; // x24
cocos2d::ccArray *data; // x1
int v7; // w25
cocos2d::CCObject **arr; // x19
cocos2d::CCObject **v9; // x21
cocos2d::CCObject *i; // x20
GameLevelManager *v11; // x0
GameLevelManager *v12; // x19
GJAccountManager *v13; // x0
GJUserScore *v14; // x0
int v15; // w1
CCMenuItemToggler *m_toggleAllToggler; // x0
UploadActionPopup *m_actionPopup; // x0
void *v18; // x3
unsigned int *v19; // x2
int v20; // w0
__int64 v21; // [xsp+60h] [xbp+60h] BYREF
v2 = GameLevelManager::sharedState();
StoredOnlineLevels = GameLevelManager::getStoredOnlineLevels(v2, (const char *)a1->m_messageKey.m_data.m_data);
v4 = StoredOnlineLevels;
if ( StoredOnlineLevels )
{
v5 = (cocos2d::CCArray *)cocos2d::CCArray::create(StoredOnlineLevels);
data = v4->data;
v7 = 0;
if ( data->num )
{
arr = data->arr;
v9 = &arr[data->num - 1];
if ( arr <= v9 )
{
for ( i = *arr; *arr; i = *arr )
{
if ( BYTE2(i[6].m_uAutoReleaseCount) )
{
cocos2d::CCArray::addObject(v5, i);
if ( !LOBYTE(i[6].m_uAutoReleaseCount) )
{
LOBYTE(i[6].m_uAutoReleaseCount) = 1;
++v7;
}
}
if ( v9 < ++arr )
break;
}
}
}
if ( (unsigned int)cocos2d::CCArray::count(v5) )
{
GameLevelManager::sharedState()->m_messageListDelegate = &a1->MessageListDelegate;
GameLevelManager::sharedState()->m_uploadActionDelegate = &a1->UploadActionDelegate;
v11 = GameLevelManager::sharedState();
if ( GameLevelManager::deleteUserMessages(v11, nullptr, v5, a1->m_sentMessages) )
{
sub_D153B8((int)&v21, "Deleting Messages...");
m_actionPopup = (UploadActionPopup *)UploadActionPopup::create((__int64)&a1->UploadPopupDelegate);
a1->m_actionPopup = m_actionPopup;
v18 = (void *)(v21 - 24);
if ( (__int64 *)(v21 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v19 = (unsigned int *)(v21 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *(_DWORD *)(v21 - 8);
*(_DWORD *)(v21 - 8) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v18);
m_actionPopup = a1->m_actionPopup;
}
m_actionPopup->show(m_actionPopup);
if ( !v7 )
goto LABEL_16;
}
else if ( !v7 )
{
LABEL_16:
m_toggleAllToggler = a1->m_toggleAllToggler;
a1->m_toggledAll = 0;
CCMenuItemToggler::toggle(m_toggleAllToggler, 0);
return;
}
v12 = GameLevelManager::sharedState();
v13 = GJAccountManager::sharedState();
v14 = GameLevelManager::userInfoForAccountID(v12, v13->m_accountID - v13->m_unkInt1);
if ( v14 )
{
v15 = v14->m_newMsgCount - v7;
if ( v15 < 0 )
v15 = 0;
v14->m_newMsgCount = v15;
}
goto LABEL_16;
}
}
}