//
// GameManager::unloadIcon from 0x41d4a4 to 0x41d5ec (328 bytes)
//
// 3 xrefs:
// > GameManager::unloadIcons @ 0x41d646
// > GameManager::loadIcon @ 0x41d79a
// > GameManager::finishedLoadingIconAsync @ 0x41d884
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:47:59 +0000
//
GameManager *__fastcall GameManager::unloadIcon(GameManager *this, int a2, int a3, int a4)
{
int v5; // r5
_DWORD *v7; // r0
cocos2d::CCTextureCache *v8; // r0
cocos2d::CCTextureCache *v9; // r0
const char *v10; // r1
int **v11; // r5
int **v12; // r7
int *v13; // r10
int *v14; // r4
int *i; // r3
int *v16; // r2
int *v17; // r0
bool v18; // zf
int v19; // [sp+4h] [bp-24h] BYREF
int v20; // [sp+8h] [bp-20h] BYREF
_BYTE v21[12]; // [sp+Ch] [bp-1Ch] BYREF
int v22[3]; // [sp+18h] [bp-10h] BYREF
v19 = a4;
v5 = (int)this;
if ( a2 > 0 )
{
v20 = GameManager::keyForIcon(this, a2, a3);
v7 = std::map::operator[]((int **)(v5 + 924), &v20);
--*v7;
if ( a2 == 1 && (int)*std::map::operator[]((int **)(v5 + 924), &v20) <= 0 )
*std::map::operator[]((int **)(v5 + 924), &v20) = 1;
if ( (int)*std::map::operator[]((int **)(v5 + 924), &v20) <= 0 )
{
GameManager::sheetNameForIcon((GameManager *)v21, v5, a2, a3);
std::string::basic_string(v22, (int)v21);
v8 = (cocos2d::CCTextureCache *)std::string::append(v22, ".png");
v9 = (cocos2d::CCTextureCache *)cocos2d::CCTextureCache::sharedTextureCache(v8);
if ( (v22[0] & 1) != 0 )
v10 = (const char *)v22[2];
else
v10 = (char *)v22 + 1;
cocos2d::CCTextureCache::removeTextureForKey(v9, v10);
std::string::~string((int)v22);
std::string::~string((int)v21);
}
v11 = (int **)(v5 + 936);
v12 = (int **)std::map>::operator[](v11, &v19);
v13 = v12[1];
v14 = (int *)(v12 + 1);
for ( i = v13; i; i = v16 )
{
if ( i[4] >= a3 )
{
v16 = (int *)*i;
}
else
{
v16 = (int *)i[1];
i = v14;
}
v14 = i;
}
if ( v14 != (int *)(v12 + 1) && a3 >= v14[4] )
{
v17 = std::__tree_next *>(v14);
v18 = *v12 == v14;
v12[2] = (int *)((char *)v12[2] - 1);
if ( v18 )
*v12 = v17;
std::__tree_remove *>(v13, v14);
operator delete(v14);
}
this = (GameManager *)std::map>::operator[](v11, &v19);
if ( !*((_DWORD *)this + 2) )
return (GameManager *)std::__tree>,std::__map_value_compare>,std::less,true>,std::allocator>>>::__erase_unique(
(int)v11,
&v19);
}
return this;
}