//
// GameLevelManager::onRemoveFriendCompleted from 0x140161cb0 to 0x140161ef6 (582 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x1401437d4
// > ??> @ 0x1406caba8
//
// 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=3
void __fastcall GameLevelManager::onRemoveFriendCompleted(GameLevelManager *a1, const void **a2, _QWORD *a3)
{
_BYTE *v6; // rbx
size_t v7; // r8
GameLevelManager *v8; // rcx
void *v9; // rcx
__int64 SplitIntFromKey; // rsi
const void *v11; // rcx
unsigned __int64 v12; // rbx
size_t v13; // r8
UploadActionDelegate *v14; // rcx
struct cocos2d::CCObject *v15; // rax
unsigned int v16; // ebx
UserInfoDelegate *m_userInfoDelegate; // rcx
cocos2d::CCArray *StoredUserList; // rax
cocos2d::CCArray *v19; // rdi
UserListDelegate *m_userListDelegate; // rcx
UploadActionDelegate *m_uploadActionDelegate; // rcx
void *Block[2]; // [rsp+30h] [rbp-58h] BYREF
__int128 v23; // [rsp+40h] [rbp-48h]
v6 = a3;
if ( a3[3] > 0xFu )
v6 = (_BYTE *)*a3;
*(_OWORD *)Block = 0;
v23 = 0;
v7 = -1;
do
++v7;
while ( v6[v7] );
sub_14003A930(Block, v6, v7);
cocos2d::CCDictionary::removeObjectForKey(a1->m_friendReqAndUserBlocks, Block);
if ( *((_QWORD *)&v23 + 1) > 0xFu )
{
v9 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v23 + 1) + 1LL) >= 0x1000 )
{
v9 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v9 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v9);
}
SplitIntFromKey = GameLevelManager::getSplitIntFromKey(v8, v6, 1);
*(_OWORD *)Block = 0;
*(_QWORD *)&v23 = 2;
*((_QWORD *)&v23 + 1) = 15;
strcpy((char *)Block, "-1");
v11 = a2;
if ( (unsigned __int64)a2[3] > 0xF )
v11 = *a2;
v12 = (unsigned __int64)a2[2];
v13 = v12;
if ( v12 > 2 )
v13 = 2;
if ( !memcmp(v11, Block, v13) && v12 == 2 )
{
m_uploadActionDelegate = a1->m_uploadActionDelegate;
if ( m_uploadActionDelegate )
m_uploadActionDelegate->uploadActionFailed(m_uploadActionDelegate, SplitIntFromKey, 33);
}
else
{
v14 = a1->m_uploadActionDelegate;
if ( v14 )
v14->uploadActionFinished(v14, SplitIntFromKey, 33);
v15 = cocos2d::CCDictionary::objectForKey(a1->m_storedUserInfo, SplitIntFromKey);
v16 = 0;
if ( v15 )
{
v15[13].m_nTag = 0;
m_userInfoDelegate = a1->m_userInfoDelegate;
if ( m_userInfoDelegate )
m_userInfoDelegate->userInfoChanged(m_userInfoDelegate, (GJUserScore *)v15);
}
StoredUserList = GameLevelManager::getStoredUserList(a1, (UserListType)0);
v19 = StoredUserList;
if ( StoredUserList && cocos2d::CCArray::count(StoredUserList) )
{
while ( LODWORD(cocos2d::CCArray::objectAtIndex(v19, v16)[7].__vftable) != (_DWORD)SplitIntFromKey )
{
if ( ++v16 >= cocos2d::CCArray::count(v19) )
goto LABEL_30;
}
cocos2d::CCArray::removeObjectAtIndex(v19, v16, 1);
m_userListDelegate = a1->m_userListDelegate;
if ( m_userListDelegate )
m_userListDelegate->userListChanged(m_userListDelegate, v19, (UserListType)0LL);
}
}
LABEL_30:
sub_14003A830((__int64)a2);
sub_14003A830((__int64)a3);
}