// // SecretRewardsLayer::generateChestItems from 0xba0e08 to 0xba1874 (2668 bytes) // // 2 xrefs: // > SecretRewardsLayer::createSecondaryLayer @ 0xba1b7c // > @ 0x51f28 // // This function is hookable on this platform (idp: arm, 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 13:02:47 +0000 // cocos2d::CCArray *__fastcall SecretRewardsLayer::generateChestItems(SecretRewardsLayer *this, unsigned int a2) { cocos2d::CCDirector *v3; // x0 GameStatsManager *v4; // x0 GJChestSprite *v5; // x0 unsigned int v6; // w1 int v7; // w23 int v8; // w0 int v9; // w1 unsigned __int64 v10; // x0 signed int i; // w26 __int64 v12; // x19 size_t v13; // x0 const char *v14; // x1 size_t v15; // x0 cocos2d::CCArray *v16; // x0 int v17; // w19 int v18; // w28 __int64 *v19; // x2 int v20; // w0 bool v21; // cc __int64 v22; // x0 int v23; // w0 __int64 **v24; // x28 __int64 v25; // x2 __int64 *v26; // x1 int v27; // w28 unsigned int v28; // w23 cocos2d::CCLayer *v29; // x0 cocos2d::CCObject *v30; // x25 int v31; // w20 __int64 v32; // x19 unsigned int v33; // w26 __int64 v34; // x0 GameStatsManager *v35; // x0 unsigned int *v36; // x24 __int64 *v37; // x19 cocos2d::CCArray *v38; // x1 size_t v39; // x2 void (__fastcall *v40)(__int64 *, __int64 ***); // x27 void (__fastcall *v41)(unsigned int *, __int64 ***); // x27 float v42; // s15 __int64 v43; // x0 int v44; // w24 int v45; // w23 unsigned int v46; // w4 cocos2d::CCNode *v47; // x0 int v48; // w2 void (__fastcall *v49)(__int64 *, __int64 ***); // x24 int v50; // w25 int v51; // w0 char *v52; // x1 __int64 v53; // x2 signed int v54; // w0 char *v55; // x3 char *v56; // x2 size_t v57; // x19 char *v58; // x19 cocos2d::CCMenu *v59; // x19 __int64 *v60; // x24 bool v61; // cc __int64 v62; // x0 __int64 **v63; // x19 __int64 *v64; // x1 __int64 *v65; // x19 char *v67; // x0 __int64 v68; // x19 GJChestSprite *v70; // [xsp+B8h] [xbp+B8h] cocos2d::CCArray *v71; // [xsp+C0h] [xbp+C0h] _BOOL4 isSecretChestUnlocked; // [xsp+D8h] [xbp+D8h] unsigned __int64 v74; // [xsp+E0h] [xbp+E0h] cocos2d::CCArray *v75; // [xsp+E8h] [xbp+E8h] cocos2d::CCArray *v76; // [xsp+E8h] [xbp+E8h] cocos2d::CCArray *v77; // [xsp+E8h] [xbp+E8h] cocos2d::CCArray *v78; // [xsp+E8h] [xbp+E8h] cocos2d::CCArray *v79; // [xsp+E8h] [xbp+E8h] int v80; // [xsp+F8h] [xbp+F8h] BYREF __int64 v81; // [xsp+100h] [xbp+100h] BYREF char v82[8]; // [xsp+108h] [xbp+108h] BYREF __int64 v83; // [xsp+110h] [xbp+110h] BYREF __int64 **v84; // [xsp+118h] [xbp+118h] BYREF __int64 **v85; // [xsp+120h] [xbp+120h] BYREF char *v86; // [xsp+128h] [xbp+128h] BYREF char *v87; // [xsp+130h] [xbp+130h] char *v88; // [xsp+138h] [xbp+138h] __int64 **v89; // [xsp+140h] [xbp+140h] BYREF __int64 *v90; // [xsp+148h] [xbp+148h] BYREF __int64 v91; // [xsp+150h] [xbp+150h] __int64 v92[2]; // [xsp+158h] [xbp+158h] BYREF char *v93; // [xsp+168h] [xbp+168h] __int64 v94[2]; // [xsp+170h] [xbp+170h] BYREF void *v95; // [xsp+180h] [xbp+180h] __int64 v96; // [xsp+188h] [xbp+188h] BYREF unsigned __int64 v97; // [xsp+190h] [xbp+190h] cocos2d::CCArray *v98; // [xsp+198h] [xbp+198h] _BYTE v99[504]; // [xsp+1A0h] [xbp+1A0h] BYREF v3 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(_stack_chk_guard); cocos2d::CCDirector::getWinSize(&v81, v3); v4 = (GameStatsManager *)cocos2d::CCPoint::CCPoint( (cocos2d::CCPoint *)v82, *(float *)&v81 * 0.5, (float)(*((float *)&v81 + 1) * 0.5) + 80.0); v5 = *(GJChestSprite **)(GameStatsManager::sharedState(v4) + 760); v6 = a2 - 3; v86 = nullptr; v87 = nullptr; v88 = nullptr; v90 = nullptr; v91 = 0; v89 = &v90; v70 = v5; if ( a2 - 3 > 5 ) { v10 = 1; v74 = 1; } else { v7 = dword_1194AA0[v6]; v8 = dword_1194AC0[v6]; v9 = v8 + 1; v10 = (unsigned int)(v7 + v8); v74 = __PAIR64__(v10, v9); if ( v9 <= (int)v10 ) { for ( i = v9; SHIDWORD(v74) >= i; ++i ) { v97 = 500; v96 = 0; v98 = (cocos2d::CCArray *)v99; LODWORD(v83) = i; v80 = i; fmt::BasicWriter::FormatInt,char>>((size_t *)&v96, i); v12 = v96; if ( v96 + 1 > v97 ) fmt::internal::Array::grow((size_t *)&v96, v96 + 1); *((_BYTE *)v98 + v12) = 0; v92[0] = 0; v92[1] = 0; v93 = nullptr; v75 = v98; v13 = strlen((const char *)v98); std::string::__init(v92, v75, v13); v14 = (char *)v92 + 1; if ( (v92[0] & 1) != 0 ) v14 = v93; v94[0] = 0; v94[1] = 0; v95 = nullptr; v76 = (cocos2d::CCArray *)v14; v15 = strlen(v14); std::string::__init(v94, v76, v15); v77 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v70, v94); if ( (v94[0] & 1) != 0 ) { operator delete(v95); v16 = v77; if ( v77 ) { LABEL_10: v17 = *((_DWORD *)v16 + 14); if ( v7 < v17 || v17 < 0 ) { v17 = 1; *((_DWORD *)v77 + 14) = 1; } LODWORD(v85) = v17; if ( std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::__count_unique( (__int64)&v89, (int *)&v85) ) { LODWORD(v85) = 1; if ( v7 > 0 ) { v18 = 1; while ( std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::__count_unique( (__int64)&v89, (int *)&v85) ) { LODWORD(v85) = ++v18; if ( v7 < v18 ) goto LABEL_18; } v17 = v18; *((_DWORD *)v77 + 14) = v18; } } LABEL_18: v19 = v90; if ( v90 ) { v20 = *((_DWORD *)v90 + 7); v21 = v17 <= v20; if ( v17 >= v20 ) goto LABEL_22; LABEL_20: v22 = *v19; if ( *v19 ) { do { v19 = (__int64 *)v22; v23 = *(_DWORD *)(v22 + 28); v21 = v17 <= v23; if ( v17 < v23 ) goto LABEL_20; LABEL_22: if ( v21 ) goto LABEL_29; v22 = v19[1]; } while ( v22 ); v24 = (__int64 **)(v19 + 1); v84 = (__int64 **)v19; } else { v24 = (__int64 **)v19; v84 = (__int64 **)v19; } } else { v24 = &v90; v84 = &v90; } v25 = operator new(0x28u); *(_DWORD *)(v25 + 28) = v17; *(_DWORD *)(v25 + 32) = 0; *(_QWORD *)(v25 + 16) = v84; *(_QWORD *)v25 = 0; *(_QWORD *)(v25 + 8) = 0; *v24 = (__int64 *)v25; if ( *v89 ) { v89 = (__int64 **)*v89; v26 = *v24; } else { v26 = (__int64 *)v25; } v78 = (cocos2d::CCArray *)v25; std::__tree_balance_after_insert *>(v90, v26); v19 = (__int64 *)v78; ++v91; LABEL_29: *((_DWORD *)v19 + 8) = v83; LABEL_30: if ( (v92[0] & 1) == 0 ) goto LABEL_31; goto LABEL_84; } } else { v16 = v77; if ( v77 ) goto LABEL_10; } v67 = v87; if ( v87 == v88 ) { std::vector::__push_back_slow_path((__int64)&v86, &v83); goto LABEL_30; } if ( v87 ) { *(_DWORD *)v87 = v83; v67 = v87; } v87 = v67 + 4; if ( (v92[0] & 1) == 0 ) goto LABEL_31; LABEL_84: operator delete(v93); LABEL_31: if ( v98 != (cocos2d::CCArray *)v99 && v98 ) operator delete[](v98); v10 = HIDWORD(v74); } } } v79 = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)v10); v71 = (cocos2d::CCArray *)cocos2d::CCArray::create(v79); v27 = 0; if ( SHIDWORD(v74) >= (int)v74 ) { while ( 1 ) { v28 = vcvtms_s32_f32((float)v27 / 12.0); v29 = (cocos2d::CCLayer *)cocos2d::CCArray::count(v79); if ( (unsigned int)v29 <= v28 ) { v59 = (cocos2d::CCMenu *)cocos2d::CCLayer::create(v29); v30 = (cocos2d::CCObject *)cocos2d::CCMenu::create(v59); (*(void (__fastcall **)(cocos2d::CCMenu *, cocos2d::CCObject *))(*(_QWORD *)v59 + 456LL))(v59, v30); cocos2d::CCArray::addObject(v79, v59); cocos2d::CCArray::addObject(v71, v30); v31 = v27 + 1; v80 = v27 + 1; v32 = std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::__count_unique( (__int64)&v89, &v80); if ( v32 ) { LABEL_58: v60 = v90; if ( v90 ) { v34 = *((unsigned int *)v90 + 7); v61 = v31 <= (int)v34; if ( v31 >= (int)v34 ) goto LABEL_62; LABEL_60: v62 = *v60; if ( *v60 ) { do { v60 = (__int64 *)v62; v34 = *(unsigned int *)(v62 + 28); v61 = v31 <= (int)v34; if ( v31 < (int)v34 ) goto LABEL_60; LABEL_62: if ( v61 ) goto LABEL_70; v62 = v60[1]; } while ( v62 ); v63 = (__int64 **)(v60 + 1); v85 = (__int64 **)v60; } else { v63 = (__int64 **)v60; v85 = (__int64 **)v60; } } else { v63 = &v90; v85 = &v90; } v60 = (__int64 *)operator new(0x28u); *((_DWORD *)v60 + 7) = v31; *((_DWORD *)v60 + 8) = 0; v60[2] = (__int64)v85; *v60 = 0; v60[1] = 0; *v63 = v60; if ( *v89 ) { v89 = (__int64 **)*v89; v64 = *v63; } else { v64 = v60; } std::__tree_balance_after_insert *>(v90, v64); v34 = ++v91; LABEL_70: v33 = *((_DWORD *)v60 + 8); goto LABEL_39; } } else { cocos2d::CCArray::objectAtIndex(v79, v28); v30 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(v71, v28); v31 = v27 + 1; v80 = v27 + 1; v32 = std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::__count_unique( (__int64)&v89, &v80); if ( v32 ) goto LABEL_58; } v33 = 0; v34 = (v87 - v86) >> 2; if ( !v34 ) goto LABEL_39; v51 = rand(); v52 = v87; v53 = (v87 - v86) >> 2; v54 = vcvtms_s32_f32((float)((float)v51 * 4.6566e-10) * (float)(unsigned __int64)v53); if ( v53 - 1 <= (unsigned __int64)v54 ) break; if ( v54 ) v68 = 4LL * v54; else v68 = 0; v55 = &v86[v68]; v56 = &v86[v68 + 4]; v33 = *(_DWORD *)&v86[v68]; v57 = v87 - v56; v34 = (v87 - v56) >> 2; if ( v34 ) goto LABEL_89; LABEL_54: v58 = &v55[v57]; if ( v58 != v52 ) { v34 = (__int64)&v86; v87 = &v52[4 * ~((unsigned __int64)(v52 - 4 - v58) >> 2)]; } LABEL_39: v35 = (GameStatsManager *)GameStatsManager::sharedState((GameStatsManager *)v34); isSecretChestUnlocked = GameStatsManager::isSecretChestUnlocked(v35, (const char *)v33); v36 = (unsigned int *)GJChestSprite::create((GJChestSprite *)a2); GJChestSprite::switchToState(v36, 2u, 0); (*(void (__fastcall **)(unsigned int *, float))(*(_QWORD *)v36 + 160LL))(v36, 0.55); v37 = (__int64 *)CCMenuItemSpriteExtra::create( (__int64)v36, 0, (__int64)this, (__int64)SecretRewardsLayer::onSelectItem, 0); v96 = 0; v97 = 0; v98 = nullptr; std::string::__init(&v96, "chestClick.ogg", 0xEu); if ( v37 + 55 != &v96 ) { if ( (v96 & 1) != 0 ) { v38 = v98; v39 = v97; } else { v39 = (unsigned __int8)v96 >> 1; v38 = (cocos2d::CCArray *)((char *)&v96 + 1); } std::string::assign(v37 + 55, v38, v39); } if ( (v96 & 1) != 0 ) operator delete(v98); v40 = *(void (__fastcall **)(__int64 *, __int64 ***))(*v37 + 320); cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v85, 55.0, 44.0); v40(v37, &v85); v41 = *(void (__fastcall **)(unsigned int *, __int64 ***))(*(_QWORD *)v36 + 184LL); v42 = *(float *)(*(__int64 (__fastcall **)(__int64 *))(*v37 + 328))(v37); v43 = (*(__int64 (__fastcall **)(__int64 *))(*v37 + 328))(v37); cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v85, v42 * 0.5, *(float *)(v43 + 4) * 0.5); v41(v36, &v85); (*(void (__fastcall **)(cocos2d::CCObject *, __int64 *))(*(_QWORD *)v30 + 456LL))(v30, v37); (*(void (__fastcall **)(__int64 *, _QWORD))(*v37 + 72))(v37, v33); (*(void (__fastcall **)(unsigned int *, _QWORD))(*(_QWORD *)v36 + 72LL))(v36, (unsigned int)v31); v44 = v27 - 12 * v28; v45 = v44 + 3; if ( v44 >= 0 ) v45 = v44; v46 = (unsigned int)(v44 >> 31) >> 30; v47 = v30; v48 = ((_BYTE)v44 + (_BYTE)v46) & 3; v49 = *(void (__fastcall **)(__int64 *, __int64 ***))(*v37 + 184); v50 = v48 - v46; cocos2d::CCNode::convertToNodeSpace(&v83, v47, (const cocos2d::CCPoint *)v82); cocos2d::CCPoint::CCPoint( (cocos2d::CCPoint *)&v84, (float)((float)v50 - 1.5) * 90.0, (float)-vcvtms_s32_f32((float)(v45 >> 2)) * 80.0); cocos2d::CCPoint::operator+(&v85, &v83); v49(v37, &v85); if ( isSecretChestUnlocked ) { SecretRewardsLayer::switchToOpenedState(this, (CCMenuItemSpriteExtra *)v37); if ( SHIDWORD(v74) < v31 + (int)v74 ) goto LABEL_72; } else if ( SHIDWORD(v74) < v31 + (int)v74 ) { goto LABEL_72; } v27 = v31; } if ( v53 != 1 ) v32 = 4LL * ((int)v53 - 1); v55 = &v86[v32]; v33 = *(_DWORD *)&v86[v32]; v56 = &v86[v32 + 4]; v57 = v87 - v56; v34 = (v87 - v56) >> 2; if ( !v34 ) goto LABEL_54; LABEL_89: v55 = (char *)memmove(v55, v56, v57); v34 = (__int64)&v86; v52 = v87; goto LABEL_54; } LABEL_72: v65 = v90; if ( v90 ) { std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::destroy( (__int64)&v89, (_QWORD *)*v90); std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::destroy( (__int64)&v89, (_QWORD *)v65[1]); operator delete(v65); } if ( v86 ) { if ( v86 != v87 ) v87 += 4 * ~((unsigned __int64)(v87 - 4 - v86) >> 2); operator delete(v86); } return v79; }
GD Web Decomp Icon

GD Web Decomp

Raw Source