//
// EditorSFXManager::encodeDataTo from 0x1008ec380 to 0x1008ec789 (1033 bytes)
//
// 1 xrefs:
// > GameManager::encodeDataTo @ 0x100375764
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:37:54 +0000
//
void __fastcall EditorSFXManager::encodeDataTo(__int64 a1, __int64 a2)
{
__int64 v2; // r12
__int64 v3; // r14
unsigned int v4; // eax
__int64 v5; // rdi
int v6; // ebx
unsigned int v7; // r13d
__int64 v8; // rax
__int64 v9; // rbx
char *v10; // rax
const char *CString; // r14
size_t v12; // rax
std::string::size_type v13; // r15
char *data; // rbx
char *v15; // rsi
__int64 v16; // rax
size_t v17; // r12
__int64 v18; // rdi
int v19; // ebx
unsigned int v20; // r13d
__int64 v21; // rax
char *v22; // rax
const char *v23; // r15
size_t v24; // rax
std::string::size_type v25; // r14
char *v26; // rbx
char *v27; // rsi
__int64 v28; // rax
size_t v29; // r12
__int64 v30; // [rsp+0h] [rbp-60h]
__int64 v32; // [rsp+10h] [rbp-50h]
__int64 v33; // [rsp+10h] [rbp-50h]
int v34; // [rsp+1Ch] [rbp-44h]
int v35; // [rsp+1Ch] [rbp-44h]
std::string __dst[2]; // [rsp+20h] [rbp-40h] BYREF
if ( !a2 )
return;
v2 = a2;
v3 = a1;
DS_Dictionary::setIntegerForKey_1(a2, (__int64)"editorSFXVersion", 1);
v4 = *(unsigned __int8 *)(a1 + 168);
if ( (v4 & 1) == 0 )
{
if ( !(v4 >> 1) )
goto LABEL_8;
LABEL_6:
__dst[0] = *(std::string *)(a1 + 168);
*(_OWORD *)(a1 + 168) = 0;
*(_QWORD *)(a1 + 184) = 0;
EditorSFXManager::deserializeAll((_QWORD *)a1, __dst, 1);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
goto LABEL_8;
}
if ( *(_QWORD *)(a1 + 176) )
goto LABEL_6;
LABEL_8:
EditorSFXManager::serializeAll(__dst, (_QWORD *)a1);
DS_Dictionary::setStringForKey_1(a2, (__int64)"editorSFX", (__int64)__dst);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
v5 = *(_QWORD *)(a1 + 144);
v30 = v3;
if ( v5 )
{
v6 = sub_1007FEF90(v5);
DS_Dictionary::setIntegerForKey_1(a2, (__int64)"editorSFXFavoriteCount", (unsigned int)v6);
v34 = v6;
if ( v6 > 0 )
{
v7 = 0;
while ( 1 )
{
v8 = sub_1007FEFE0(*(_QWORD *)(v3 + 144), v7);
if ( v8 )
break;
LABEL_13:
if ( v34 == ++v7 )
goto LABEL_28;
}
v9 = v8;
v10 = sub_10088E820("editorSFXFavorite_%d", v7);
CString = (const char *)cocos2d::CCString::getCString((__int64)v10);
v12 = strlen(CString);
if ( v12 >= 0xFFFFFFFFFFFFFFF8LL )
LABEL_49:
sub_100003630();
v13 = v12;
v32 = v9;
if ( v12 >= 0x17 )
{
v16 = v12 | 7;
v17 = 26;
if ( (v13 | 7) != 0x17 )
v17 = v16 + 1;
data = (char *)operator new(v17);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst[0].__r_.__value_.__r.__words[0] = v17 + 1;
__dst[0].__r_.__value_.__l.__size_ = v13;
v2 = a2;
}
else
{
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v12);
data = __dst[0].__r_.__value_.__s.__data_;
if ( !v12 )
{
__dst[0].__r_.__value_.__s.__data_[0] = 0;
v15 = __dst[0].__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_20;
goto LABEL_19;
}
}
memmove(data, CString, v13);
data[v13] = 0;
v15 = __dst[0].__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_20:
DS_Dictionary::setSubDictForKey(v2, v15, 0, 1);
v3 = v30;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v32 + 48LL))(v32, v2);
DS_Dictionary::stepOutOfSubDict(v2);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
goto LABEL_13;
}
LABEL_19:
v15 = __dst[0].__r_.__value_.__l.__data_;
goto LABEL_20;
}
}
else
{
DS_Dictionary::setIntegerForKey_1(a2, (__int64)"editorSFXFavoriteCount", 0);
}
LABEL_28:
v18 = *(_QWORD *)(v3 + 152);
if ( v18 )
v19 = sub_1007FEF90(v18);
else
v19 = 0;
DS_Dictionary::setIntegerForKey_1(v2, (__int64)"editorSFXMyCount", (unsigned int)v19);
DS_Dictionary::setIntegerForKey_1(v2, (__int64)"editorSFXNextLocalID", *(unsigned int *)(v3 + 160));
if ( v19 > 0 )
{
v20 = 0;
v35 = v19;
while ( 1 )
{
v21 = sub_1007FEFE0(*(_QWORD *)(v3 + 152), v20);
if ( v21 )
break;
LABEL_33:
if ( v19 == ++v20 )
goto LABEL_47;
}
v33 = v21;
v22 = sub_10088E820("editorSFXMy_%d", v20);
v23 = (const char *)cocos2d::CCString::getCString((__int64)v22);
v24 = strlen(v23);
if ( v24 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_49;
v25 = v24;
if ( v24 >= 0x17 )
{
v28 = v24 | 7;
v29 = 26;
if ( (v25 | 7) != 0x17 )
v29 = v28 + 1;
v26 = (char *)operator new(v29);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)v26;
__dst[0].__r_.__value_.__r.__words[0] = v29 + 1;
__dst[0].__r_.__value_.__l.__size_ = v25;
v2 = a2;
}
else
{
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v24);
v26 = __dst[0].__r_.__value_.__s.__data_;
if ( !v24 )
{
__dst[0].__r_.__value_.__s.__data_[0] = 0;
v27 = __dst[0].__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_40;
goto LABEL_39;
}
}
memmove(v26, v23, v25);
v26[v25] = 0;
v27 = __dst[0].__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_40:
DS_Dictionary::setSubDictForKey(v2, v27, 0, 1);
v3 = v30;
v19 = v35;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v33 + 48LL))(v33, v2);
DS_Dictionary::stepOutOfSubDict(v2);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
goto LABEL_33;
}
LABEL_39:
v27 = __dst[0].__r_.__value_.__l.__data_;
goto LABEL_40;
}
LABEL_47:
DS_Dictionary::setFloatForKey_1(v2, (__int64)"editorSFXGlobalVolume");
}