//
// ProfilePage::onFollow from 0x1007b94c0 to 0x1007b971e (606 bytes)
//
// 1 xrefs:
// > ProfilePage::init @ 0x1007b8e68
//
// 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
//
void __fastcall ProfilePage::onFollow(ProfilePage *a1, cocos2d::CCObject *a2)
{
__m128 v2; // xmm0
GameManager *v3; // rax
GameLevelManager *v4; // rax
bool isFollowingUser; // r14
GameLevelManager *v6; // rax
const char *v7; // r14
signed int v8; // r14d
GameManager *v9; // rax
GameManager *v10; // rax
__m128 v11; // xmm0
GameManager *v12; // rax
__m128 v13; // xmm0
double v14; // xmm0_8
GameLevelManager *v15; // rax
__int64 v16; // rbx
cocos2d::CCSpriteFrameCache *v17; // rax
cocos2d::CCSpriteFrame *v18; // rax
char *v19; // rax
const char *CString; // r14
size_t v21; // rax
size_t v22; // rbx
char *v23; // r15
size_t v24; // r12
__int64 v25; // rbx
__int128 __dst; // [rsp+0h] [rbp-40h] BYREF
void *__p; // [rsp+10h] [rbp-30h]
float v28; // [rsp+1Ch] [rbp-24h]
v3 = GameManager::sharedState();
GameManager::reportAchievementWithID(v3, "geometry.ach.followCreator", 100, 0);
v4 = GameLevelManager::sharedState();
isFollowingUser = GameLevelManager::isFollowingUser(v4, a1->m_accountID);
v6 = GameLevelManager::sharedState();
if ( isFollowingUser )
{
GameLevelManager::unfollowUser(v6, a1->m_accountID);
v7 = "gj_heartOff_001.png";
LABEL_5:
v16 = ((__int64 (__fastcall *)(CCMenuItemSpriteExtra *))a1->m_followBtn->getNormalImage)(a1->m_followBtn);
v17 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
v18 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v17, v7);
(*(void (__fastcall **)(__int64, cocos2d::CCSpriteFrame *))(*(_QWORD *)v16 + 1144LL))(v16, v18);
return;
}
v8 = cocos2d::CCDictionary::count(v6->m_followedCreators);
v28 = (float)(v8 + 1);
v2.f32[0] = (float)(v28 / 10.0) * 100.0;
v9 = GameManager::sharedState();
GameManager::reportAchievementWithID(v9, "geometry.ach.followCreator02", (int)_mm_round_ss(v2, v2, 9).f32[0], 0);
v10 = GameManager::sharedState();
v11 = (__m128)LODWORD(v28);
v11.f32[0] = (float)(v28 / 25.0) * 100.0;
GameManager::reportAchievementWithID(v10, "geometry.ach.followCreator03", (int)_mm_round_ss(v11, v11, 9).f32[0], 0);
v12 = GameManager::sharedState();
v13 = (__m128)LODWORD(v28);
v13.f32[0] = (float)(v28 / 50.0) * 100.0;
*(_QWORD *)&v14 = _mm_round_ss(v13, v13, 9).u64[0];
GameManager::reportAchievementWithID(v12, "geometry.ach.followCreator04", (int)*(float *)&v14, 0);
if ( v8 < 100 )
{
v15 = GameLevelManager::sharedState();
GameLevelManager::followUser(v15, a1->m_accountID);
v7 = "gj_heartOn_001.png";
goto LABEL_5;
}
v19 = sub_1007AB580("You can only follow %i users at the same time.", 100);
CString = cocos2d::CCString::getCString((cocos2d::CCString *)v19);
v21 = strlen(CString);
if ( v21 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v14);
v22 = v21;
if ( v21 >= 0x17 )
{
v24 = 26;
if ( (v21 | 7) != 0x17 )
v24 = (v21 | 7) + 1;
v23 = (char *)operator new(v24);
__p = v23;
*(_QWORD *)&__dst = v24 + 1;
*((_QWORD *)&__dst + 1) = v22;
}
else
{
LOBYTE(__dst) = 2 * v21;
v23 = (char *)&__dst + 1;
if ( !v21 )
goto LABEL_14;
}
memmove(v23, CString, v22);
LABEL_14:
v23[v22] = 0;
v25 = sub_10049B0F0(0, (__int64)"Max Followed", &__dst, (__int64)"OK", 0, v14);
if ( (__dst & 1) != 0 )
operator delete(__p);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v25 + 1288LL))(v25);
}