Fix Great Offshop Memory Leak

  • Autor subiect Petrinel
  • Dată creare
  • Răspunsuri: Răspunsuri 1
  • Vizualizări: Vizualizări 2K

Petrinel

Well-known member
29 Aug 2020
159
707
93
23
Falciu
Monede Dragon
0
If you use SQLMsg* pkMsg(DBManager::instance().DirectQuery

Cod:
void CHARACTER::UpdateShopItems()

At the End:
delete Msg;

#######################################################
void CHARACTER::LoadPrivShops()

At the End:
delete pkMsg;

#######################################################
void CHARACTER::OpenShop(DWORD id, const char* name, bool onboot)

At the End:
pkMsg.reset(nullptr);

#######################################################
ACMD(do_shop_update_item)

After:
                    if (CHARACTER_MANAGER::instance().GetCharactersByRaceNum(30000, i))
                    {
                        CharacterVectorInteractor::iterator it = i.begin();
                        while (it != i.end())
                        {
                            LPCHARACTER pc = *it++;
                            if (pc)
                                if (pc->GetRaceNum() == 30000 && pc->GetPrivShop() == shop_id)
                                {
                                    pc->UpdateShopItems();
                                    return;
                                }
                        }
                    }
Add:
                    delete pkMsg;                   

After:
                    if (CHARACTER_MANAGER::instance().GetCharactersByRaceNum(30000, i))
                    {
                        CharacterVectorInteractor::iterator it = i.begin();
                        while (it != i.end())
                        {
                            LPCHARACTER pc = *it++;
                            if (pc)
                                if (pc->GetRaceNum() == 30000 && pc->GetPrivShop() == shop_id)
                                {
                                    pc->UpdateShopItems();
                                    return;
                                }
                        }
                    }
Add:
                    delete pkMsg;
                    
After:
                            TPacketShopUpdateItem packet;
                            packet.shop_id = shop_id;
                            db_clientdesc->DBPacket(HEADER_GD_SHOP_UPDATE_ITEM, 0, &packet, sizeof(packet));
                    }
                }
Add:
                delete pkMsg;
                    
#######################################################   
ACMD(do_shop_refresh_items)   

At the End:
delete pkMsg;

#######################################################   
EVENTFUNC(fix_shop_event)

Before:
    return PASSES_PER_SEC(SHOP_TIME_REFRESH * 60);
Insert:
    delete pkMsg;

trebuie c++11