//
// LevelEditorLayer::init from 0x1000daed0 to 0x1000dc1f1 (4897 bytes)
//
// 2 xrefs:
// > LevelEditorLayer::scene @ 0x1000dae01
// > LevelEditorLayer::create @ 0x1000dae8f
//
// 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
//
bool __fastcall LevelEditorLayer::init(LevelEditorLayer *a1, GJGameLevel *a2, bool a3)
{
__int128 v3; // xmm0
float v4; // xmm3_4
LevelEditorLayer *v5; // r14
bool v6; // bl
MusicDownloadManager *v7; // rax
GameManager *v8; // rax
GameManager *v9; // rax
GameManager *v10; // rax
bool GameVariable; // al
GameManager *v12; // rax
FMODAudioEngine *v13; // rax
cocos2d::CCObject *v14; // rdi
cocos2d::CCObject *v15; // rax
cocos2d::CCDictionary *v16; // rax
cocos2d::CCDictionary *v17; // rax
cocos2d::CCDictionary *v18; // rax
cocos2d::CCDictionary *v19; // rdi
cocos2d::CCObject *v20; // rax
cocos2d::CCObject *v21; // rdi
cocos2d::CCObject *v22; // rax
cocos2d::CCObject *v23; // rdi
cocos2d::CCObject *v24; // rax
cocos2d::CCObject *v25; // rdi
cocos2d::CCObject *v26; // rax
cocos2d::CCObject *v27; // rdi
cocos2d::CCObject *v28; // rax
cocos2d::CCDictionary *v29; // rax
cocos2d::CCDictionary *v30; // rdi
cocos2d::CCObject *v31; // rax
cocos2d::CCDictionary *v32; // rax
cocos2d::CCDictionary *v33; // rdi
cocos2d::CCObject *v34; // rax
cocos2d::CCObject *v35; // rdi
cocos2d::CCObject *v36; // rax
cocos2d::CCObject *v37; // rdi
cocos2d::CCObject *v38; // rax
cocos2d::CCObject *v39; // rdi
cocos2d::CCObject *v40; // rax
cocos2d::CCObject *v41; // rdi
cocos2d::CCObject *v42; // rax
cocos2d::CCObject *v43; // rdi
cocos2d::CCObject *v44; // rax
cocos2d::CCObject *v45; // rdi
cocos2d::CCObject *v46; // rax
std::__vector_base::pointer begin; // rax
__int64 v48; // rcx
unsigned __int8 *v49; // rbx
std::__vector_base::pointer end; // rdi
size_t v51; // r12
size_t v52; // r15
unsigned __int64 v53; // rax
__int64 v54; // rdx
size_t v55; // r14
unsigned __int8 *v56; // r13
unsigned __int8 *v57; // rbx
std::__vector_base::pointer v58; // rax
unsigned __int64 v59; // rdx
__int128 *p_m_sortedGroups; // rdi
std::__vector_base::pointer v61; // rax
unsigned __int64 v62; // rdx
unsigned __int64 i; // rcx
unsigned __int64 v64; // rsi
unsigned __int64 v65; // rdx
GJGameLevel *m_level; // rax
std::string *p_m_lockedEditorLayers; // rax
unsigned int v68; // eax
cocos2d::CCArray *v69; // r12
char *v70; // rax
__int64 v71; // r14
std::vector *v72; // rsi
char *v73; // rdx
unsigned __int64 v74; // r13
bool v75; // zf
unsigned __int64 v76; // r15
char *v77; // rbx
size_t v78; // r15
char *v79; // r13
char v80; // al
const char *v81; // rbx
size_t v82; // r12
size_t v83; // rax
std::string::size_type v84; // r15
char *data; // r13
size_t v86; // r12
__int64 v87; // rax
__int64 v88; // rbx
char *v89; // rax
unsigned __int64 v90; // rsi
char *v91; // rdx
unsigned __int64 v92; // rdi
unsigned int v93; // ebx
cocos2d::CCString *v94; // rax
int v95; // eax
std::__vector_base::pointer v96; // r15
std::__vector_base::pointer v97; // rbx
unsigned __int64 v98; // rcx
__int64 v99; // rbx
__int64 v100; // rbx
bool v101; // cf
GJGameLevel *v102; // rax
std::string *p_m_savedCameraPositions; // rax
std::string::size_type v104; // r12
std::string::size_type size; // r15
__int64 v106; // r14
unsigned __int64 v107; // rbx
__int64 v108; // r13
cocos2d::CCPoint v109; // rax
int v110; // r15d
const char *v111; // r12
int v112; // eax
void *v113; // rdi
OBB2D *v114; // rax
DrawGridLayer *v115; // rbx
cocos2d::CCLayer *m_objectLayer; // r15
GameManager *v117; // rax
bool v118; // al
__int64 v119; // rdx
cocos2d::CCDrawNode *v120; // rax
cocos2d::CCSprite *v121; // rax
GJGameLevel *v122; // rax
std::string *p_m_levelString; // rax
LevelSettingsObject *m_levelSettings; // rax
char *v125; // r15
ColorAction *ColorAction; // rax
PlayerObject *m_player1; // rcx
__int16 v128; // dx
ColorAction *v129; // rax
PlayerObject *v130; // rcx
__int16 v131; // dx
EditorUI *v132; // rax
std::string *p_m_lastCameraPos; // rsi
cocos2d::CCLayer *v134; // rbx
double v135; // xmm0_8
EditorUI *m_editorUI; // rdi
EditorUI *v137; // rdi
cocos2d::CCArray *m_objects; // rax
cocos2d::ccArray *v139; // rax
LabelGameObject **arr; // rbx
unsigned __int64 v141; // r14
LabelGameObject *v142; // rsi
LevelEditorLayer *v143; // rbx
cocos2d::CCArray *m_batchNodes; // rax
cocos2d::ccArray *v145; // rax
__int64 num; // rcx
unsigned __int64 v147; // rax
unsigned __int64 v148; // rcx
cocos2d::CCArray *v149; // rax
cocos2d::ccArray *v150; // rax
cocos2d::CCObject **v151; // r14
unsigned __int64 v152; // r15
cocos2d::CCObject *v153; // rbx
GJBaseGameLayer *v154; // rbx
GameManager *v155; // rax
bool v156; // al
char v158; // [rsp+8h] [rbp-F8h] BYREF
__int64 v159; // [rsp+10h] [rbp-F0h] BYREF
std::vector *p_m_lockedLayers; // [rsp+18h] [rbp-E8h]
cocos2d::CCArray *v161; // [rsp+20h] [rbp-E0h]
GJGameLevel *v162; // [rsp+28h] [rbp-D8h]
__int128 v163; // [rsp+30h] [rbp-D0h] BYREF
void *v164; // [rsp+40h] [rbp-C0h]
_BOOL4 v165; // [rsp+54h] [rbp-ACh]
std::vector *p_m_savedPositions; // [rsp+58h] [rbp-A8h]
__int128 v167; // [rsp+60h] [rbp-A0h] BYREF
void *longStorage; // [rsp+70h] [rbp-90h]
__int128 __dst; // [rsp+80h] [rbp-80h] BYREF
void *v170; // [rsp+90h] [rbp-70h]
cocos2d::CCPoint v171; // [rsp+A0h] [rbp-60h]
LevelEditorLayer *v172; // [rsp+A8h] [rbp-58h]
std::string v173; // [rsp+B0h] [rbp-50h] BYREF
bool v174; // [rsp+D7h] [rbp-29h]
double v175; // 0:xmm0_8.8
v165 = a3;
v162 = a2;
v5 = a1;
v6 = GJBaseGameLayer::init(a1);
if ( !v6 )
return v6;
v7 = MusicDownloadManager::sharedState();
MusicDownloadManager::tryLoadLibraries(v7);
UILayer::enableEditorMode(a1->m_uiLayer);
a1->m_isEditor = 1;
a1->m_initializing = 1;
v8 = GameManager::sharedState();
a1->m_playTestSmoothFix = GameManager::getGameVariable(v8, "0102");
v9 = GameManager::sharedState();
a1->m_previewParticles = GameManager::getGameVariable(v9, "0117");
v10 = GameManager::sharedState();
a1->m_previewAnimations = GameManager::getGameVariable(v10, "0118");
GameVariable = 1;
if ( !a1->m_alwaysHideParticleIcons )
{
v12 = GameManager::sharedState();
GameVariable = GameManager::getGameVariable(v12, "0137");
}
a1->m_hideParticleIcons = GameVariable;
LevelEditorLayer::updateOptions(a1);
a1->m_objectCount.value = 0;
*(float *)&v3 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
a1->m_objectCount.seed = (int)*(float *)&v3;
a1->m_objectCount.random = (int)*(float *)&v3;
v13 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::stopAllMusic(v13, 1);
v14 = v162;
v5->m_level = v162;
cocos2d::CCObject::retain(v14);
GameManager::sharedState()->m_editorEnabled = 1;
GameManager::sharedState()->m_levelEditorLayer = v5;
v15 = (cocos2d::CCObject *)sub_10071F9E0(v14, 1);
v5->m_durationObjects = (cocos2d::CCArray *)v15;
cocos2d::CCObject::retain(v15);
v16 = cocos2d::CCDictionary::create();
v5->m_triggerGroupsDict = v16;
cocos2d::CCObject::retain(v16);
v17 = cocos2d::CCDictionary::create();
v5->m_unk3778 = v17;
cocos2d::CCObject::retain(v17);
v18 = cocos2d::CCDictionary::create();
v5->m_unk3780 = v18;
v19 = v18;
cocos2d::CCObject::retain(v18);
v20 = (cocos2d::CCObject *)sub_10071F9E0(v19, 1);
v5->m_pulseTriggers = (cocos2d::CCArray *)v20;
v21 = v20;
cocos2d::CCObject::retain(v20);
v22 = (cocos2d::CCObject *)sub_10071F9E0(v21, 1);
v5->m_colorTriggers = (cocos2d::CCArray *)v22;
v23 = v22;
cocos2d::CCObject::retain(v22);
v24 = (cocos2d::CCObject *)sub_10071F9E0(v23, 1);
v5->m_alphaTriggers = (cocos2d::CCArray *)v24;
v25 = v24;
cocos2d::CCObject::retain(v24);
v26 = (cocos2d::CCObject *)sub_10071F9E0(v25, 1);
v5->m_spawnTriggers = (cocos2d::CCArray *)v26;
v27 = v26;
cocos2d::CCObject::retain(v26);
v28 = (cocos2d::CCObject *)sub_10071F9E0(v27, 1);
v5->m_playtestTriggers = (cocos2d::CCArray *)v28;
cocos2d::CCObject::retain(v28);
v29 = cocos2d::CCDictionary::create();
v5->m_spawnOrderTriggers = (cocos2d::CCArray *)v29;
v30 = v29;
cocos2d::CCObject::retain(v29);
v31 = (cocos2d::CCObject *)sub_10071F9E0(v30, 1);
v5->m_spawnOrderObjects = (cocos2d::CCArray *)v31;
cocos2d::CCObject::retain(v31);
v32 = cocos2d::CCDictionary::create();
v5->m_unk3740 = v32;
v33 = v32;
cocos2d::CCObject::retain(v32);
v34 = (cocos2d::CCObject *)sub_10071F9E0(v33, 1);
v5->m_unk3748 = (cocos2d::CCArray *)v34;
v35 = v34;
cocos2d::CCObject::retain(v34);
v5->m_unk3751 = 1;
v36 = (cocos2d::CCObject *)sub_10071F9E0(v35, 1);
v5->m_moveTriggers = (cocos2d::CCArray *)v36;
v37 = v36;
cocos2d::CCObject::retain(v36);
v38 = (cocos2d::CCObject *)sub_10071F9E0(v37, 1);
v5->m_undoObjects = (cocos2d::CCArray *)v38;
v39 = v38;
cocos2d::CCObject::retain(v38);
v40 = (cocos2d::CCObject *)sub_10071F9E0(v39, 1);
v5->m_redoObjects = (cocos2d::CCArray *)v40;
v41 = v40;
cocos2d::CCObject::retain(v40);
v42 = (cocos2d::CCObject *)sub_10071F9E0(v41, 1);
v5->m_cameraGuideTriggers = (cocos2d::CCArray *)v42;
v43 = v42;
cocos2d::CCObject::retain(v42);
v44 = (cocos2d::CCObject *)sub_10071F9E0(v43, 1);
v5->m_particleObjects = (cocos2d::CCArray *)v44;
v45 = v44;
cocos2d::CCObject::retain(v44);
v46 = (cocos2d::CCObject *)sub_10071F9E0(v45, 1);
v5->m_keyframeObjects = (cocos2d::CCArray *)v46;
cocos2d::CCObject::retain(v46);
begin = v5->m_objectVector.__begin_;
v48 = (char *)v5->m_objectVector.__end_ - (char *)begin;
v174 = v6;
if ( (unsigned __int64)(v48 >> 3) > 0x270F )
{
if ( v48 != 80000 )
v5->m_objectVector.__end_ = begin + 10000;
}
else
{
sub_100105530(&v5->m_objectVector, 10000 - (v48 >> 3));
}
sub_1000DC570(&v5->m_toggledGroups, 10000, 0);
p_m_lockedLayers = &v5->m_lockedLayers;
sub_1000DC570(&v5->m_lockedLayers, 10000, 0);
v49 = v5->m_toggledGroupStates.__begin_;
end = v5->m_toggledGroupStates.__end_;
v51 = end - v49;
v172 = v5;
if ( (unsigned __int64)(end - v49) > 0x270F )
{
if ( v51 == 10000 )
goto LABEL_20;
v57 = v49 + 10000;
goto LABEL_19;
}
v52 = 10000 - v51;
if ( v5->m_toggledGroupStates.__end_cap_.__value_ - end >= 10000 - v51 )
{
v57 = &end[v52];
__bzero(end, v52);
LABEL_19:
v5->m_toggledGroupStates.__end_ = v57;
goto LABEL_20;
}
v53 = v5->m_toggledGroupStates.__end_cap_.__value_ - v49;
v54 = 10000;
if ( 2 * v53 >= 0x2711 )
v54 = 2 * v53;
v55 = 0x7FFFFFFFFFFFFFFFLL;
if ( v53 < 0x3FFFFFFFFFFFFFFFLL )
v55 = v54;
v56 = (unsigned __int8 *)operator new(v55);
v171 = (cocos2d::CCPoint)&v56[v55];
__bzero(&v56[v51], v52);
memcpy(v56, v49, v51);
v172->m_toggledGroupStates.__begin_ = v56;
v172->m_toggledGroupStates.__end_ = v56 + 10000;
v5 = v172;
v172->m_toggledGroupStates.__end_cap_.__value_ = (unsigned __int8 *)v171;
if ( v49 )
operator delete(v49);
LABEL_20:
sub_1000DC570(&v5->m_blendingColors2, 10000, 0);
sub_1000DC570(&v5->m_blendingColors, 10000, 0);
v58 = v5->m_triggerGroups.__begin_;
v59 = v5->m_triggerGroups.__end_ - v58;
if ( v59 > 0x270F )
{
if ( (std::__vector_base::pointer)((char *)v5->m_triggerGroups.__end_ - (char *)v58) != (std::__vector_base::pointer)80000 )
v5->m_triggerGroups.__end_ = v58 + 10000;
}
else
{
sub_1001057D0(&v5->m_triggerGroups, 10000 - v59);
}
p_m_sortedGroups = (__int128 *)&v5->m_sortedGroups;
sub_1000DC570(&v5->m_sortedGroups, 10000, 0);
v61 = v5->m_spawnGroupDelays.__begin_;
v62 = v5->m_spawnGroupDelays.__end_ - v61;
if ( v62 > 0x270F )
{
if ( (std::__vector_base::pointer)((char *)v5->m_spawnGroupDelays.__end_ - (char *)v61) != (std::__vector_base::pointer)40000 )
v5->m_spawnGroupDelays.__end_ = v61 + 10000;
}
else
{
p_m_sortedGroups = (__int128 *)&v5->m_spawnGroupDelays;
sub_1000CB0D0((void **)&v5->m_spawnGroupDelays.__begin_, 10000 - v62);
}
for ( i = 0; i != 10000; ++i )
{
v5->m_objectVector.__begin_[i] = nullptr;
v64 = __ROL8__(-2, i);
v65 = i >> 6;
*(_QWORD *)&v5->m_toggledGroups.__begin_[8 * v65] &= v64;
*(_QWORD *)&v5->m_blendingColors2.__begin_[8 * v65] &= v64;
*(_QWORD *)&v5->m_lockedLayers.__begin_[8 * v65] &= v64;
*(_QWORD *)&v5->m_blendingColors.__begin_[8 * v65] &= v64;
*(_QWORD *)&v5->m_sortedGroups.__begin_[8 * v65] &= v64;
v5->m_toggledGroupStates.__begin_[i] = 0;
v5->m_triggerGroups.__begin_[i] = nullptr;
v5->m_spawnGroupDelays.__begin_[i] = 0.0;
}
m_level = v5->m_level;
if ( (m_level->m_lockedEditorLayers.m_data.m_short.sizex2 & 1) == 0 )
{
p_m_lockedEditorLayers = &m_level->m_lockedEditorLayers;
longStorage = p_m_lockedEditorLayers->m_data.m_long.longStorage;
v3 = *(_OWORD *)&p_m_lockedEditorLayers->m_data.m_short.sizex2;
v167 = *(_OWORD *)&p_m_lockedEditorLayers->m_data.m_short.sizex2;
v68 = (unsigned __int8)v167;
if ( (v167 & 1) == 0 )
goto LABEL_32;
LABEL_35:
if ( !*((_QWORD *)&v167 + 1) )
goto LABEL_98;
goto LABEL_36;
}
v64 = (unsigned __int64)m_level->m_lockedEditorLayers.m_data.m_long.longStorage;
p_m_sortedGroups = &v167;
sub_100006B70(&v167, (const void *)v64, m_level->m_lockedEditorLayers.m_data.m_long.size, *(double *)&v3);
v68 = (unsigned __int8)v167;
if ( (v167 & 1) != 0 )
goto LABEL_35;
LABEL_32:
if ( !(v68 >> 1) )
goto LABEL_98;
LABEL_36:
v69 = (cocos2d::CCArray *)sub_10071F9E0(p_m_sortedGroups, v64);
v70 = (char *)&v167 + 1;
if ( (v167 & 1) != 0 )
{
v70 = (char *)longStorage;
v71 = -1;
p_m_savedPositions = *((std::vector **)&v167 + 1);
if ( !*((_QWORD *)&v167 + 1) )
goto LABEL_46;
LABEL_40:
v72 = p_m_savedPositions;
v73 = v70;
while ( *v73 != 44 )
{
++v73;
v72 = (std::vector *)((char *)v72 - 1);
if ( !v72 )
{
v73 = (char *)p_m_savedPositions + (_QWORD)v70;
break;
}
}
v71 = -1;
if ( v73 != (char *)p_m_savedPositions + (_QWORD)v70 )
v71 = v73 - v70;
goto LABEL_46;
}
v71 = -1;
p_m_savedPositions = (std::vector *)((unsigned __int8)v167 >> 1);
if ( (unsigned __int8)v167 >> 1 )
goto LABEL_40;
LABEL_46:
v74 = 0;
v161 = v69;
do
{
if ( (v167 & 1) != 0 )
{
v76 = *((_QWORD *)&v167 + 1);
if ( *((_QWORD *)&v167 + 1) < v74 )
LABEL_174:
sub_1000547C0();
v77 = (char *)longStorage;
}
else
{
v76 = (unsigned __int8)v167 >> 1;
v77 = (char *)&v167 + 1;
if ( v74 > v76 )
goto LABEL_174;
}
v78 = v76 - v74;
if ( v78 >= v71 - v74 )
v78 = v71 - v74;
if ( v78 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)&v3);
v171 = (cocos2d::CCPoint)v74;
if ( v78 >= 0x17 )
{
v82 = (v78 | 7) + 1;
if ( (v78 | 7) == 0x17 )
v82 = 26;
v79 = (char *)operator new(v82);
v170 = v79;
*(_QWORD *)&__dst = v82 | 1;
*((_QWORD *)&__dst + 1) = v78;
v69 = v161;
}
else
{
LOBYTE(__dst) = 2 * v78;
v79 = (char *)&__dst + 1;
if ( !v78 )
{
BYTE1(__dst) = 0;
v80 = __dst;
if ( (__dst & 1) == 0 )
goto LABEL_59;
goto LABEL_66;
}
}
memmove(v79, &v77[*(_QWORD *)&v171], v78);
v79[v78] = 0;
v80 = __dst;
if ( (__dst & 1) == 0 )
{
LABEL_59:
v74 = (unsigned __int64)v171;
if ( !v80 && *(std::vector **)&v171 == p_m_savedPositions )
goto LABEL_79;
v81 = (char *)&__dst + 1;
goto LABEL_69;
}
LABEL_66:
v74 = (unsigned __int64)v171;
if ( !*((_QWORD *)&__dst + 1) && *(std::vector **)&v171 == p_m_savedPositions )
goto LABEL_79;
v81 = (const char *)v170;
LABEL_69:
v83 = strlen(v81);
if ( v83 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)&v3);
v84 = v83;
if ( v83 >= 0x17 )
{
v86 = (v83 | 7) + 1;
if ( (v83 | 7) == 0x17 )
v86 = 26;
data = (char *)operator new(v86);
v173.__r_.__value_.__r.__words[2] = (std::string::size_type)data;
v173.__r_.__value_.__r.__words[0] = v86 | 1;
v173.__r_.__value_.__l.__size_ = v84;
v69 = v161;
LABEL_76:
memmove(data, v81, v84);
goto LABEL_77;
}
v173.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v83);
data = v173.__r_.__value_.__s.__data_;
if ( v83 )
goto LABEL_76;
LABEL_77:
data[v84] = 0;
v87 = sub_1007AB360(&v173);
sub_10071FCD0(v69, v87);
v74 = (unsigned __int64)v171;
if ( (*(_BYTE *)&v173.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v173.__r_.__value_.__l.__data_);
LABEL_79:
v88 = -1;
if ( v71 == -1 )
goto LABEL_80;
if ( (v167 & 1) != 0 )
{
v89 = (char *)longStorage;
v90 = *((_QWORD *)&v167 + 1);
v74 = v71 + 1;
if ( *((_QWORD *)&v167 + 1) <= (unsigned __int64)(v71 + 1) )
goto LABEL_80;
}
else
{
v90 = (unsigned __int8)v167 >> 1;
v89 = (char *)&v167 + 1;
v74 = v71 + 1;
if ( v90 <= v71 + 1 )
goto LABEL_80;
}
v91 = &v89[v74];
v92 = v90 + ~v71;
while ( *v91 != 44 )
{
++v91;
if ( !--v92 )
{
v91 = &v89[v90];
break;
}
}
v88 = v91 - v89;
if ( v91 == &v89[v90] )
v88 = -1;
LABEL_80:
if ( (__dst & 1) != 0 )
operator delete(v170);
v75 = v71 == -1;
v71 = v88;
}
while ( !v75 );
v93 = 0;
v5 = v172;
while ( v93 < (unsigned int)sub_100720070(v69) )
{
v94 = cocos2d::CCArray::stringAtIndex(v69, v93);
v95 = cocos2d::CCString::intValue(v94);
if ( v95 <= 9999 )
*(_QWORD *)&p_m_lockedLayers->__begin_[8 * ((unsigned __int64)v95 >> 6)] |= 1LL << v95;
++v93;
}
LABEL_98:
v96 = v5->m_savedPositions.__begin_;
v97 = v5->m_savedPositions.__end_;
v98 = v97 - v96;
if ( v98 > 9 )
{
if ( (std::__vector_base::pointer)((char *)v5->m_savedPositions.__end_ - (char *)v96) != (std::__vector_base::pointer)80 )
{
v97 = v96 + 10;
v5->m_savedPositions.__end_ = v96 + 10;
}
}
else
{
sub_100105930(&v5->m_savedPositions, 10 - v98);
v96 = v5->m_savedPositions.__begin_;
v97 = v5->m_savedPositions.__end_;
}
v99 = v97 - v96;
if ( v99 > 0 )
{
v100 = v99 + 1;
do
{
*(double *)&v3 = sub_10028CC90();
++v96;
v101 = v100-- == 1;
}
while ( !v101 && v100 != 1 );
}
v102 = v5->m_level;
if ( (v102->m_savedCameraPositions.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
&__dst,
v102->m_savedCameraPositions.m_data.m_long.longStorage,
v102->m_savedCameraPositions.m_data.m_long.size,
*(double *)&v3);
}
else
{
p_m_savedCameraPositions = &v102->m_savedCameraPositions;
v170 = p_m_savedCameraPositions->m_data.m_long.longStorage;
__dst = *(_OWORD *)&p_m_savedCameraPositions->m_data.m_short.sizex2;
}
if ( (__dst & 1) != 0 )
{
if ( !*((_QWORD *)&__dst + 1) )
goto LABEL_129;
}
else if ( !((unsigned __int8)__dst >> 1) )
{
goto LABEL_129;
}
memset(&v173, 0, sizeof(v173));
sub_1000DC810(&__dst, ",", &v173);
size = v173.__r_.__value_.__l.__size_;
v104 = v173.__r_.__value_.__r.__words[0];
if ( v173.__r_.__value_.__l.__size_ - v173.__r_.__value_.__r.__words[0] != 24 )
{
p_m_savedPositions = &v5->m_savedPositions;
v106 = 25;
v107 = 2;
v108 = 0;
v109 = 0;
while ( 1 )
{
v75 = (*(_BYTE *)(v104 + v106 - 25) & 1) == 0;
v171 = v109;
if ( v75 )
{
v110 = atoi((const char *)(v104 + v106 - 24));
if ( (*(_BYTE *)(v104 + v106 - 1) & 1) != 0 )
goto LABEL_116;
}
else
{
v110 = atoi(*(const char **)(v104 + v106 - 9));
if ( (*(_BYTE *)(v104 + v106 - 1) & 1) != 0 )
{
LABEL_116:
v111 = *(const char **)(v104 + v106 + 15);
goto LABEL_119;
}
}
v111 = (const char *)(v106 + v104);
LABEL_119:
v112 = atoi(v111);
sub_10028CBE0(&v163, (float)v110, (float)v112);
sub_10028CC90();
size = v173.__r_.__value_.__l.__size_;
v104 = v173.__r_.__value_.__r.__words[0];
if ( 0xAAAAAAAAAAAAAAABLL * ((__int64)(v173.__r_.__value_.__l.__size_ - v173.__r_.__value_.__r.__words[0]) >> 3)
- 1 > v107 )
{
v109 = (cocos2d::CCPoint)(*(_QWORD *)&v171 + 1LL);
v106 += 48;
v107 += 2LL;
v108 += 8;
if ( *(unsigned __int64 *)&v171 < 9 )
continue;
}
break;
}
}
v5 = v172;
if ( v104 )
{
v113 = (void *)v104;
if ( size != v104 )
{
do
{
if ( (*(_BYTE *)(size - 24) & 1) != 0 )
operator delete(*(void **)(size - 8));
size -= 24LL;
}
while ( size != v104 );
v113 = (void *)v173.__r_.__value_.__r.__words[0];
}
v173.__r_.__value_.__l.__size_ = v104;
operator delete(v113);
}
LABEL_129:
sub_10028CC60(&v173);
sub_10028CC90();
sub_10028CC60(&v173);
v114 = OBB2D::create((cocos2d::CCPoint)1065353216LL, 1.0, 0.0, v4);
v5->m_currentOBB2D = v114;
cocos2d::CCObject::retain(v114);
cocos2d::CCDirector::sharedDirector();
*(cocos2d::CCSize *)&v175 = cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v158);
GJBaseGameLayer::setupLayers(v5);
v115 = DrawGridLayer::create(v5->m_objectLayer, v5);
v5->m_drawGridLayer = v115;
m_objectLayer = v5->m_objectLayer;
v117 = GameManager::sharedState();
v118 = GameManager::getGameVariable(v117, "0039");
v119 = 4294965697LL;
if ( v118 )
v119 = 1399;
((void (__fastcall *)(cocos2d::CCLayer *, DrawGridLayer *, __int64, double))m_objectLayer->addChild_0)(
m_objectLayer,
v115,
v119,
v175);
v120 = cocos2d::CCDrawNode::create();
v5->m_debugDrawNode = v120;
v159 = 0x30300000302LL;
cocos2d::CCDrawNode::setBlendFunc(v120, (const cocos2d::ccBlendFunc *)&v159);
((void (__fastcall *)(cocos2d::CCDrawNode *, __int64))v5->m_debugDrawNode->setTag)(v5->m_debugDrawNode, 4294957297LL);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCDrawNode *, __int64))v5->m_aboveShaderObjectLayer->addChild_0)(
v5->m_aboveShaderObjectLayer,
v5->m_debugDrawNode,
1401);
GJBaseGameLayer::createPlayer(v5);
v121 = cocos2d::CCSprite::createWithSpriteFrameName("d_cross_01_001.png");
v5->m_playtestDeathSprite = v121;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *, cocos2d::CCSprite *, __int64))v5->m_gameLayerT1->addChild_0)(
v5->m_gameLayerT1,
v121,
10);
((void (__fastcall *)(cocos2d::CCSprite *, void *))v5->m_playtestDeathSprite->setColor)(
v5->m_playtestDeathSprite,
&unk_100816670);
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v5->m_playtestDeathSprite->setVisible)(
v5->m_playtestDeathSprite,
0);
((void (__fastcall *)(cocos2d::CCSprite *, float))v5->m_playtestDeathSprite->setScale)(
v5->m_playtestDeathSprite,
0.69999999);
GJBaseGameLayer::createPlayerCollisionBlock(v5);
v5->m_collisionBlocksAdded = 0;
GJBaseGameLayer::removeObjectFromSection(v5, v5->m_player1CollisionBlock);
GJBaseGameLayer::removeObjectFromSection(v5, v5->m_player2CollisionBlock);
v122 = v5->m_level;
if ( (v122->m_levelString.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
&v163,
v122->m_levelString.m_data.m_long.longStorage,
v122->m_levelString.m_data.m_long.size,
COERCE_DOUBLE(1060320051));
}
else
{
p_m_levelString = &v122->m_levelString;
v164 = p_m_levelString->m_data.m_long.longStorage;
v163 = *(_OWORD *)&p_m_levelString->m_data.m_short.sizex2;
}
cocos2d::ZipUtils::decompressString(&v173);
if ( (v5->m_levelString.m_data.m_short.sizex2 & 1) != 0 )
operator delete(v5->m_levelString.m_data.m_long.longStorage);
v5->m_levelString = (std::string)v173;
*(_WORD *)&v173.__r_.__value_.__l.0 = 0;
if ( (v163 & 1) != 0 )
operator delete(v164);
LevelEditorLayer::createObjectsFromSetup(v5, &v5->m_levelString);
GJBaseGameLayer::createTextLayers(v5);
GJBaseGameLayer::increaseBatchNodeCapacity(v5);
m_levelSettings = v5->m_levelSettings;
if ( !m_levelSettings )
{
v125 = (char *)operator new(0x1D0u);
cocos2d::CCNode::CCNode(v125);
*(_QWORD *)v125 = off_1008C0F30;
*((_QWORD *)v125 + 40) = 0;
*((_DWORD *)v125 + 84) = 0;
*((_WORD *)v125 + 170) = 0;
*((_DWORD *)v125 + 86) = 0;
*(_DWORD *)(v125 + 347) = 0;
*((_OWORD *)v125 + 22) = 0;
*(_OWORD *)(v125 + 364) = 0;
*((_OWORD *)v125 + 24) = 0;
*((_OWORD *)v125 + 25) = 0;
v125[416] = 0;
*(_QWORD *)(v125 + 420) = 0;
*(_DWORD *)(v125 + 427) = 0;
*((_QWORD *)v125 + 54) = 0;
v125[440] = 0;
*(_OWORD *)(v125 + 444) = 0;
v125[460] = 0;
if ( !LevelSettingsObject::init((LevelSettingsObject *)v125) )
sub_1007CB960(v125);
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v125);
v5->m_levelSettings = (LevelSettingsObject *)v125;
*((_QWORD *)v125 + 48) = v5->m_level;
cocos2d::CCObject::retain((cocos2d::CCObject *)v125);
GJBaseGameLayer::loadLevelSettings(v5);
m_levelSettings = v5->m_levelSettings;
}
ColorAction = GJEffectManager::getColorAction(m_levelSettings->m_effectManager, 1005);
ColorAction->m_duration = 0.0;
m_player1 = v5->m_player1;
v128 = *(_WORD *)&m_player1->m_playerColor1.r;
ColorAction->m_fromColor.b = m_player1->m_playerColor1.b;
*(_WORD *)&ColorAction->m_fromColor.r = v128;
ColorAction->m_blending = 1;
v129 = GJEffectManager::getColorAction(v5->m_levelSettings->GJBaseGameLayer::m_effectManager, 1006);
v129->m_duration = 0.0;
v130 = v5->m_player1;
v131 = *(_WORD *)&v130->m_playerColor2.r;
v129->m_fromColor.b = v130->m_playerColor2.b;
*(_WORD *)&v129->m_fromColor.r = v131;
v129->m_blending = 1;
if ( !v165 )
{
v132 = EditorUI::create(v5);
v5->m_editorUI = v132;
((void (__fastcall *)(LevelEditorLayer *, EditorUI *, __int64))v5->addChild_0)(v5, v132, 100);
}
GJBaseGameLayer::createGroundLayer(v5, v5->m_levelSettings->m_groundIndex, v5->m_levelSettings->m_groundLineIndex);
v5->m_spawnOrderObjectsChanged = 1;
GJBaseGameLayer::createBackground(v5, v5->m_levelSettings->m_backgroundIndex);
GJBaseGameLayer::createMiddleground(v5, v5->m_levelSettings->m_middleGroundIndex);
sub_10028CC60(&v173);
if ( *(float *)&v173.__r_.__value_.__l.0 != *(float *)&dword_10099EF78
|| (p_m_lastCameraPos = (std::string *)&v5->m_level->m_lastCameraPos,
sub_10028CC60(&v163),
*((float *)&v163 + 1) != *(float *)&dword_10099EF7C) )
{
v134 = v5->m_objectLayer;
v135 = sub_10028CC60(&v173);
p_m_lastCameraPos = &v173;
((void (__fastcall *)(cocos2d::CCLayer *, std::string *, double))v134->setPosition)(v134, &v173, v135);
m_editorUI = v5->m_editorUI;
if ( m_editorUI )
EditorUI::updateSlider(m_editorUI);
}
if ( v5->m_level->m_lastEditorZoom != 0.0 )
{
((void (__fastcall *)(cocos2d::CCLayer *, std::string *))v5->m_objectLayer->setScale)(
v5->m_objectLayer,
p_m_lastCameraPos);
v137 = v5->m_editorUI;
if ( v137 )
EditorUI::updateSlider(v137);
}
m_objects = v5->m_objects;
if ( m_objects )
{
v139 = m_objects->data;
if ( v139->num )
{
arr = (LabelGameObject **)v139->arr;
v141 = (unsigned __int64)&arr[v139->num - 1];
do
{
v142 = *arr;
if ( !*arr )
break;
if ( v142->m_objectID == 1615 )
GJBaseGameLayer::addObjectCounter(v172, v142);
++arr;
}
while ( (unsigned __int64)arr <= v141 );
}
}
v143 = v172;
GJBaseGameLayer::resetGroupCounters(v172, 0);
GJBaseGameLayer::sortStickyGroups(v143);
((void (__fastcall *)(LevelEditorLayer *))v143->levelSettingsUpdated)(v143);
m_batchNodes = v143->m_batchNodes;
if ( m_batchNodes )
{
v145 = m_batchNodes->data;
num = v145->num;
if ( v145->num )
{
v147 = (unsigned __int64)v145->arr;
v148 = v147 + 8 * num - 8;
do
{
if ( !*(_QWORD *)v147 )
break;
*(_BYTE *)(*(_QWORD *)v147 + 352LL) = 1;
v147 += 8LL;
}
while ( v147 <= v148 );
}
}
cocos2d::CCNode::schedule_2(v143, (cocos2d::SEL_SCHEDULE)(unsigned __int64)LevelEditorLayer::updateEditor);
v143->m_previewMode = 1;
LevelEditorLayer::updateGameObjects(v143);
LevelEditorLayer::updateEditorMode(v143);
GJBaseGameLayer::refreshKeyframeAnims(v143);
v149 = v143->m_objects;
if ( v149 )
{
v150 = v149->data;
if ( v150->num )
{
v151 = v150->arr;
v152 = (unsigned __int64)&v151[v150->num - 1];
do
{
v153 = *v151;
if ( !*v151 )
break;
if ( ((unsigned __int8 (__fastcall *)(cocos2d::CCObject *))v153->__vftable[21].acceptVisitor)(*v151) )
((void (__fastcall *)(cocos2d::CCObject *, __int64))v153->__vftable[23].copyWithZone)(v153, 1);
++v151;
}
while ( (unsigned __int64)v151 <= v152 );
}
}
v154 = v172;
v172->m_initializing = 0;
v155 = GameManager::sharedState();
v156 = GameManager::getGameVariable(v155, "0037");
v154->m_hideGround = !v156;
((void (__fastcall *)(GJGroundLayer *, bool))v154->m_groundLayer->setVisible)(v154->m_groundLayer, v156);
v154->m_loadingProgress = 1.0;
v6 = v174;
if ( (__dst & 1) != 0 )
operator delete(v170);
if ( (v167 & 1) != 0 )
operator delete(longStorage);
return v6;
}