From 36bf685462f371b306f51a29331e7a1d86ce3a91 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 16 Sep 2014 20:22:52 +0300 Subject: add server feature haveItemColors. --- src/net/tmwa/beinghandler.cpp | 8 ++++---- src/net/tmwa/buysellhandler.cpp | 7 +++++-- src/net/tmwa/inventoryhandler.cpp | 15 +++++++++------ src/net/tmwa/npchandler.cpp | 5 ++++- src/net/tmwa/serverfeatures.cpp | 5 +++++ src/net/tmwa/serverfeatures.h | 2 ++ 6 files changed, 29 insertions(+), 13 deletions(-) (limited to 'src/net/tmwa') 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(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(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 -- cgit v1.2.3-70-g09d2