//
// GameToolbox::stringSetupToDict from 0x581334 to 0x581794 (1120 bytes)
//
// 3 xrefs:
// > LevelSettingsObject::objectFromString @ 0x66ada8
// > StartPosObject::loadSettingsFromString @ 0x7605a4
// > ??> @ 0xc3390
//
// 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
//
cocos2d::CCDictionary *__fastcall GameToolbox::stringSetupToDict(char **a1, char *a2)
{
cocos2d::CCArray *v4; // x0
cocos2d::CCArray *v5; // x25
size_t v6; // x0
__int64 v7; // x20
__int64 v8; // x3
unsigned __int64 v9; // x19
__int64 v10; // x27
const std::string *v11; // x1
cocos2d::CCObject *v12; // x0
void *v13; // x0
size_t v14; // x0
char *v15; // x0
unsigned int *v16; // x1
int v17; // w2
unsigned int *v18; // x1
int v19; // w2
char *v20; // x0
void *v21; // x0
unsigned int v22; // w19
unsigned int v23; // w26
cocos2d::CCString *v24; // x0
char *CString; // x27
cocos2d::CCObject *v26; // x26
void *v27; // x0
unsigned int *v28; // x1
int v29; // w2
unsigned int *v31; // x1
int v32; // w2
unsigned int *v33; // x1
int v34; // w2
cocos2d::CCDictionary *v35; // [xsp+68h] [xbp+68h]
__int64 v36; // [xsp+90h] [xbp+90h] BYREF
char *v37; // [xsp+98h] [xbp+98h] BYREF
__int64 v38; // [xsp+A0h] [xbp+A0h] BYREF
v35 = cocos2d::CCDictionary::create();
v4 = (cocos2d::CCArray *)sub_D153B8((int)&v36, *a1);
v5 = (cocos2d::CCArray *)cocos2d::CCArray::create(v4);
v6 = strlen(a2);
v7 = sub_D168E0((int)&v36, a2, 0, v6);
v8 = v7;
v9 = 0;
v10 = *(_QWORD *)(v36 - 24);
while ( 1 )
{
sub_D14F84(&v37, &v36, v9, v8);
if ( v10 != v9 || *((_QWORD *)v37 - 3) )
{
sub_D153B8((int)&v38, v37);
v12 = (cocos2d::CCObject *)cocos2d::CCString::create((cocos2d::CCString *)&v38, v11);
cocos2d::CCArray::addObject(v5, v12);
v13 = (void *)(v38 - 24);
if ( (__int64 *)(v38 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(v38 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(_DWORD *)(v38 - 8);
*(_DWORD *)(v38 - 8) = v19 - 1;
}
if ( v19 <= 0 )
break;
}
}
if ( v7 == -1 )
goto LABEL_19;
LABEL_7:
v9 = v7 + 1;
v14 = strlen(a2);
v7 = sub_D168E0((int)&v36, a2, (int)v7 + 1, v14);
v15 = v37 - 24;
if ( v37 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)(v37 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v37 - 2);
*((_DWORD *)v37 - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v15);
}
v8 = v7 - v9;
if ( *(_QWORD *)(v36 - 24) < v9 )
sub_D13C5C(
"%s: __pos (which is %zu) > this->size() (which is %zu)",
"basic_string::substr",
v9,
*(_QWORD *)(v36 - 24));
}
operator delete(v13);
if ( v7 != -1 )
goto LABEL_7;
LABEL_19:
v20 = v37 - 24;
if ( v37 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v33 = (unsigned int *)(v37 - 8);
do
v34 = __ldaxr(v33);
while ( __stlxr(v34 - 1, v33) );
}
else
{
v34 = *((_DWORD *)v37 - 2);
*((_DWORD *)v37 - 2) = v34 - 1;
}
if ( v34 <= 0 )
operator delete(v20);
}
v21 = (void *)(v36 - 24);
if ( (__int64 *)(v36 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v31 = (unsigned int *)(v36 - 8);
do
v32 = __ldaxr(v31);
while ( __stlxr(v32 - 1, v31) );
}
else
{
v32 = *(_DWORD *)(v36 - 8);
*(_DWORD *)(v36 - 8) = v32 - 1;
}
if ( v32 <= 0 )
operator delete(v21);
}
v22 = 0;
LABEL_22:
v23 = v22;
if ( v22 >= (unsigned int)cocos2d::CCArray::count(v5) )
return v35;
while ( 1 )
{
v22 += 2;
if ( (unsigned int)cocos2d::CCArray::count(v5) < v22 )
return nullptr;
v24 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v5, v23);
CString = (char *)cocos2d::CCString::getCString(v24);
v26 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(v5, v22 - 1);
sub_D153B8((int)&v38, CString);
cocos2d::CCDictionary::setObject((int)v35, v26);
v27 = (void *)(v38 - 24);
if ( (__int64 *)(v38 - 24) == &qword_124B6B0 )
goto LABEL_22;
if ( &pthread_create )
{
v28 = (unsigned int *)(v38 - 8);
do
v29 = __ldaxr(v28);
while ( __stlxr(v29 - 1, v28) );
}
else
{
v29 = *(_DWORD *)(v38 - 8);
*(_DWORD *)(v38 - 8) = v29 - 1;
}
if ( v29 > 0 )
goto LABEL_22;
v23 = v22;
operator delete(v27);
if ( v22 >= (unsigned int)cocos2d::CCArray::count(v5) )
return v35;
}
}