Bot Metin2 Dev 4874 Posted March 25, 2015 Bot Share Posted March 25, 2015 Based on the github sourcecode this should be correct. bool CExchange::CheckSpace() { static CGrid s_grid1(5, INVENTORY_MAX_NUM / 5 / 4); // inven page 1 9 Rows a 5 Columns static CGrid s_grid2(5, INVENTORY_MAX_NUM / 5 / 4); // inven page 2 9 Rows a 5 Columns static CGrid s_grid3(5, INVENTORY_MAX_NUM / 5 / 4); // inven page 3 9 Rows a 5 Columns static CGrid s_grid4(5, INVENTORY_MAX_NUM / 5 / 4); // inven page 4 9 Rows a 5 Columns s_grid1.Clear(); s_grid2.Clear(); s_grid3.Clear(); s_grid4.Clear(); LPCHARACTER victim = GetCompany()->GetOwner(); LPITEM item; int i; const int perPageSlotCount = INVENTORY_MAX_NUM / 4; for (i = 0; i < INVENTORY_MAX_NUM; ++i) { if (!(item = victim->GetInventoryItem(i))) continue; BYTE itemSize = item->GetSize(); if (i < perPageSlotCount) // Notice: This is adjusted for 4 Pages only! s_grid1.Put(i, 1, itemSize); else if (i < perPageSlotCount * 2) s_grid2.Put(i - perPageSlotCount, 1, itemSize); else if (i < perPageSlotCount * 3) s_grid3.Put(i - perPageSlotCount * 2, 1, itemSize); else s_grid4.Put(i - perPageSlotCount * 3, 1, itemSize); } static std::vector <WORD> s_vDSGrid(DRAGON_SOUL_INVENTORY_MAX_NUM); bool bDSInitialized = false; for (i = 0; i < EXCHANGE_ITEM_MAX_NUM; ++i) { if (!(item = m_apItems[i])) continue; BYTE itemSize = item->GetSize(); if (item->IsDragonSoul()) { if (!victim->DragonSoul_IsQualified()) return false; if (!bDSInitialized) { bDSInitialized = true; victim->CopyDragonSoulItemGrid(s_vDSGrid); } bool bExistEmptySpace = false; WORD wBasePos = DSManager::instance().GetBasePosition(item); if (wBasePos >= DRAGON_SOUL_INVENTORY_MAX_NUM) return false; for (int i = 0; i < DRAGON_SOUL_BOX_SIZE; i++) { WORD wPos = wBasePos + i; if (0 == s_vDSGrid[wBasePos]) { bool bEmpty = true; for (int j = 1; j < item->GetSize(); j++) { if (s_vDSGrid[wPos + j * DRAGON_SOUL_BOX_COLUMN_NUM]) { bEmpty = false; break; } } if (bEmpty) { for (int j = 0; j < item->GetSize(); j++) { s_vDSGrid[wPos + j * DRAGON_SOUL_BOX_COLUMN_NUM] = wPos + 1; } bExistEmptySpace = true; break; } } if (bExistEmptySpace) break; } if (!bExistEmptySpace) return false; } else { int iPos = s_grid1.FindBlank(1, itemSize); if (iPos >= 0) { s_grid1.Put(iPos, 1, itemSize); continue; } iPos = s_grid2.FindBlank(1, itemSize); if (iPos >= 0) { s_grid2.Put(iPos, 1, itemSize); continue; } iPos = s_grid3.FindBlank(1, itemSize); if (iPos >= 0) { s_grid3.Put(iPos, 1, itemSize); continue; } iPos = s_grid4.FindBlank(1, itemSize); if (iPos >= 0) { s_grid4.Put(iPos, 1, itemSize); continue; } return false; // No space left in inventory } } return true; } PS: If there are any errors please report them asap because i have no way to test this. Kind regards MartPwnS Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted March 25, 2015 Premium Share Posted March 25, 2015 cBaran version wasn't doing anything. He added a variable, but never used it. Your code is working for sure. Great job Link to comment Share on other sites More sharing options...
Think 117 Posted March 25, 2015 Share Posted March 25, 2015 Looks almost good to me: INVENTORY_MAX_NUM /5 / 2 Should be / 5 / 4 1 Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4874 Posted March 25, 2015 Author Bot Share Posted March 25, 2015 Looks almost good to me: INVENTORY_MAX_NUM /5 / 2 Should be / 5 / 4 Thanks (Team)Mate I even wrote the correct thing <.< Link to comment Share on other sites More sharing options...
JinHan 187 Posted March 25, 2015 Share Posted March 25, 2015 (edited) https://metin2.download/picture/Fdye8KwanpW5vd0fxcLqSk8LMqSWKPec/.png Edited August 30, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4874 Posted March 25, 2015 Author Bot Share Posted March 25, 2015 Can someone maybe provide the clean source code for that function everyone is using this is a WoM custom function <.< Link to comment Share on other sites More sharing options...
Morphe 159 Posted March 25, 2015 Share Posted March 25, 2015 Good job. Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted March 25, 2015 Premium Share Posted March 25, 2015 Can someone maybe provide the clean source code for that function everyone is using this is a WoM custom function <.< if (!(item = m_apItems[i])) continue; instead of if (!(item = GetCompany()->GetItemByPosition(i))) continue; EDIT: Nvm Link to comment Share on other sites More sharing options...
ѕeмa™ 308 Posted March 25, 2015 Share Posted March 25, 2015 Can someone maybe provide the clean source code for that function everyone is using this is a WoM custom function <.< *EDIT: Fail. 1 https://m2admin.net/ Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4874 Posted March 25, 2015 Author Bot Share Posted March 25, 2015 Ok fixed version up there thanks to Cataclisimo for the original function. Link to comment Share on other sites More sharing options...
Ken 904 Posted March 25, 2015 Share Posted March 25, 2015 (edited) Everyone is understand cbaran's function is not provide anything to you. I am only see one variable is defined in cpp file and any function or condition is not call this. Actually one thing is too strange (Everyone thank to him) Mostly people understand these codes doing nothing Btw thanks for share to us. Kind Regards Ken Edited March 25, 2015 by Ken Do not be sorry, be better. Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted March 25, 2015 Premium Share Posted March 25, 2015 Ok fixed version up there thanks to Cataclisimo for the original function. Ahahaha. People always write my name wrong xD Also, in the clean code it's checked the victim (i think), not the owner: LPCHARACTER victim = GetCompany()->GetOwner(); Can you check that too? Link to comment Share on other sites More sharing options...
Syron 296 Posted March 25, 2015 Share Posted March 25, 2015 Any possible to adapt this for any number of inventories ? Trying to understand the code... Link to comment Share on other sites More sharing options...
Think 117 Posted March 25, 2015 Share Posted March 25, 2015 Yeah, you are right @Cataclismo. WoM's logic is changed a bit, thus the difference. The problems of helping out after you change a few things xD That's the reason for the GetCompany in if (!(item = GetCompany()->GetItemByPosition(i))) Link to comment Share on other sites More sharing options...
Premium Galet 510 Posted March 25, 2015 Premium Share Posted March 25, 2015 Where's your code ? Anyway, I don't have this bug I think Link to comment Share on other sites More sharing options...
Think 117 Posted March 25, 2015 Share Posted March 25, 2015 Where's your code ? Anyway, I don't have this bug I think If you don't use more than 2 inventories you don't. If you do, and you didn't patch it, you do. Link to comment Share on other sites More sharing options...
ScreamMyName 100 Posted March 25, 2015 Share Posted March 25, 2015 Where's your code ? Anyway, I don't have this bug I think Yeah i don't have it either dunno how everyone else have it lol. 1 Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4874 Posted March 25, 2015 Author Bot Share Posted March 25, 2015 Sorry dudes the "classic" version is up now. Link to comment Share on other sites More sharing options...
Premium Galet 510 Posted March 25, 2015 Premium Share Posted March 25, 2015 I have 4 inventory page, but I've modified some things, I don't know if I have this bug or not Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted March 25, 2015 Premium Share Posted March 25, 2015 I have 4 inventory page, but I've modified some things, I don't know if I have this bug or not Then check your code. @Think, Oh. That's nice. Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4874 Posted March 25, 2015 Author Bot Share Posted March 25, 2015 Fill up the first 2 Inventory pages if it returns that you have no inventory space you have this bug. Link to comment Share on other sites More sharing options...
ScreamMyName 100 Posted March 25, 2015 Share Posted March 25, 2015 Where's your code ? Anyway, I don't have this bug I think If you don't use more than 2 inventories you don't. If you do, and you didn't patch it, you do. I have 4 inventories and I've just tested twice and I don't have this.. all I did is copied the loop that was used for inventory 1 and 2 and change it a little bit so it works with 4 inventories. Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4874 Posted March 25, 2015 Author Bot Share Posted March 25, 2015 Ofc you dont have it you fixed it with that xD Mine is just a refined version of the one CBaran didnt provide in his first edit. He now edited his post and provided the "ugly" version with the nested if / else conditions and multiple for loops which i wanted to avoid. Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted March 25, 2015 Premium Share Posted March 25, 2015 Ofc you dont have it you fixed it with that xD Mine is just a refined version of the one CBaran didnt provide in his first edit. He now edited his post and provided the "ugly" version with the nested if / else conditions and multiple for loops which i wanted to avoid. Very ugly xD Link to comment Share on other sites More sharing options...
ѕeмa™ 308 Posted March 26, 2015 Share Posted March 26, 2015 (edited) Edited August 19, 2022 by Metin2 Dev Core X - External 2 Internal https://m2admin.net/ Link to comment Share on other sites More sharing options...
Recommended Posts