//
// GJMultiplayerManager::addComment from 0x50ffc8 to 0x5100d2 (266 bytes)
//
// 2 xrefs:
// > GJMultiplayerManager::onJoinLobbyCompleted @ 0x51031c
// > GJMultiplayerManager::createAndAddComment @ 0x510608
//
// 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
//
GJAccountManager *__fastcall GJMultiplayerManager::addComment(int a1, char *a2, char *a3)
{
cocos2d::CCArray *v5; // r8
GJComment *v6; // r5
int m_accountID; // r6
GJAccountManager *v8; // r0
intptr_t v9; // r1
unsigned int i; // r6
int v11; // r0
int v12; // r11
int v13; // r9
GJAccountManager *result; // r0
char *v15[3]; // [sp+0h] [bp-Ch] BYREF
v15[0] = (char *)a1;
v15[1] = a2;
v15[2] = a3;
v5 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(a1 + 276), (intptr_t)a3);
if ( !v5 )
{
v5 = (cocos2d::CCArray *)cocos2d::CCArray::create(nullptr);
cocos2d::CCDictionary::setObject(*(cocos2d::CCDictionary **)(a1 + 276), v5, (intptr_t)a3);
}
sub_775C20(v15);
GameLevelManager::responseToDict(v15, 1);
v6 = GJComment::create();
sub_774008(v15);
m_accountID = v6->m_accountID;
v8 = GJAccountManager::sharedState();
if ( m_accountID == v8->m_accountID - v8->m_unkInt1 && v6->m_commentID != -1 )
{
for ( i = 0; i < cocos2d::CCArray::count(v5); ++i )
{
v11 = cocos2d::CCArray::objectAtIndex(v5, i);
v12 = *(_DWORD *)(v11 + 292);
v13 = v11;
result = GJAccountManager::sharedState();
if ( v12 == result->m_accountID - result->m_unkInt1 && *(_DWORD *)(v13 + 272) == -1 )
{
*(_DWORD *)(v13 + 272) = v6->m_commentID;
return result;
}
}
}
v9 = v6->m_accountID;
v6->m_unkMultiplayerBool = 1;
if ( cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(a1 + 268), v9) )
{
sub_775C20(v15);
sub_775D40(&v6->m_userName, v15);
sub_774008(v15);
}
return (GJAccountManager *)cocos2d::CCArray::addObject(v5, v6);
}