//
// DS_Dictionary::getObjectForKey from 0x18001aa40 to 0x18001ad60 (800 bytes)
//
// 3 xrefs:
// > DS_Dictionary::getArrayForKey @ 0x180019db5
// > ??> @ 0x1801438a8
// > ??> @ 0x1801aea1c
//
// 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
//
// Hidden C++ exception states: #wind=1
struct cocos2d::CCArray *__fastcall DS_Dictionary::getObjectForKey(DS_Dictionary *this, const char *a2)
{
std::_Vector_val>::pointer v4; // rcx
const char *v5; // r8
const char *v6; // r8
struct cocos2d::CCArray *result; // rax
__int64 v8; // rax
const char *v9; // rcx
__int64 v10; // rax
int v11; // edx
int v12; // r8d
std::_Vector_val>::pointer Mylast; // rdx
bool BoolForKey; // r15
int IntegerForKey; // eax
int v16; // esi
ObjectDecoder *v17; // rax
__int64 v18; // rax
const char *v19; // rcx
__int64 v20; // rax
int v21; // edx
int v22; // r8d
cocos2d::CCObject *v23; // rbx
void *v24; // rcx
_BYTE *v25; // rax
size_t v26; // r8
__int64 v27; // [rsp+20h] [rbp-40h] BYREF
pugi::xml_node_struct *v28; // [rsp+28h] [rbp-38h] BYREF
void *Block[2]; // [rsp+30h] [rbp-30h] BYREF
__int128 v30; // [rsp+40h] [rbp-20h]
v4 = this->dictTree._Mypair._Myval2._Mylast - 1;
v5 = "k";
if ( this->compatible )
v5 = "key";
sub_18007FB10(v4, &v27, v5);
if ( !sub_18007F4E0(&v27) )
return nullptr;
while ( strcmp(a2, (const char *)sub_18007FB70(&v27)) )
{
v6 = "k";
if ( this->compatible )
v6 = "key";
v27 = *(_QWORD *)sub_180081A50(&v27, &v28, v6);
if ( !sub_18007F4E0(&v27) )
return nullptr;
}
sub_180081AB0(&v27, &v28);
v8 = sub_180081A30(&v28);
v9 = "d";
if ( this->compatible )
v9 = "dict";
v10 = v8 - (_QWORD)v9;
do
{
v11 = (unsigned __int8)v9[v10];
v12 = *(unsigned __int8 *)v9 - v11;
if ( v12 )
break;
++v9;
}
while ( v11 );
if ( v12 )
{
v18 = sub_180081A30(&v28);
v19 = "t";
if ( this->compatible )
v19 = "true";
v20 = v18 - (_QWORD)v19;
do
{
v21 = (unsigned __int8)v19[v20];
v22 = *(unsigned __int8 *)v19 - v21;
if ( v22 )
break;
++v19;
}
while ( v21 );
if ( v22 )
{
v25 = (_BYTE *)sub_18007FB70(&v28);
*(_OWORD *)Block = 0;
v30 = 0;
v26 = -1;
do
++v26;
while ( v25[v26] );
sub_18000CE60(Block, v25, v26);
v23 = cocos2d::CCString::create((__int64)Block);
if ( *((_QWORD *)&v30 + 1) <= 0xFu )
return (struct cocos2d::CCArray *)v23;
v24 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v30 + 1) + 1LL) >= 0x1000 )
{
v24 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v24 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
}
else
{
*(_OWORD *)Block = 0;
*(_QWORD *)&v30 = 1;
*((_QWORD *)&v30 + 1) = 15;
LOWORD(Block[0]) = 49;
v23 = cocos2d::CCString::create((__int64)Block);
if ( *((_QWORD *)&v30 + 1) <= 0xFu )
return (struct cocos2d::CCArray *)v23;
v24 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v30 + 1) + 1LL) >= 0x1000 )
{
v24 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v24 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
}
j_j_free_0(v24);
return (struct cocos2d::CCArray *)v23;
}
Mylast = this->dictTree._Mypair._Myval2._Mylast;
if ( Mylast == this->dictTree._Mypair._Myval2._Myend )
{
sub_180015D80((const void **)&this->dictTree._Mypair._Myval2._Myfirst, Mylast, &v28);
}
else
{
Mylast->_root = v28;
++this->dictTree._Mypair._Myval2._Mylast;
}
BoolForKey = DS_Dictionary::getBoolForKey(this, "_isArr");
IntegerForKey = DS_Dictionary::getIntegerForKey(this, "kCEK");
v16 = IntegerForKey;
if ( IntegerForKey )
{
if ( IntegerForKey == -1 )
v16 = DS_Dictionary::getIntegerForKey(this, "kCEK");
v17 = ObjectDecoder::sharedDecoder();
result = (struct cocos2d::CCArray *)ObjectDecoder::getDecodedObject(v17, v16, this);
if ( (unsigned __int64)(this->dictTree._Mypair._Myval2._Mylast - this->dictTree._Mypair._Myval2._Myfirst) > 1 )
--this->dictTree._Mypair._Myval2._Mylast;
}
else if ( BoolForKey )
{
return DS_Dictionary::getArrayForKey(this, a2, 1);
}
else
{
return (struct cocos2d::CCArray *)DS_Dictionary::getDictForKey(this, a2, 1);
}
return result;
}