diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-03-24 23:29:04 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-03-24 23:29:04 +0300 |
commit | 4e97da8e138b21a5f5bea75e6a8d3211e4f28594 (patch) | |
tree | c10d3cad963066a908ebd42041723e110a0c9bf0 /src/net/eathena/markethandler.cpp | |
parent | ca0ca278d0c4aed9a6d50bb9a8982f5261151ab8 (diff) | |
download | plus-4e97da8e138b21a5f5bea75e6a8d3211e4f28594.tar.gz plus-4e97da8e138b21a5f5bea75e6a8d3211e4f28594.tar.bz2 plus-4e97da8e138b21a5f5bea75e6a8d3211e4f28594.tar.xz plus-4e97da8e138b21a5f5bea75e6a8d3211e4f28594.zip |
Add enum for item types.
Diffstat (limited to 'src/net/eathena/markethandler.cpp')
-rw-r--r-- | src/net/eathena/markethandler.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
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 ++) { |