// // SecretRewardsLayer::generateChestItems from 0x589854 to 0x589ec0 (1644 bytes) // // 1 xrefs: // > SecretRewardsLayer::createSecondaryLayer @ 0x58a0f6 // // 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 // cocos2d::CCArray *SecretRewardsLayer::generateChestItems(SecretRewardsLayer *a1, int a2) { cocos2d::CCDirector *v2; // r0 cocos2d::CCArray *v3; // r0 __int16 *v4; // r3 int v5; // r2 float v6; // r7 char *v7; // r4 char *v8; // r10 _BYTE *v9; // r5 unsigned int v10; // r8 int v11; // r9 int v12; // r3 _DWORD *v13; // r0 _DWORD **v14; // r3 int i; // r2 _DWORD *v16; // r0 _DWORD *v17; // r3 int v18; // r11 _DWORD **v19; // r9 _DWORD *v20; // r2 int *v21; // r3 int *v22; // r8 _BOOL4 v23; // r0 int v24; // r4 int v25; // r9 int v26; // r8 unsigned int v27; // r3 int v28; // r8 char *v29; // r11 cocos2d::CCMenu *v30; // r8 cocos2d::CCLayer *v31; // r4 int *v32; // r3 int *v33; // r4 int *v34; // r1 int *v35; // r0 int v36; // r9 int *v37; // r6 _BOOL4 v38; // r0 unsigned int v39; // r6 unsigned int v40; // r0 unsigned int v41; // r3 unsigned int *v42; // r0 const void *v43; // r1 GameStatsManager *v44; // r0 GJChestSprite *v45; // r7 CCMenuItemSpriteExtra *v46; // r4 float width; // s16 int v48; // r0 signed int v49; // r7 float v50; // r0 int v51; // r6 void (__fastcall *v52)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7 float v53; // s15 int v55; // [sp+Ch] [bp-298h] int v56; // [sp+Ch] [bp-298h] int v57; // [sp+10h] [bp-294h] cocos2d::CCDictionary *m_treasureRoomChests; // [sp+14h] [bp-290h] cocos2d::CCArray *v59; // [sp+14h] [bp-290h] unsigned int v60; // [sp+18h] [bp-28Ch] unsigned int v61; // [sp+18h] [bp-28Ch] unsigned int v62; // [sp+18h] [bp-28Ch] int v63; // [sp+1Ch] [bp-288h] cocos2d::CCArray *v64; // [sp+20h] [bp-284h] _BOOL4 isSecretChestUnlocked; // [sp+30h] [bp-274h] void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // [sp+34h] [bp-270h] void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // [sp+34h] [bp-270h] int v70; // [sp+40h] [bp-264h] BYREF cocos2d::CCSize v71; // [sp+44h] [bp-260h] BYREF cocos2d::CCPoint v72; // [sp+4Ch] [bp-258h] BYREF cocos2d::CCPoint v73; // [sp+54h] [bp-250h] BYREF cocos2d::CCPoint v74; // [sp+5Ch] [bp-248h] BYREF cocos2d::CCPoint v75; // [sp+64h] [bp-240h] BYREF char *v76[2]; // [sp+6Ch] [bp-238h] BYREF unsigned int v77; // [sp+74h] [bp-230h] BYREF int v78; // [sp+78h] [bp-22Ch] int *v79; // [sp+7Ch] [bp-228h] BYREF int v80; // [sp+80h] [bp-224h] int v81; // [sp+84h] [bp-220h] BYREF _DWORD *v82[4]; // [sp+88h] [bp-21Ch] BYREF int v83; // [sp+98h] [bp-20Ch] unsigned int v84; // [sp+9Ch] [bp-208h] BYREF unsigned int v85; // [sp+A0h] [bp-204h] void *v86; // [sp+A4h] [bp-200h] _BYTE v87[500]; // [sp+A8h] [bp-1FCh] BYREF v2 = cocos2d::CCDirector::sharedDirector(); cocos2d::CCDirector::getWinSize(&v71, v2); cocos2d::CCPoint::CCPoint(&v72, v71.width * 0.5, (float)(v71.height * 0.5) + 80.0); m_treasureRoomChests = GameStatsManager::sharedState()->m_treasureRoomChests; v3 = (cocos2d::CCArray *)memset(v82, 0, sizeof(v82)); v82[2] = v82; v83 = 0; v82[3] = v82; if ( (unsigned int)(a2 - 3) > 5 ) { v5 = 0; v55 = 0; } else { v4 = &word_9ADBF0[a2 - 3]; v55 = v4[10]; v5 = v4[16]; } v57 = v5 + 1; LODWORD(v6) = v5 + 1; v7 = nullptr; v8 = nullptr; v9 = nullptr; v63 = v5 + v55; while ( SLODWORD(v6) <= v63 ) { v84 = 0; v85 = 500; v86 = v87; v75.x = v6; fmt::BasicWriter::FormatInt,char>>( &v84, SLODWORD(v6), (int)&v75); v10 = v84; if ( v84 + 1 > v85 ) fmt::internal::Array::grow((int)&v84, v84 + 1); *((_BYTE *)v86 + v10) = 0; sub_776584((int)v76, (char *)v86); sub_776584((int)&v73, v76[0]); v11 = cocos2d::CCDictionary::objectForKey(m_treasureRoomChests, (const std::string *)&v73); sub_774008(&v73); if ( !v11 ) { if ( v8 != v7 ) { if ( v8 ) *(float *)v8 = v6; v8 += 4; goto LABEL_49; } v24 = v8 - v9; v25 = (v8 - v9) >> 2; if ( v25 ) v26 = (v8 - v9) >> 2; else v26 = 1; v27 = v26 + v25; if ( __CFADD__(v26, v25) || v27 >= 0x40000000 ) { v28 = 0x3FFFFFFF; goto LABEL_41; } v28 = v26 + v25; if ( v27 ) LABEL_41: v29 = (char *)operator new(4 * v28); else v29 = nullptr; if ( &v29[v24] ) *(float *)&v29[v24] = v6; if ( v25 ) memmove(v29, v9, v8 - v9); v8 = &v29[v24 + 4]; if ( v9 ) operator delete(v9); v7 = &v29[4 * v28]; v9 = v29; goto LABEL_49; } v12 = *(_DWORD *)(v11 + 52); if ( v12 > v55 || v12 < 0 ) *(_DWORD *)(v11 + 52) = 1; v79 = *(int **)(v11 + 52); v13 = std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::find( (int)&v81, &v79); v14 = v82; if ( v82 != v13 ) { for ( i = 1; ; i = (int)v79 + 1 ) { v79 = (int *)i; if ( i > v55 ) break; v60 = (unsigned int)v14; v16 = std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::find( (int)&v81, &v79); v14 = (_DWORD **)v60; if ( (_DWORD *)v60 == v16 ) { *(_DWORD *)(v11 + 52) = v79; break; } } } v17 = v82[1]; v18 = *(_DWORD *)(v11 + 52); v19 = v82; while ( v17 ) { if ( v17[4] >= v18 ) { v20 = (_DWORD *)v17[2]; } else { v20 = (_DWORD *)v17[3]; v17 = v19; } v19 = (_DWORD **)v17; v17 = v20; } v21 = (int *)v19; if ( v19 == v82 || v18 < (int)v19[4] ) { v22 = (int *)operator new(0x18u); v22[4] = v18; v22[5] = 0; std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::_M_get_insert_hint_unique_pos( (int *)&v77, &v81, v19, v22 + 4); if ( v78 ) { v23 = v77 || (_DWORD **)v78 == v82 || v18 < *(_DWORD *)(v78 + 16); sub_7620E8(v23, v22, v78, v82); ++v83; v21 = v22; } else { v62 = v77; operator delete(v22); v21 = (int *)v62; } } *((float *)v21 + 5) = v6; LABEL_49: sub_774008(v76); v3 = (cocos2d::CCArray *)v86; if ( v86 != v87 && v86 ) operator delete[](v86); ++LODWORD(v6); } v59 = (cocos2d::CCArray *)cocos2d::CCArray::create(v3); v56 = 0; v64 = (cocos2d::CCArray *)cocos2d::CCArray::create(v59); while ( v57 <= v63 ) { v61 = (int)floorf((float)v56 / 12.0); if ( cocos2d::CCArray::count(v59) <= v61 ) { v31 = cocos2d::CCLayer::create(); v30 = cocos2d::CCMenu::create(); v31->addChild(v31, v30); cocos2d::CCArray::addObject(v59, v31); cocos2d::CCArray::addObject(v64, v30); } else { cocos2d::CCArray::objectAtIndex(v59, v61); v30 = (cocos2d::CCMenu *)cocos2d::CCArray::objectAtIndex(v64, v61); } v70 = v56 + 1; if ( v82 == std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::find( (int)&v81, &v70) ) { v39 = (v8 - v9) >> 2; if ( v39 ) { v40 = rand(); v41 = (int)floorf(vcvts_n_f32_s32(v40, 0x1Fu) * (float)v39); if ( v39 - 1 <= v41 ) { if ( v39 == 1 ) v41 = 0; else v41 = v39 - 1; } v42 = (unsigned int *)&v9[4 * v41]; v39 = *v42; v43 = v42 + 1; if ( v42 + 1 != (unsigned int *)v8 && (unsigned int)(v8 - (_BYTE *)v43) >> 2 ) memmove(v42, v43, v8 - (_BYTE *)v43); v8 -= 4; } } else { v32 = v82[1]; v33 = (int *)v82; while ( v32 ) { if ( v32[4] >= v70 ) { v34 = (int *)v32[2]; } else { v34 = (int *)v32[3]; v32 = v33; } v33 = v32; v32 = v34; } if ( v33 == (int *)v82 || v70 < v33[4] ) { v35 = (int *)operator new(0x18u); v36 = v70; v37 = v35; v35[5] = 0; v35[4] = v36; std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::_M_get_insert_hint_unique_pos( (int *)&v79, &v81, v33, v35 + 4); v33 = v79; if ( v80 ) { v38 = v79 || (_DWORD **)v80 == v82 || v36 < *(_DWORD *)(v80 + 16); sub_7620E8(v38, v37, v80, v82); ++v83; v33 = v37; } else { operator delete(v37); } } v39 = v33[5]; } v44 = GameStatsManager::sharedState(); isSecretChestUnlocked = GameStatsManager::isSecretChestUnlocked(v44, v39); v45 = GJChestSprite::create(a2); GJChestSprite::switchToState(v45, Closed, 0); ((void (__fastcall *)(GJChestSprite *, int))v45->setScale)(v45, 1057803469); v76[0] = (char *)SecretRewardsLayer::onSelectItem; v76[1] = nullptr; v46 = CCMenuItemSpriteExtra::create( v45, nullptr, (cocos2d::SEL_MenuHandler)__PAIR64__(SecretRewardsLayer::onSelectItem, (unsigned int)a1)); sub_776584((int)&v74, "chestClick.ogg"); sub_775D40(&v46->m_selectSound, &v74); sub_774008(&v74); setContentSize = v46->setContentSize; cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v75, 55.0, 44.0); setContentSize(v46, (const cocos2d::CCSize *)&v75); setPosition = v45->setPosition; width = v46->getContentSize(v46)->width; v48 = (int)v46->getContentSize(v46); cocos2d::CCPoint::CCPoint(&v75, width * 0.5, *(float *)(v48 + 4) * 0.5); setPosition(v45, &v75); v30->addChild(v30, v46); v46->setTag(v46, v39); v45->setTag(v45, v70); v49 = v56 - 12 * v61; v50 = floorf((float)(v49 / 4)); v51 = v49 % 4; v52 = v46->setPosition; v53 = v50; cocos2d::CCNode::convertToNodeSpace(&v73, v30, &v72); cocos2d::CCPoint::CCPoint(&v74, (float)((float)v51 - 1.5) * 90.0, (float)-(int)v53 * 80.0); cocos2d::CCPoint::operator+(&v75, &v73, &v74); v52(v46, &v75); if ( isSecretChestUnlocked ) SecretRewardsLayer::switchToOpenedState(a1, v46); ++v57; ++v56; } std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::_M_erase( (int)&v81, v82[1]); if ( v9 ) operator delete(v9); return v59; }
GD Web Decomp Icon

GD Web Decomp

Raw Source