vagabond20 102 Posted March 26, 2015 Share Posted March 26, 2015 I read the version of CBaran (The old one which he now edited away and corrected after i posted) and it didnt really make a lot of sense to me so well here is mine: If someone is able to test this great i did not because we dont need 4 inventories at WoM 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 bool CExchange::CheckSpace() // vagabond20 4 env. { static CGrid s_grid1(5, INVENTORY_MAX_NUM/5 / 4); // inven page 1 static CGrid s_grid2(5, INVENTORY_MAX_NUM/5 / 4); // inven page 2 static CGrid s_grid3(5, INVENTORY_MAX_NUM/5 / 4); // inven page 3 static CGrid s_grid4(5, INVENTORY_MAX_NUM/5 / 4); // inven page 4 s_grid1.Clear(); s_grid2.Clear(); s_grid3.Clear(); s_grid4.Clear(); LPCHARACTER victim = GetCompany()->GetOwner(); LPITEM item; int i; for (i = 0; i < INVENTORY_MAX_NUM / 4; ++i) { if (!(item = victim->GetInventoryItem(i))) continue; s_grid1.Put(i, 1, item->GetSize()); } for (i = INVENTORY_MAX_NUM / 4; i < INVENTORY_MAX_NUM / 2; ++i) { if (!(item = victim->GetInventoryItem(i))) continue; s_grid2.Put(i - INVENTORY_MAX_NUM / 4, 1, item->GetSize()); } for (i = INVENTORY_MAX_NUM / 2; i < (INVENTORY_MAX_NUM / 4) * 3; ++i) { if (!(item = victim->GetInventoryItem(i))) continue; s_grid3.Put(i - INVENTORY_MAX_NUM / 2, 1, item->GetSize()); } for (i = (INVENTORY_MAX_NUM / 4) * 3; i < INVENTORY_MAX_NUM; ++i) { if (!(item = victim->GetInventoryItem(i))) continue; s_grid4.Put(i - (INVENTORY_MAX_NUM / 4) * 3, 1, item->GetSize()); } // ¾Æ... ¹º°¡ °³º´½Å °°Áö¸¸... ¿ëÈ¥¼® Àκ¥À» ³ë¸Ö Àκ¥ º¸°í µû¶ó ¸¸µç ³» À߸øÀÌ´Ù ¤Ğ¤Ğ 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; 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, item->GetSize()); if (iPos >= 0) { s_grid1.Put(iPos, 1, item->GetSize()); } else { iPos = s_grid2.FindBlank(1, item->GetSize()); if (iPos >= 0) { s_grid2.Put(iPos, 1, item->GetSize()); } else { iPos = s_grid3.FindBlank(1, item->GetSize()); if (iPos >= 0) { s_grid3.Put(iPos, 1, item->GetSize()); } else { iPos = s_grid4.FindBlank(1, item->GetSize()); if (iPos >= 0) { s_grid4.Put(iPos, 1, item->GetSize()); } else { return false; } } } } } } return true; } 1 Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4881 Posted March 26, 2015 Author Bot Share Posted March 26, 2015 (edited) Are you sure that you copied everything properly ? It works for me even with the old source. Edited August 19, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Premium Galet 510 Posted March 26, 2015 Premium Share Posted March 26, 2015 Even if the bug wasn't on my source, your code works ! Link to comment Share on other sites More sharing options...
ѕeмa™ 308 Posted March 26, 2015 Share Posted March 26, 2015 (edited) Are you sure that you copied everything properly ? It works for me even with the old source. sorry was my fail. Thanks. 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...
partor 0 Posted March 26, 2015 Share Posted March 26, 2015 %100 working thx Link to comment Share on other sites More sharing options...
Premium phayara 424 Posted March 31, 2015 Premium Share Posted March 31, 2015 Please help me. exchange.cpp:429: error: expected unqualified-id before 'for' exchange.cpp:429: error: expected constructor, destructor, or type conversion before '<' token exchange.cpp:429: error: expected unqualified-id before '++' token 429= for (i = 0; i < EXCHANGE_ITEM_MAX_NUM; ++i) Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted March 31, 2015 Premium Share Posted March 31, 2015 Please help me. exchange.cpp:429: error: expected unqualified-id before 'for' exchange.cpp:429: error: expected constructor, destructor, or type conversion before '<' token exchange.cpp:429: error: expected unqualified-id before '++' token 429= for (i = 0; i < EXCHANGE_ITEM_MAX_NUM; ++i) What is that "429="? Remove it o.O Link to comment Share on other sites More sharing options...
Adrian1428 31 Posted April 10, 2015 Share Posted April 10, 2015 I tested and everything works fine. Thanks. Link to comment Share on other sites More sharing options...
partor 0 Posted April 11, 2015 Share Posted April 11, 2015 I can not change the inventory is full article , i using 4 inv, ex : stun tam mekale Link to comment Share on other sites More sharing options...
Adrian1428 31 Posted April 11, 2015 Share Posted April 11, 2015 I can not change the inventory is full article , i using 4 inv, ex : stun tam mekale Can you be more specific? 1 Link to comment Share on other sites More sharing options...
partor 0 Posted April 11, 2015 Share Posted April 11, 2015 full inventory, I wear when the item error : stun tam mekale Link to comment Share on other sites More sharing options...
nichtwork 2 Posted April 22, 2015 Share Posted April 22, 2015 code for 5 inventory? please post plis e iam noob c++ Link to comment Share on other sites More sharing options...
Morphe 159 Posted June 7, 2015 Share Posted June 7, 2015 code for 5 inventory? please post plis e iam noob c++ bool CExchange::CheckSpace() { static CGrid s_grid1(5, INVENTORY_MAX_NUM / 5 / 5); // inven page 1 9 Rows a 5 Columns static CGrid s_grid2(5, INVENTORY_MAX_NUM / 5 / 5); // inven page 2 9 Rows a 5 Columns static CGrid s_grid3(5, INVENTORY_MAX_NUM / 5 / 5); // inven page 3 9 Rows a 5 Columns static CGrid s_grid4(5, INVENTORY_MAX_NUM / 5 / 5); // inven page 4 9 Rows a 5 Columns static CGrid s_grid5(5, INVENTORY_MAX_NUM / 5 / 5); // inven page 5 9 Rows a 5 Columns s_grid1.Clear(); s_grid2.Clear(); s_grid3.Clear(); s_grid4.Clear(); s_grid5.Clear(); LPCHARACTER victim = GetCompany()->GetOwner(); LPITEM item; int i; const int perPageSlotCount = INVENTORY_MAX_NUM / 5; 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 if (i < perPageSlotCount * 3) s_grid4.Put(i - perPageSlotCount * 3, 1, itemSize); else s_grid5.Put(i - perPageSlotCount * 4, 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; } iPos = s_grid5.FindBlank(1, itemSize); if (iPos >= 0) { s_grid5.Put(iPos, 1, itemSize); continue; } return false; // No space left in inventory } } return true; } Link to comment Share on other sites More sharing options...
Former Staff flygun 304 Posted June 7, 2015 Former Staff Share Posted June 7, 2015 why cannot we make it like this ??? static CGrid s_grid1(5,9) // 9 Rows a 5 Columns Link to comment Share on other sites More sharing options...
Cilindro 14 Posted July 23, 2015 Share Posted July 23, 2015 i have 5 inventory but now i don't can add itens on Belt_system any one can help me ? Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted July 23, 2015 Premium Share Posted July 23, 2015 i have 5 inventory but now i don't can add itens on Belt_system any one can help me ? So, we have: 5 inventory, each 45 slots 32 equipment slots 30 DS slots 16 belt slots And we are allowed to 255 maximum slots because the type of position is BYTE. Let's calculate your total amount of slots: (5 x 45) + 32 + 30 + 16 = 303. 303 is way bigger than 255. And as I see, you can't even use DS slots because inventory + equipment slots = 257. Stop destroying your game. Think about it. Link to comment Share on other sites More sharing options...
Former Staff Shisui 491 Posted July 23, 2015 Former Staff Share Posted July 23, 2015 i have 5 inventory but now i don't can add itens on Belt_system any one can help me ? So, we have: 5 inventory, each 45 slots 32 equipment slots 30 DS slots 16 belt slots And we are allowed to 255 maximum slots because the type of position is BYTE. Let's calculate your total amount of slots: (5 x 45) + 32 + 30 + 16 = 303. 303 is way bigger than 255. And as I see, you can't even use DS slots because inventory + equipment slots = 257. Stop destroying your game. Think about it. And if I want to take ds slots? Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted July 23, 2015 Premium Share Posted July 23, 2015 i have 5 inventory but now i don't can add itens on Belt_system any one can help me ? So, we have: 5 inventory, each 45 slots 32 equipment slots 30 DS slots 16 belt slots And we are allowed to 255 maximum slots because the type of position is BYTE. Let's calculate your total amount of slots: (5 x 45) + 32 + 30 + 16 = 303. 303 is way bigger than 255. And as I see, you can't even use DS slots because inventory + equipment slots = 257. Stop destroying your game. Think about it. And if I want to take ds slots? With the 5 inventory you can't even use whole equipment. Link to comment Share on other sites More sharing options...
Former Staff Shisui 491 Posted July 23, 2015 Former Staff Share Posted July 23, 2015 You already said that, sorry I misread. Link to comment Share on other sites More sharing options...
Cilindro 14 Posted July 23, 2015 Share Posted July 23, 2015 but you don't know wher i need too change the BYTE to int for work ? Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted July 24, 2015 Premium Share Posted July 24, 2015 but you don't know wher i need too change the BYTE to int for work ? There's a lot of places to change that. Every function that uses position should be changed. The packets have to be changed too. Link to comment Share on other sites More sharing options...
Recommended Posts