//
// GameLevelManager::tryGetUsername from 0x100540400 to 0x1005406db (731 bytes)
//
// 16 xrefs:
// > CommentCell::loadFromComment @ 0x10022d55c
// > FriendRequestPopup::init @ 0x10029147d
// > FriendRequestPopup::onBlock @ 0x1002925ed
// > GJWriteMessagePopup::init @ 0x10029571e
// > LevelBrowserLayer::getSearchTitle @ 0x10048641d
// > GJGameLevel::create @ 0x100541997
// > ShareCommentLayer::init @ 0x1006b14f6
// > ProfilePage::init @ 0x10089de29
// > ProfilePage::onInfo @ 0x1008a35ee
// > ProfilePage::onCopyName @ 0x1008a3e23
// > sub_100932760 @ 0x100932889
// > NewThreadPopup::init @ 0x1009446dd
// > NewThreadPopup::threadSendFinished @ 0x100948af4
// > sub_100965DF0 @ 0x100965f11
// > sub_100966200 @ 0x1009662fe
// > CommentOptionsPopup::init @ 0x100967d14
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:31:57 +0000
//
std::string *__fastcall GameLevelManager::tryGetUsername(std::string *this, __int64 *a2, int a3)
{
unsigned __int64 v5; // r15
void *v6; // rax
int v7; // r13d
__int64 v8; // rax
unsigned __int64 v9; // rdi
char v10; // r8
std::string::size_type size; // r9
unsigned __int64 v12; // rax
unsigned __int64 v13; // r10
unsigned __int64 v14; // r11
__int64 v15; // rcx
__int64 **v16; // rax
__int64 *v17; // rsi
unsigned __int64 v18; // r10
unsigned __int64 v19; // rax
__int64 v20; // rax
__int64 v21; // rax
__int64 v22; // rax
std::string::size_type v23; // rax
char v24; // cl
std::string::size_type v25; // rdx
unsigned __int64 v26; // rsi
__int64 v27; // rax
__int128 v29; // [rsp+0h] [rbp-40h] BYREF
std::string::size_type v30; // [rsp+10h] [rbp-30h]
if ( !a3 )
{
*(_WORD *)&this->__r_.__value_.__l.0 = 11522;
this->__r_.__value_.__s.__data_[1] = 0;
return this;
}
v5 = a3;
v6 = cocos2d::CCDictionary::valueForKey_1(a2[123], a3);
v7 = cocos2d::CCString::intValue(v6);
v8 = GameLevelManager::sharedState();
GameLevelManager::userNameForUserID(this, v8, v7);
v9 = *(_BYTE *)&this->__r_.__value_.__l.0 >> 1;
v10 = *(_BYTE *)&this->__r_.__value_.__s.0 & 1;
size = this->__r_.__value_.__l.__size_;
v12 = size;
if ( !v10 )
v12 = *(_BYTE *)&this->__r_.__value_.__l.0 >> 1;
if ( v12 <= 1 )
{
v13 = a2[126];
if ( v13 )
{
v14 = (0x101010101010101LL
* ((((v13 - ((v13 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v13 - ((v13 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((v13 - ((v13 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v13 - ((v13 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v14 <= 1 )
{
v15 = v5 & (v13 - 1);
v16 = *(__int64 ***)(a2[125] + 8 * v15);
if ( !v16 )
goto LABEL_34;
goto LABEL_14;
}
v15 = v5;
if ( v13 > v5 )
goto LABEL_13;
if ( (v13 | v5) >> 32 )
{
v15 = v5 % v13;
LABEL_13:
v16 = *(__int64 ***)(a2[125] + 8 * v15);
if ( !v16 )
goto LABEL_34;
goto LABEL_14;
}
v15 = a3 % (unsigned int)v13;
v16 = *(__int64 ***)(a2[125] + 8 * v15);
if ( v16 )
{
LABEL_14:
v17 = *v16;
if ( !*v16 )
goto LABEL_34;
if ( (unsigned int)v14 < 2 )
{
v18 = v13 - 1;
while ( 1 )
{
v20 = v17[1];
if ( v20 == v5 )
{
if ( *((_DWORD *)v17 + 4) == a3 )
goto LABEL_32;
}
else if ( (v18 & v20) != v15 )
{
goto LABEL_34;
}
v17 = (__int64 *)*v17;
if ( !v17 )
goto LABEL_34;
}
}
do
{
v19 = v17[1];
if ( v19 == v5 )
{
if ( *((_DWORD *)v17 + 4) == a3 )
{
LABEL_32:
std::string::operator=(this, (const std::string *)v17 + 1);
size = this->__r_.__value_.__l.__size_;
v10 = *(_BYTE *)&this->__r_.__value_.__s.0 & 1;
v9 = *(_BYTE *)&this->__r_.__value_.__l.0 >> 1;
break;
}
}
else
{
if ( v19 < v13 )
goto LABEL_23;
if ( (v13 | v19) >> 32 )
{
v19 %= v13;
LABEL_23:
if ( v19 != v15 )
break;
goto LABEL_18;
}
if ( (unsigned int)v19 % (unsigned int)v13 != v15 )
break;
}
LABEL_18:
v17 = (__int64 *)*v17;
}
while ( v17 );
}
}
}
LABEL_34:
if ( v10 )
v9 = size;
if ( v9 <= 1 )
{
v21 = GameLevelManager::sharedState();
v22 = cocos2d::CCDictionary::objectForKey_1(*(_QWORD *)(v21 + 1120), v5);
if ( v22 )
std::string::operator=(this, (const std::string *)(v22 + 320));
}
v23 = *(_BYTE *)&this->__r_.__value_.__l.0 >> 1;
v24 = *(_BYTE *)&this->__r_.__value_.__s.0 & 1;
v25 = this->__r_.__value_.__l.__size_;
v26 = v25;
if ( !v24 )
v26 = *(_BYTE *)&this->__r_.__value_.__l.0 >> 1;
if ( v26 <= 1 )
{
v27 = GameStatsManager::sharedState();
GameStatsManager::usernameForAccountID(&v29, v27, a3);
if ( (*(_BYTE *)&this->__r_.__value_.__s.0 & 1) != 0 )
operator delete(this->__r_.__value_.__l.__data_);
this->__r_.__value_.__r.__words[2] = v30;
*(_OWORD *)&this->__r_.__value_.__l.0 = v29;
v25 = this->__r_.__value_.__l.__size_;
v24 = *(_BYTE *)&this->__r_.__value_.__s.0 & 1;
v23 = *(_BYTE *)&this->__r_.__value_.__l.0 >> 1;
}
if ( v24 )
v23 = v25;
if ( !v23 )
std::string::assign(this, "-");
return this;
}