//
// MessagesProfilePage::deleteSelected from 0x140337690 to 0x140337910 (640 bytes)
//
// 2 xrefs:
// > MessagesProfilePage::FLAlert_Clicked @ 0x140337932
// > ??> @ 0x1406d527c
//
// 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
//
// Hidden C++ exception states: #wind=5
void MessagesProfilePage::deleteSelected(MessagesProfilePage *a1)
{
std::string *p_m_messageKey; // rbx
GameLevelManager *v3; // rcx
__int64 v4; // rcx
cocos2d::CCArray *StoredOnlineLevels; // rbx
cocos2d::CCArray *v6; // r15
int v7; // esi
cocos2d::ccArray *data; // rdi
__int64 num; // rax
struct cocos2d::CCObject **arr; // rdi
struct cocos2d::CCObject **i; // r14
struct cocos2d::CCObject *v12; // rbx
MessageListDelegate *v13; // rbx
GameLevelManager *v14; // rcx
UploadActionDelegate *v15; // rax
UploadActionPopup *v16; // rax
GJAccountManager *v17; // rax
int v18; // ebx
__int64 v19; // rcx
struct cocos2d::CCObject *v20; // rax
int v21; // ecx
__int128 v22; // [rsp+20h] [rbp-48h] BYREF
__int64 v23; // [rsp+30h] [rbp-38h]
__int64 v24; // [rsp+38h] [rbp-30h]
void *v25; // [rsp+70h] [rbp+8h]
void *v26; // [rsp+70h] [rbp+8h]
void *v27; // [rsp+70h] [rbp+8h]
p_m_messageKey = &a1->m_messageKey;
if ( a1->m_messageKey.m_data.m_capacity > 0xF )
p_m_messageKey = (std::string *)p_m_messageKey->m_data.m_bigStorage;
v3 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v25 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v3 = (GameLevelManager *)qword_1406C2EC0;
}
StoredOnlineLevels = GameLevelManager::getStoredOnlineLevels(v3, p_m_messageKey->m_data.m_smallStorage._Elems);
if ( StoredOnlineLevels )
{
v6 = (cocos2d::CCArray *)cocos2d::CCArray::create(v4);
v7 = 0;
data = StoredOnlineLevels->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
for ( i = &arr[num - 1]; arr <= i; ++arr )
{
v12 = *arr;
if ( !*arr )
break;
if ( BYTE2(v12[8].m_nTag) )
{
cocos2d::CCArray::addObject(v6, *arr);
if ( !LOBYTE(v12[8].m_nTag) )
{
LOBYTE(v12[8].m_nTag) = 1;
++v7;
}
}
}
}
if ( cocos2d::CCArray::count(v6) )
{
v13 = &a1->MessageListDelegate;
if ( !a1 )
v13 = nullptr;
v14 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v26 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v14 = (GameLevelManager *)qword_1406C2EC0;
}
v14->m_messageListDelegate = v13;
v15 = &a1->UploadActionDelegate;
if ( !a1 )
v15 = nullptr;
v14->m_uploadActionDelegate = v15;
if ( GameLevelManager::deleteUserMessages(v14, nullptr, v6, a1->m_sentMessages) )
{
v22 = 0;
*(_QWORD *)&v22 = sub_14003AA10(0x20u);
v23 = 20;
v24 = 31;
strcpy((char *)v22, "Deleting Messages...");
v16 = (UploadActionPopup *)UploadActionPopup::create((__int64)&a1->UploadPopupDelegate, (__int64)&v22);
a1->m_actionPopup = v16;
v16->show(v16);
}
if ( v7 > 0 )
{
v17 = GJAccountManager::sharedState();
v18 = v17->m_accountID - v17->m_unkInt1;
v19 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v27 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v27);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v19 = qword_1406C2EC0;
}
v20 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(v19 + 600), v18);
if ( v20 )
{
v21 = v20[13].m_uReference - v7;
if ( v21 < 0 )
v21 = 0;
v20[13].m_uReference = v21;
}
}
a1->m_toggledAll = 0;
CCMenuItemToggler::toggle(a1->m_toggleAllToggler, 0);
}
}
}