//
// cocos2d::CCDirector::popToSceneStackLevel from 0x1800bed50 to 0x1800bee42 (242 bytes)
//
// 6 xrefs:
// > cocos2d::CCDirector::popToRootScene @ 0x1800becd5
// > cocos2d::CCDirector::popToSceneInStack @ 0x1800bed42
// > ??> @ 0x180141efc
// > ??> @ 0x180141f0c
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b9240
//
// 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::CCDirector::popToSceneStackLevel(cocos2d::CCDirector *this, int a2)
{
int v4; // eax
__int64 v5; // rsi
struct cocos2d::CCObject *Object; // rdi
v4 = cocos2d::CCArray::count(this->m_pobScenesStack);
if ( a2 )
{
if ( a2 < v4 )
{
v5 = (unsigned int)(v4 - a2);
do
{
Object = cocos2d::CCArray::lastObject(this->m_pobScenesStack);
if ( ((unsigned __int8 (__fastcall *)(struct cocos2d::CCObject *))Object->__vftable[9].~CCObject)(Object) )
{
((void (__fastcall *)(struct cocos2d::CCObject *))Object->__vftable[9].getTag)(Object);
((void (__fastcall *)(struct cocos2d::CCObject *))Object->__vftable[9].canEncode)(Object);
}
((void (__fastcall *)(struct cocos2d::CCObject *))Object->__vftable[9].setTag)(Object);
if ( this->m_pSceneReference )
{
if ( this->m_pSceneReference == cocos2d::CCArray::lastObject(this->m_pobScenesStack) )
this->m_pSceneReference = nullptr;
}
cocos2d::CCArray::removeLastObject(this->m_pobScenesStack, 1u);
--v5;
}
while ( v5 );
this->m_pNextScene = (cocos2d::CCScene *)cocos2d::CCArray::lastObject(this->m_pobScenesStack);
this->m_bSendCleanupToScene = 0;
}
}
else
{
this->m_bPurgeDirecotorInNextLoop = 1;
}
}