What's new

New messages New topics Systems Serverfiles 3D Models Web Scripting

[C++] Cube renewal memory leak fix

JIGSAW

Be the best, Ignore the rest.
Staff member
Administrator
Premium
Joined
Jul 14, 2025
Messages
134
Reaction score
1,099
Points
93
Discord
jigsaw86
Replace
Code:
            LPITEM item = ITEM_MANAGER::instance().CreateItem(materialInfo.reward.vnum, materialInfo.reward.count);
            if (item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK)){
                pack.date_cube_renewal.item_reward_stackable = true;
            }else{
                pack.date_cube_renewal.item_reward_stackable = false;
            }

With

Code:
            auto item = ITEM_MANAGER::instance().GetTable(materialInfo.reward.vnum);
            if (!item)
            {
                sys_err("%s: unknown material vnum (reward vnum %u) (category %s)", ch->GetName(), materialInfo.reward.vnum, materialInfo.category.c_str());
                continue;
            }
            pack.date_cube_renewal.item_reward_stackable = IS_SET(item->dwFlags, ITEM_FLAG_STACKABLE) && !IS_SET(item->dwAntiFlags, ITEM_ANTIFLAG_STACK);

What does it do?

- Previously, an item was created just to check if it was stackable and it remained in memory.
 
shape1
shape2
shape3
shape4
shape5
shape6
Top