//
// cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile_2 from 0x10031cf10 to 0x10031d215 (773 bytes)
//
// 25 xrefs:
// > LevelAreaLayer::init @ 0x100277992
// > LevelAreaInnerLayer::init @ 0x100279d71
// > GJPathsLayer::init @ 0x1002fe3c9
// > GJShopLayer::init @ 0x100323422
// > GameManager::loadIcon @ 0x1003820e4
// > GameManager::loadDeathEffect @ 0x10038323c
// > LoadingLayer::init @ 0x1003a2733
// > LoadingLayer::loadAssets @ 0x1003a2f43
// > LoadingLayer::loadAssets @ 0x1003a306e
// > LoadingLayer::loadAssets @ 0x1003a3098
// > LoadingLayer::loadAssets @ 0x1003a30ee
// > LoadingLayer::loadAssets @ 0x1003a3273
// > LoadingLayer::loadAssets @ 0x1003a3399
// > LoadingLayer::loadAssets @ 0x1003a33d5
// > SecretLayer4::init @ 0x1003b0ccc
// > WorldSelectLayer::init @ 0x1003c1e00
// > cocos2d::CCAnimationCache::addAnimationsWithDictionary @ 0x10046dd76
// > cocos2d::CCAnimationCache::addAnimationsWithDictionary @ 0x10046dda6
// > SecretLayer5::init @ 0x10047a09d
// > SecretLayer5::init @ 0x10047a0c7
// > SecretLayer6::init @ 0x10047ebb9
// > SecretLayer2::init @ 0x10049d1ec
// > SecretLayer3::init @ 0x1004a365b
// > GauntletSelectLayer::init @ 0x1005713c9
// > SecretRewardsLayer::init @ 0x1006300f6
//
// 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
//
void __fastcall cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile_2(cocos2d::CCSpriteFrameCache *a1, const char *a2)
{
double v2; // xmm0_8
const char *v3; // rbx
__int64 v4; // r15
size_t v5; // rax
std::string::size_type v6; // r12
char *data; // r13
size_t v8; // rbx
__int64 v9; // r15
__int64 v10; // rbx
CCContentManager *v11; // rax
cocos2d::CCDictionary *v12; // r15
__int64 v13; // r12
cocos2d::CCString *v14; // rax
const char *CString; // rax
const char *v16; // r12
std::string::size_type size; // rax
std::string::pointer v18; // rcx
std::string::size_type v19; // rsi
std::string *v21; // rax
std::string *v22; // rax
cocos2d::CCTextureCache *v23; // rax
cocos2d::CCTexture2D *v24; // rax
__int64 v25; // r14
size_t v26; // rax
size_t v27; // r15
_BYTE *v28; // r12
size_t v29; // r13
_BYTE v31[24]; // [rsp+8h] [rbp-58h] BYREF
std::string __dst[2]; // [rsp+20h] [rbp-40h] BYREF
v3 = a2;
v4 = *(_QWORD *)&a1[1].m_nTag;
v5 = strlen(a2);
if ( v5 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v6 = v5;
if ( v5 >= 0x17 )
{
v8 = 26;
if ( (v5 | 7) != 0x17 )
v8 = (v5 | 7) + 1;
data = (char *)operator new(v8);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst[0].__r_.__value_.__r.__words[0] = v8 + 1;
v3 = a2;
__dst[0].__r_.__value_.__l.__size_ = v6;
goto LABEL_8;
}
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v5);
data = __dst[0].__r_.__value_.__s.__data_;
if ( v5 )
LABEL_8:
memcpy(data, v3, v6);
data[v6] = 0;
v9 = sub_10031E0A0(v4, __dst);
v10 = *(_QWORD *)&a1[1].m_nTag + 8LL;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
if ( v9 == v10 )
{
v11 = CCContentManager::sharedManager();
v12 = CCContentManager::addDict(v11, a2, 0);
*(_WORD *)&__dst[0].__r_.__value_.__l.0 = 0;
v31[0] = 16;
strcpy(&v31[1], "metadata");
v13 = cocos2d::CCDictionary::objectForKey_1((__int64)v12, v31);
if ( (v31[0] & 1) != 0 )
operator delete(*(void **)&v31[16]);
if ( v13 )
{
v31[0] = 30;
strcpy(&v31[1], "textureFileName");
v14 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey_1(v13, (__int64)v31);
CString = cocos2d::CCString::getCString(v14);
std::string::assign(__dst, CString);
if ( (v31[0] & 1) != 0 )
operator delete(*(void **)&v31[16]);
}
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
{
v16 = __dst[0].__r_.__value_.__s.__data_;
if ( __dst[0].__r_.__value_.__l.__size_ )
goto LABEL_29;
}
else
{
v16 = __dst[0].__r_.__value_.__s.__data_;
if ( *(_BYTE *)&__dst[0].__r_.__value_.__l.0 >> 1 )
goto LABEL_29;
}
std::string::assign(__dst, a2);
size = *(_BYTE *)&__dst[0].__r_.__value_.__l.0 >> 1;
v18 = __dst[0].__r_.__value_.__l.__data_;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
size = __dst[0].__r_.__value_.__l.__size_;
else
v18 = __dst[0].__r_.__value_.__s.__data_;
while ( size )
{
v19 = size - 1;
if ( v18[--size] == 46 )
goto LABEL_28;
}
v19 = -1;
LABEL_28:
v21 = std::string::erase(__dst, v19, 0xFFFFFFFFFFFFFFFFLL);
std::string::operator=(__dst, v21);
v22 = std::string::append(__dst, ".png");
std::string::operator=(__dst, v22);
LABEL_29:
v23 = cocos2d::CCTextureCache::sharedTextureCache();
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
v16 = __dst[0].__r_.__value_.__l.__data_;
v24 = cocos2d::CCTextureCache::addImage(v23, v16, 0);
if ( !v24 )
goto LABEL_42;
cocos2d::CCSpriteFrameCache::addSpriteFramesWithDictionary(a1, v12, v24);
v25 = *(_QWORD *)&a1[1].m_nTag;
v26 = strlen(a2);
if ( v26 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v27 = v26;
if ( v26 >= 0x17 )
{
v29 = 26;
if ( (v26 | 7) != 0x17 )
v29 = (v26 | 7) + 1;
v28 = operator new(v29);
*(_QWORD *)&v31[16] = v28;
*(_QWORD *)v31 = v29 | 1;
*(_QWORD *)&v31[8] = v27;
}
else
{
v31[0] = 2 * v26;
v28 = &v31[1];
if ( !v26 )
{
LABEL_40:
v28[v27] = 0;
sub_10031E1B0(v25, v31);
if ( (v31[0] & 1) != 0 )
operator delete(*(void **)&v31[16]);
LABEL_42:
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
return;
}
}
memcpy(v28, a2, v27);
goto LABEL_40;
}
}