diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-09-16 20:22:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-09-16 20:22:52 +0300 |
commit | 36bf685462f371b306f51a29331e7a1d86ce3a91 (patch) | |
tree | 79ef1ffdb59524f9fec7ce2dcb3e1cf7f490c70f /src | |
parent | d54c371ad9d3c8a019d7d6bdc0262cd352a06ae5 (diff) | |
download | mv-36bf685462f371b306f51a29331e7a1d86ce3a91.tar.gz mv-36bf685462f371b306f51a29331e7a1d86ce3a91.tar.bz2 mv-36bf685462f371b306f51a29331e7a1d86ce3a91.tar.xz mv-36bf685462f371b306f51a29331e7a1d86ce3a91.zip |
add server feature haveItemColors.
Diffstat (limited to 'src')
-rw-r--r-- | src/being/localplayer.cpp | 2 | ||||
-rw-r--r-- | src/flooritem.cpp | 5 | ||||
-rw-r--r-- | src/gui/popups/itempopup.cpp | 7 | ||||
-rw-r--r-- | src/gui/popups/popupmenu.cpp | 4 | ||||
-rw-r--r-- | src/item.cpp | 5 | ||||
-rw-r--r-- | src/net/ea/adminhandler.cpp | 3 | ||||
-rw-r--r-- | src/net/eathena/inventoryhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/eathena/serverfeatures.cpp | 5 | ||||
-rw-r--r-- | src/net/eathena/serverfeatures.h | 2 | ||||
-rw-r--r-- | src/net/serverfeatures.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 8 | ||||
-rw-r--r-- | src/net/tmwa/buysellhandler.cpp | 7 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.cpp | 15 | ||||
-rw-r--r-- | src/net/tmwa/npchandler.cpp | 5 | ||||
-rw-r--r-- | src/net/tmwa/serverfeatures.cpp | 5 | ||||
-rw-r--r-- | src/net/tmwa/serverfeatures.h | 2 | ||||
-rw-r--r-- | src/shopitem.cpp | 9 |
17 files changed, 66 insertions, 25 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index d5e32316c..6917cc465 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -858,7 +858,7 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo, const int amount, else { std::string str; - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) str = itemInfo.getName(color); else str = itemInfo.getName(); diff --git a/src/flooritem.cpp b/src/flooritem.cpp index 1d0b9948d..f3e7f66d2 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -37,6 +37,9 @@ #include "resources/map/map.h" +#include "net/net.h" +#include "net/serverfeatures.h" + #include "debug.h" extern int serverVersion; @@ -101,7 +104,7 @@ const ItemInfo &FloorItem::getInfo() const std::string FloorItem::getName() const { const ItemInfo &info = ItemDB::get(mItemId); - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) return info.getName(mColor); else return info.getName(); diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp index 797520c7b..42eeed6be 100644 --- a/src/gui/popups/itempopup.cpp +++ b/src/gui/popups/itempopup.cpp @@ -41,6 +41,9 @@ #include "resources/iteminfo.h" #include "resources/resourcemanager.h" +#include "net/net.h" +#include "net/serverfeatures.h" + #include "debug.h" extern int serverVersion; @@ -117,7 +120,7 @@ void ItemPopup::setItem(const Item *const item, const bool showImage) mLastName = ii.getName(); mLastColor = item->getColor(); mLastId = item->getId(); - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) { mItemName->setCaption(strprintf("%s (+%u), %d", ii.getName(item->getColor()).c_str(), @@ -181,7 +184,7 @@ void ItemPopup::setItem(const ItemInfo &item, const unsigned char color, mLastColor = color; mLastId = id; - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) { mItemName->setCaption(strprintf("%s, %d", item.getName(color).c_str(), id)); diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index bcc0b92ef..b92d572fb 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -1089,7 +1089,7 @@ void PopupMenu::handleLink(const std::string &link, { if (mItem) { - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) { chatWindow->addItemText(mItem->getInfo().getName( mItem->getColor())); @@ -1106,7 +1106,7 @@ void PopupMenu::handleLink(const std::string &link, if (item) { - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) { chatWindow->addItemText(item->getInfo().getName( item->getColor())); diff --git a/src/item.cpp b/src/item.cpp index ad84b724d..01a47e0dd 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -31,6 +31,9 @@ #include "resources/resourcemanager.h" #include "configuration.h" +#include "net/net.h" +#include "net/serverfeatures.h" + #include "debug.h" extern int serverVersion; @@ -116,7 +119,7 @@ Image *Item::getImage(const int id, const unsigned char color) std::string Item::getName() const { const ItemInfo &info = ItemDB::get(mId); - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) return info.getName(mColor); else return info.getName(); diff --git a/src/net/ea/adminhandler.cpp b/src/net/ea/adminhandler.cpp index 23dacccbf..000f96132 100644 --- a/src/net/ea/adminhandler.cpp +++ b/src/net/ea/adminhandler.cpp @@ -26,6 +26,7 @@ #include "net/chathandler.h" #include "net/net.h" +#include "net/serverfeatures.h" #include <string> @@ -74,7 +75,7 @@ void AdminHandler::ipcheckName(const std::string &name) const void AdminHandler::createItems(const int id, const int color, const int amount) const { - if (serverVersion < 1) + if (!Net::getServerFeatures()->haveItemColors()) { Net::getChatHandler()->talk(strprintf("@item %d %d", id, amount), GENERAL_CHANNEL); diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index 610b27194..ccc303cdf 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -29,6 +29,9 @@ #include "listeners/arrowslistener.h" +#include "net/net.h" +#include "net/serverfeatures.h" + #include "net/eathena/messageout.h" #include "net/eathena/protocol.h" @@ -376,7 +379,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) if (item && item->getId() == itemId) amount += item->getQuantity(); - if (serverVersion < 1 && identified > 1) + if (!Net::getServerFeatures()->haveItemColors() && identified > 1) identified = 1; inventory->setItem(index, itemId, amount, refine, diff --git a/src/net/eathena/serverfeatures.cpp b/src/net/eathena/serverfeatures.cpp index b0787cb40..807c2292b 100644 --- a/src/net/eathena/serverfeatures.cpp +++ b/src/net/eathena/serverfeatures.cpp @@ -102,4 +102,9 @@ bool ServerFeatures::haveMove3() const return false; } +bool ServerFeatures::haveItemColors() const +{ + return false; +} + } // namespace EAthena diff --git a/src/net/eathena/serverfeatures.h b/src/net/eathena/serverfeatures.h index 045679659..36bd1bc4b 100644 --- a/src/net/eathena/serverfeatures.h +++ b/src/net/eathena/serverfeatures.h @@ -61,6 +61,8 @@ class ServerFeatures final : public Net::ServerFeatures bool haveServerIgnore() const override final; bool haveMove3() const override final; + + bool haveItemColors() const override final; }; } // namespace EAthena diff --git a/src/net/serverfeatures.h b/src/net/serverfeatures.h index b3ed6f4ff..b25c98573 100644 --- a/src/net/serverfeatures.h +++ b/src/net/serverfeatures.h @@ -58,6 +58,8 @@ class ServerFeatures notfinal virtual bool haveServerIgnore() const = 0; virtual bool haveMove3() const = 0; + + virtual bool haveItemColors() const = 0; }; } // namespace Net diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 2bf3ed887..398d582bd 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -298,7 +298,7 @@ void BeingHandler::processBeingChangeLook2(Net::MessageIn &msg) const int id2 = 0; const int16_t id = msg.readInt16("id1"); - if (type == 2 || serverVersion > 0) + if (type == 2 || Net::getServerFeatures()->haveItemColors()) { id2 = msg.readInt16("id2"); } @@ -571,7 +571,7 @@ void BeingHandler::processPlayerUpdate1(Net::MessageIn &msg) const dstBeing->updateSprite(SPRITE_WEAPON, weapon, "", 1, true); if (!mHideShield) dstBeing->updateSprite(SPRITE_SHIELD, shield); - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) { dstBeing->updateSprite(SPRITE_BOTTOMCLOTHES, headBottom, "", colors[0]); @@ -722,7 +722,7 @@ void BeingHandler::processPlayerUpdate2(Net::MessageIn &msg) const dstBeing->updateSprite(SPRITE_WEAPON, weapon, "", 1, true); if (!mHideShield) dstBeing->updateSprite(SPRITE_SHIELD, shield); - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) { dstBeing->updateSprite(SPRITE_BOTTOMCLOTHES, headBottom, "", colors[0]); @@ -873,7 +873,7 @@ void BeingHandler::processPlayerMove(Net::MessageIn &msg) const dstBeing->updateSprite(SPRITE_WEAPON, weapon, "", 1, true); if (!mHideShield) dstBeing->updateSprite(SPRITE_SHIELD, shield); - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) { dstBeing->updateSprite(SPRITE_BOTTOMCLOTHES, headBottom, "", colors[0]); diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp index 2c8414a1c..2bb2788f6 100644 --- a/src/net/tmwa/buysellhandler.cpp +++ b/src/net/tmwa/buysellhandler.cpp @@ -29,6 +29,9 @@ #include "gui/windows/buydialog.h" +#include "net/net.h" +#include "net/serverfeatures.h" + #include "net/tmwa/protocol.h" #include "resources/notifytypes.h" @@ -94,7 +97,7 @@ void BuySellHandler::processNpcBuy(Net::MessageIn &msg) { msg.readInt16("len"); unsigned int sz = 11; - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) sz += 1; const unsigned int n_items = (msg.getLength() - 4U) / sz; mBuyDialog = new BuyDialog(mNpcId); @@ -107,7 +110,7 @@ void BuySellHandler::processNpcBuy(Net::MessageIn &msg) msg.readUInt8("type"); const int itemId = msg.readInt16("item id"); uint8_t color = 1; - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) color = msg.readUInt8("item color"); mBuyDialog->addItem(itemId, color, 0, value); } diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 811ce6c3b..e99246d25 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -29,6 +29,9 @@ #include "listeners/arrowslistener.h" +#include "net/net.h" +#include "net/serverfeatures.h" + #include "net/tmwa/messageout.h" #include "net/tmwa/protocol.h" @@ -265,7 +268,7 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) index, itemId, itemType, identified); } - if (serverVersion < 1 && identified > 1) + if (!Net::getServerFeatures()->haveItemColors() && identified > 1) identified = 1; if (inventory) @@ -336,7 +339,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) if (item && item->getId() == itemId) amount += item->getQuantity(); - if (serverVersion < 1 && identified > 1) + if (!Net::getServerFeatures()->haveItemColors() && identified > 1) identified = 1; inventory->setItem(index, itemId, amount, refine, @@ -386,7 +389,7 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg) cards[0], cards[1], cards[2], cards[3]); } - if (serverVersion < 1 && identified > 1) + if (!Net::getServerFeatures()->haveItemColors() && identified > 1) identified = 1; // Trick because arrows are not considered equipment @@ -429,7 +432,7 @@ void InventoryHandler::processPlayerStorage(Net::MessageIn &msg) cards[0], cards[1], cards[2], cards[3]); } - if (serverVersion < 1 && identified > 1) + if (!Net::getServerFeatures()->haveItemColors() && identified > 1) identified = 1; mInventoryItems.push_back(Ea::InventoryItem(index, itemId, @@ -497,7 +500,7 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg) static_cast<unsigned int>(refine)); } - if (serverVersion < 1 && identified > 1U) + if (!Net::getServerFeatures()->haveItemColors() && identified > 1U) identified = 1U; mInventoryItems.push_back(Ea::InventoryItem(index, @@ -528,7 +531,7 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg) { if (mStorage) { - if (serverVersion < 1 && identified > 1) + if (!Net::getServerFeatures()->haveItemColors() && identified > 1) identified = 1; mStorage->setItem(index, itemId, amount, diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index ec5da280a..bfe833577 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -28,6 +28,9 @@ #include "gui/windows/npcdialog.h" +#include "net/net.h" +#include "net/serverfeatures.h" + #include "net/tmwa/messageout.h" #include "net/tmwa/protocol.h" @@ -178,7 +181,7 @@ void NpcHandler::buyItem(const int beingId A_UNUSED, const int itemId, const unsigned char color, const int amount) const { MessageOut outMsg(CMSG_NPC_BUY_REQUEST); - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) { outMsg.writeInt16(10); // One item (length of packet) outMsg.writeInt16(static_cast<int16_t>(amount)); diff --git a/src/net/tmwa/serverfeatures.cpp b/src/net/tmwa/serverfeatures.cpp index 7f60f139f..07b567b72 100644 --- a/src/net/tmwa/serverfeatures.cpp +++ b/src/net/tmwa/serverfeatures.cpp @@ -104,4 +104,9 @@ bool ServerFeatures::haveMove3() const return serverVersion >= 10; } +bool ServerFeatures::haveItemColors() const +{ + return serverVersion >= 1; +} + } // namespace TmwAthena diff --git a/src/net/tmwa/serverfeatures.h b/src/net/tmwa/serverfeatures.h index 8444fd930..4307dc002 100644 --- a/src/net/tmwa/serverfeatures.h +++ b/src/net/tmwa/serverfeatures.h @@ -61,6 +61,8 @@ class ServerFeatures final : public Net::ServerFeatures bool haveServerIgnore() const override final; bool haveMove3() const override final; + + bool haveItemColors() const override final; }; } // namespace TmwAthena diff --git a/src/shopitem.cpp b/src/shopitem.cpp index 45ab60e05..071247483 100644 --- a/src/shopitem.cpp +++ b/src/shopitem.cpp @@ -28,6 +28,9 @@ #include "utils/stringutils.h" +#include "net/net.h" +#include "net/serverfeatures.h" + #include "debug.h" extern int serverVersion; @@ -41,7 +44,7 @@ ShopItem::ShopItem(const int inventoryIndex, const int id, mPrice(price), mShowQuantity(true) { - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) { mDisplayName = std::string(getInfo().getName(color)).append(" (") .append(Units::formatCurrency(mPrice)).append(") "); @@ -65,7 +68,7 @@ ShopItem::ShopItem(const int id, const unsigned char color, const int price) : mPrice(price), mShowQuantity(false) { - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) { mDisplayName = std::string(getInfo().getName(color)).append(" (") .append(Units::formatCurrency(mPrice)).append(")"); @@ -93,7 +96,7 @@ void ShopItem::update() { if (mShowQuantity) { - if (serverVersion > 0) + if (Net::getServerFeatures()->haveItemColors()) { mDisplayName = std::string(getInfo().getName(mColor)).append(" (") .append(Units::formatCurrency(mPrice)).append(") "); |