//
// CCAnimatedSprite::initWithType from 0x10034fef0 to 0x1003500ab (443 bytes)
//
// 4 xrefs:
// > AnimatedShopKeeper::create @ 0x100324842
// > AnimatedShopKeeper::init @ 0x1003286f4
// > CCAnimatedSprite::createWithType @ 0x10034feaa
// > GJRobotSprite::init @ 0x1005dbe6e
//
// 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
//
bool __fastcall CCAnimatedSprite::initWithType(CCAnimatedSprite *a1, const char *a2, cocos2d::CCTexture2D *a3, bool a4)
{
double v4; // xmm0_8
bool v5; // r13
cocos2d::CCTexture2D *v6; // r12
const char *v7; // r14
ObjectManager *v8; // rax
cocos2d::CCDictionary *Definition; // rax
cocos2d::CCString *v10; // rax
const char *CString; // r12
size_t v12; // rax
std::string::size_type v13; // r13
char *data; // r14
cocos2d::CCTextureCache *v15; // rax
const char *v16; // rsi
size_t v17; // rbx
bool result; // al
bool v19; // bl
char v20; // [rsp+10h] [rbp-60h] BYREF
void *v21[3]; // [rsp+11h] [rbp-5Fh] BYREF
_BOOL4 v22; // [rsp+2Ch] [rbp-44h]
std::string __dst; // [rsp+30h] [rbp-40h] BYREF
v5 = a4;
v6 = a3;
v7 = a2;
if ( a3 )
goto LABEL_17;
v22 = a4;
v8 = ObjectManager::instance();
Definition = ObjectManager::getDefinition(v8, a2);
v20 = 22;
strcpy((char *)v21, "spriteSheet");
v10 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey_1((__int64)Definition, (__int64)&v20);
CString = cocos2d::CCString::getCString(v10);
v12 = strlen(CString);
if ( v12 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v4);
v13 = v12;
if ( v12 >= 0x17 )
{
v17 = 26;
if ( (v12 | 7) != 0x17 )
v17 = (v12 | 7) + 1;
data = (char *)operator new(v17);
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst.__r_.__value_.__r.__words[0] = v17 | 1;
__dst.__r_.__value_.__l.__size_ = v13;
}
else
{
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v12);
data = __dst.__r_.__value_.__s.__data_;
if ( !v12 )
{
__dst.__r_.__value_.__s.__data_[0] = 0;
if ( (v20 & 1) == 0 )
goto LABEL_7;
goto LABEL_6;
}
}
memmove(data, CString, v13);
data[v13] = 0;
if ( (v20 & 1) != 0 )
LABEL_6:
operator delete(*(void **)((char *)&v21[1] + 7));
LABEL_7:
std::string::append(&__dst, ".png");
v7 = a2;
v5 = v22;
v15 = cocos2d::CCTextureCache::sharedTextureCache();
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
v16 = __dst.__r_.__value_.__l.__data_;
else
v16 = __dst.__r_.__value_.__s.__data_;
v6 = cocos2d::CCTextureCache::addImage(v15, v16, 0);
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
LABEL_17:
sub_10028CC00((__int64)&__dst, 0.0, 0.0, (__m128)0LL, (__m128)0LL);
result = cocos2d::CCSprite::initWithTexture_1(a1, v6, (const cocos2d::CCRect *)&__dst);
if ( result )
{
a1->m_bDontDraw = 1;
v19 = result;
std::string::assign((std::string *)&a1->m_unkString1, "");
CCAnimatedSprite::loadType(a1, v7, v6, v5);
return v19;
}
return result;
}