{"type": "func", "start": 5371784512, "end": 5371784970, "name": "GameStatsManager::unlockSecretChest", "pseudocode": "// \n// GameStatsManager::unlockSecretChest from 0x1402eed40 to 0x1402eef0a (458 bytes)\n// \n// 2 xrefs:\n// > SecretRewardsLayer::onSelectItem @ 0x14056bfb0\n// > <???> @ 0x14091e140\n// \n// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!\n// \n// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA\n// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings\n// Generated at Fri, 27 Nov 2026 11:29:56 +0000\n// \n\n// Hidden C++ exception states: #wind=1\nstruct cocos2d::CCObject *__fastcall GameStatsManager::unlockSecretChest(__int64 a1, int a2)\n{\n  __int64 v2; // rsi\n  struct cocos2d::CCObject *v4; // rbx\n  int Stat; // eax\n  int v6; // 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+30h] [rbp-38h] BYREF\n  __int128 v14; // [rsp+40h] [rbp-28h]\n\n  v2 = a2;\n  if ( GameStatsManager::isSecretChestUnlocked(a1) )\n    return nullptr;\n  v4 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(a1 + 352), v2);\n  if ( !v4 )\n    return nullptr;\n  Stat = GameStatsManager::getStat(a1, &word_140737620);\n  v6 = *((_DWORD *)v4 + 14);\n  if ( v6 <= 6000 )\n  {\n    if ( v6 <= 5000 )\n    {\n      if ( v6 <= 4000 )\n      {\n        if ( v6 <= 3000 )\n        {\n          if ( v6 <= 2000 )\n          {\n            v7 = 1;\n            if ( v6 > 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, &word_140737620, Stat - v7);\n  GameStatsManager::preProcessReward(a1, (__int64)v4);\n  GameStatsManager::registerRewardsFromItem(a1, v4);\n  v8 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8, (unsigned int)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_14003D230(Block, CString, v10);\n  cocos2d::CCDictionary::setObject(*(_QWORD *)(a1 + 864), 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        invoke_watson(nullptr, nullptr, nullptr, 0, 0);\n    }\n    j_j_free(v11);\n  }\n  return v4;\n}", "assembly": "; \n; GameStatsManager::unlockSecretChest from 0x1402eed40 to 0x1402eef0a (458 bytes)\n; \n; 2 xrefs:\n; > SecretRewardsLayer::onSelectItem @ 0x14056bfb0\n; > <???> @ 0x14091e140\n; \n; This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!\n; \n; Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA\n; Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings\n; Generated at Fri, 27 Nov 2026 11:29:56 +0000\n; \nmov     [rsp+arg_10], rbx                                              ; +0x0, 0x1402eed40\nmov     [rsp+arg_18], rsi                                              ; +0x5, 0x1402eed45\npush    rdi                                                            ; +0xa, 0x1402eed4a\nsub     rsp, 60h                                                       ; +0xb, 0x1402eed4b\nmov     rax, cs:__security_cookie                                      ; +0xf, 0x1402eed4f\nxor     rax, rsp                                                       ; +0x16, 0x1402eed56\nmov     [rsp+68h+var_18], rax                                          ; +0x19, 0x1402eed59\nmovsxd  rsi, edx                                                       ; +0x1e, 0x1402eed5e\nmov     rdi, rcx                                                       ; +0x21, 0x1402eed61\nmov     edx, esi                                                       ; +0x24, 0x1402eed64\ncall    GameStatsManager__isSecretChestUnlocked                        ; +0x26, 0x1402eed66\ntest    al, al                                                         ; +0x2b, 0x1402eed6b\njnz     loc_1402EEEE9                                                  ; +0x2d, 0x1402eed6d\nmov     rdx, rsi                                                       ; +0x33, 0x1402eed73\nmov     rcx, [rdi+160h]                                                ; +0x36, 0x1402eed76\ncall    cs:?objectForKey@CCDictionary@cocos2d@@QEAAPEAVCCObject@2@_J@Z; cocos2d::CCDictionary::objectForKey(__int64) ; +0x3d, 0x1402eed7d\nmov     rbx, rax                                                       ; +0x43, 0x1402eed83\ntest    rax, rax                                                       ; +0x46, 0x1402eed86\njz      loc_1402EEEE9                                                  ; +0x49, 0x1402eed89\nlea     rdx, word_140737620                                            ; +0x4f, 0x1402eed8f\nmov     rcx, rdi                                                       ; +0x56, 0x1402eed96\ncall    GameStatsManager__getStat                                      ; +0x59, 0x1402eed99\nmov     edx, [rbx+38h]                                                 ; +0x5e, 0x1402eed9e\ncmp     edx, 1770h                                                     ; +0x61, 0x1402eeda1\njle     short loc_1402EEDB0                                            ; +0x67, 0x1402eeda7\nmov     ecx, 1                                                         ; +0x69, 0x1402eeda9\njmp     short loc_1402EEE01                                            ; +0x6e, 0x1402eedae\ncmp     edx, 1388h                                                     ; +0x70, 0x1402eedb0\njle     short loc_1402EEDBF                                            ; +0x76, 0x1402eedb6\nmov     ecx, 64h ; 'd'                                                 ; +0x78, 0x1402eedb8\njmp     short loc_1402EEE01                                            ; +0x7d, 0x1402eedbd\ncmp     edx, 0FA0h                                                     ; +0x7f, 0x1402eedbf\njle     short loc_1402EEDCE                                            ; +0x85, 0x1402eedc5\nmov     ecx, 32h ; '2'                                                 ; +0x87, 0x1402eedc7\njmp     short loc_1402EEE01                                            ; +0x8c, 0x1402eedcc\ncmp     edx, 0BB8h                                                     ; +0x8e, 0x1402eedce\njle     short loc_1402EEDDD                                            ; +0x94, 0x1402eedd4\nmov     ecx, 19h                                                       ; +0x96, 0x1402eedd6\njmp     short loc_1402EEE01                                            ; +0x9b, 0x1402eeddb\ncmp     edx, 7D0h                                                      ; +0x9d, 0x1402eeddd\njle     short loc_1402EEDEC                                            ; +0xa3, 0x1402eede3\nmov     ecx, 0Ah                                                       ; +0xa5, 0x1402eede5\njmp     short loc_1402EEE01                                            ; +0xaa, 0x1402eedea\nmov     ecx, 1                                                         ; +0xac, 0x1402eedec\nmov     r8d, 5                                                         ; +0xb1, 0x1402eedf1\ncmp     edx, 3E8h                                                      ; +0xb7, 0x1402eedf7\ncmovg   ecx, r8d                                                       ; +0xbd, 0x1402eedfd\ncmp     eax, ecx                                                       ; +0xc1, 0x1402eee01\njl      loc_1402EEEE9                                                  ; +0xc3, 0x1402eee03\nsub     eax, ecx                                                       ; +0xc9, 0x1402eee09\nmov     r8d, eax                                                       ; +0xcb, 0x1402eee0b\nlea     rdx, word_140737620                                            ; +0xce, 0x1402eee0e\nmov     rcx, rdi                                                       ; +0xd5, 0x1402eee15\ncall    GameStatsManager__setStat                                      ; +0xd8, 0x1402eee18\nmov     rdx, rbx                                                       ; +0xdd, 0x1402eee1d\nmov     rcx, rdi                                                       ; +0xe0, 0x1402eee20\ncall    GameStatsManager__preProcessReward                             ; +0xe3, 0x1402eee23\nmov     rdx, rbx                                                       ; +0xe8, 0x1402eee28\nmov     rcx, rdi                                                       ; +0xeb, 0x1402eee2b\ncall    GameStatsManager__registerRewardsFromItem                      ; +0xee, 0x1402eee2e\nmov     edx, esi                                                       ; +0xf3, 0x1402eee33\nlea     rcx, word_1406ED6F8                                            ; +0xf5, 0x1402eee35\ncall    cs:?createWithFormat@CCString@cocos2d@@SAPEAV12@PEBDZZ; cocos2d::CCString::createWithFormat(char const *,...) ; +0xfc, 0x1402eee3c\nmov     rcx, rax                                                       ; +0x102, 0x1402eee42\ncall    cs:?getCString@CCString@cocos2d@@QEBAPEBDXZ; cocos2d::CCString::getCString(void) ; +0x105, 0x1402eee45\nxorps   xmm0, xmm0                                                     ; +0x10b, 0x1402eee4b\nmovups  xmmword ptr [rsp+68h+Block], xmm0                              ; +0x10e, 0x1402eee4e\nxorps   xmm1, xmm1                                                     ; +0x113, 0x1402eee53\nmovdqu  [rsp+68h+var_28], xmm1                                         ; +0x116, 0x1402eee56\nmov     r8, 0FFFFFFFFFFFFFFFFh                                         ; +0x11c, 0x1402eee5c\ninc     r8                                                             ; +0x123, 0x1402eee63\ncmp     byte ptr [rax+r8], 0                                           ; +0x126, 0x1402eee66\njnz     short loc_1402EEE63                                            ; +0x12b, 0x1402eee6b\nmov     rdx, rax                                                       ; +0x12d, 0x1402eee6d\nlea     rcx, [rsp+68h+Block]                                           ; +0x130, 0x1402eee70\ncall    sub_14003D230                                                  ; +0x135, 0x1402eee75\nnop                                                                    ; +0x13a, 0x1402eee7a\nlea     r8, [rsp+68h+Block]                                            ; +0x13b, 0x1402eee7b\nmov     rdx, rbx                                                       ; +0x140, 0x1402eee80\nmov     rcx, [rdi+360h]                                                ; +0x143, 0x1402eee83\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, 0x1402eee8a\nnop                                                                    ; +0x150, 0x1402eee90\nmov     rdx, qword ptr [rsp+68h+var_28+8]                              ; +0x151, 0x1402eee91\ncmp     rdx, 0Fh                                                       ; +0x156, 0x1402eee96\njbe     short loc_1402EEEE4                                            ; +0x15a, 0x1402eee9a\ninc     rdx                                                            ; +0x15c, 0x1402eee9c\nmov     rcx, [rsp+68h+Block]; Block                                    ; +0x15f, 0x1402eee9f\nmov     rax, rcx                                                       ; +0x164, 0x1402eeea4\ncmp     rdx, 1000h                                                     ; +0x167, 0x1402eeea7\njb      short loc_1402EEEDF                                            ; +0x16e, 0x1402eeeae\nadd     rdx, 27h ; '''                                                 ; +0x170, 0x1402eeeb0\nmov     rcx, [rcx-8]                                                   ; +0x174, 0x1402eeeb4\nsub     rax, rcx                                                       ; +0x178, 0x1402eeeb8\nsub     rax, 8                                                         ; +0x17b, 0x1402eeebb\ncmp     rax, 1Fh                                                       ; +0x17f, 0x1402eeebf\njbe     short loc_1402EEEDF                                            ; +0x183, 0x1402eeec3\nmov     [rsp+68h+Reserved], 0; Reserved                                ; +0x185, 0x1402eeec5\nxor     r9d, r9d; LineNo                                               ; +0x18e, 0x1402eeece\nxor     r8d, r8d; FileName                                             ; +0x191, 0x1402eeed1\nxor     edx, edx; FunctionName                                         ; +0x194, 0x1402eeed4\nxor     ecx, ecx; Expression                                           ; +0x196, 0x1402eeed6\ncall    cs:_invoke_watson                                              ; +0x198, 0x1402eeed8\ndb 0CCh                                                                ; +0x19e, 0x1402eeede\ncall    j_j_free                                                       ; +0x19f, 0x1402eeedf\nmov     rax, rbx                                                       ; +0x1a4, 0x1402eeee4\njmp     short loc_1402EEEEB                                            ; +0x1a7, 0x1402eeee7\nxor     eax, eax                                                       ; +0x1a9, 0x1402eeee9\nmov     rcx, [rsp+68h+var_18]                                          ; +0x1ab, 0x1402eeeeb\nxor     rcx, rsp; StackCookie                                          ; +0x1b0, 0x1402eeef0\ncall    __security_check_cookie                                        ; +0x1b3, 0x1402eeef3\nlea     r11, [rsp+68h+var_8]                                           ; +0x1b8, 0x1402eeef8\nmov     rbx, [r11+20h]                                                 ; +0x1bd, 0x1402eeefd\nmov     rsi, [r11+28h]                                                 ; +0x1c1, 0x1402eef01\nmov     rsp, r11                                                       ; +0x1c5, 0x1402eef05\npop     rdi                                                            ; +0x1c8, 0x1402eef08\nretn                                                                   ; +0x1c9, 0x1402eef09", "xrefs": ["SecretRewardsLayer::onSelectItem @ 0x14056bfb0", "<???> @ 0x14091e140"], "is_objc": false, "is_32_bit": false, "is_64_bit": true, "idp_name": "pc", "bida_info": "8.3.0 @ https://github.com/Stazzical/BromaIDA", "bindings_info": "commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings"}