{"type": "func", "start": 4295147760, "end": 4295148182, "name": "GameStatsManager::purchaseItem", "pseudocode": "// \n// GameStatsManager::purchaseItem from 0x10002c0f0 to 0x10002c296 (422 bytes)\n// \n// 1 xrefs:\n// > PurchaseItemPopup::onPurchase @ 0x100313d24\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 12:19:27 +0000\n// \n\n__int64 __fastcall GameStatsManager::purchaseItem(__int64 a1, int a2)\n{\n  unsigned int v2; // ebx\n  __int64 v3; // rax\n  __int64 v4; // r15\n  __int16 v5; // cx\n  int Stat; // eax\n  int v7; // ecx\n  bool v8; // cc\n  unsigned int v9; // eax\n  __int64 v10; // rax\n  const char *CString; // r12\n  size_t v12; // rax\n  size_t v13; // r13\n  char *v14; // r14\n  size_t v16; // r15\n  char v17; // [rsp+0h] [rbp-70h]\n  char v18; // [rsp+0h] [rbp-70h]\n  __int64 v19; // [rsp+8h] [rbp-68h]\n  __int64 v20; // [rsp+10h] [rbp-60h]\n  __int16 v21; // [rsp+19h] [rbp-57h] BYREF\n  char v22; // [rsp+1Bh] [rbp-55h]\n  _QWORD __dst[2]; // [rsp+30h] [rbp-40h] BYREF\n  void *__p; // [rsp+40h] [rbp-30h]\n\n  if ( a2 <= 0 )\n    return 0;\n  if ( GameStatsManager::isStoreItemUnlocked(a1) )\n    return 0;\n  v3 = cocos2d::CCDictionary::objectForKey_1(*(_QWORD *)(a1 + 336));\n  if ( !v3 )\n    return 0;\n  v4 = v3;\n  v5 = 13361;\n  if ( *(_DWORD *)(v3 + 364) == 4 )\n    v5 = 14642;\n  v21 = v5;\n  v22 = 0;\n  Stat = GameStatsManager::getStat(a1, &v21);\n  v7 = *(_DWORD *)(v4 + 352) - *(_DWORD *)(v4 + 356);\n  v8 = Stat < v7;\n  v9 = Stat - v7;\n  LOBYTE(v2) = !v8;\n  if ( !v8 )\n  {\n    GameStatsManager::setStat(a1, &v21, v9);\n    v19 = *(_QWORD *)(a1 + 632);\n    v20 = sub_10088E820(\"%i\", v17);\n    v10 = sub_10088E820(\"%i\", v18);\n    CString = (const char *)cocos2d::CCString::getCString(v10);\n    v12 = strlen(CString);\n    if ( v12 >= 0xFFFFFFFFFFFFFFF8LL )\n      sub_100003630();\n    v13 = v12;\n    if ( v12 >= 0x17 )\n    {\n      v16 = 26;\n      if ( (v12 | 7) != 0x17 )\n        v16 = (v12 | 7) + 1;\n      v14 = (char *)operator new(v16);\n      __p = v14;\n      __dst[0] = v16 | 1;\n      __dst[1] = v13;\n    }\n    else\n    {\n      LOBYTE(__dst[0]) = 2 * v12;\n      v14 = (char *)__dst + 1;\n      if ( !v12 )\n      {\nLABEL_17:\n        v14[v13] = 0;\n        cocos2d::CCDictionary::setObject(v19, v20, __dst);\n        if ( (__dst[0] & 1) != 0 )\n          operator delete(__p);\n        return v2;\n      }\n    }\n    memmove(v14, CString, v13);\n    goto LABEL_17;\n  }\n  return v2;\n}", "assembly": "; \n; GameStatsManager::purchaseItem from 0x10002c0f0 to 0x10002c296 (422 bytes)\n; \n; 1 xrefs:\n; > PurchaseItemPopup::onPurchase @ 0x100313d24\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 12:19:27 +0000\n; \npush    rbp                                                            ; +0x0, 0x10002c0f0\nmov     rbp, rsp                                                       ; +0x1, 0x10002c0f1\npush    r15                                                            ; +0x4, 0x10002c0f4\npush    r14                                                            ; +0x6, 0x10002c0f6\npush    r13                                                            ; +0x8, 0x10002c0f8\npush    r12                                                            ; +0xa, 0x10002c0fa\npush    rbx                                                            ; +0xc, 0x10002c0fc\nsub     rsp, 48h                                                       ; +0xd, 0x10002c0fd\ntest    esi, esi                                                       ; +0x11, 0x10002c101\njle     loc_10002C203                                                  ; +0x13, 0x10002c103\nmov     r12d, esi                                                      ; +0x19, 0x10002c109\nmov     r14, rdi                                                       ; +0x1c, 0x10002c10c\ncall    GameStatsManager__isStoreItemUnlocked                          ; +0x1f, 0x10002c10f\ntest    al, al                                                         ; +0x24, 0x10002c114\njnz     loc_10002C203                                                  ; +0x26, 0x10002c116\nmov     rdi, [r14+150h]                                                ; +0x2c, 0x10002c11c\nmov     esi, r12d                                                      ; +0x33, 0x10002c123\ncall    cocos2d__CCDictionary__objectForKey_1                          ; +0x36, 0x10002c126\ntest    rax, rax                                                       ; +0x3b, 0x10002c12b\njz      loc_10002C203                                                  ; +0x3e, 0x10002c12e\nmov     r15, rax                                                       ; +0x44, 0x10002c134\ncmp     dword ptr [rax+16Ch], 4                                        ; +0x47, 0x10002c137\nmov     [rbp+var_58], 4                                                ; +0x4e, 0x10002c13e\nlea     r13, [rbp+var_57]                                              ; +0x52, 0x10002c142\nmov     eax, 3932h                                                     ; +0x56, 0x10002c146\nmov     ecx, 3431h                                                     ; +0x5b, 0x10002c14b\ncmovz   ecx, eax                                                       ; +0x60, 0x10002c150\nmov     [rbp+var_57], cx                                               ; +0x63, 0x10002c153\nmov     [rbp+var_55], 0                                                ; +0x67, 0x10002c157\nmov     rdi, r14                                                       ; +0x6b, 0x10002c15b\nmov     rsi, r13                                                       ; +0x6e, 0x10002c15e\ncall    GameStatsManager__getStat                                      ; +0x71, 0x10002c161\nmov     ecx, [r15+160h]                                                ; +0x76, 0x10002c166\nsub     ecx, [r15+164h]                                                ; +0x7d, 0x10002c16d\nsub     eax, ecx                                                       ; +0x84, 0x10002c174\nsetnl   bl                                                             ; +0x86, 0x10002c176\njl      loc_10002C205                                                  ; +0x89, 0x10002c179\nmov     rdi, r14                                                       ; +0x8f, 0x10002c17f\nmov     rsi, r13                                                       ; +0x92, 0x10002c182\nmov     edx, eax                                                       ; +0x95, 0x10002c185\ncall    GameStatsManager__setStat                                      ; +0x97, 0x10002c187\nmov     rax, [r14+278h]                                                ; +0x9c, 0x10002c18c\nmov     [rbp+var_68], rax                                              ; +0xa3, 0x10002c193\nmov     esi, [r15+160h]                                                ; +0xa7, 0x10002c197\nsub     esi, [r15+164h]                                                ; +0xae, 0x10002c19e\nlea     r14, aI_14; \"%i\"                                               ; +0xb5, 0x10002c1a5\nmov     rdi, r14; __format                                             ; +0xbc, 0x10002c1ac\nxor     eax, eax                                                       ; +0xbf, 0x10002c1af\ncall    sub_10088E820                                                  ; +0xc1, 0x10002c1b1\nmov     [rbp+var_60], rax                                              ; +0xc6, 0x10002c1b6\nmov     rdi, r14; __format                                             ; +0xca, 0x10002c1ba\nmov     esi, r12d                                                      ; +0xcd, 0x10002c1bd\nxor     eax, eax                                                       ; +0xd0, 0x10002c1c0\ncall    sub_10088E820                                                  ; +0xd2, 0x10002c1c2\nmov     rdi, rax                                                       ; +0xd7, 0x10002c1c7\ncall    cocos2d__CCString__getCString                                  ; +0xda, 0x10002c1ca\nmov     r12, rax                                                       ; +0xdf, 0x10002c1cf\nmov     rdi, rax; __s                                                  ; +0xe2, 0x10002c1d2\ncall    _strlen                                                        ; +0xe5, 0x10002c1d5\ncmp     rax, 0FFFFFFFFFFFFFFF8h                                        ; +0xea, 0x10002c1da\njnb     loc_10002C291                                                  ; +0xee, 0x10002c1de\nmov     r13, rax                                                       ; +0xf4, 0x10002c1e4\ncmp     rax, 17h                                                       ; +0xf7, 0x10002c1e7\njnb     short loc_10002C216                                            ; +0xfb, 0x10002c1eb\nlea     eax, ds:0[r13*2]                                               ; +0xfd, 0x10002c1ed\nmov     byte ptr [rbp+__dst], al                                       ; +0x105, 0x10002c1f5\nlea     r14, [rbp+__dst+1]                                             ; +0x108, 0x10002c1f8\ntest    r13, r13                                                       ; +0x10c, 0x10002c1fc\njnz     short loc_10002C24A                                            ; +0x10f, 0x10002c1ff\njmp     short loc_10002C258                                            ; +0x111, 0x10002c201\nxor     ebx, ebx                                                       ; +0x113, 0x10002c203\nmov     eax, ebx                                                       ; +0x115, 0x10002c205\nadd     rsp, 48h                                                       ; +0x117, 0x10002c207\npop     rbx                                                            ; +0x11b, 0x10002c20b\npop     r12                                                            ; +0x11c, 0x10002c20c\npop     r13                                                            ; +0x11e, 0x10002c20e\npop     r14                                                            ; +0x120, 0x10002c210\npop     r15                                                            ; +0x122, 0x10002c212\npop     rbp                                                            ; +0x124, 0x10002c214\nretn                                                                   ; +0x125, 0x10002c215\nmov     rax, r13                                                       ; +0x126, 0x10002c216\nor      rax, 7                                                         ; +0x129, 0x10002c219\nlea     rcx, [rax+1]                                                   ; +0x12d, 0x10002c21d\ncmp     rax, 17h                                                       ; +0x131, 0x10002c221\nmov     r15d, 1Ah                                                      ; +0x135, 0x10002c225\ncmovnz  r15, rcx                                                       ; +0x13b, 0x10002c22b\nmov     rdi, r15; __sz                                                 ; +0x13f, 0x10002c22f\ncall    __Znwm; operator new(ulong)                                    ; +0x142, 0x10002c232\nmov     r14, rax                                                       ; +0x147, 0x10002c237\nmov     [rbp+__p], rax                                                 ; +0x14a, 0x10002c23a\nor      r15, 1                                                         ; +0x14e, 0x10002c23e\nmov     [rbp+__dst], r15                                               ; +0x152, 0x10002c242\nmov     [rbp+var_38], r13                                              ; +0x156, 0x10002c246\nmov     rdi, r14; __dst                                                ; +0x15a, 0x10002c24a\nmov     rsi, r12; __src                                                ; +0x15d, 0x10002c24d\nmov     rdx, r13; __len                                                ; +0x160, 0x10002c250\ncall    _memmove                                                       ; +0x163, 0x10002c253\nmov     byte ptr [r14+r13], 0                                          ; +0x168, 0x10002c258\nlea     rdx, [rbp+__dst]                                               ; +0x16d, 0x10002c25d\nmov     rdi, [rbp+var_68]                                              ; +0x171, 0x10002c261\nmov     rsi, [rbp+var_60]                                              ; +0x175, 0x10002c265\ncall    cocos2d__CCDictionary__setObject                               ; +0x179, 0x10002c269\ntest    byte ptr [rbp+__dst], 1                                        ; +0x17e, 0x10002c26e\njz      short loc_10002C27D                                            ; +0x182, 0x10002c272\nmov     rdi, [rbp+__p]; __p                                            ; +0x184, 0x10002c274\ncall    __ZdlPv; operator delete(void *)                               ; +0x188, 0x10002c278\ntest    [rbp+var_58], 1                                                ; +0x18d, 0x10002c27d\njz      short loc_10002C205                                            ; +0x191, 0x10002c281\nmov     rdi, [rbp+var_48]; __p                                         ; +0x193, 0x10002c283\ncall    __ZdlPv; operator delete(void *)                               ; +0x197, 0x10002c287\njmp     loc_10002C205                                                  ; +0x19c, 0x10002c28c\ncall    sub_100003630                                                  ; +0x1a1, 0x10002c291", "xrefs": ["PurchaseItemPopup::onPurchase @ 0x100313d24"], "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"}