//
// MessagesProfilePage::deleteSelected from 0x10022ed40 to 0x10022ef0e (462 bytes)
//
// 2 xrefs:
// > MessagesProfilePage::FLAlert_Clicked @ 0x10022ef54
// > sub_10022EF60 @ 0x10022ef8b
//
// 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 MessagesProfilePage::deleteSelected(MessagesProfilePage *a1)
{
GameLevelManager *v2; // rax
std::array *longStorage; // rsi
GameLevelManager *v4; // rdi
cocos2d::CCArray *StoredOnlineLevels; // rax
cocos2d::CCArray *v6; // r15
cocos2d::CCArray *v7; // r14
cocos2d::ccArray *data; // rax
cocos2d::CCObject **arr; // r13
cocos2d::CCObject **v10; // r12
int v11; // ebx
cocos2d::CCObject *v12; // r15
GameLevelManager *v13; // rax
__int64 m_actionPopup; // rax
GameLevelManager *v15; // r14
GJAccountManager *v16; // rax
GJUserScore *v17; // rax
int v18; // edx
MessagesProfilePage *v19; // [rsp+8h] [rbp-48h]
void *v20[8]; // [rsp+10h] [rbp-40h] BYREF
v2 = GameLevelManager::sharedState();
if ( (a1->m_messageKey.m_data.m_short.sizex2 & 1) != 0 )
{
longStorage = (std::array *)a1->m_messageKey.m_data.m_long.longStorage;
v4 = v2;
StoredOnlineLevels = GameLevelManager::getStoredOnlineLevels(v2, longStorage->__elems_);
if ( !StoredOnlineLevels )
return;
}
else
{
longStorage = &a1->m_messageKey.m_data.m_short.shortStorage;
v4 = v2;
StoredOnlineLevels = GameLevelManager::getStoredOnlineLevels(v2, longStorage->__elems_);
if ( !StoredOnlineLevels )
return;
}
v6 = StoredOnlineLevels;
v19 = a1;
v7 = (cocos2d::CCArray *)sub_10071F9E0(v4, longStorage);
data = v6->data;
if ( data->num )
{
arr = data->arr;
v10 = &arr[data->num - 1];
v11 = 0;
do
{
v12 = *arr;
if ( !*arr )
break;
if ( BYTE2(v12[7].m_uIndexInArray) == 1 )
{
sub_10071FCD0(v7, *arr);
if ( !LOBYTE(v12[7].m_uIndexInArray) )
{
LOBYTE(v12[7].m_uIndexInArray) = 1;
++v11;
}
}
++arr;
}
while ( arr <= v10 );
}
else
{
v11 = 0;
}
if ( (unsigned int)sub_100720070(v7) )
{
GameLevelManager::sharedState()->m_messageListDelegate = &v19->MessageListDelegate;
GameLevelManager::sharedState()->m_uploadActionDelegate = &v19->UploadActionDelegate;
v13 = GameLevelManager::sharedState();
if ( GameLevelManager::deleteUserMessages(v13, nullptr, v7, v19->m_sentMessages) )
{
strcpy((char *)v20, "(Deleting Messages...");
m_actionPopup = UploadActionPopup::create(&v19->UploadPopupDelegate, v20);
v19->m_actionPopup = (UploadActionPopup *)m_actionPopup;
if ( ((__int64)v20[0] & 1) != 0 )
{
operator delete(v20[2]);
m_actionPopup = (__int64)v19->m_actionPopup;
}
(*(void (__fastcall **)(__int64))(*(_QWORD *)m_actionPopup + 1288LL))(m_actionPopup);
}
if ( v11 > 0 )
{
v15 = GameLevelManager::sharedState();
v16 = GJAccountManager::sharedState();
v17 = GameLevelManager::userInfoForAccountID(v15, v16->m_accountID - v16->m_unkInt1);
if ( v17 )
{
v18 = 0;
if ( v17->m_newMsgCount - v11 > 0 )
v18 = v17->m_newMsgCount - v11;
v17->m_newMsgCount = v18;
}
}
v19->m_toggledAll = 0;
CCMenuItemToggler::toggle(v19->m_toggleAllToggler, 0);
}
}