//
// LevelEditorLayer::duplicateKeyframeAnimation from 0x1402e1880 to 0x1402e1afd (637 bytes)
//
// 2 xrefs:
// > SetupKeyframePopup::onCustomButton @ 0x1404268aa
// > ??> @ 0x1406d371c
//
// 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
//
// Hidden C++ exception states: #wind=4
cocos2d::CCArray *LevelEditorLayer::duplicateKeyframeAnimation(LevelEditorLayer *a1, int a2)
{
__int64 v2; // rbx
cocos2d::CCArray *v4; // r15
cocos2d::CCArray *v5; // rax
cocos2d::CCArray *v6; // rdi
__int64 v7; // r8
EditorUI *m_editorUI; // r14
cocos2d::ccArray *data; // rdi
__int64 num; // rax
cocos2d::CCObject **arr; // rdi
cocos2d::CCObject **i; // rbp
cocos2d::CCObject *v13; // rbx
cocos2d::CCObjectType m_eObjType; // eax
void **v15; // rdx
__int64 v16; // r8
cocos2d::CCArray *ObjectsFromString; // rax
void *v18; // rcx
int v20; // [rsp+20h] [rbp-C8h] BYREF
int v21; // [rsp+24h] [rbp-C4h]
char v22[8]; // [rsp+30h] [rbp-B8h] BYREF
void *v23; // [rsp+38h] [rbp-B0h] BYREF
char v24[40]; // [rsp+48h] [rbp-A0h] BYREF
void *Block[2]; // [rsp+70h] [rbp-78h] BYREF
__int64 v26; // [rsp+80h] [rbp-68h]
unsigned __int64 v27; // [rsp+88h] [rbp-60h]
void *v28[4]; // [rsp+90h] [rbp-58h] BYREF
v2 = a2;
v21 = 0;
v4 = (cocos2d::CCArray *)cocos2d::CCArray::create(a1);
v4->setTag(v4, a1->m_keyframeGroup);
cocos2d::CCDictionary::setObject(a1->m_keyframeGroups, v4, a1->m_keyframeGroup);
++a1->m_keyframeGroup;
a1->m_duplicateKeyframeGroup = v4->getTag(v4);
v5 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(a1->m_keyframeGroups, v2);
v6 = v5;
if ( v5 && cocos2d::CCArray::count(v5) )
{
m_editorUI = a1->m_editorUI;
v20 = 0;
sub_14005E660((__int64)v22, &v20, v7);
*(_OWORD *)Block = 0;
v26 = 0;
v27 = 15;
LOBYTE(Block[0]) = 0;
v21 = 1;
data = v6->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
for ( i = &arr[num - 1]; arr <= i; ++arr )
{
v13 = *arr;
if ( !*arr )
break;
m_eObjType = v13[18].m_eObjType;
if ( m_eObjType != 749 )
{
if ( m_eObjType == 3032 )
++v13[33].m_eObjType;
((void (__fastcall *)(cocos2d::CCObject *, void **, LevelEditorLayer *))v13->__vftable[17].copyWithZone)(
v13,
v28,
m_editorUI->m_editorLayer);
v15 = v28;
if ( v28[3] > (void *)0xF )
v15 = (void **)v28[0];
sub_140041270(Block, v15, (size_t)v28[2]);
sub_140041270(Block, ";", 1u);
if ( v13[18].m_eObjType == 3032 )
--v13[33].m_eObjType;
sub_14003A830((__int64)v28);
}
}
}
sub_14005D100((__int64)v24);
sub_14005D870(&v23);
a1->m_keepEditorLayer = 1;
ObjectsFromString = (cocos2d::CCArray *)LevelEditorLayer::createObjectsFromString(a1, (__int64 *)Block, v16, 1);
GJBaseGameLayer::assignNewStickyGroups(a1, ObjectsFromString);
a1->m_keepEditorLayer = 0;
if ( v27 > 0xF )
{
v18 = Block[0];
if ( v27 + 1 >= 0x1000 )
{
v18 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v18 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v18);
}
}
a1->m_duplicateKeyframeGroup = 0;
return v4;
}