{"type": "func", "start": 5370718512, "end": 5370718949, "name": "GameStatsManager::unlockSecretChest", "pseudocode": "// \n// GameStatsManager::unlockSecretChest from 0x1401ea930 to 0x1401eaae5 (437 bytes)\n// \n// 2 xrefs:\n// > SecretRewardsLayer::onSelectItem @ 0x1403d6552\n// > <???> @ 0x1406cc69c\n// \n// This function is hookable on this platform!\n// \n// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA\n// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings\n// \n\n// Hidden C++ exception states: #wind=1\nGJRewardItem *GameStatsManager::unlockSecretChest(GameStatsManager *a1, int a2)\n{\n  __int64 v2; // rsi\n  GJRewardItem *v4; // rbx\n  int Stat; // eax\n  int m_chestID; // edx\n  int v7; // ecx\n  cocos2d::CCString *v8; // rax\n  const char *CString; // rax\n  size_t v10; // r8\n  void *v11; // rcx\n  void *Block[2]; // [rsp+20h] [rbp-38h] BYREF\n  __int128 v14; // [rsp+30h] [rbp-28h]\n\n  v2 = a2;\n  if ( GameStatsManager::isSecretChestUnlocked(a1, a2) )\n    return nullptr;\n  v4 = (GJRewardItem *)cocos2d::CCDictionary::objectForKey(a1->m_allTreasureRoomChests, v2);\n  if ( !v4 )\n    return nullptr;\n  Stat = GameStatsManager::getStat(a1, (const char *)&word_140543238);\n  m_chestID = v4->m_chestID;\n  if ( m_chestID <= 6000 )\n  {\n    if ( m_chestID <= 5000 )\n    {\n      if ( m_chestID <= 4000 )\n      {\n        if ( m_chestID <= 3000 )\n        {\n          if ( m_chestID <= 2000 )\n          {\n            v7 = 1;\n            if ( m_chestID > 1000 )\n              v7 = 5;\n          }\n          else\n          {\n            v7 = 10;\n          }\n        }\n        else\n        {\n          v7 = 25;\n        }\n      }\n      else\n      {\n        v7 = 50;\n      }\n    }\n    else\n    {\n      v7 = 100;\n    }\n  }\n  else\n  {\n    v7 = 1;\n  }\n  if ( Stat < v7 )\n    return nullptr;\n  GameStatsManager::setStat(a1, (const char *)&word_140543238, Stat - v7);\n  GameStatsManager::preProcessReward(a1, v4);\n  GameStatsManager::registerRewardsFromItem(a1, v4);\n  v8 = cocos2d::CCString::createWithFormat(\"%i\", v2);\n  CString = cocos2d::CCString::getCString(v8);\n  *(_OWORD *)Block = 0;\n  v14 = 0;\n  v10 = -1;\n  do\n    ++v10;\n  while ( CString[v10] );\n  sub_14003A930(Block, CString, v10);\n  cocos2d::CCDictionary::setObject(a1->m_treasureRoomChests, v4, Block);\n  if ( *((_QWORD *)&v14 + 1) > 0xFu )\n  {\n    v11 = Block[0];\n    if ( (unsigned __int64)(*((_QWORD *)&v14 + 1) + 1LL) >= 0x1000 )\n    {\n      v11 = *((void **)Block[0] - 1);\n      if ( (unsigned __int64)((char *)Block[0] - (char *)v11 - 8) > 0x1F )\n        invalid_parameter_noinfo_noreturn();\n    }\n    j_j_free(v11);\n  }\n  return v4;\n}", "assembly": "; \n; GameStatsManager::unlockSecretChest from 0x1401ea930 to 0x1401eaae5 (437 bytes)\n; \n; 2 xrefs:\n; > SecretRewardsLayer::onSelectItem @ 0x1403d6552\n; > <???> @ 0x1406cc69c\n; \n; This function is hookable on this platform!\n; \n; Using BromaIDA 8.0.0 @ https:;github.com/Stazzical/BromaIDA\n; Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https:;github.com/geode-sdk/bindings\n; \n\nmov     [rsp+arg_10], rbx                                              ; +0x0, 0x1401ea930\nmov     [rsp+arg_18], rsi                                              ; +0x5, 0x1401ea935\npush    rdi                                                            ; +0xa, 0x1401ea93a\nsub     rsp, 50h                                                       ; +0xb, 0x1401ea93b\nmov     rax, cs:__security_cookie                                      ; +0xf, 0x1401ea93f\nxor     rax, rsp                                                       ; +0x16, 0x1401ea946\nmov     [rsp+58h+var_18], rax                                          ; +0x19, 0x1401ea949\nmovsxd  rsi, edx                                                       ; +0x1e, 0x1401ea94e\nmov     rdi, rcx                                                       ; +0x21, 0x1401ea951\nmov     edx, esi                                                       ; +0x24, 0x1401ea954\ncall    GameStatsManager__isSecretChestUnlocked                        ; +0x26, 0x1401ea956\ntest    al, al                                                         ; +0x2b, 0x1401ea95b\njnz     loc_1401EAAC6                                                  ; +0x2d, 0x1401ea95d\nmov     rdx, rsi                                                       ; +0x33, 0x1401ea963\nmov     rcx, [rdi+160h]                                                ; +0x36, 0x1401ea966\ncall    cs:?objectForKey@CCDictionary@cocos2d@@QEAAPEAVCCObject@2@_J@Z; cocos2d::CCDictionary::objectForKey(__int64) ; +0x3d, 0x1401ea96d\nmov     rbx, rax                                                       ; +0x43, 0x1401ea973\ntest    rax, rax                                                       ; +0x46, 0x1401ea976\njz      loc_1401EAAC6                                                  ; +0x49, 0x1401ea979\nlea     rdx, word_140543238                                            ; +0x4f, 0x1401ea97f\nmov     rcx, rdi                                                       ; +0x56, 0x1401ea986\ncall    GameStatsManager__getStat                                      ; +0x59, 0x1401ea989\nmov     edx, [rbx+38h]                                                 ; +0x5e, 0x1401ea98e\ncmp     edx, 1770h                                                     ; +0x61, 0x1401ea991\njle     short loc_1401EA9A0                                            ; +0x67, 0x1401ea997\nmov     ecx, 1                                                         ; +0x69, 0x1401ea999\njmp     short loc_1401EA9F1                                            ; +0x6e, 0x1401ea99e\ncmp     edx, 1388h                                                     ; +0x70, 0x1401ea9a0\njle     short loc_1401EA9AF                                            ; +0x76, 0x1401ea9a6\nmov     ecx, 64h ; 'd'                                                 ; +0x78, 0x1401ea9a8\njmp     short loc_1401EA9F1                                            ; +0x7d, 0x1401ea9ad\ncmp     edx, 0FA0h                                                     ; +0x7f, 0x1401ea9af\njle     short loc_1401EA9BE                                            ; +0x85, 0x1401ea9b5\nmov     ecx, 32h ; '2'                                                 ; +0x87, 0x1401ea9b7\njmp     short loc_1401EA9F1                                            ; +0x8c, 0x1401ea9bc\ncmp     edx, 0BB8h                                                     ; +0x8e, 0x1401ea9be\njle     short loc_1401EA9CD                                            ; +0x94, 0x1401ea9c4\nmov     ecx, 19h                                                       ; +0x96, 0x1401ea9c6\njmp     short loc_1401EA9F1                                            ; +0x9b, 0x1401ea9cb\ncmp     edx, 7D0h                                                      ; +0x9d, 0x1401ea9cd\njle     short loc_1401EA9DC                                            ; +0xa3, 0x1401ea9d3\nmov     ecx, 0Ah                                                       ; +0xa5, 0x1401ea9d5\njmp     short loc_1401EA9F1                                            ; +0xaa, 0x1401ea9da\nmov     ecx, 1                                                         ; +0xac, 0x1401ea9dc\nmov     r8d, 5                                                         ; +0xb1, 0x1401ea9e1\ncmp     edx, 3E8h                                                      ; +0xb7, 0x1401ea9e7\ncmovg   ecx, r8d                                                       ; +0xbd, 0x1401ea9ed\ncmp     eax, ecx                                                       ; +0xc1, 0x1401ea9f1\njl      loc_1401EAAC6                                                  ; +0xc3, 0x1401ea9f3\nsub     eax, ecx                                                       ; +0xc9, 0x1401ea9f9\nmov     r8d, eax                                                       ; +0xcb, 0x1401ea9fb\nlea     rdx, word_140543238                                            ; +0xce, 0x1401ea9fe\nmov     rcx, rdi                                                       ; +0xd5, 0x1401eaa05\ncall    GameStatsManager__setStat                                      ; +0xd8, 0x1401eaa08\nmov     rdx, rbx                                                       ; +0xdd, 0x1401eaa0d\nmov     rcx, rdi                                                       ; +0xe0, 0x1401eaa10\ncall    GameStatsManager__preProcessReward                             ; +0xe3, 0x1401eaa13\nmov     rdx, rbx                                                       ; +0xe8, 0x1401eaa18\nmov     rcx, rdi                                                       ; +0xeb, 0x1401eaa1b\ncall    GameStatsManager__registerRewardsFromItem                      ; +0xee, 0x1401eaa1e\nmov     edx, esi                                                       ; +0xf3, 0x1401eaa23\nlea     rcx, aI_11; \"%i\"                                               ; +0xf5, 0x1401eaa25\ncall    cs:?createWithFormat@CCString@cocos2d@@SAPEAV12@PEBDZZ; cocos2d::CCString::createWithFormat(char const *,...) ; +0xfc, 0x1401eaa2c\nmov     rcx, rax                                                       ; +0x102, 0x1401eaa32\ncall    cs:?getCString@CCString@cocos2d@@QEBAPEBDXZ; cocos2d::CCString::getCString(void) ; +0x105, 0x1401eaa35\nxorps   xmm0, xmm0                                                     ; +0x10b, 0x1401eaa3b\nmovups  xmmword ptr [rsp+58h+Block], xmm0                              ; +0x10e, 0x1401eaa3e\nxorps   xmm1, xmm1                                                     ; +0x113, 0x1401eaa43\nmovdqu  [rsp+58h+var_28], xmm1                                         ; +0x116, 0x1401eaa46\nmov     r8, 0FFFFFFFFFFFFFFFFh                                         ; +0x11c, 0x1401eaa4c\ninc     r8                                                             ; +0x123, 0x1401eaa53\ncmp     byte ptr [rax+r8], 0                                           ; +0x126, 0x1401eaa56\njnz     short loc_1401EAA53                                            ; +0x12b, 0x1401eaa5b\nmov     rdx, rax                                                       ; +0x12d, 0x1401eaa5d\nlea     rcx, [rsp+58h+Block]                                           ; +0x130, 0x1401eaa60\ncall    sub_14003A930                                                  ; +0x135, 0x1401eaa65\nnop                                                                    ; +0x13a, 0x1401eaa6a\nlea     r8, [rsp+58h+Block]                                            ; +0x13b, 0x1401eaa6b\nmov     rdx, rbx                                                       ; +0x140, 0x1401eaa70\nmov     rcx, [rdi+358h]                                                ; +0x143, 0x1401eaa73\ncall    cs:?setObject@CCDictionary@cocos2d@@QEAAXPEAVCCObject@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z; cocos2d::CCDictionary::setObject(cocos2d::CCObject *,std::string const &) ; +0x14a, 0x1401eaa7a\nnop                                                                    ; +0x150, 0x1401eaa80\nmov     rdx, qword ptr [rsp+58h+var_28+8]                              ; +0x151, 0x1401eaa81\ncmp     rdx, 0Fh                                                       ; +0x156, 0x1401eaa86\njbe     short loc_1401EAAC1                                            ; +0x15a, 0x1401eaa8a\ninc     rdx                                                            ; +0x15c, 0x1401eaa8c\nmov     rcx, [rsp+58h+Block]; Block                                    ; +0x15f, 0x1401eaa8f\nmov     rax, rcx                                                       ; +0x164, 0x1401eaa94\ncmp     rdx, 1000h                                                     ; +0x167, 0x1401eaa97\njb      short loc_1401EAABC                                            ; +0x16e, 0x1401eaa9e\nadd     rdx, 27h ; '''                                                 ; +0x170, 0x1401eaaa0\nmov     rcx, [rcx-8]                                                   ; +0x174, 0x1401eaaa4\nsub     rax, rcx                                                       ; +0x178, 0x1401eaaa8\nadd     rax, 0FFFFFFFFFFFFFFF8h                                        ; +0x17b, 0x1401eaaab\ncmp     rax, 1Fh                                                       ; +0x17f, 0x1401eaaaf\njbe     short loc_1401EAABC                                            ; +0x183, 0x1401eaab3\ncall    cs:_invalid_parameter_noinfo_noreturn                          ; +0x185, 0x1401eaab5\nalign 4                                                                ; +0x18b, 0x1401eaabb\ncall    j_j_free                                                       ; +0x18c, 0x1401eaabc\nmov     rax, rbx                                                       ; +0x191, 0x1401eaac1\njmp     short loc_1401EAAC8                                            ; +0x194, 0x1401eaac4\nxor     eax, eax                                                       ; +0x196, 0x1401eaac6\nmov     rcx, [rsp+58h+var_18]                                          ; +0x198, 0x1401eaac8\nxor     rcx, rsp; StackCookie                                          ; +0x19d, 0x1401eaacd\ncall    __security_check_cookie                                        ; +0x1a0, 0x1401eaad0\nmov     rbx, [rsp+58h+arg_10]                                          ; +0x1a5, 0x1401eaad5\nmov     rsi, [rsp+58h+arg_18]                                          ; +0x1aa, 0x1401eaada\nadd     rsp, 50h                                                       ; +0x1af, 0x1401eaadf\npop     rdi                                                            ; +0x1b3, 0x1401eaae3\nretn                                                                   ; +0x1b4, 0x1401eaae4", "xrefs": ["SecretRewardsLayer::onSelectItem @ 0x1403d6552", "<???> @ 0x1406cc69c"], "is_objc": false, "is_arm32": false, "is_arm64": false, "bida_info": "8.0.0 @ https://github.com/Stazzical/BromaIDA", "bindings_info": "commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings"}