//
// DS_Dictionary::loadRootSubDictFromFile from 0x18001bd70 to 0x18001c05a (746 bytes)
//
// 3 xrefs:
// > CCContentManager::addDictDS @ 0x180005e93
// > ??> @ 0x1801438a8
// > ??> @ 0x1801aea94
//
// 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=2
__int64 __fastcall DS_Dictionary::loadRootSubDictFromFile(DS_Dictionary *this, const char *a2)
{
std::vector
*p_dictTree; // rbx
std::_Simple_types::value_type *Myfirst; // rax
_QWORD *v6; // rax
_BYTE *Mylast; // rdx
struct cocos2d::CCFileUtils *v8; // rax
struct cocos2d::CCFileUtils *v9; // rax
void **v10; // rdx
__int64 v11; // rbx
const struct __crt_strtox::big_integer *v12; // rdx
const struct __crt_strtox::big_integer *v13; // rdx
unsigned __int64 Size; // rdi
__int64 v15; // rcx
void **v16; // rbx
char *v17; // rbx
struct cocos2d::CCFileUtils *v18; // rax
void **v19; // rdx
__int64 buffer; // rax
void *v21; // rcx
std::_Vector_val>::pointer v22; // rbx
__int64 v23; // rax
__int64 v24; // rax
__int64 v25; // rax
unsigned __int8 v26; // bl
void *v27; // rcx
unsigned int v29; // [rsp+30h] [rbp-59h] BYREF
cocos2d::CCThread v30; // [rsp+38h] [rbp-51h] BYREF
_BYTE v31[8]; // [rsp+40h] [rbp-49h] BYREF
__int128 v32; // [rsp+48h] [rbp-41h] BYREF
__int64 v33; // [rsp+58h] [rbp-31h]
_BYTE v34[24]; // [rsp+60h] [rbp-29h] BYREF
void *Block[2]; // [rsp+78h] [rbp-11h] BYREF
__int64 v36; // [rsp+88h] [rbp-1h]
unsigned __int64 v37; // [rsp+90h] [rbp+7h]
void *v38[3]; // [rsp+98h] [rbp+Fh] BYREF
unsigned __int64 v39; // [rsp+B0h] [rbp+27h]
p_dictTree = &this->dictTree;
Myfirst = this->dictTree._Mypair._Myval2._Myfirst;
if ( Myfirst != this->dictTree._Mypair._Myval2._Mylast )
this->dictTree._Mypair._Myval2._Mylast = Myfirst;
v6 = (_QWORD *)pugi::xml_node::xml_node(&v30);
Mylast = p_dictTree->_Mypair._Myval2._Mylast;
if ( Mylast == (_BYTE *)p_dictTree->_Mypair._Myval2._Myend )
{
sub_180015D80((const void **)&p_dictTree->_Mypair._Myval2._Myfirst, Mylast, v6);
}
else
{
*(_QWORD *)Mylast = *v6;
++p_dictTree->_Mypair._Myval2._Mylast;
}
v8 = cocos2d::CCFileUtils::sharedFileUtils();
((void (__fastcall *)(struct cocos2d::CCFileUtils *, void **, const char *, _QWORD))v8->createCCArrayWithContentsOfFile)(
v8,
v38,
a2,
0);
v29 = 0;
v9 = cocos2d::CCFileUtils::sharedFileUtils();
v10 = v38;
if ( v39 > 0xF )
v10 = (void **)v38[0];
v11 = ((__int64 (__fastcall *)(struct cocos2d::CCFileUtils *, void **, const char *, unsigned int *))v9->addSearchResolutionsOrder)(
v9,
v10,
"r",
&v29);
pugi::xml_document::load_buffer(this, &v32, v11, v29, 116, 0);
if ( !__crt_strtox::is_zero((__crt_strtox *)&v32, v12) || !v11 )
{
sub_18003D240(Block);
Size = -1;
do
++Size;
while ( a2[Size] );
v15 = v36;
if ( Size > v37 - v36 )
{
sub_180007900(Block, Size, 0, a2, Size);
}
else
{
v36 += Size;
v16 = Block;
if ( v37 > 0xF )
v16 = (void **)Block[0];
v17 = (char *)v16 + v15;
memmove(v17, a2, Size);
v17[Size] = 0;
}
v29 = 0;
v18 = cocos2d::CCFileUtils::sharedFileUtils();
v19 = Block;
if ( v37 > 0xF )
v19 = (void **)Block[0];
v11 = ((__int64 (__fastcall *)(struct cocos2d::CCFileUtils *, void **, const char *, unsigned int *))v18->addSearchResolutionsOrder)(
v18,
v19,
"r",
&v29);
buffer = pugi::xml_document::load_buffer(this, v34, v11, v29, 116, 0);
v32 = *(_OWORD *)buffer;
v33 = *(_QWORD *)(buffer + 16);
v13 = (const struct __crt_strtox::big_integer *)v37;
if ( v37 > 0xF )
{
v21 = Block[0];
if ( v37 + 1 >= 0x1000 )
{
v21 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v21 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v21);
}
}
if ( __crt_strtox::is_zero((__crt_strtox *)&v32, v13) && v11 )
{
v22 = this->dictTree._Mypair._Myval2._Mylast;
v23 = sub_18007FB10(this, &v30, "plist");
v22[-1]._root = *(pugi::xml_node_struct **)sub_18007FB10(v23, v31, "dict");
v24 = sub_18007FB10(this, v31, "plist");
v25 = sub_18007FAB0(v24, &v30, "gjver");
this->compatible = (int)sub_18007FA30(v25, 0) < 2;
v26 = 1;
}
else
{
v26 = 0;
}
if ( v39 > 0xF )
{
v27 = v38[0];
if ( v39 + 1 >= 0x1000 )
{
v27 = *((void **)v38[0] - 1);
if ( (unsigned __int64)((char *)v38[0] - (char *)v27 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v27);
}
return v26;
}