//
// GJMultiplayerManager::addComment from 0x10065aef0 to 0x10065b0d3 (483 bytes)
//
// 2 xrefs:
// > GJMultiplayerManager::onJoinLobbyCompleted @ 0x100659e6d
// > GJMultiplayerManager::createAndAddComment @ 0x10065be8a
//
// 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
//
__int64 __fastcall GJMultiplayerManager::addComment(__int64 a1, __int64 a2, int a3, __m128 a4)
{
cocos2d::CCDictionary *v6; // rdi
intptr_t v7; // r12
__int64 v8; // rsi
cocos2d::CCObject *v9; // rbx
cocos2d::CCDictionary *v10; // rax
GJComment *v11; // r15
int m_accountID; // r12d
GJAccountManager *v13; // rax
unsigned int v14; // r12d
__int64 v15; // r13
int v16; // r14d
GJAccountManager *v17; // rax
__int64 result; // rax
cocos2d::CCObject *v19; // rax
__int64 v20; // [rsp+8h] [rbp-68h]
__m128 v21; // [rsp+10h] [rbp-60h] BYREF
void *__p; // [rsp+20h] [rbp-50h]
std::string __str; // [rsp+30h] [rbp-40h] BYREF
v6 = *(cocos2d::CCDictionary **)(a1 + 344);
v7 = a3;
v8 = a3;
v9 = cocos2d::CCDictionary::objectForKey(v6, a3);
if ( v9 )
{
if ( (*(_BYTE *)a2 & 1) == 0 )
{
LABEL_3:
__p = *(void **)(a2 + 16);
a4 = *(__m128 *)a2;
v21 = *(__m128 *)a2;
goto LABEL_6;
}
}
else
{
v9 = (cocos2d::CCObject *)sub_10071F9E0(v6, v8);
cocos2d::CCDictionary::setObject(*(cocos2d::CCDictionary **)(a1 + 344), v9, v7);
if ( (*(_BYTE *)a2 & 1) == 0 )
goto LABEL_3;
}
sub_100006B70(&v21, *(const void **)(a2 + 16), *(_QWORD *)(a2 + 8), *(double *)a4.i64);
LABEL_6:
v20 = a1;
v10 = GameLevelManager::responseToDict((__int64)&v21, 1, *(double *)a4.i64);
v11 = GJComment::create(v10);
if ( (v21.i8[0] & 1) != 0 )
operator delete(__p);
m_accountID = v11->m_accountID;
v13 = GJAccountManager::sharedState();
if ( m_accountID == v13->m_accountID - v13->m_unkInt1 && v11->m_commentID != -1 && (unsigned int)sub_100720070(v9) )
{
v14 = 0;
while ( 1 )
{
v15 = sub_1007200C0(v9, v14);
v16 = *(_DWORD *)(v15 + 388);
v17 = GJAccountManager::sharedState();
if ( v16 == v17->m_accountID - v17->m_unkInt1 && *(_DWORD *)(v15 + 368) == -1 )
break;
if ( ++v14 >= (unsigned int)sub_100720070(v9) )
goto LABEL_16;
}
result = (unsigned int)v11->m_commentID;
*(_DWORD *)(v15 + 368) = result;
}
else
{
LABEL_16:
v11->m_unkMultiplayerBool = 1;
v19 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(v20 + 328), v11->m_accountID);
if ( v19 )
{
if ( (v19[5].m_unknown2 & 1) != 0 )
sub_100006B70(&__str, v19[6].__vftable, *(_QWORD *)&v19[5].m_uOrderOfArrival, *(double *)a4.i64);
else
__str = *(std::string *)&v19[5].m_unknown2;
std::string::operator=((std::string *)&v11->m_userName, &__str);
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__str.__r_.__value_.__l.__data_);
}
return sub_10071FCD0(v9, v11);
}
return result;
}