//
// cocos2d::CCBMFontConfiguration::parseConfigFile from 0x5cc418 to 0x5cc902 (1258 bytes)
//
// 1 xrefs:
// > cocos2d::CCBMFontConfiguration::initWithFNTfile @ 0x5cc942
//
// 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
//
std::set *cocos2d::CCBMFontConfiguration::parseConfigFile(
cocos2d::CCBMFontConfiguration *a1,
const char *a2)
{
cocos2d::CCFileUtils *v3; // r0
cocos2d::CCString *v4; // r6
cocos2d::CCString *v5; // r9
char *CString; // r0
int v7; // r0
int v8; // r6
int v9; // r4
char *v10; // r2
char *v11; // r3
int v12; // r4
int v13; // r2
int v14; // r3
int v15; // r4
int v16; // r3
int v17; // r4
int v18; // r7
cocos2d::tCCFontDefHashElement *v19; // r4
unsigned int charID; // r3
unsigned __int8 *p_hh; // r5
cocos2d::tCCFontDefHashElement *m_pFontDefDictionary; // r7
UT_hash_table *v23; // r0
UT_hash_table *v24; // r6
UT_hash_bucket *v25; // r0
UT_hash_table *tbl; // r2
UT_hash_handle *tail; // r3
std::ptrdiff_t hho; // r1
cocos2d::tCCFontDefHashElement *v29; // r0
UT_hash_table *v30; // r5
int key_low; // r2
UT_hash_table *v32; // r0
int v33; // r1
unsigned int v34; // r3
unsigned int v35; // r2
int v36; // r1
unsigned int v37; // r3
unsigned int v38; // r2
unsigned int v39; // r1
unsigned int v40; // r6
unsigned int num_buckets; // r3
UT_hash_bucket *buckets; // r0
int v43; // r3
UT_hash_handle *hh_head; // r6
unsigned int v45; // r2
unsigned __int8 *v46; // r7
unsigned int expand_mult; // r1
size_t v48; // r6
UT_hash_bucket *v49; // r0
unsigned int num_items; // r7
int v51; // r3
unsigned int v52; // r7
int v53; // r6
UT_hash_handle *i; // r8
int v55; // r2
unsigned int v56; // r0
UT_hash_handle *v57; // r3
UT_hash_table *v58; // r3
unsigned int v59; // r1
unsigned int nonideal_items; // r2
bool v61; // cc
unsigned int ineff_expands; // r2
unsigned int *m_nLuaID; // r3
int v64; // r2
unsigned int *v65; // r5
unsigned int *v66; // r1
int v67; // r0
int v68; // r4
_BOOL4 v70; // r6
int v71; // r0
unsigned int *p_m_uID; // [sp+0h] [bp-5Ch]
UT_hash_bucket *v73; // [sp+4h] [bp-58h]
unsigned int v74; // [sp+8h] [bp-54h]
int v75; // [sp+Ch] [bp-50h]
UT_hash_handle *hh_next; // [sp+14h] [bp-48h]
cocos2d::CCString *v78; // [sp+44h] [bp-18h] BYREF
void *v79; // [sp+48h] [bp-14h] BYREF
int v80; // [sp+4Ch] [bp-10h] BYREF
char v81[4]; // [sp+50h] [bp-Ch] BYREF
v3 = cocos2d::CCFileUtils::sharedFileUtils();
((void (__fastcall *)(cocos2d::CCString **, cocos2d::CCFileUtils *, const char *, _DWORD))v3->createCCArrayWithContentsOfFile)(
&v78,
v3,
a2,
0);
v4 = cocos2d::CCString::createWithContentsOfFile((const char *)v78);
v5 = (cocos2d::CCString *)operator new(0x18u);
p_m_uID = &v5->m_uID;
memset(&v5->m_uID, 0, 0x10u);
v5->m_uAutoReleaseCount = 0;
v5->m_nTag = (int)&v5->m_uID;
v5->m_uReference = (unsigned int)&v5->m_uID;
if ( v4 )
{
v79 = &unk_ACDDA8;
CString = (char *)cocos2d::CCString::getCString(v4);
sub_776584((int)&v80, CString);
while ( 1 )
{
while ( 1 )
{
do
{
if ( !*(_DWORD *)(v80 - 12) )
{
sub_774008(&v80);
sub_774008(&v79);
v4 = v5;
goto LABEL_61;
}
v7 = sub_774910(&v80, 10, 0);
v8 = v7;
if ( v7 == -1 )
{
sub_775D40(&v79, &v80);
sub_7751B8(&v80, 0, -1);
}
else
{
sub_776158(v81, &v80, 0, v7);
sub_774794(&v79, v81);
sub_774008(v81);
sub_776158(v81, &v80, v8 + 1, -1);
sub_774794(&v80, v81);
sub_774008(v81);
}
sub_776158(v81, &v79, 0, 9);
v9 = sub_774E98((int)v81, "info face");
sub_774008(v81);
if ( !v9 )
{
sub_775C20(v81);
cocos2d::CCBMFontConfiguration::parseInfoArguments((int)a1, (int)v81, v10, v11);
goto LABEL_59;
}
sub_776158(v81, &v79, 0, 17);
v12 = sub_774E98((int)v81, "common lineHeight");
sub_774008(v81);
if ( !v12 )
{
sub_775C20(v81);
cocos2d::CCBMFontConfiguration::parseCommonArguments((int)a1, v81, v13, v14);
goto LABEL_59;
}
sub_776158(v81, &v79, 0, 7);
v15 = sub_774E98((int)v81, "page id");
sub_774008(v81);
if ( !v15 )
{
sub_775C20(v81);
cocos2d::CCBMFontConfiguration::parseImageFileName((int)a1, (int)v81, (int)a2, v16);
goto LABEL_59;
}
sub_776158(v81, &v79, 0, 7);
v17 = sub_774E98((int)v81, "chars c");
sub_774008(v81);
}
while ( !v17 );
sub_776158(v81, &v79, 0, 4);
v18 = sub_774E98((int)v81, "char");
sub_774008(v81);
if ( !v18 )
break;
sub_776158(v81, &v79, 0, 13);
v68 = sub_774E98((int)v81, "kerning first");
sub_774008(v81);
if ( !v68 )
{
sub_775C20(v81);
cocos2d::CCBMFontConfiguration::parseKerningEntry((int)a1, (int)v81);
LABEL_59:
sub_774008(v81);
}
}
v19 = (cocos2d::tCCFontDefHashElement *)malloc(0x40u);
sub_775C20(v81);
cocos2d::CCBMFontConfiguration::parseCharacterDefinition((int)a1, (int)v81, (int)&v19->fontDef);
sub_774008(v81);
charID = v19->fontDef.charID;
v19->hh.next = nullptr;
p_hh = (unsigned __int8 *)&v19->hh;
m_pFontDefDictionary = a1->m_pFontDefDictionary;
v19->key = charID;
v19->hh.key = v19;
v19->hh.keylen = 4;
if ( m_pFontDefDictionary )
{
tbl = m_pFontDefDictionary->hh.tbl;
tail = tbl->tail;
hho = tbl->hho;
tail->next = v19;
v19->hh.prev = (char *)tail - hho;
tbl->tail = (UT_hash_handle *)p_hh;
}
else
{
a1->m_pFontDefDictionary = v19;
v19->hh.prev = nullptr;
v23 = (UT_hash_table *)malloc(0x2Cu);
v24 = v23;
v19->hh.tbl = v23;
if ( !v23
|| (memset(v23, 0, sizeof(UT_hash_table)),
v24->tail = (UT_hash_handle *)p_hh,
v24->num_buckets = 32,
v24->log2_num_buckets = 5,
v24->hho = 32,
v25 = (UT_hash_bucket *)malloc(0x180u),
(v24->buckets = v25) == nullptr) )
{
LABEL_17:
exit(-1);
}
memset(v25, 0, 0x180u);
v24->signature = -1609490463;
}
v29 = a1->m_pFontDefDictionary;
v30 = v29->hh.tbl;
++v30->num_items;
key_low = LOBYTE(v19->key);
v19->hh.tbl = v30;
v32 = v29->hh.tbl;
v33 = (key_low + 17973517 + (HIBYTE(v19->key) << 24) + (BYTE2(v19->key) << 16) + (BYTE1(v19->key) << 8)) ^ 0x7F76D;
v34 = (-1622558010 - v33) ^ (v33 << 8);
v35 = (-17973517 - v33 - v34) ^ (v34 >> 13);
v36 = (v33 - v34 - v35) ^ (v35 >> 12);
v37 = (v34 - v35 - v36) ^ (v36 << 16);
v38 = (v35 - v36 - v37) ^ (v37 >> 5);
v39 = v36 - v37 - v38;
v40 = (v38 - (v39 ^ (v38 >> 3)) - ((v37 - v38 - (v39 ^ (v38 >> 3))) ^ ((v39 ^ (v38 >> 3)) << 10)))
^ (((v37 - v38 - (v39 ^ (v38 >> 3))) ^ ((v39 ^ (v38 >> 3)) << 10)) >> 15);
num_buckets = v32->num_buckets;
v19->hh.hashv = v40;
buckets = v32->buckets;
v43 = v40 & (num_buckets - 1);
hh_head = buckets[v43].hh_head;
v45 = buckets[v43].count + 1;
buckets[v43].count = v45;
v19->hh.hh_prev = nullptr;
v46 = (unsigned __int8 *)&v19->hh;
v19->hh.hh_next = hh_head;
if ( hh_head )
hh_head->hh_prev = (UT_hash_handle *)v46;
expand_mult = buckets[v43].expand_mult;
buckets[v43].hh_head = (UT_hash_handle *)v46;
if ( v45 >= 10 * expand_mult + 10 && v30->noexpand != 1 )
{
v48 = 24 * v30->num_buckets;
v49 = (UT_hash_bucket *)malloc(v48);
v73 = v49;
if ( !v49 )
goto LABEL_17;
memset(v49, 0, v48);
num_items = v30->num_items;
v74 = v30->num_buckets;
v75 = 2 * v74 - 1;
v51 = v75 & num_items;
v52 = num_items >> (v30->log2_num_buckets + 1);
v53 = 0;
if ( v51 )
++v52;
v30->nonideal_items = 0;
v30->ideal_chain_maxlen = v52;
while ( v53 != v74 )
{
for ( i = v30->buckets[v53].hh_head; i; i = hh_next )
{
hh_next = i->hh_next;
v55 = i->hashv & v75;
v56 = v73[v55].count + 1;
v73[v55].count = v56;
if ( v56 > v52 )
{
++v30->nonideal_items;
v73[v55].expand_mult = v56 / v52;
}
i->hh_prev = nullptr;
v57 = v73[v55].hh_head;
i->hh_next = v57;
if ( v57 )
v57->hh_prev = i;
v73[v55].hh_head = i;
}
++v53;
}
free(v30->buckets);
v58 = v19->hh.tbl;
v59 = v58->num_items;
v58->num_buckets *= 2;
++v58->log2_num_buckets;
v58->buckets = v73;
nonideal_items = v58->nonideal_items;
v61 = nonideal_items > v59 >> 1;
if ( nonideal_items <= v59 >> 1 )
ineff_expands = 0;
else
ineff_expands = v58->ineff_expands;
if ( v61 )
++ineff_expands;
v58->ineff_expands = ineff_expands;
if ( ineff_expands > 1 )
v58->noexpand = 1;
}
m_nLuaID = (unsigned int *)v5->m_nLuaID;
v64 = 1;
v65 = &v5->m_uID;
while ( m_nLuaID )
{
v65 = m_nLuaID;
if ( v19->fontDef.charID >= m_nLuaID[4] )
{
v66 = (unsigned int *)m_nLuaID[3];
v64 = 0;
}
else
{
v66 = (unsigned int *)m_nLuaID[2];
v64 = 1;
}
m_nLuaID = v66;
}
if ( v64 )
{
if ( v65 == (unsigned int *)v5->m_nTag )
goto LABEL_62;
v67 = sub_762018(v65);
}
else
{
v67 = (int)v65;
}
if ( *(_DWORD *)(v67 + 16) < v19->fontDef.charID )
{
LABEL_62:
v70 = v65 == p_m_uID || v19->fontDef.charID < v65[4];
v71 = operator new(0x14u);
*(_DWORD *)(v71 + 16) = v19->fontDef.charID;
sub_7620E8(v70, v71, v65, p_m_uID);
++v5->m_uAutoReleaseCount;
}
}
}
LABEL_61:
sub_774008(&v78);
return (std::set *)v4;
}