diff options
Diffstat (limited to 'src/net/eathena')
-rw-r--r-- | src/net/eathena/buyingstorerecv.cpp | 4 | ||||
-rw-r--r-- | src/net/eathena/buysellrecv.cpp | 2 | ||||
-rw-r--r-- | src/net/eathena/cashshoprecv.cpp | 2 | ||||
-rw-r--r-- | src/net/eathena/inventoryrecv.cpp | 30 | ||||
-rw-r--r-- | src/net/eathena/itemrecv.cpp | 10 | ||||
-rw-r--r-- | src/net/eathena/markethandler.cpp | 25 | ||||
-rw-r--r-- | src/net/eathena/markethandler.h | 2 | ||||
-rw-r--r-- | src/net/eathena/marketrecv.cpp | 2 | ||||
-rw-r--r-- | src/net/eathena/npchandler.cpp | 18 | ||||
-rw-r--r-- | src/net/eathena/traderecv.cpp | 2 | ||||
-rw-r--r-- | src/net/eathena/vendingrecv.cpp | 2 |
11 files changed, 69 insertions, 30 deletions
diff --git a/src/net/eathena/buyingstorerecv.cpp b/src/net/eathena/buyingstorerecv.cpp index 3596638b6..89a756ad3 100644 --- a/src/net/eathena/buyingstorerecv.cpp +++ b/src/net/eathena/buyingstorerecv.cpp @@ -134,7 +134,9 @@ void BuyingStoreRecv::processBuyingStoreItemsList(Net::MessageIn &msg) { const int price = msg.readInt32("price"); const int amount = msg.readInt16("amount"); - const int itemType = msg.readUInt8("item type"); + const ItemTypeT itemType = fromInt( + msg.readUInt8("item type"), + ItemTypeT); const int itemId = msg.readInt16("item id"); if (!inv) diff --git a/src/net/eathena/buysellrecv.cpp b/src/net/eathena/buysellrecv.cpp index e59eb47a7..8fa02d185 100644 --- a/src/net/eathena/buysellrecv.cpp +++ b/src/net/eathena/buysellrecv.cpp @@ -55,7 +55,7 @@ void BuySellRecv::processNpcBuy(Net::MessageIn &msg) { const int value = msg.readInt32("price"); msg.readInt32("dc value?"); - const int type = msg.readUInt8("type"); + const ItemTypeT type = fromInt(msg.readUInt8("type"), ItemTypeT); const int itemId = msg.readInt16("item id"); const ItemColor color = ItemColor_one; Ea::BuySellRecv::mBuyDialog->addItem(itemId, type, color, 0, value); diff --git a/src/net/eathena/cashshoprecv.cpp b/src/net/eathena/cashshoprecv.cpp index 45f48eadc..4da1edcf3 100644 --- a/src/net/eathena/cashshoprecv.cpp +++ b/src/net/eathena/cashshoprecv.cpp @@ -51,7 +51,7 @@ void CashShopRecv::processCashShopOpen(Net::MessageIn &msg) { msg.readInt32("price"); const int value = msg.readInt32("discount price"); - const int type = msg.readUInt8("item type"); + const ItemTypeT type = fromInt(msg.readUInt8("item type"), ItemTypeT); const int itemId = msg.readInt16("item id"); const ItemColor color = ItemColor_one; mBuyDialog->addItem(itemId, type, color, 0, value); diff --git a/src/net/eathena/inventoryrecv.cpp b/src/net/eathena/inventoryrecv.cpp index 4d5565d1b..967c74978 100644 --- a/src/net/eathena/inventoryrecv.cpp +++ b/src/net/eathena/inventoryrecv.cpp @@ -127,7 +127,9 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) { const int index = msg.readInt16("index") - INVENTORY_OFFSET; const int itemId = msg.readInt16("item id"); - const int itemType = msg.readUInt8("item type"); + const ItemTypeT itemType = fromInt( + msg.readUInt8("item type"), + ItemTypeT); msg.readInt32("location"); const int equipType = msg.readInt32("wear state"); const uint8_t refine = CAST_U8(msg.readInt8("refine")); @@ -198,7 +200,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); const int equipType = msg.readInt32("location"); - const int itemType = msg.readUInt8("item type"); + const ItemTypeT itemType = fromInt(msg.readUInt8("item type"), ItemTypeT); const unsigned char err = msg.readUInt8("result"); msg.readInt32("hire expire date"); msg.readInt16("bind on equip"); @@ -322,7 +324,9 @@ void InventoryRecv::processPlayerInventory(Net::MessageIn &msg) { const int index = msg.readInt16("item index") - INVENTORY_OFFSET; const int itemId = msg.readInt16("item id"); - const int itemType = msg.readUInt8("item type"); + const ItemTypeT itemType = fromInt( + msg.readUInt8("item type"), + ItemType); const int amount = msg.readInt16("count"); msg.readInt32("wear state / equip"); int cards[maxCards]; @@ -365,7 +369,9 @@ void InventoryRecv::processPlayerStorage(Net::MessageIn &msg) { const int index = msg.readInt16("item index") - STORAGE_OFFSET; const int itemId = msg.readInt16("item id"); - const int itemType = msg.readUInt8("item type"); + const ItemTypeT itemType = fromInt( + msg.readUInt8("item type"), + ItemTypeT); const int amount = msg.readInt16("count"); msg.readInt32("wear state / equip"); int cards[maxCards]; @@ -526,7 +532,9 @@ void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg) { const int index = msg.readInt16("index") - STORAGE_OFFSET; const int itemId = msg.readInt16("item id"); - const int itemType = msg.readUInt8("item type"); + const ItemTypeT itemType = fromInt( + msg.readUInt8("item type"), + ItemTypeT); const int amount = 1; msg.readInt32("location"); msg.readInt32("wear state"); @@ -575,7 +583,7 @@ void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg) const int index = msg.readInt16("index") - STORAGE_OFFSET; const int amount = msg.readInt32("amount"); const int itemId = msg.readInt16("item id"); - const int itemType = msg.readUInt8("type"); + const ItemTypeT itemType = fromInt(msg.readUInt8("type"), ItemTypeT); const unsigned char identified = msg.readUInt8("identify"); const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged); const uint8_t refine = msg.readUInt8("refine"); @@ -777,7 +785,7 @@ void InventoryRecv::processPlayerCartAdd(Net::MessageIn &msg) const int index = msg.readInt16("index") - INVENTORY_OFFSET; int amount = msg.readInt32("count"); const int itemId = msg.readInt16("item id"); - const int itemType = msg.readUInt8("item type"); + const ItemTypeT itemType = fromInt(msg.readUInt8("item type"), ItemTypeT); const uint8_t identified = msg.readUInt8("identified"); const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged); const uint8_t refine = msg.readUInt8("refine"); @@ -853,7 +861,9 @@ void InventoryRecv::processPlayerCartEquip(Net::MessageIn &msg) { const int index = msg.readInt16("index") - INVENTORY_OFFSET; const int itemId = msg.readInt16("item id"); - const int itemType = msg.readUInt8("item type"); + const ItemTypeT itemType = fromInt( + msg.readUInt8("item type"), + ItemTypeT); const int amount = 1; msg.readInt32("location"); msg.readInt32("wear state"); @@ -905,7 +915,9 @@ void InventoryRecv::processPlayerCartItems(Net::MessageIn &msg) { const int index = msg.readInt16("item index") - INVENTORY_OFFSET; const int itemId = msg.readInt16("item id"); - const int itemType = msg.readUInt8("item type"); + const ItemTypeT itemType = fromInt( + msg.readUInt8("item type"), + ItemTypeT); const int amount = msg.readInt16("count"); msg.readInt32("wear state / equip"); int cards[maxCards]; diff --git a/src/net/eathena/itemrecv.cpp b/src/net/eathena/itemrecv.cpp index 822b4684d..80b0bd7a2 100644 --- a/src/net/eathena/itemrecv.cpp +++ b/src/net/eathena/itemrecv.cpp @@ -28,6 +28,8 @@ #include "const/resources/item/cards.h" +#include "enums/resources/itemtype.h" + #include "net/messagein.h" #include "debug.h" @@ -39,7 +41,7 @@ void ItemRecv::processItemDropped(Net::MessageIn &msg) { const BeingId id = msg.readBeingId("id"); const int itemId = msg.readInt16("item id"); - const int itemType = msg.readInt16("type"); + const ItemTypeT itemType = fromInt(msg.readInt16("type"), ItemTypeT); const Identified identified = fromInt( msg.readUInt8("identify"), Identified); const int x = msg.readInt16("x"); @@ -68,7 +70,7 @@ void ItemRecv::processItemDropped2(Net::MessageIn &msg) { const BeingId id = msg.readBeingId("id"); const int itemId = msg.readInt16("item id"); - const int itemType = msg.readUInt8("type"); + const ItemTypeT itemType = fromInt(msg.readUInt8("type"), ItemTypeT); const Identified identified = fromInt( msg.readUInt8("identify"), Identified); const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged); @@ -127,7 +129,7 @@ void ItemRecv::processItemVisible(Net::MessageIn &msg) actorManager->createItem(id, itemId, x, y, - 0, + ItemType::Unknown, amount, 0, ItemColor_one, @@ -142,7 +144,7 @@ void ItemRecv::processItemVisible2(Net::MessageIn &msg) { const BeingId id = msg.readBeingId("item object id"); const int itemId = msg.readInt16("item id"); - const int itemType = msg.readUInt8("type"); + const ItemTypeT itemType = fromInt(msg.readUInt8("type"), ItemTypeT); const Identified identified = fromInt( msg.readUInt8("identify"), Identified); const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged); diff --git a/src/net/eathena/markethandler.cpp b/src/net/eathena/markethandler.cpp index 6c69664ea..15370d91c 100644 --- a/src/net/eathena/markethandler.cpp +++ b/src/net/eathena/markethandler.cpp @@ -45,11 +45,14 @@ void MarketHandler::close() const } void MarketHandler::buyItem(const int itemId, - const int type, + const ItemTypeT type, const ItemColor color A_UNUSED, const int amount) const { - const bool nonStack = type == 4 || type == 5 || type == 7 || type == 8; + const bool nonStack = type == ItemType::Weapon || + type == ItemType::Armor || + type == ItemType::PetEgg || + type == ItemType::PetArmor; int cnt = nonStack ? amount : 1; const int amount2 = nonStack ? 1 : amount; if (cnt > 100) @@ -73,13 +76,20 @@ void MarketHandler::buyItems(const std::vector<ShopItem*> &items) const { const ShopItem *const item = *it; const int usedQuantity = item->getUsedQuantity(); - const int type = item->getType(); + const ItemTypeT type = item->getType(); if (!usedQuantity) continue; - if (type == 4 || type == 5 || type == 7 || type == 8) + if (type == ItemType::Weapon || + type == ItemType::Armor || + type == ItemType::PetEgg || + type == ItemType::PetArmor) + { cnt += item->getUsedQuantity(); + } else + { cnt ++; + } } if (cnt > 100) @@ -96,8 +106,11 @@ void MarketHandler::buyItems(const std::vector<ShopItem*> &items) const item->increaseQuantity(usedQuantity); item->increaseUsedQuantity(-usedQuantity); item->update(); - const int type = item->getType(); - if (type == 4 || type == 5 || type == 7 || type == 8) + const ItemTypeT type = fromInt(item->getType(), ItemTypeT); + if (type == ItemType::Weapon || + type == ItemType::Armor || + type == ItemType::PetEgg || + type == ItemType::PetArmor) { for (int f = 0; f < usedQuantity; f ++) { diff --git a/src/net/eathena/markethandler.h b/src/net/eathena/markethandler.h index 8ba0be922..fd0d4aea5 100644 --- a/src/net/eathena/markethandler.h +++ b/src/net/eathena/markethandler.h @@ -36,7 +36,7 @@ class MarketHandler final : public Net::MarketHandler void close() const override final; void buyItem(const int itemId, - const int type, + const ItemTypeT type, const ItemColor color, const int amount) const override final; diff --git a/src/net/eathena/marketrecv.cpp b/src/net/eathena/marketrecv.cpp index 2f8d5aaae..66cab540a 100644 --- a/src/net/eathena/marketrecv.cpp +++ b/src/net/eathena/marketrecv.cpp @@ -53,7 +53,7 @@ void MarketRecv::processMarketOpen(Net::MessageIn &msg) for (int f = 0; f < len; f ++) { const int itemId = msg.readInt16("item id"); - const int type = msg.readUInt8("type"); + const ItemTypeT type = fromInt(msg.readUInt8("type"), ItemTypeT); const int value = msg.readInt32("price"); const int amount = msg.readInt32("amount"); msg.readInt16("view"); diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp index 7d0a65abc..2e5175253 100644 --- a/src/net/eathena/npchandler.cpp +++ b/src/net/eathena/npchandler.cpp @@ -142,13 +142,20 @@ void NpcHandler::buyItems(std::vector<ShopItem*> &items) const { ShopItem *const item = *it; const int usedQuantity = item->getUsedQuantity(); - const int type = item->getType(); + const ItemTypeT type = item->getType(); if (!usedQuantity) continue; - if (type == 4 || type == 5 || type == 7 || type == 8) + if (type == ItemType::Weapon || + type == ItemType::Armor || + type == ItemType::PetEgg || + type == ItemType::PetArmor) + { cnt += item->getUsedQuantity(); + } else + { cnt ++; + } } if (cnt > 100) @@ -164,8 +171,11 @@ void NpcHandler::buyItems(std::vector<ShopItem*> &items) const continue; item->increaseUsedQuantity(-usedQuantity); item->update(); - const int type = item->getType(); - if (type == 4 || type == 5 || type == 7 || type == 8) + const ItemTypeT type = item->getType(); + if (type == ItemType::Weapon || + type == ItemType::Armor || + type == ItemType::PetEgg || + type == ItemType::PetArmor) { for (int f = 0; f < usedQuantity; f ++) { diff --git a/src/net/eathena/traderecv.cpp b/src/net/eathena/traderecv.cpp index b77c8af87..edac5d21e 100644 --- a/src/net/eathena/traderecv.cpp +++ b/src/net/eathena/traderecv.cpp @@ -72,7 +72,7 @@ void TradeRecv::processTradeResponse(Net::MessageIn &msg) void TradeRecv::processTradeItemAdd(Net::MessageIn &msg) { const int type = msg.readInt16("type"); - const int itemType = msg.readUInt8("item type"); + const ItemTypeT itemType = fromInt(msg.readUInt8("item type"), ItemTypeT); const int amount = msg.readInt32("amount"); const uint8_t identify = msg.readUInt8("identify"); const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged); diff --git a/src/net/eathena/vendingrecv.cpp b/src/net/eathena/vendingrecv.cpp index 7e088a2b0..06cdfa44c 100644 --- a/src/net/eathena/vendingrecv.cpp +++ b/src/net/eathena/vendingrecv.cpp @@ -93,7 +93,7 @@ void VendingRecv::processItemsList(Net::MessageIn &msg) const int value = msg.readInt32("price"); const int amount = msg.readInt16("amount"); const int index = msg.readInt16("inv index"); - const int type = msg.readUInt8("item type"); + const ItemTypeT type = fromInt(msg.readUInt8("item type"), ItemTypeT); const int itemId = msg.readInt16("item id"); msg.readUInt8("identify"); msg.readUInt8("attribute"); |