summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-16 20:22:52 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-16 20:22:52 +0300
commit36bf685462f371b306f51a29331e7a1d86ce3a91 (patch)
tree79ef1ffdb59524f9fec7ce2dcb3e1cf7f490c70f /src/net
parentd54c371ad9d3c8a019d7d6bdc0262cd352a06ae5 (diff)
downloadmv-36bf685462f371b306f51a29331e7a1d86ce3a91.tar.gz
mv-36bf685462f371b306f51a29331e7a1d86ce3a91.tar.bz2
mv-36bf685462f371b306f51a29331e7a1d86ce3a91.tar.xz
mv-36bf685462f371b306f51a29331e7a1d86ce3a91.zip
add server feature haveItemColors.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/adminhandler.cpp3
-rw-r--r--src/net/eathena/inventoryhandler.cpp5
-rw-r--r--src/net/eathena/serverfeatures.cpp5
-rw-r--r--src/net/eathena/serverfeatures.h2
-rw-r--r--src/net/serverfeatures.h2
-rw-r--r--src/net/tmwa/beinghandler.cpp8
-rw-r--r--src/net/tmwa/buysellhandler.cpp7
-rw-r--r--src/net/tmwa/inventoryhandler.cpp15
-rw-r--r--src/net/tmwa/npchandler.cpp5
-rw-r--r--src/net/tmwa/serverfeatures.cpp5
-rw-r--r--src/net/tmwa/serverfeatures.h2
11 files changed, 44 insertions, 15 deletions
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