//
// GauntletLayer::unlockActiveItem from 0x91ddd0 to 0x91e1f8 (1064 bytes)
//
// 3 xrefs:
// > ??> @ 0xc5f70
// > GauntletLayer::setupGauntlet @ 0x91efe4
// > ??> @ 0x122ee10
//
// 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 GauntletLayer::unlockActiveItem(GauntletLayer *a1)
{
GauntletSprite *v2; // x23
float v3; // s8
cocos2d::CCArray *v4; // x22
unsigned int i; // w21
__int64 v6; // x0
unsigned int j; // w21
__int64 v8; // x0
int v9; // w24
cocos2d::CCSprite *v10; // x21
cocos2d::CCSprite *v11; // x22
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x28
float width; // s8
__int64 v14; // x0
cocos2d::CCFadeOut *v15; // x0
cocos2d::CCFadeTo *v16; // x0
float v17; // s8
cocos2d::CCScaleTo *v18; // x0
cocos2d::CCActionInterval *v19; // x0
cocos2d::CCEaseBounceOut *v20; // x0
CCMenuItemSpriteExtra *m_activeItemButton; // x1
cocos2d::CCArray *m_levels; // x19
unsigned int v23; // w0
GJGameLevel *v24; // x19
GameLevelManager *v25; // x0
GJGameLevel *SavedLevel; // x0
char *v27; // x0
unsigned int *v28; // x2
int v29; // w1
const char *v30; // [xsp+98h] [xbp+98h] BYREF
cocos2d::CCPoint v31; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v32; // [xsp+A8h] [xbp+A8h] BYREF
cocos2d::CCPoint v33; // [xsp+B0h] [xbp+B0h] BYREF
if ( a1->m_activeItemButton )
{
GauntletNode::frameForType(a1->m_gauntletType, (__int64)&v30);
v2 = (GauntletSprite *)a1->m_activeItemButton->getNormalImage(a1->m_activeItemButton);
GauntletSprite::toggleLockedSprite(v2, 0);
((void (__fastcall *)(__int64 *__return_ptr, GauntletSprite *))v2->getScaledContentSize)(&v32, v2);
v3 = *(float *)&v32 * 0.5;
((void (__fastcall *)(cocos2d::CCPoint *__return_ptr, GauntletSprite *))v2->getScaledContentSize)(&v33, v2);
cocos2d::CCPoint::CCPoint(&v31, v3, v33.y * 0.5);
v4 = v2->getChildren(v2);
for ( i = 0; i < (unsigned int)cocos2d::CCArray::count(v4); ++i )
{
v6 = cocos2d::CCArray::objectAtIndex(v4, i);
(*(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v6 + 184LL))(v6, &v31);
}
for ( j = 0; j < (unsigned int)cocos2d::CCArray::count(a1->m_activeObjects); ++j )
{
v8 = cocos2d::CCArray::objectAtIndex(a1->m_activeObjects, j);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v8 + 328LL))(v8, 1);
}
v9 = 3;
do
{
v10 = cocos2d::CCSprite::createWithSpriteFrameName(v30);
v11 = cocos2d::CCSprite::createWithSpriteFrameName("gauntletLock_001.png");
v10->addChild_0(v10, v11, 1);
setPosition = v11->setPosition;
width = v10->getContentSize(v10)->width;
v14 = (__int64)v10->getContentSize(v10);
cocos2d::CCPoint::CCPoint(&v33, width * 0.5, *(float *)(v14 + 4) * 0.5);
setPosition(v11, &v33);
v2->addChild_0(v2, v10, 2);
v10->setPosition(v10, &v31);
v10->setColor(v10, (const cocos2d::ccColor3B *)&off_EF4C38);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v10->setBlendFunc)(v10, 0x100000302LL);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v11->setBlendFunc)(v11, 0x100000302LL);
v15 = cocos2d::CCFadeOut::create(0.5);
cocos2d::CCNode::runAction(v10, v15);
v11->setOpacity(v11, 4294967240LL);
v16 = cocos2d::CCFadeTo::create(0.5, 0);
cocos2d::CCNode::runAction(v11, v16);
--v9;
}
while ( v9 );
v17 = v2->getScale(v2);
v18 = (cocos2d::CCScaleTo *)((__int64 (__fastcall *)(GauntletSprite *, float))v2->setScale)(v2, 1.6);
v19 = (cocos2d::CCActionInterval *)cocos2d::CCScaleTo::create(v18, 0.5, v17);
v20 = cocos2d::CCEaseBounceOut::create(v19);
cocos2d::CCNode::runAction(v2, v20);
a1->m_activeItemButton->setEnabled(a1->m_activeItemButton, 1);
m_activeItemButton = a1->m_activeItemButton;
m_levels = a1->m_levels;
v23 = m_activeItemButton->getTag(m_activeItemButton);
v24 = (GJGameLevel *)cocos2d::CCArray::objectAtIndex(m_levels, v23);
v24->m_gauntletLevel2 = (unsigned __int8)&dword_0 + 1;
v25 = GameLevelManager::sharedState();
SavedLevel = GameLevelManager::getSavedLevel(v25, v24);
if ( SavedLevel )
SavedLevel->m_gauntletLevel2 = 1;
v27 = (char *)(v30 - 24);
if ( v30 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v28 = (unsigned int *)(v30 - 8);
do
v29 = __ldaxr(v28);
while ( __stlxr(v29 - 1, v28) );
}
else
{
v29 = *((_DWORD *)v30 - 2);
*((_DWORD *)v30 - 2) = v29 - 1;
}
if ( v29 <= 0 )
operator delete(v27);
}
}
}