//
// PlayerObject::toggleSpiderMode from 0x630bb4 to 0x630f4c (920 bytes)
//
// 8 xrefs:
// > PlayerObject::switchedToMode @ 0x630b38
// > PlayerObject::switchedToMode @ 0x630b78
// > PlayerObject::switchedToMode @ 0x630b98
// > PlayerObject::copyAttributes @ 0x631dc4
// > MenuGameLayer::resetPlayer @ 0x6c971c
// > GJBaseGameLayer::switchToSpiderMode @ 0x859e10
// > GJBaseGameLayer::switchToSpiderMode @ 0x859e28
// > ??> @ 0x98fa0
//
// 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 PlayerObject::toggleSpiderMode(PlayerObject *a1, bool a2, bool a3)
{
_BOOL4 v4; // w22
double m_totalTime; // x0
cocos2d::CCNode *m_mainLayer; // x3
GameManager *v7; // x2
unsigned __int64 v8; // x1
cocos2d::CCString *v9; // x0
char *CString; // x0
cocos2d::CCSprite *m_iconSprite; // x23
void (__fastcall *setDisplayFrame)(cocos2d::CCSprite *__hidden, cocos2d::CCSpriteFrame *); // x25
cocos2d::CCSpriteFrameCache *v13; // x0
cocos2d::CCSpriteFrame *v14; // x0
char *v15; // x0
GJSpiderSprite *m_spiderSprite; // x23
void *v17; // x0
unsigned int *v18; // x1
int v19; // w2
unsigned int *v20; // x1
int v21; // w2
cocos2d::ccColor3B v22; // [xsp+60h] [xbp+60h]
char *v23; // [xsp+68h] [xbp+68h] BYREF
__int64 v24; // [xsp+70h] [xbp+70h] BYREF
v4 = a3;
if ( a1->m_isSpider != a2 )
{
m_totalTime = a1->m_totalTime;
a1->m_isSpider = a2;
m_mainLayer = a1->m_mainLayer;
a1->m_gameModeChangedTime = m_totalTime;
if ( a2 )
{
m_mainLayer->addChild_0(m_mainLayer, a1->m_spiderBatchNode, 2);
PlayerObject::switchedToMode(a1, SpiderPortal);
a1->m_unkAngle1 = 27.0;
a1->m_width = 27.0;
a1->m_height = 27.0;
a1->m_accelerationOrSpeed = 1.5;
PlayerObject::stopRotation(a1, 0, 14);
a1->setRotation(a1, 0.0);
v7 = GameManager::sharedState();
LODWORD(v8) = v7->m_playerSpider.random - v7->m_playerSpider.seed;
if ( (int)v8 > 69 )
LODWORD(v8) = 69;
if ( (int)v8 <= 0 )
v8 = 1;
else
v8 = (unsigned int)v8;
v9 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"spider_%02d_01_001.png",
(const char *)v8);
CString = (char *)cocos2d::CCString::getCString(v9);
sub_D153B8((int)&v23, CString);
m_iconSprite = a1->m_iconSprite;
setDisplayFrame = m_iconSprite->setDisplayFrame;
v13 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
v14 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v13, v23);
setDisplayFrame(m_iconSprite, v14);
if ( a1->m_isPlatformer && a1->m_platformerXVelocity == 0.0 )
{
m_spiderSprite = a1->m_spiderSprite;
sub_D153B8((int)&v24, "idle01");
CCAnimatedSprite::runAnimation((__int64)m_spiderSprite, (__int64)&v24);
v17 = (void *)(v24 - 24);
if ( (__int64 *)(v24 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(v24 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(_DWORD *)(v24 - 8);
*(_DWORD *)(v24 - 8) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v17);
}
}
else
{
PlayerObject::playDynamicSpiderRun(a1);
}
a1->m_iconSprite->setVisible(a1->m_iconSprite, 0);
if ( !v4 )
{
*(_WORD *)&v22.r = 13055;
v22.b = 50;
PlayerObject::spawnPortalCircle(a1, v22, 50.0);
}
PlayerObject::updatePlayerScale(a1);
v15 = v23 - 24;
if ( v23 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)(v23 - 8);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *((_DWORD *)v23 - 2);
*((_DWORD *)v23 - 2) = v21 - 1;
}
if ( v21 <= 0 )
operator delete(v15);
}
PlayerObject::updatePlayerGlow(a1);
PlayerObject::stopRotation(a1, 1, 15);
PlayerObject::modeDidChange(a1);
}
else
{
m_mainLayer->removeChild_0(m_mainLayer, a1->m_spiderBatchNode, 0);
a1->m_iconSprite->setVisible(a1->m_iconSprite, 1);
SpriteAnimationManager::stopAnimations(a1->m_spiderSprite->m_animationManager);
if ( a1->m_vehicleSize != 1.0 && a1->m_defaultMiniIcon )
PlayerObject::updatePlayerFrame(a1, 0);
else
PlayerObject::updatePlayerFrame(a1, a1->m_maybeSavedPlayerFrame);
PlayerObject::resetPlayerIcon(a1);
PlayerObject::updatePlayerGlow(a1);
PlayerObject::stopRotation(a1, 1, 15);
}
}
}