//
// GJBaseGameLayer::getSavedPosition from 0x1402192a0 to 0x1402195d2 (818 bytes)
//
// 4 xrefs:
// > GJBaseGameLayer::processAdvancedFollowAction @ 0x14022f5b9
// > ??> @ 0x14067f798
// > ??> @ 0x14067f7cc
// > ??> @ 0x1406cd308
//
// 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
//
// local variable allocation has failed, the output may be wrong!
cocos2d::CCPoint GJBaseGameLayer::getSavedPosition(GJBaseGameLayer *a1, int a2, float a3)
{
int v3; // r8d
float v4; // xmm3_4
unsigned int m_uniqueID; // ebx
cocos2d::CCPoint *v6; // rsi
PlayerObject *m_player1; // rcx
GameObject *MainObject; // rax
float v10; // xmm6_4
float v11; // xmm0_4
unsigned int v12; // edx
unsigned int v13; // r8d
unsigned int v14; // r9d
int m_unk52C; // r14d
GameObject *v16; // rax
int v17; // r15d
std::_Vector_val>>>>>::pointer Myfirst; // rcx
unsigned __int64 v19; // rdx
std::_List_unchecked_const_iterator>>, std::_Iterator_base0>::_Nodeptr Ptr; // rax
std::_List_unchecked_const_iterator>>, std::_Iterator_base0>::_Nodeptr v21; // rcx
int v22; // edi
int v23; // edx
int v24; // eax
int v25; // ebx
double v26; // xmm0_8
char v28[8]; // [rsp+20h] [rbp-68h] BYREF
char v29[8]; // [rsp+28h] [rbp-60h] BYREF
char v30[8]; // [rsp+30h] [rbp-58h] BYREF
_BYTE v31[16]; // [rsp+38h] [rbp-50h] BYREF
char v32[8]; // [rsp+48h] [rbp-40h] BYREF
unsigned int v33; // [rsp+A8h] [rbp+20h] BYREF
m_uniqueID = v3;
v6 = *(cocos2d::CCPoint **)&a2;
if ( v4 <= 0.0 )
{
if ( v3 == -1 )
{
m_player1 = a1->m_player1;
LABEL_4:
m_player1->getPosition_0(m_player1);
cocos2d::CCPoint::CCPoint(v6);
return (cocos2d::CCPoint)v6;
}
if ( v3 == -2 )
{
m_player1 = a1->m_player2;
goto LABEL_4;
}
if ( v3 != -3 )
{
MainObject = GJBaseGameLayer::tryGetMainObject(a1, v3);
if ( MainObject )
{
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *))MainObject->getRealPosition)(MainObject, v6);
return (cocos2d::CCPoint)v6;
}
}
LABEL_28:
cocos2d::CCPoint::CCPoint(v6);
return (cocos2d::CCPoint)v6;
}
v10 = fmax(
0.0,
v4 / 0.004166666666666667 - (float)((float)(a1->m_gameState.m_unkUint6 - a1->m_gameState.m_unkUint5) / 1000.0));
v11 = ceilf(v10);
if ( (int)v11 >= a1->m_gameState.m_unkUint11 )
goto LABEL_28;
v33 = m_uniqueID;
v12 = HIBYTE(m_uniqueID);
v13 = HIWORD(m_uniqueID);
v14 = m_uniqueID >> 8;
switch ( m_uniqueID )
{
case 0xFFFFFFFF:
m_unk52C = a1->m_player1->m_unk52C;
break;
case 0xFFFFFFFE:
m_unk52C = a1->m_player2->m_unk52C;
break;
case 0xFFFFFFFD:
m_unk52C = a1->m_gameState.m_unkUint12;
break;
default:
v16 = GJBaseGameLayer::tryGetMainObject(a1, m_uniqueID);
if ( !v16 )
goto LABEL_28;
m_uniqueID = v16->m_uniqueID;
m_unk52C = v16->m_unk52C;
v12 = HIBYTE(m_uniqueID);
v13 = HIWORD(m_uniqueID);
v14 = m_uniqueID >> 8;
v33 = m_uniqueID;
break;
}
if ( m_unk52C < 0 )
goto LABEL_28;
v17 = 0;
Myfirst = a1->m_savePositionValues._Vec._Mypair._Myval2._Myfirst;
v19 = 2
* ((0x100000001B3LL
* ((unsigned __int8)v12
^ (0x100000001B3LL
* ((unsigned __int8)v13
^ (0x100000001B3LL
* ((unsigned __int8)v14 ^ (0x100000001B3LL * ((unsigned __int8)m_uniqueID ^ 0xCBF29CE484222325uLL))))))))
& a1->m_savePositionValues._Mask);
Ptr = Myfirst[v19 + 1]._Ptr;
if ( Ptr != a1->m_savePositionValues._List._Mypair._Myval2._Myhead )
{
v21 = Myfirst[v19]._Ptr;
if ( m_uniqueID == *((_DWORD *)Ptr + 4) )
goto LABEL_27;
while ( Ptr != v21 )
{
Ptr = *((std::_List_unchecked_const_iterator>>, std::_Iterator_base0>::_Nodeptr *)Ptr
+ 1);
if ( m_uniqueID == *((_DWORD *)Ptr + 4) )
goto LABEL_27;
}
}
Ptr = nullptr;
LABEL_27:
if ( !Ptr )
goto LABEL_28;
v22 = *(_DWORD *)(*(_QWORD *)sub_140060B20(
&a1->m_savePositionValues._Traitsobj._Mypair._Myval2._Myval2,
(__int64)v31,
(unsigned __int8 *)&v33)
+ 20LL);
v23 = a1->m_gameState.m_unkUint11 % v22 - (int)v11;
v24 = v23 + v22;
if ( v23 >= 0 )
v24 = a1->m_gameState.m_unkUint11 % v22 - (int)v11;
v25 = v24 + 1;
v26 = cocos2d::CCPoint::CCPoint(v11, a1->m_gameState.m_unkVecFloat1._Mypair._Myval2._Myfirst[2 * m_unk52C + 2 * v24]);
if ( v25 < v22 )
v17 = v25;
cocos2d::CCPoint::CCPoint(
*(float *)&v26,
a1->m_gameState.m_unkVecFloat1._Mypair._Myval2._Myfirst[2 * m_unk52C + 2 * v17]);
cocos2d::CCPoint::operator-(v29, v30, v28);
cocos2d::CCPoint::operator*(v30, v31);
cocos2d::CCPoint::operator+(v28, v32);
cocos2d::CCPoint::CCPoint(v6);
return (cocos2d::CCPoint)v6;
}