summaryrefslogtreecommitdiff
path: root/src/net/ea
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-15 13:58:32 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-16 01:52:14 +0300
commit41cc92f73e39cec5dfea6b1164176610cccc7df4 (patch)
tree22fd3d388084d2c61fe80f0441c3c30ab8ffd33c /src/net/ea
parent7aa637abc8b0bca35aacdb9492e65f557ed32038 (diff)
downloadmv-41cc92f73e39cec5dfea6b1164176610cccc7df4.tar.gz
mv-41cc92f73e39cec5dfea6b1164176610cccc7df4.tar.bz2
mv-41cc92f73e39cec5dfea6b1164176610cccc7df4.tar.xz
mv-41cc92f73e39cec5dfea6b1164176610cccc7df4.zip
Add strong typed int for item color.
Diffstat (limited to 'src/net/ea')
-rw-r--r--src/net/ea/adminhandler.cpp5
-rw-r--r--src/net/ea/adminhandler.h3
-rw-r--r--src/net/ea/beinghandler.cpp2
-rw-r--r--src/net/ea/beinghandler.h2
-rw-r--r--src/net/ea/inventoryitem.h5
-rw-r--r--src/net/ea/itemhandler.cpp10
6 files changed, 17 insertions, 10 deletions
diff --git a/src/net/ea/adminhandler.cpp b/src/net/ea/adminhandler.cpp
index bf4bd590c..2cc98acb0 100644
--- a/src/net/ea/adminhandler.cpp
+++ b/src/net/ea/adminhandler.cpp
@@ -74,7 +74,8 @@ void AdminHandler::ipcheckName(const std::string &name) const
chatHandler->talk("@ipcheck " + name, GENERAL_CHANNEL);
}
-void AdminHandler::createItems(const int id, const int color,
+void AdminHandler::createItems(const int id,
+ const ItemColor color,
const int amount) const
{
if (!serverFeatures->haveItemColors())
@@ -85,7 +86,7 @@ void AdminHandler::createItems(const int id, const int color,
else
{
chatHandler->talk(strprintf("@item %d %d %d",
- id, color, amount), GENERAL_CHANNEL);
+ id, toInt(color, int), amount), GENERAL_CHANNEL);
}
}
diff --git a/src/net/ea/adminhandler.h b/src/net/ea/adminhandler.h
index acabd288a..ab7b8c557 100644
--- a/src/net/ea/adminhandler.h
+++ b/src/net/ea/adminhandler.h
@@ -60,7 +60,8 @@ class AdminHandler notfinal : public Net::AdminHandler
void ipcheckName(const std::string &name) const override final;
- void createItems(const int id, const int color,
+ void createItems(const int id,
+ const ItemColor color,
const int amount) const override final;
protected:
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 76fe061ed..2c2c65652 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -76,7 +76,7 @@ Being *BeingHandler::createBeing(const BeingId id,
void BeingHandler::setSprite(Being *const being, const unsigned int slot,
const int id, const std::string &color,
- const unsigned char colorId,
+ const ItemColor colorId,
const bool isWeapon,
const bool isTempSprite)
{
diff --git a/src/net/ea/beinghandler.h b/src/net/ea/beinghandler.h
index 20622e514..6c372ce1f 100644
--- a/src/net/ea/beinghandler.h
+++ b/src/net/ea/beinghandler.h
@@ -42,7 +42,7 @@ class BeingHandler notfinal : public Net::BeingHandler
static void setSprite(Being *const being, const unsigned int slot,
const int id,
const std::string &color = "",
- const unsigned char colorId = 1,
+ const ItemColor colorId = ItemColor_one,
const bool isWeapon = false,
const bool isTempSprite = false);
diff --git a/src/net/ea/inventoryitem.h b/src/net/ea/inventoryitem.h
index b318b2f23..d4d9c3637 100644
--- a/src/net/ea/inventoryitem.h
+++ b/src/net/ea/inventoryitem.h
@@ -27,6 +27,7 @@
#include "enums/simpletypes/equipm.h"
#include "enums/simpletypes/favorite.h"
#include "enums/simpletypes/identified.h"
+#include "enums/simpletypes/itemcolor.h"
#if defined(__GXX_EXPERIMENTAL_CXX0X__)
#include <cstdint>
@@ -51,7 +52,7 @@ class InventoryItem final
int cards[4];
int quantity;
uint8_t refine;
- unsigned char color;
+ ItemColor color;
Identified identified;
Damaged damaged;
Favorite favorite;
@@ -63,7 +64,7 @@ class InventoryItem final
const int *const cards0,
const int quantity0,
const uint8_t refine0,
- const unsigned char color0,
+ const ItemColor color0,
const Identified identified0,
const Damaged damaged0,
const Favorite favorite0,
diff --git a/src/net/ea/itemhandler.cpp b/src/net/ea/itemhandler.cpp
index 2c297f69f..478c17990 100644
--- a/src/net/ea/itemhandler.cpp
+++ b/src/net/ea/itemhandler.cpp
@@ -43,7 +43,7 @@ void ItemHandler::processItemVisible(Net::MessageIn &msg)
{
const BeingId id = msg.readBeingId("item object id");
const int itemId = msg.readInt16("item id");
- const uint8_t identify = msg.readUInt8("identify");
+ const ItemColor identify = fromInt(msg.readUInt8("identify"), ItemColor);
const int x = msg.readInt16("x");
const int y = msg.readInt16("y");
const int amount = msg.readInt16("amount");
@@ -52,8 +52,12 @@ void ItemHandler::processItemVisible(Net::MessageIn &msg)
if (actorManager)
{
- actorManager->createItem(id, itemId,
- x, y, amount, identify, subX, subY);
+ actorManager->createItem(id,
+ itemId,
+ x, y,
+ amount,
+ identify,
+ subX, subY);
}
}