//
// GJBaseGameLayer::preUpdateVisibility from 0x140236200 to 0x14023742d (4653 bytes)
//
// 3 xrefs:
// > LevelEditorLayer::updateVisibility @ 0x1402d8f51
// > PlayLayer::updateVisibility @ 0x1403af41f
// > ??> @ 0x1406ce0e8
//
// 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=1
void GJBaseGameLayer::preUpdateVisibility(GJBaseGameLayer *a1, float a2)
{
cocos2d::CCDirector *v3; // rax
__int64 v4; // r8
float m_cameraZoom; // xmm14_4
double v6; // xmm0_8
const cocos2d::CCPoint *v7; // rax
float v8; // xmm2_4
float v9; // xmm3_4
float v10; // xmm1_4
float m_cameraAngle; // xmm0_4
float v12; // xmm2_4
float v13; // xmm0_4
float v14; // xmm1_4
float v15; // xmm6_4
cocos2d::CCPoint v16; // rax
float v17; // xmm6_4
cocos2d::CCPoint v18; // rax
float *p_m_cameraAngle; // rax
bool v20; // cl
GJGroundLayer *m_groundLayer; // rdx
double v22; // xmm0_8
double v23; // xmm0_8
float v24; // xmm2_4
float v25; // xmm3_4
float MaxX; // xmm12_4
float MinX; // xmm11_4
float MaxY; // xmm10_4
float MinY; // xmm9_4
float m_sectionXFactor; // xmm8_4
float v31; // xmm0_4
float v32; // xmm0_4
int v33; // r13d
float m_sectionYFactor; // xmm8_4
float v35; // xmm0_4
int v36; // edi
float v37; // xmm0_4
int v38; // ebx
ColorActionSprite *ColorSprite; // rax
char b; // al
__int64 v41; // rcx
cocos2d::CCDirector *v42; // rax
std::_Vector_val *, std::allocator *>> *>>::pointer Myfirst; // rax
__int64 v44; // r9
__int64 m_leftSectionIndex; // r15
__int64 v46; // r14
__int64 v47; // rdi
_QWORD *p_Myfirst; // rdx
__int64 v49; // rcx
int m_bottomSectionIndex; // ebx
__int64 v51; // r11
std::_Simple_types *, std::allocator *>> *>::value_type *v52; // r8
_QWORD *v53; // r9
__int64 v54; // rdx
__int64 v55; // r10
__int64 v56; // rdx
__int64 v57; // rcx
__int64 v58; // r12
int v59; // eax
unsigned __int8 *p_m_unk35C; // r8
__int64 v61; // r11
__int64 v62; // r10
bool v63; // r9
std::_Simple_types *, std::allocator *>> *>::value_type v64; // rcx
__int64 v65; // r13
__int64 v66; // rax
bool v67; // dl
std::_Simple_types *>::value_type v68; // r12
__int64 v69; // r15
__int64 v70; // r14
std::_Simple_types::value_type v71; // rbx
__int64 v72; // rcx
std::_Vector_val>::pointer v73; // rdx
cocos2d::CCRect *v74; // rdi
__int64 v75; // rcx
std::_Vector_val>::pointer v76; // rdx
std::_Simple_types::value_type v77; // rbx
cocos2d::CCRect *v78; // rdi
__int64 m_activeObjectsCount; // rcx
std::_Vector_val>::pointer Mylast; // rdx
cocos2d::CCArray *m_uiObjects; // rax
cocos2d::ccArray *data; // r14
__int64 num; // rax
GameObject **arr; // r14
GameObject **i; // r15
GameObject *v86; // rbx
cocos2d::CCRect *v87; // rdi
float v88; // xmm0_4
float v89; // xmm0_4
__int64 v90; // rcx
float *v91; // r12
float *j; // rbx
__int64 v93; // rax
GameObject **v94; // r15
GameObject **k; // r14
GameObject *v96; // rdi
__int64 v97; // rcx
__int64 m_visibleObjectsCount; // rcx
int v99; // ebx
__int64 v100; // rdi
std::_Simple_types::value_type v101; // rcx
int v102; // r14d
int v103; // ecx
__int64 v104; // rdi
std::_Vector_val>::pointer v105; // rax
__int64 v106; // r13
std::_Simple_types *, std::allocator *>> *>::value_type v107; // rcx
__int64 v108; // rax
int v109; // r12d
__int64 v110; // rdi
std::_Simple_types *>::value_type v111; // r14
__int64 v112; // rbx
__int64 v113; // r15
cocos2d::CCArray *v114; // rax
cocos2d::ccArray *v115; // rbx
__int64 v116; // rax
cocos2d::CCObject **v117; // rbx
cocos2d::CCObject **m; // rdi
cocos2d::CCDictionary **p_m_objectsToDeactivate; // rax
cocos2d::CCDictionary *m_objectsToDeactivate; // rcx
int v121; // r14d
int v122; // r15d
cocos2d::CCDictElement *m_pElements; // rcx
cocos2d::CCDictElement *n; // rbx
cocos2d::CCObject *m_pObject; // rcx
int m_nTag; // eax
int m_uReference; // eax
cocos2d::CCNode *v128; // rcx
cocos2d::CCArray *m_batchNodes; // rax
cocos2d::ccArray *v130; // rbx
__int64 v131; // rax
cocos2d::CCNode **v132; // rbx
cocos2d::CCNode **ii; // rdi
cocos2d::CCParticleSystemQuad *m_glitterParticles; // rbx
cocos2d::CCParticleSystemQuad_vtbl *v135; // rdi
cocos2d::CCDirector *v136; // rax
__int64 v137; // rcx
cocos2d::CCDirector *v138; // rax
float v139; // xmm0_4
__int64 v140; // rax
__int64 v141; // rax
int v142; // [rsp+38h] [rbp-D0h]
int v143; // [rsp+3Ch] [rbp-CCh]
cocos2d::CCRect v144; // [rsp+40h] [rbp-C8h] BYREF
float v145; // [rsp+50h] [rbp-B8h]
float v146; // [rsp+54h] [rbp-B4h]
cocos2d::CCPoint v147; // [rsp+58h] [rbp-B0h] BYREF
std::_Simple_types::value_type v148; // [rsp+60h] [rbp-A8h] BYREF
unsigned __int64 v149; // [rsp+68h] [rbp-A0h] BYREF
float v150; // [rsp+70h] [rbp-98h]
float v151; // [rsp+74h] [rbp-94h]
__int64 v152; // [rsp+78h] [rbp-90h]
__int64 v153; // [rsp+80h] [rbp-88h] BYREF
float v154; // [rsp+8Ch] [rbp-7Ch]
__int64 v155; // [rsp+90h] [rbp-78h]
__int64 v156; // [rsp+98h] [rbp-70h]
__int64 v157; // [rsp+A0h] [rbp-68h]
_BYTE v158[16]; // [rsp+A8h] [rbp-60h] BYREF
char v159[8]; // [rsp+B8h] [rbp-50h] BYREF
float *v160; // [rsp+C0h] [rbp-48h] BYREF
char v161[40]; // [rsp+D0h] [rbp-38h] BYREF
char v162[16]; // [rsp+F8h] [rbp-10h] BYREF
char v163[184]; // [rsp+108h] [rbp+0h] BYREF
unsigned __int8 *v164; // [rsp+208h] [rbp+100h] BYREF
float v165; // [rsp+210h] [rbp+108h] BYREF
int v166; // [rsp+218h] [rbp+110h] BYREF
int v167; // [rsp+220h] [rbp+118h]
v165 = a2;
v3 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(a1);
cocos2d::CCDirector::getWinSize(v3);
v165 = 0.0;
sub_14005E660((__int64)v159, &v165, v4);
cocos2d::CCPoint::CCPoint(&v147);
m_cameraZoom = a1->m_gameState.m_cameraZoom;
if ( a1->m_isEditor && !a1->m_started )
{
v6 = ((double (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getScale)(a1->m_objectLayer);
m_cameraZoom = *(float *)&v6;
v7 = a1->m_objectLayer->getPosition_0(a1->m_objectLayer);
cocos2d::CCPoint::operator-(v7, &v164);
cocos2d::CCPoint::operator*(&v164, &v166);
cocos2d::CCPoint::operator=(&v147, &v166);
if ( a1->m_gameState.m_cameraShakeEnabled )
{
cocos2d::CCPoint::operator-(&v147, &v164, &a1->m_gameState.m_unkPoint34);
cocos2d::CCPoint::operator=(&v147, &v164);
}
}
v8 = v145;
v9 = v145 / m_cameraZoom;
a1->m_cameraWidth = v145 / m_cameraZoom;
v10 = v146 / m_cameraZoom;
a1->m_cameraHeight = v146 / m_cameraZoom;
a1->m_halfCameraWidth = v9 * 0.5;
a1->m_cameraUnzoomedX = (float)(v8 * 0.5) + a1->m_gameState.m_cameraPosition2.x;
a1->m_activeObjectsCount = 0;
cocos2d::CCRect::CCRect(&v144, v147.x, v147.y, v9, v10);
m_cameraAngle = a1->m_gameState.m_cameraAngle;
if ( m_cameraAngle == 0.0 )
{
a1->m_targetCameraHeightOffset = 0.0;
v12 = 0.0;
v13 = 0.0;
v14 = 0.0;
}
else
{
if ( a1->m_calculateTargetHeightOffset )
{
v15 = a1->m_gameState.m_targetCameraAngle * 0.017453292;
cocos2d::CCPoint::CCPoint(m_cameraAngle, v145 * 0.5);
OBB2D::calculateWithCenter(a1->m_cameraObb2, v16, v144.size.width, v144.size.height, v15);
OBB2D::getBoundingRect((cocos2d::CCRect *)a1->m_cameraObb2, (OBB2D *)&v153);
m_cameraAngle = v154 - v144.size.height;
a1->m_targetCameraHeightOffset = v154 - v144.size.height;
a1->m_calculateTargetHeightOffset = 0;
}
v17 = a1->m_gameState.m_cameraAngle * 0.017453292;
cocos2d::CCPoint::CCPoint(m_cameraAngle, v145 * 0.5);
OBB2D::calculateWithCenter(a1->m_cameraObb2, v18, v144.size.width, v144.size.height, v17);
OBB2D::getBoundingRect((cocos2d::CCRect *)a1->m_cameraObb2, (OBB2D *)&v149);
v14 = v151 - v144.size.height;
v12 = (float)(v151 - v144.size.height) * m_cameraZoom;
v13 = (float)(v150 - v144.size.width) * m_cameraZoom;
}
p_m_cameraAngle = &a1->m_gameState.m_cameraAngle;
a1->m_cameraUnzoomedHeightOffset = v14;
a1->m_cameraWidthOffset = v13;
a1->m_cameraHeightOffset = v12;
v20 = a1->m_gameState.m_cameraAngle != 0.0;
m_groundLayer = a1->m_groundLayer;
if ( v20 != m_groundLayer->m_cameraRotated )
{
m_groundLayer->m_cameraRotated = v20;
a1->m_groundLayer2->m_cameraRotated = v20;
v22 = ((double (__fastcall *)(GJGroundLayer *))a1->m_groundLayer->getScaleX)(a1->m_groundLayer);
GJGroundLayer::scaleGround(a1->m_groundLayer, *(float *)&v22);
v23 = ((double (__fastcall *)(GJGroundLayer *))a1->m_groundLayer2->getScaleX)(a1->m_groundLayer2);
GJGroundLayer::scaleGround(a1->m_groundLayer2, *(float *)&v23);
p_m_cameraAngle = &a1->m_gameState.m_cameraAngle;
}
if ( *p_m_cameraAngle == 0.0 || a1->m_cameraWidthOffset == 0.0 )
{
if ( a1->m_updateGroundShadows )
{
GJGroundLayer::updateShadowXPos(a1->m_groundLayer, 0.0, 0.0);
GJGroundLayer::updateShadows(a1->m_groundLayer);
GJGroundLayer::updateShadowXPos(a1->m_groundLayer2, 0.0, 0.0);
GJGroundLayer::updateShadows(a1->m_groundLayer2);
a1->m_updateGroundShadows = 0;
}
}
else
{
GJBaseGameLayer::updateGroundShadows(a1);
v24 = a1->m_cameraWidthOffset / m_cameraZoom;
v25 = a1->m_cameraHeightOffset / m_cameraZoom;
v144.origin.x = v144.origin.x - (float)(v24 * 0.5);
v144.origin.y = v144.origin.y - (float)(v25 * 0.5);
v144.size.width = v144.size.width + v24;
v144.size.height = v144.size.height + v25;
a1->m_updateGroundShadows = 1;
}
MaxX = cocos2d::CCRect::getMaxX(&v144);
MinX = cocos2d::CCRect::getMinX(&v144);
MaxY = cocos2d::CCRect::getMaxY(&v144);
MinY = cocos2d::CCRect::getMinY(&v144);
m_sectionXFactor = a1->m_sectionXFactor;
v31 = floorf(fminf(MinX, 10000000.0) * m_sectionXFactor) - 1.0;
if ( v31 < 0.0 )
v31 = 0.0;
v142 = (int)v31;
v32 = ceilf(fminf(MaxX, 10000000.0) * m_sectionXFactor) + 1.0;
if ( v32 < 0.0 )
v32 = 0.0;
v33 = (int)v32;
v143 = (int)v32;
m_sectionYFactor = a1->m_sectionYFactor;
v35 = floorf(fminf(MinY, 10000000.0) * m_sectionYFactor) - 1.0;
if ( v35 < 0.0 )
v35 = 0.0;
v36 = (int)v35;
v167 = (int)v35;
v37 = ceilf(fminf(MaxY, 10000000.0) * m_sectionYFactor) + 1.0;
if ( v37 < 0.0 )
v37 = 0.0;
v38 = (int)v37;
v166 = (int)v37;
GJEffectManager::getColorSprite(a1->m_effectManager, 1007);
ColorSprite = GJEffectManager::getColorSprite(a1->m_effectManager, 1000);
if ( ColorSprite )
{
LOWORD(v165) = *(_WORD *)&ColorSprite->m_copyColor.r;
b = ColorSprite->m_copyColor.b;
}
else
{
LOWORD(v165) = -1;
b = -1;
}
BYTE2(v165) = b;
LOWORD(v154) = 257;
v149 = 0xBE4CCCCD00000000uLL;
v150 = 0.2;
v151 = v154;
GameToolbox::transformColor(
(cocos2d::ccColor3B *)&v164,
(const cocos2d::ccColor3B *)&v165,
(cocos2d::ccHSVValue *)&v149);
*(_WORD *)&a1->m_lightBGColor.r = (_WORD)v164;
a1->m_lightBGColor.b = BYTE2(v164);
v42 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v41);
cocos2d::CCDirector::getScreenRight(v42);
Myfirst = a1->m_sections._Mypair._Myval2._Myfirst;
v44 = a1->m_sections._Mypair._Myval2._Mylast - Myfirst;
v156 = v44;
m_leftSectionIndex = a1->m_leftSectionIndex;
v46 = (int)v44;
v152 = (int)v44;
if ( (int)m_leftSectionIndex <= a1->m_rightSectionIndex )
{
v47 = m_leftSectionIndex;
do
{
if ( v47 >= v46 )
break;
p_Myfirst = &Myfirst[v47]->_Mypair._Myval2._Myfirst;
if ( p_Myfirst )
v49 = (__int64)(p_Myfirst[1] - *p_Myfirst) >> 3;
else
LODWORD(v49) = -1;
m_bottomSectionIndex = a1->m_bottomSectionIndex;
if ( m_bottomSectionIndex <= a1->m_topSectionIndex )
{
v51 = a1->m_bottomSectionIndex;
v52 = Myfirst;
do
{
Myfirst = v52;
if ( v51 >= (int)v49 )
break;
v53 = &v52[v47]->_Mypair._Myval2._Myfirst[v51]->_Mypair._Myval2._Myfirst;
Myfirst = v52;
if ( v53 )
{
v54 = 0;
v55 = a1->m_sectionSizes._Mypair._Myval2._Myfirst[v47]->_Mypair._Myval2._Myfirst[v51];
Myfirst = v52;
if ( v55 > 0 )
{
do
*(_BYTE *)(*(_QWORD *)(*v53 + 8 * v54++) + 1006LL) = 1;
while ( v54 < v55 );
Myfirst = a1->m_sections._Mypair._Myval2._Myfirst;
}
}
++m_bottomSectionIndex;
++v51;
v52 = Myfirst;
}
while ( m_bottomSectionIndex <= a1->m_topSectionIndex );
v46 = v152;
}
LODWORD(m_leftSectionIndex) = m_leftSectionIndex + 1;
++v47;
}
while ( (int)m_leftSectionIndex <= a1->m_rightSectionIndex );
v44 = v156;
v38 = v166;
v36 = v167;
}
v56 = 0;
if ( a1->m_visibleObjects2Count > 0 )
{
v57 = 0;
do
{
a1->m_visibleObjects2._Mypair._Myval2._Myfirst[v57]->m_unk3ee = 1;
v56 = (unsigned int)(v56 + 1);
++v57;
}
while ( (int)v56 < a1->m_visibleObjects2Count );
}
v58 = v38;
v59 = v142;
p_m_unk35C = (unsigned __int8 *)v142;
v164 = (unsigned __int8 *)v142;
v61 = v33;
v149 = v33;
if ( v142 <= (__int64)v33 )
{
v62 = v36;
v153 = v36;
do
{
if ( (__int64)p_m_unk35C >= v46 )
break;
v63 = (int)v44 <= v59 + 1 || (int)v44 >= v33 - 1;
LOBYTE(v165) = v63;
v64 = a1->m_sections._Mypair._Myval2._Myfirst[(_QWORD)p_m_unk35C];
if ( v64 )
v56 = v64->_Mypair._Myval2._Mylast - v64->_Mypair._Myval2._Myfirst;
else
v56 = 0xFFFFFFFFLL;
v155 = v56;
v65 = v62;
if ( v62 <= v58 )
{
v66 = (int)v56;
v157 = (int)v56;
do
{
if ( v65 >= v66 )
break;
v67 = v63 || (int)v56 <= v36 + 1 || (int)v56 >= v38 - 1;
v68 = a1->m_sections._Mypair._Myval2._Myfirst[(_QWORD)p_m_unk35C]->_Mypair._Myval2._Myfirst[v65];
if ( v68 )
{
v69 = a1->m_sectionSizes._Mypair._Myval2._Myfirst[(_QWORD)p_m_unk35C]->_Mypair._Myval2._Myfirst[v65];
v70 = 0;
if ( v67 )
{
if ( v69 > 0 )
{
do
{
v77 = v68->_Mypair._Myval2._Myfirst[v70];
if ( v77->m_isGroupDisabled
|| ((v78 = (cocos2d::CCRect *)v77->getObjectTextureRect(v68->_Mypair._Myval2._Myfirst[v70]),
cocos2d::CCRect::getMinX(v78) > MaxX)
|| MinX > cocos2d::CCRect::getMaxX(v78)
|| cocos2d::CCRect::getMinY(v78) > MaxY
|| MinY > cocos2d::CCRect::getMaxY(v78))
&& !v77->m_unk370 )
{
v77->m_unk3ee = 1;
}
else
{
v77->m_unk3ee = 0;
v148 = v77;
m_activeObjectsCount = a1->m_activeObjectsCount;
if ( a1->m_activeObjectsIndex > (int)m_activeObjectsCount )
{
a1->m_activeObjects._Mypair._Myval2._Myfirst[m_activeObjectsCount] = v77;
}
else
{
Mylast = a1->m_activeObjects._Mypair._Myval2._Mylast;
if ( Mylast == a1->m_activeObjects._Mypair._Myval2._Myend )
{
sub_14012D2A0((const void **)&a1->m_activeObjects._Mypair._Myval2._Myfirst, Mylast, &v148);
}
else
{
*Mylast = v77;
++a1->m_activeObjects._Mypair._Myval2._Mylast;
}
++a1->m_activeObjectsIndex;
}
++a1->m_activeObjectsCount;
if ( v77->m_unk35C > 0 )
sub_140060D70((__int64)v159, (__int64)v158, (unsigned __int8 *)&v77->m_unk35C);
}
++v70;
}
while ( v70 < v69 );
LABEL_112:
v36 = v167;
v38 = v166;
v63 = LOBYTE(v165);
p_m_unk35C = v164;
}
}
else if ( v69 > 0 )
{
while ( 1 )
{
v71 = v68->_Mypair._Myval2._Myfirst[v70];
if ( !v71->m_isGroupDisabled )
{
if ( v71->m_isActivated )
{
v71->m_unk3ee = 0;
v148 = v71;
v72 = a1->m_activeObjectsCount;
if ( a1->m_activeObjectsIndex > (int)v72 )
{
a1->m_activeObjects._Mypair._Myval2._Myfirst[v72] = v71;
}
else
{
v73 = a1->m_activeObjects._Mypair._Myval2._Mylast;
if ( v73 == a1->m_activeObjects._Mypair._Myval2._Myend )
{
sub_14012D2A0((const void **)&a1->m_activeObjects._Mypair._Myval2._Myfirst, v73, &v148);
}
else
{
*v73 = v71;
++a1->m_activeObjects._Mypair._Myval2._Mylast;
}
++a1->m_activeObjectsIndex;
}
++a1->m_activeObjectsCount;
if ( v71->m_unk35C > 0 )
sub_140060D70((__int64)v159, (__int64)v162, (unsigned __int8 *)&v71->m_unk35C);
goto LABEL_93;
}
v74 = (cocos2d::CCRect *)v71->getObjectTextureRect(v68->_Mypair._Myval2._Myfirst[v70]);
if ( cocos2d::CCRect::getMinX(v74) <= MaxX
&& MinX <= cocos2d::CCRect::getMaxX(v74)
&& cocos2d::CCRect::getMinY(v74) <= MaxY
&& MinY <= cocos2d::CCRect::getMaxY(v74)
|| v71->m_unk370 )
{
v71->m_unk3ee = 0;
v148 = v71;
v75 = a1->m_activeObjectsCount;
if ( a1->m_activeObjectsIndex > (int)v75 )
{
a1->m_activeObjects._Mypair._Myval2._Myfirst[v75] = v71;
}
else
{
v76 = a1->m_activeObjects._Mypair._Myval2._Mylast;
if ( v76 == a1->m_activeObjects._Mypair._Myval2._Myend )
{
sub_14012D2A0((const void **)&a1->m_activeObjects._Mypair._Myval2._Myfirst, v76, &v148);
}
else
{
*v76 = v71;
++a1->m_activeObjects._Mypair._Myval2._Mylast;
}
++a1->m_activeObjectsIndex;
}
++a1->m_activeObjectsCount;
if ( v71->m_unk35C > 0 )
sub_140060D70((__int64)v159, (__int64)v163, (unsigned __int8 *)&v71->m_unk35C);
goto LABEL_93;
}
}
v71->m_unk3ee = 1;
LABEL_93:
if ( ++v70 >= v69 )
goto LABEL_112;
}
}
}
++v65;
v58 = v38;
v56 = v155;
v66 = v157;
}
while ( v65 <= v38 );
v62 = v153;
v61 = v149;
v46 = v152;
}
v164 = ++p_m_unk35C;
v44 = v156;
v33 = v143;
v59 = v142;
}
while ( (__int64)p_m_unk35C <= v61 );
}
m_uiObjects = a1->m_uiObjects;
if ( m_uiObjects )
{
data = m_uiObjects->data;
num = data->num;
if ( (_DWORD)num )
{
arr = (GameObject **)data->arr;
for ( i = &arr[num - 1]; arr <= i; ++arr )
{
v86 = *arr;
if ( !*arr )
break;
if ( v86->m_isGroupDisabled
|| ((v87 = (cocos2d::CCRect *)((__int64 (__fastcall *)(GameObject *, __int64, unsigned __int8 *, __int64))v86->getObjectTextureRect)(
*arr,
v56,
p_m_unk35C,
v44),
v88 = cocos2d::CCRect::getMinX(v87),
v88 > v145)
|| cocos2d::CCRect::getMaxX(v87) < 0.0
|| (v89 = cocos2d::CCRect::getMinY(v87), v89 > v146)
|| cocos2d::CCRect::getMaxY(v87) < 0.0)
&& !v86->m_unk370 )
{
v86->m_unk3ee = 1;
}
else
{
v86->m_unk3ee = 0;
v164 = (unsigned __int8 *)v86;
v90 = a1->m_activeObjectsCount;
if ( a1->m_activeObjectsIndex > (int)v90 )
{
a1->m_activeObjects._Mypair._Myval2._Myfirst[v90] = v86;
}
else
{
v56 = (__int64)a1->m_activeObjects._Mypair._Myval2._Mylast;
if ( (std::_Vector_val>::pointer)v56 == a1->m_activeObjects._Mypair._Myval2._Myend )
{
sub_14012D2A0((const void **)&a1->m_activeObjects._Mypair._Myval2._Myfirst, (_BYTE *)v56, &v164);
}
else
{
*(_QWORD *)v56 = v86;
++a1->m_activeObjects._Mypair._Myval2._Mylast;
}
++a1->m_activeObjectsIndex;
}
++a1->m_activeObjectsCount;
p_m_unk35C = (unsigned __int8 *)&v86->m_unk35C;
if ( v86->m_unk35C > 0 )
sub_140060D70((__int64)v159, (__int64)v158, p_m_unk35C);
}
}
}
}
a1->m_visibleObjectsCount = 0;
v91 = v160;
for ( j = *(float **)v160; j != v91; j = *(float **)j )
{
v165 = j[4];
v93 = sub_14024F020(&a1->m_visibilityGroups, v158, &v165);
v94 = *(GameObject ***)(*(_QWORD *)v93 + 32LL);
for ( k = *(GameObject ***)(*(_QWORD *)v93 + 24LL); k != v94; ++k )
{
v96 = *k;
if ( (!(*k)->m_isActivated || v96->m_unk3ee) && !v96->m_isGroupDisabled )
{
v96->m_unk3ee = 0;
v164 = (unsigned __int8 *)v96;
v97 = a1->m_activeObjectsCount;
if ( a1->m_activeObjectsIndex > (int)v97 )
{
a1->m_activeObjects._Mypair._Myval2._Myfirst[v97] = v96;
}
else
{
v56 = (__int64)a1->m_activeObjects._Mypair._Myval2._Mylast;
if ( (std::_Vector_val>::pointer)v56 == a1->m_activeObjects._Mypair._Myval2._Myend )
{
sub_14012D2A0((const void **)&a1->m_activeObjects._Mypair._Myval2._Myfirst, (_BYTE *)v56, &v164);
}
else
{
*(_QWORD *)v56 = v96;
++a1->m_activeObjects._Mypair._Myval2._Mylast;
}
++a1->m_activeObjectsIndex;
}
++a1->m_activeObjectsCount;
v164 = (unsigned __int8 *)v96;
m_visibleObjectsCount = a1->m_visibleObjectsCount;
if ( a1->m_visibleObjectsIndex > (int)m_visibleObjectsCount )
{
a1->m_visibleObjects._Mypair._Myval2._Myfirst[m_visibleObjectsCount] = v96;
}
else
{
v56 = (__int64)a1->m_visibleObjects._Mypair._Myval2._Mylast;
if ( (std::_Vector_val>::pointer)v56 == a1->m_visibleObjects._Mypair._Myval2._Myend )
{
sub_14012D2A0((const void **)&a1->m_visibleObjects._Mypair._Myval2._Myfirst, (_BYTE *)v56, &v164);
}
else
{
*(_QWORD *)v56 = v96;
++a1->m_visibleObjects._Mypair._Myval2._Mylast;
}
++a1->m_visibleObjectsIndex;
}
++a1->m_visibleObjectsCount;
}
}
}
v99 = 0;
if ( a1->m_visibleObjects2Count > 0 )
{
v100 = 0;
do
{
v101 = a1->m_visibleObjects2._Mypair._Myval2._Myfirst[v100];
if ( v101->m_unk3ee )
((void (__fastcall *)(std::_Simple_types::value_type, _QWORD, unsigned __int8 *, __int64))v101->deactivateObject)(
v101,
0,
p_m_unk35C,
v44);
++v99;
++v100;
}
while ( v99 < a1->m_visibleObjects2Count );
}
a1->m_visibleObjects2Count = 0;
v102 = 0;
if ( a1->m_visibleObjectsCount > 0 )
{
v103 = 0;
v104 = 0;
do
{
v56 = (__int64)a1->m_visibleObjects._Mypair._Myval2._Myfirst[v104];
v164 = (unsigned __int8 *)v56;
if ( a1->m_visibleObjects2Index > v103 )
{
a1->m_visibleObjects2._Mypair._Myval2._Myfirst[v103] = (std::_Simple_types::value_type)v56;
}
else
{
v105 = a1->m_visibleObjects2._Mypair._Myval2._Mylast;
if ( v105 == a1->m_visibleObjects2._Mypair._Myval2._Myend )
{
sub_14012D2A0(
(const void **)&a1->m_visibleObjects2._Mypair._Myval2._Myfirst,
(_BYTE *)a1->m_visibleObjects2._Mypair._Myval2._Mylast,
&v164);
}
else
{
*v105 = (std::_Simple_types::value_type)v56;
++a1->m_visibleObjects2._Mypair._Myval2._Mylast;
}
++a1->m_visibleObjects2Index;
}
v103 = ++a1->m_visibleObjects2Count;
++v102;
++v104;
}
while ( v102 < a1->m_visibleObjectsCount );
}
if ( !a1->m_objectsDeactivated )
{
v56 = a1->m_leftSectionIndex;
v165 = *(float *)&v56;
if ( (int)v56 <= a1->m_rightSectionIndex )
{
v106 = v56;
do
{
if ( v106 >= v152 )
break;
v107 = a1->m_sections._Mypair._Myval2._Myfirst[v106];
if ( v107 )
v108 = v107->_Mypair._Myval2._Mylast - v107->_Mypair._Myval2._Myfirst;
else
LODWORD(v108) = -1;
v109 = a1->m_bottomSectionIndex;
if ( v109 <= a1->m_topSectionIndex )
{
v110 = a1->m_bottomSectionIndex;
v108 = (int)v108;
v164 = (unsigned __int8 *)(int)v108;
do
{
if ( v110 >= v108 )
break;
v111 = a1->m_sections._Mypair._Myval2._Myfirst[v106]->_Mypair._Myval2._Myfirst[v110];
if ( v111 )
{
v112 = 0;
v113 = a1->m_sectionSizes._Mypair._Myval2._Myfirst[v106]->_Mypair._Myval2._Myfirst[v110];
if ( v113 > 0 )
{
do
{
((void (__fastcall *)(std::_Simple_types::value_type, _QWORD, unsigned __int8 *, __int64))v111->_Mypair._Myval2._Myfirst[v112]->deactivateObject)(
v111->_Mypair._Myval2._Myfirst[v112],
0,
p_m_unk35C,
v44);
++v112;
}
while ( v112 < v113 );
}
}
++v109;
++v110;
v108 = (__int64)v164;
}
while ( v109 <= a1->m_topSectionIndex );
*(float *)&v56 = v165;
}
v56 = (unsigned int)(v56 + 1);
v165 = *(float *)&v56;
++v106;
}
while ( (int)v56 <= a1->m_rightSectionIndex );
}
}
v114 = a1->m_uiObjects;
if ( v114 )
{
v115 = v114->data;
v116 = v115->num;
if ( (_DWORD)v116 )
{
v117 = v115->arr;
for ( m = &v117[v116 - 1]; v117 <= m; ++v117 )
{
if ( !*v117 )
break;
((void (__fastcall *)(cocos2d::CCObject *, _QWORD, unsigned __int8 *, __int64))(*v117)->__vftable[15].setTag)(
*v117,
0,
p_m_unk35C,
v44);
}
}
}
p_m_objectsToDeactivate = &a1->m_objectsToDeactivate;
m_objectsToDeactivate = a1->m_objectsToDeactivate;
v121 = v166;
v122 = v167;
if ( m_objectsToDeactivate )
{
m_pElements = m_objectsToDeactivate->m_pElements;
if ( m_pElements )
{
for ( n = (cocos2d::CCDictElement *)m_pElements->hh.next; ; n = (cocos2d::CCDictElement *)n->hh.next )
{
m_pObject = m_pElements->m_pObject;
m_nTag = m_pObject[11].m_nTag;
if ( m_nTag < v142
|| m_nTag > v143
|| (m_uReference = m_pObject[11].m_uReference, m_uReference < v122)
|| m_uReference > v121 )
{
LOBYTE(v56) = 1;
((void (__fastcall *)(cocos2d::CCObject *, __int64, unsigned __int8 *, __int64))m_pObject->__vftable[15].setTag)(
m_pObject,
v56,
p_m_unk35C,
v44);
}
m_pElements = n;
if ( !n )
break;
}
p_m_objectsToDeactivate = &a1->m_objectsToDeactivate;
}
}
cocos2d::CCDictionary::removeAllObjects(*p_m_objectsToDeactivate);
m_batchNodes = a1->m_batchNodes;
if ( m_batchNodes )
{
v130 = m_batchNodes->data;
v131 = v130->num;
if ( (_DWORD)v131 )
{
v132 = (cocos2d::CCNode **)v130->arr;
for ( ii = &v132[v131 - 1]; v132 <= ii; ++v132 )
{
v128 = *v132;
if ( !*v132 )
break;
cocos2d::CCNode::updateChildIndexes(v128);
}
}
}
if ( a1->m_glitterParticles )
{
m_glitterParticles = a1->m_glitterParticles;
v135 = m_glitterParticles->cocos2d::CCParticleSystem::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v136 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v128);
cocos2d::CCDirector::getScreenScaleFactorH(v136);
v138 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v137);
v139 = (float)((float)(cocos2d::CCDirector::getScreenScaleFactorW(v138) * 480.0) / 1.8) / m_cameraZoom;
cocos2d::CCPoint::CCPoint(v139, v139);
v141 = cocos2d::CCPoint::operator/(v140, &v166);
v135->setPosVar(m_glitterParticles, (const cocos2d::CCPoint *)v141);
}
a1->m_objectsDeactivated = 0;
a1->m_leftSectionIndex = v142;
a1->m_rightSectionIndex = v143;
a1->m_bottomSectionIndex = v122;
a1->m_topSectionIndex = v121;
sub_14005D100((__int64)v161);
sub_14005D870((void **)&v160);
}