//
// GameManager::getNextUsedKey from 0x10036db80 to 0x10036dcb1 (305 bytes)
//
// 1 xrefs:
// > GameManager::reorderKey @ 0x10036dfec
//
// 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:29:01 +0000
//
__int64 __fastcall GameManager::getNextUsedKey(__int64 a1, int a2, char a3)
{
__int64 v4; // rbx
unsigned int v5; // r15d
__int64 v6; // rax
unsigned int v7; // eax
unsigned int v8; // r12d
__int64 v9; // rax
int v10; // r13d
unsigned int v11; // eax
__int64 v13; // rax
unsigned int i; // r12d
__int64 v16; // rax
v4 = cocos2d::CCDictionary::allKeys(*(_QWORD *)(a1 + 456));
if ( (unsigned int)sub_1007FEF90(v4) )
qsort(
*(void **)(*(_QWORD *)(v4 + 56) + 16LL),
**(unsigned int **)(v4 + 56),
8u,
(int (__cdecl *)(const void *, const void *))sub_10035FC40);
v5 = 0;
if ( (unsigned int)sub_1007FEF90(v4) )
{
if ( a3 )
{
v6 = cocos2d::CCArray::stringAtIndex(v4, 0);
v7 = cocos2d::CCString::intValue(v6);
if ( v7 != a2 )
{
for ( i = 1; ; ++i )
{
v5 = v7;
if ( i >= (unsigned int)sub_1007FEF90(v4) )
break;
v16 = cocos2d::CCArray::stringAtIndex(v4, i);
v7 = cocos2d::CCString::intValue(v16);
if ( v7 == a2 )
return v5;
}
}
return 0;
}
else
{
v8 = 1;
while ( 1 )
{
v9 = cocos2d::CCArray::stringAtIndex(v4, v8 - 1);
v10 = cocos2d::CCString::intValue(v9);
v11 = sub_1007FEF90(v4);
if ( v10 == a2 )
break;
if ( v8++ >= v11 )
return v5;
}
if ( v8 < v11 )
{
v13 = cocos2d::CCArray::stringAtIndex(v4, v8);
return cocos2d::CCString::intValue(v13);
}
}
}
return v5;
}