//
// GJBaseGameLayer::getSavedPosition from 0x489ed0 to 0x48a0b6 (486 bytes)
//
// 1 xrefs:
// > GJBaseGameLayer::processAdvancedFollowAction @ 0x48a208
//
// 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
//
cocos2d::CCPoint *GJBaseGameLayer::getSavedPosition(
cocos2d::CCPoint *__return_ptr retstr,
GJBaseGameLayer *a2,
int a3,
float a4)
{
cocos2d::CCPoint *v4; // r6
PlayerObject *m_player2; // r0
cocos2d::CCPoint *p_m_cameraPosition; // r1
GameObject *v9; // r0
double v10; // d7
float v11; // s16
int v12; // r7
PlayerObject *m_player1; // r3
int m_unkUint12; // r5
GameObject *MainObject; // r0
int *v16; // r0
int v17; // r9
float v18; // s16
int v19; // r1
int v20; // r3
int v21; // r1
int v22; // r5
unsigned int m_uniqueID; // [sp+0h] [bp-34h] BYREF
cocos2d::CCPoint v25; // [sp+4h] [bp-30h] BYREF
cocos2d::CCPoint v26; // [sp+Ch] [bp-28h] BYREF
_BYTE v27[8]; // [sp+14h] [bp-20h] BYREF
_BYTE v28[8]; // [sp+1Ch] [bp-18h] BYREF
_BYTE v29[8]; // [sp+24h] [bp-10h] BYREF
v4 = retstr;
if ( a4 > 0.0 )
{
v10 = a4 / 0.00416666667
- (float)((float)(unsigned int)(a2->m_gameState.m_unkUint6 - a2->m_gameState.m_unkUint5) / 1000.0);
if ( v10 <= 0.0 )
v11 = 0.0;
else
v11 = v10;
v12 = (int)ceilf(v11);
if ( v12 >= a2->m_gameState.m_unkUint11 )
{
retstr = v4;
LABEL_34:
p_m_cameraPosition = &stru_AC68C0;
goto LABEL_35;
}
m_uniqueID = a3;
if ( a3 == -1 )
{
m_player1 = a2->m_player1;
}
else
{
if ( a3 != -2 )
{
if ( a3 == -3 )
{
m_unkUint12 = a2->m_gameState.m_unkUint12;
}
else
{
MainObject = GJBaseGameLayer::tryGetMainObject(a2, a3);
if ( !MainObject )
{
LABEL_33:
retstr = v4;
goto LABEL_34;
}
m_unkUint12 = MainObject->m_unk52C;
m_uniqueID = MainObject->m_uniqueID;
}
LABEL_25:
if ( m_unkUint12 >= 0 )
{
if ( sub_46C450(&a2->m_savePositionValues._M_h._M_buckets, m_uniqueID) )
{
v16 = std::__detail::_Map_base,std::allocator>,std::__detail::_Select1st,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits,true>::operator[](
&a2->m_savePositionValues._M_h._M_buckets,
&m_uniqueID);
v17 = *v16;
v18 = (float)v12 - v11;
v19 = a2->m_gameState.m_unkUint11 % *v16 - v12;
if ( v19 < 0 )
v19 += v17;
v20 = v19 + 1;
v21 = v19 + m_unkUint12;
if ( v20 >= v17 )
v20 = 0;
v22 = m_unkUint12 + v20;
cocos2d::CCPoint::CCPoint(
&v25,
a2->m_gameState.m_unkVecFloat1.m_start[2 * v21],
a2->m_gameState.m_unkVecFloat1.m_start[2 * v21 + 1]);
cocos2d::CCPoint::CCPoint(
&v26,
a2->m_gameState.m_unkVecFloat1.m_start[2 * v22],
a2->m_gameState.m_unkVecFloat1.m_start[2 * v22 + 1]);
cocos2d::CCPoint::operator-(v27, &v26, &v25);
cocos2d::CCPoint::operator*(v29, v27, LODWORD(v18));
cocos2d::CCPoint::operator+(v28, &v25, v29);
retstr = v4;
p_m_cameraPosition = (cocos2d::CCPoint *)v28;
goto LABEL_35;
}
retstr = v4;
goto LABEL_34;
}
goto LABEL_33;
}
m_player1 = a2->m_player2;
}
m_unkUint12 = m_player1->m_unk52C;
goto LABEL_25;
}
switch ( a3 )
{
case -1:
m_player2 = a2->m_player1;
LABEL_6:
p_m_cameraPosition = (cocos2d::CCPoint *)m_player2->getPosition(m_player2);
retstr = v4;
LABEL_35:
cocos2d::CCPoint::CCPoint(retstr, p_m_cameraPosition);
return v4;
case -2:
m_player2 = a2->m_player2;
goto LABEL_6;
case -3:
p_m_cameraPosition = &a2->m_gameState.m_cameraPosition;
goto LABEL_35;
}
v9 = GJBaseGameLayer::tryGetMainObject(a2, a3);
if ( !v9 )
goto LABEL_33;
v9->getRealPosition(v4, v9);
return v4;
}