//
// GJMultiplayerManager::addComment from 0x981cc0 to 0x981f48 (648 bytes)
//
// 3 xrefs:
// > GJMultiplayerManager::onJoinLobbyCompleted @ 0x982554
// > GJMultiplayerManager::createAndAddComment @ 0x982f70
// > ??> @ 0x5d4e0
//
// 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)
{
intptr_t v3; // x19
cocos2d::CCArray *v5; // x20
GJComment *v6; // x21
char *v7; // x0
int m_accountID; // w19
GJAccountManager *v9; // x0
cocos2d::CCDictionary *v10; // x0
intptr_t v11; // x1
char *v12; // x1
unsigned int v14; // w19
__int64 v15; // x0
int v16; // w27
__int64 v17; // x26
GJAccountManager *v18; // x0
unsigned int *v19; // x1
int v20; // w2
unsigned int *v21; // x0
int v22; // w2
char *v23; // [xsp+70h] [xbp+70h] BYREF
v3 = a3;
v5 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(a1 + 344), a3);
if ( !v5 )
{
v5 = (cocos2d::CCArray *)cocos2d::CCArray::create(nullptr);
cocos2d::CCDictionary::setObject(*(cocos2d::CCDictionary **)(a1 + 344), v5, v3);
}
sub_D18D28(&v23);
GameLevelManager::responseToDict(&v23, 1u);
v6 = GJComment::create();
v7 = v23 - 24;
if ( v23 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v19 = (unsigned int *)(v23 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *((_DWORD *)v23 - 2);
*((_DWORD *)v23 - 2) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v7);
}
m_accountID = v6->m_accountID;
v9 = GJAccountManager::sharedState();
if ( m_accountID == v9->m_accountID - v9->m_unkInt1 )
{
v14 = 0;
if ( v6->m_commentID != -1 )
{
while ( v14 < (unsigned int)cocos2d::CCArray::count(v5) )
{
v15 = cocos2d::CCArray::objectAtIndex(v5, v14);
v16 = *(_DWORD *)(v15 + 356);
v17 = v15;
v18 = GJAccountManager::sharedState();
if ( v16 == v18->m_accountID - v18->m_unkInt1 && *(_DWORD *)(v17 + 336) == -1 )
{
*(_DWORD *)(v17 + 336) = v6->m_commentID;
return _stack_chk_guard;
}
++v14;
}
}
}
v10 = *(cocos2d::CCDictionary **)(a1 + 328);
v11 = v6->m_accountID;
v6->m_unkMultiplayerBool = 1;
if ( cocos2d::CCDictionary::objectForKey(v10, v11) )
{
sub_D18D28(&v23);
sub_D18EA8(&v6->m_userName, &v23);
v12 = v23 - 24;
if ( v23 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)(v23 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *((_DWORD *)v23 - 2);
*((_DWORD *)v23 - 2) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v12);
}
}
cocos2d::CCArray::addObject(v5, v6);
return _stack_chk_guard;
}