Honorable Member Mali 41912 Posted March 7, 2020 Honorable Member Share Posted March 7, 2020 (edited) This is the hidden content, please Sign In or Sign Up Edited March 14, 2023 by Mali 39 2 8 26 Link to comment Share on other sites More sharing options...
Active Member Exygo 1091 Posted March 25, 2020 Active Member Share Posted March 25, 2020 if (inv_item->GetType() == ITEM_BLEND && inv_item->GetVnum() == item->GetVnum()) { if (inv_item->GetCount() + item->GetCount() <= ITEM_MAX_COUNT && FN_compare_item_socket(inv_item, item)) { inv_item->SetCount(inv_item->GetCount() + item->GetCount()); return inv_item; } } 1 https://www.youtube.com/channel/UCQ8mAeda9TWq6SsTzB53emw/videos Link to comment Share on other sites More sharing options...
Forum Moderator VegaS™ 10280 Posted March 25, 2020 Forum Moderator Share Posted March 25, 2020 (edited) For those who need FN_compare_item_socket function and also with fixed 'memory leak' which already is public. Srcs/game/src/char_item.cpp 1.0) Add at the beginning of file: static bool FN_compare_item_socket(const LPITEM pkItemSrc, const LPITEM pkItemDest) { if (!pkItemSrc || !pkItemDest) return false; return memcmp(pkItemSrc->GetSockets(), pkItemDest->GetSockets(), sizeof(long) * ITEM_SOCKET_MAX_NUM) == 0; } 2.0) Search for: Spoiler if (inv_item->GetType() == ITEM_BLEND) { if (inv_item->GetVnum() == item->GetVnum()) { if (inv_item->GetSocket(0) == item->GetSocket(0) && inv_item->GetSocket(1) == item->GetSocket(1) && inv_item->GetSocket(2) == item->GetSocket(2) && inv_item->GetCount() < ITEM_MAX_COUNT) { inv_item->SetCount(inv_item->GetCount() + item->GetCount()); return inv_item; } } } 2.1) Replace it with: This is the hidden content, please Sign In or Sign Up Edited December 3, 2020 by VegaS™ 42 1 1 1 1 11 2 34 Check my GitHub Profile Click to find all the threads started by me [TOOL] Text file loader + JSON Link to comment Share on other sites More sharing options...
Active Member Exygo 1091 Posted March 26, 2020 Active Member Share Posted March 26, 2020 (edited) 15 hours ago, VegaS™ said: For those who need FN_compare_item_socket function and also with fixed memory leak which already is public. Where is the memory leak exactly ? There are just 2 LPITEM pointers entering in the function arguments, there is no "new" operator there .. Maybe you were reffering to the memory leak of the blend item load function. Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal https://www.youtube.com/channel/UCQ8mAeda9TWq6SsTzB53emw/videos Link to comment Share on other sites More sharing options...
Honorable Member Mali 41912 Posted March 26, 2020 Author Honorable Member Share Posted March 26, 2020 (edited) 51 minutes ago, Exygo said: Where is the memory leak exactly ? There are just 2 LPITEM pointers entering in the function arguments, there is no "new" operator there .. Maybe you were reffering to the memory leak of the blend item load function. He is talking about this topic Actually there isn't a real memory leak there. Because CreateItem function is creating new CItem() and saving object to the m_VIDMap. And look what is going on there Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Sherer 482 Posted March 26, 2020 Share Posted March 26, 2020 (edited) 3 hours ago, Mali61 said: He is talking about this topic Actually there isn't a real memory leak there. Because CreateItem function is creating new CItem() and saving object to the m_VIDMap. And look what is going on there Still, better to keep unused object deleted rather than keep them scrapping in memory. Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Honorable Member Mali 41912 Posted March 26, 2020 Author Honorable Member Share Posted March 26, 2020 3 minutes ago, Sherer said: Still, better to keep unused object deleted rather than keep them scrapping in memory. That is why I said there isn't a real memory leak there Link to comment Share on other sites More sharing options...
Sebypunct 24 Posted March 26, 2020 Share Posted March 26, 2020 (edited) Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Active Member Exygo 1091 Posted March 26, 2020 Active Member Share Posted March 26, 2020 (edited) by the way memcmp it's not for comparing item socket sadly .. Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal https://www.youtube.com/channel/UCQ8mAeda9TWq6SsTzB53emw/videos Link to comment Share on other sites More sharing options...
Honorable Member Mali 41912 Posted March 26, 2020 Author Honorable Member Share Posted March 26, 2020 (edited) 26 minutes ago, Exygo said: by the way memcmp it's not for comparing item socket sadly .. because memcmp usage is wrong, must be 0 if equals Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal 1 Link to comment Share on other sites More sharing options...
Active Member Exygo 1091 Posted March 26, 2020 Active Member Share Posted March 26, 2020 no, the problem is that memcmp must not be used to compare item socket .. https://www.youtube.com/channel/UCQ8mAeda9TWq6SsTzB53emw/videos Link to comment Share on other sites More sharing options...
Forum Moderator VegaS™ 10280 Posted March 26, 2020 Forum Moderator Share Posted March 26, 2020 (edited) 31 minutes ago, Exygo said: by the way memcmp it's not for comparing item socket https://en.cppreference.com/w/cpp/string/byte/memcmp #define ITEM_SOCKET_MAX_NUM 3 int main() { long lSockets[ITEM_SOCKET_MAX_NUM] = { 1, 2, 3 }; long lSockets2[ITEM_SOCKET_MAX_NUM] = { 1, 2, 3 }; cout << (memcmp(lSockets, lSockets2, sizeof(long) * ITEM_SOCKET_MAX_NUM) == 0) << endl; return 0; } //>> 1 Edited March 26, 2020 by VegaS™ 3 Check my GitHub Profile Click to find all the threads started by me [TOOL] Text file loader + JSON Link to comment Share on other sites More sharing options...
Honorable Member Mali 41912 Posted March 26, 2020 Author Honorable Member Share Posted March 26, 2020 (edited) 3 minutes ago, Exygo said: no, the problem is that memcmp must not be used to compare item socket .. db/Cache.cpp - OnFlush() Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Active Member Exygo 1091 Posted March 26, 2020 Active Member Share Posted March 26, 2020 You don't need to post another example, I just gaved you one directly from the game. https://www.youtube.com/channel/UCQ8mAeda9TWq6SsTzB53emw/videos Link to comment Share on other sites More sharing options...
Sherer 482 Posted March 27, 2020 Share Posted March 27, 2020 21 hours ago, Mali61 said: That is why I said there isn't a real memory leak there Nowadays with so many system collectors (like built-in unix/windows) there isn't a real memory leak at all. On the other hand if you keep stacking those unused items, memory will may grow to ridiculous values. Same outcome you are going to have because of classic memory leak - a lot of memory is allocated most of them is junked. 1 Link to comment Share on other sites More sharing options...
66Dragon99 273 Posted October 23, 2020 Share Posted October 23, 2020 (edited) sounds fun thanks for the topic. 00 have you seen the CSafebox::ChangeSize memory leak? Edited October 24, 2020 by 66Dragon99 Link to comment Share on other sites More sharing options...
Recommended Posts