What's new
What's new

New messages New topics Systems Serverfiles 3D Models Web Scripting

Metin2Resources

👋 Welcome to Metin2 Resources — your hub for professional Metin2 server development.

Create a free account to access advanced systems, serverfiles, tutorials and connect with other developers.

🚀 Join today and start building better.

[C++] Cube renewal memory leak fix

JIGSAW

Be the best, Ignore the rest.
Staff member
Admin
Premium
📜 Messages 226
👍 Reactions 1,645
🏆 Points 425
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.
 
Back
Top Bottom