{"type": "func", "start": 4295540960, "end": 4295541386, "name": "GameStatsManager::unlockSecretChest", "pseudocode": "// \n// GameStatsManager::unlockSecretChest from 0x10008c0e0 to 0x10008c28a (426 bytes)\n// \n// 1 xrefs:\n// > SecretRewardsLayer::onSelectItem @ 0x1006348b9\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\nGJRewardItem *__fastcall GameStatsManager::unlockSecretChest(GameStatsManager *a1, int a2)\n{\n  double v2; // xmm0_8\n  cocos2d::CCObject *v3; // rax\n  GJRewardItem *v4; // rbx\n  int Stat; // eax\n  int m_chestID; // ecx\n  int v7; // edx\n  bool v8; // cc\n  int v9; // eax\n  cocos2d::CCDictionary *m_treasureRoomChests; // r15\n  cocos2d::CCString *v12; // rax\n  const char *CString; // r12\n  size_t v14; // rax\n  size_t v15; // r14\n  char *v16; // r13\n  size_t v17; // r15\n  char v18; // [rsp+0h] [rbp-50h]\n  cocos2d::CCDictionary *v19; // [rsp+8h] [rbp-48h]\n  _QWORD __dst[2]; // [rsp+10h] [rbp-40h] BYREF\n  void *__p; // [rsp+20h] [rbp-30h]\n\n  if ( GameStatsManager::isSecretChestUnlocked(a1, a2) )\n    return nullptr;\n  v3 = cocos2d::CCDictionary::objectForKey(a1->m_allTreasureRoomChests, a2);\n  if ( !v3 )\n    return nullptr;\n  v4 = (GJRewardItem *)v3;\n  Stat = GameStatsManager::getStat(a1, \"21\");\n  m_chestID = v4->m_chestID;\n  v7 = 1;\n  if ( m_chestID <= 6000 )\n  {\n    v7 = 100;\n    if ( m_chestID <= 5000 )\n    {\n      v7 = 50;\n      if ( m_chestID <= 4000 )\n      {\n        v7 = 25;\n        if ( m_chestID <= 3000 )\n        {\n          v7 = 10;\n          if ( m_chestID <= 2000 )\n            v7 = 4 * (m_chestID >= 1001) + 1;\n        }\n      }\n    }\n  }\n  v8 = Stat < v7;\n  v9 = Stat - v7;\n  if ( v8 )\n    return nullptr;\n  GameStatsManager::setStat(a1, \"21\", v9);\n  GameStatsManager::preProcessReward(a1, v4);\n  GameStatsManager::registerRewardsFromItem(a1, v4);\n  m_treasureRoomChests = a1->m_treasureRoomChests;\n  v12 = (cocos2d::CCString *)sub_1007AB580(\"%i\", v18);\n  CString = cocos2d::CCString::getCString(v12);\n  v14 = strlen(CString);\n  if ( v14 >= 0xFFFFFFFFFFFFFFF8LL )\n    sub_100006BF0(v2);\n  v15 = v14;\n  if ( v14 >= 0x17 )\n  {\n    v19 = m_treasureRoomChests;\n    v17 = 26;\n    if ( (v14 | 7) != 0x17 )\n      v17 = (v14 | 7) + 1;\n    v16 = (char *)operator new(v17);\n    __p = v16;\n    __dst[0] = v17 + 1;\n    m_treasureRoomChests = v19;\n    __dst[1] = v15;\n    goto LABEL_19;\n  }\n  LOBYTE(__dst[0]) = 2 * v14;\n  v16 = (char *)__dst + 1;\n  if ( v14 )\nLABEL_19:\n    memmove(v16, CString, v15);\n  v16[v15] = 0;\n  cocos2d::CCDictionary::setObject_1(m_treasureRoomChests, v4, __dst);\n  if ( (__dst[0] & 1) != 0 )\n    operator delete(__p);\n  return v4;\n}", "assembly": "; \n; GameStatsManager::unlockSecretChest from 0x10008c0e0 to 0x10008c28a (426 bytes)\n; \n; 1 xrefs:\n; > SecretRewardsLayer::onSelectItem @ 0x1006348b9\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\npush    rbp                                                            ; +0x0, 0x10008c0e0\nmov     rbp, rsp                                                       ; +0x1, 0x10008c0e1\npush    r15                                                            ; +0x4, 0x10008c0e4\npush    r14                                                            ; +0x6, 0x10008c0e6\npush    r13                                                            ; +0x8, 0x10008c0e8\npush    r12                                                            ; +0xa, 0x10008c0ea\npush    rbx                                                            ; +0xc, 0x10008c0ec\nsub     rsp, 28h                                                       ; +0xd, 0x10008c0ed\nmov     r14d, esi                                                      ; +0x11, 0x10008c0f1\nmov     r15, rdi                                                       ; +0x14, 0x10008c0f4\ncall    GameStatsManager__isSecretChestUnlocked                        ; +0x17, 0x10008c0f7\ntest    al, al                                                         ; +0x1c, 0x10008c0fc\njnz     loc_10008C184                                                  ; +0x1e, 0x10008c0fe\nmov     rdi, [r15+158h]                                                ; +0x24, 0x10008c104\nmovsxd  rsi, r14d                                                      ; +0x2b, 0x10008c10b\ncall    cocos2d__CCDictionary__objectForKey                            ; +0x2e, 0x10008c10e\ntest    rax, rax                                                       ; +0x33, 0x10008c113\njz      short loc_10008C184                                            ; +0x36, 0x10008c116\nmov     rbx, rax                                                       ; +0x38, 0x10008c118\nlea     rsi, a21; \"21\"                                                 ; +0x3b, 0x10008c11b\nmov     rdi, r15                                                       ; +0x42, 0x10008c122\ncall    GameStatsManager__getStat                                      ; +0x45, 0x10008c125\nmov     ecx, [rbx+38h]                                                 ; +0x4a, 0x10008c12a\nmov     edx, 1                                                         ; +0x4d, 0x10008c12d\ncmp     ecx, 1770h                                                     ; +0x52, 0x10008c132\njg      short loc_10008C180                                            ; +0x58, 0x10008c138\nmov     edx, 64h ; 'd'                                                 ; +0x5a, 0x10008c13a\ncmp     ecx, 1388h                                                     ; +0x5f, 0x10008c13f\njg      short loc_10008C180                                            ; +0x65, 0x10008c145\nmov     edx, 32h ; '2'                                                 ; +0x67, 0x10008c147\ncmp     ecx, 0FA0h                                                     ; +0x6c, 0x10008c14c\njg      short loc_10008C180                                            ; +0x72, 0x10008c152\nmov     edx, 19h                                                       ; +0x74, 0x10008c154\ncmp     ecx, 0BB8h                                                     ; +0x79, 0x10008c159\njg      short loc_10008C180                                            ; +0x7f, 0x10008c15f\nmov     edx, 0Ah                                                       ; +0x81, 0x10008c161\ncmp     ecx, 7D0h                                                      ; +0x86, 0x10008c166\njg      short loc_10008C180                                            ; +0x8c, 0x10008c16c\nxor     edx, edx                                                       ; +0x8e, 0x10008c16e\ncmp     ecx, 3E9h                                                      ; +0x90, 0x10008c170\nsetnl   dl                                                             ; +0x96, 0x10008c176\nlea     edx, ds:1[rdx*4]                                               ; +0x99, 0x10008c179\nsub     eax, edx                                                       ; +0xa0, 0x10008c180\njge     short loc_10008C198                                            ; +0xa2, 0x10008c182\nxor     ebx, ebx                                                       ; +0xa4, 0x10008c184\nmov     rax, rbx                                                       ; +0xa6, 0x10008c186\nadd     rsp, 28h                                                       ; +0xa9, 0x10008c189\npop     rbx                                                            ; +0xad, 0x10008c18d\npop     r12                                                            ; +0xae, 0x10008c18e\npop     r13                                                            ; +0xb0, 0x10008c190\npop     r14                                                            ; +0xb2, 0x10008c192\npop     r15                                                            ; +0xb4, 0x10008c194\npop     rbp                                                            ; +0xb6, 0x10008c196\nretn                                                                   ; +0xb7, 0x10008c197\nlea     rsi, a21; \"21\"                                                 ; +0xb8, 0x10008c198\nmov     rdi, r15                                                       ; +0xbf, 0x10008c19f\nmov     edx, eax                                                       ; +0xc2, 0x10008c1a2\ncall    GameStatsManager__setStat                                      ; +0xc4, 0x10008c1a4\nmov     rdi, r15                                                       ; +0xc9, 0x10008c1a9\nmov     rsi, rbx                                                       ; +0xcc, 0x10008c1ac\ncall    GameStatsManager__preProcessReward                             ; +0xcf, 0x10008c1af\nmov     rdi, r15                                                       ; +0xd4, 0x10008c1b4\nmov     rsi, rbx                                                       ; +0xd7, 0x10008c1b7\ncall    GameStatsManager__registerRewardsFromItem                      ; +0xda, 0x10008c1ba\nmov     r15, [r15+2F0h]                                                ; +0xdf, 0x10008c1bf\nlea     rdi, aI; \"%i\"                                                  ; +0xe6, 0x10008c1c6\nmov     esi, r14d                                                      ; +0xed, 0x10008c1cd\nxor     eax, eax                                                       ; +0xf0, 0x10008c1d0\ncall    sub_1007AB580                                                  ; +0xf2, 0x10008c1d2\nmov     rdi, rax                                                       ; +0xf7, 0x10008c1d7\ncall    cocos2d__CCString__getCString                                  ; +0xfa, 0x10008c1da\nmov     r12, rax                                                       ; +0xff, 0x10008c1df\nmov     rdi, rax; __s                                                  ; +0x102, 0x10008c1e2\ncall    _strlen                                                        ; +0x105, 0x10008c1e5\ncmp     rax, 0FFFFFFFFFFFFFFF8h                                        ; +0x10a, 0x10008c1ea\njnb     loc_10008C285                                                  ; +0x10e, 0x10008c1ee\nmov     r14, rax                                                       ; +0x114, 0x10008c1f4\ncmp     rax, 17h                                                       ; +0x117, 0x10008c1f7\njnb     short loc_10008C20F                                            ; +0x11b, 0x10008c1fb\nlea     eax, [r14+r14]                                                 ; +0x11d, 0x10008c1fd\nmov     byte ptr [rbp+__dst], al                                       ; +0x121, 0x10008c201\nlea     r13, [rbp+__dst+1]                                             ; +0x124, 0x10008c204\ntest    r14, r14                                                       ; +0x128, 0x10008c208\njnz     short loc_10008C24A                                            ; +0x12b, 0x10008c20b\njmp     short loc_10008C258                                            ; +0x12d, 0x10008c20d\nmov     rax, r14                                                       ; +0x12f, 0x10008c20f\nor      rax, 7                                                         ; +0x132, 0x10008c212\nlea     rcx, [rax+1]                                                   ; +0x136, 0x10008c216\ncmp     rax, 17h                                                       ; +0x13a, 0x10008c21a\nmov     [rbp+var_48], r15                                              ; +0x13e, 0x10008c21e\nmov     r15d, 1Ah                                                      ; +0x142, 0x10008c222\ncmovnz  r15, rcx                                                       ; +0x148, 0x10008c228\nmov     rdi, r15; __sz                                                 ; +0x14c, 0x10008c22c\ncall    __Znwm; operator new(ulong)                                    ; +0x14f, 0x10008c22f\nmov     r13, rax                                                       ; +0x154, 0x10008c234\nmov     [rbp+__p], rax                                                 ; +0x157, 0x10008c237\ninc     r15                                                            ; +0x15b, 0x10008c23b\nmov     [rbp+__dst], r15                                               ; +0x15e, 0x10008c23e\nmov     r15, [rbp+var_48]                                              ; +0x162, 0x10008c242\nmov     [rbp+var_38], r14                                              ; +0x166, 0x10008c246\nmov     rdi, r13; __dst                                                ; +0x16a, 0x10008c24a\nmov     rsi, r12; __src                                                ; +0x16d, 0x10008c24d\nmov     rdx, r14; __len                                                ; +0x170, 0x10008c250\ncall    _memmove                                                       ; +0x173, 0x10008c253\nmov     byte ptr [r13+r14+0], 0                                        ; +0x178, 0x10008c258\nlea     rdx, [rbp+__dst]                                               ; +0x17e, 0x10008c25e\nmov     rdi, r15                                                       ; +0x182, 0x10008c262\nmov     rsi, rbx                                                       ; +0x185, 0x10008c265\ncall    cocos2d__CCDictionary__setObject_1                             ; +0x188, 0x10008c268\ntest    byte ptr [rbp+__dst], 1                                        ; +0x18d, 0x10008c26d\njz      loc_10008C186                                                  ; +0x191, 0x10008c271\nmov     rdi, [rbp+__p]; __p                                            ; +0x197, 0x10008c277\ncall    __ZdlPv; operator delete(void *)                               ; +0x19b, 0x10008c27b\njmp     loc_10008C186                                                  ; +0x1a0, 0x10008c280\ncall    sub_100006BF0                                                  ; +0x1a5, 0x10008c285", "xrefs": ["SecretRewardsLayer::onSelectItem @ 0x1006348b9"], "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"}