//
// GameManager::loadIcon from 0x100317a34 to 0x100317cc8 (660 bytes)
//
// 13 xrefs:
// > PlayerObject::init @ 0x100217888
// > PlayerObject::init @ 0x10021789c
// > PlayerObject::updatePlayerShipFrame @ 0x10022994c
// > PlayerObject::updatePlayerJetpackFrame @ 0x100229b00
// > PlayerObject::updatePlayerBirdFrame @ 0x10022a0dc
// > PlayerObject::updatePlayerSwingFrame @ 0x10022a520
// > PlayerObject::updatePlayerFrame @ 0x10022a768
// > PlayerObject::updatePlayerDartFrame @ 0x10022ac68
// > PlayerObject::updatePlayerRollFrame @ 0x10022af5c
// > GJRobotSprite::init @ 0x10023f41c
// > GJRobotSprite::updateFrame @ 0x10023f8d4
// > SimplePlayer::updatePlayerFrame @ 0x100303698
// > SimplePlayer::init @ 0x1003071c0
//
// 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
//
// local variable allocation has failed, the output may be wrong!
cocos2d::CCTexture2D *__fastcall GameManager::loadIcon(GameManager *a1, int a2, int a3, int a4)
{
std::string::size_type size; // x9
cocos2d::CCTexture2D *v8; // x21
cocos2d::CCTextureCache *v9; // x0
std::string *v10; // x1
cocos2d::CCTextureCache *v11; // x0
std::string *p_dst; // x1
cocos2d::CCSpriteFrameCache *v13; // x0
std::string *p_p; // x1
__int64 v15; // x0
int v16; // w22
_QWORD *v17; // x0
__int64 v18; // x0
std::string __p; // [xsp+0h] [xbp-90h] BYREF
std::string __dst; // [xsp+20h] [xbp-70h] BYREF
int v22; // [xsp+44h] [xbp-4Ch] BYREF
std::string __src; // [xsp+48h] [xbp-48h] BYREF
int v24; // [xsp+64h] [xbp-2Ch] BYREF
int v25; // [xsp+68h] [xbp-28h] BYREF
char v26; // [xsp+6Fh] [xbp-21h] BYREF
v24 = a4;
v25 = a3;
GameManager::sheetNameForIcon(*(__int64 *)&a2, a3, &__src);
size = HIBYTE(__src.__r_.__value_.__r.__words[2]);
if ( (__src.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
size = __src.__r_.__value_.__l.__size_;
if ( size )
{
v22 = a2 + a1->m_keyStartForIcon.__begin_[a3] - 1;
if ( SHIBYTE(__src.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__dst, __src.__r_.__value_.__l.__data_, __src.__r_.__value_.__l.__size_);
else
__dst = __src;
std::string::append(&__dst, ".png");
__p.__r_.__value_.__r.__words[0] = (std::string::size_type)&v22;
if ( *((int *)sub_1001A6048((__int64)&a1->m_iconLoadCounts, &v22, (__int64)&unk_100644FD5, (unsigned int **)&__p) + 8) <= 0 )
{
if ( SHIBYTE(__src.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__p, __src.__r_.__value_.__l.__data_, __src.__r_.__value_.__l.__size_);
else
__p = __src;
std::string::append(&__p, ".plist");
v11 = cocos2d::CCTextureCache::sharedTextureCache();
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_dst = &__dst;
else
p_dst = (std::string *)__dst.__r_.__value_.__r.__words[0];
v8 = cocos2d::CCTextureCache::addImage(v11, (const char *)p_dst, 0);
v13 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
if ( (__p.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_p = &__p;
else
p_p = (std::string *)__p.__r_.__value_.__r.__words[0];
cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile(v13, (const char *)p_p);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
}
else
{
v9 = cocos2d::CCTextureCache::sharedTextureCache();
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v10 = &__dst;
else
v10 = (std::string *)__dst.__r_.__value_.__r.__words[0];
v8 = cocos2d::CCTextureCache::textureForKey(v9, (const char *)v10);
}
__p.__r_.__value_.__r.__words[0] = (std::string::size_type)&v24;
v15 = sub_10031E41C(&a1->m_iconRequests, &v24, &unk_100644FD5, &__p, &v26);
__p.__r_.__value_.__r.__words[0] = (std::string::size_type)&v25;
v16 = *((_DWORD *)sub_1001A6048(v15 + 40, &v25, (__int64)&unk_100644FD5, (unsigned int **)&__p) + 8);
if ( v16 != a2 )
{
__p.__r_.__value_.__r.__words[0] = (std::string::size_type)&v22;
v17 = sub_1001A6048((__int64)&a1->m_iconLoadCounts, &v22, (__int64)&unk_100644FD5, (unsigned int **)&__p);
++*((_DWORD *)v17 + 8);
if ( v16 >= 1 )
GameManager::unloadIcon(a1, v16, v25, v24);
__p.__r_.__value_.__r.__words[0] = (std::string::size_type)&v24;
v18 = sub_10031E41C(&a1->m_iconRequests, &v24, &unk_100644FD5, &__p, &v26);
__p.__r_.__value_.__r.__words[0] = (std::string::size_type)&v25;
*((_DWORD *)sub_1001A6048(v18 + 40, &v25, (__int64)&unk_100644FD5, (unsigned int **)&__p) + 8) = a2;
}
if ( SHIBYTE(__dst.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
if ( (*((_BYTE *)&__src.__r_.__value_.__s + 23) & 0x80) != 0 )
goto LABEL_32;
}
else
{
v8 = nullptr;
if ( (*((_BYTE *)&__src.__r_.__value_.__s + 23) & 0x80) != 0 )
LABEL_32:
operator delete(__src.__r_.__value_.__l.__data_);
}
return v8;
}