summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-07-14 23:43:54 +0300
committerAndrei Karas <akaras@inbox.ru>2014-07-14 23:43:54 +0300
commit15a79eee1b3baa91953daf33dc021a1e7c147365 (patch)
tree21fc078237a8c635308c1e84e0bba869918ba3d5
parente1841e31c606f1d97ea54c3f00f3380db814f3d2 (diff)
downloadplus-15a79eee1b3baa91953daf33dc021a1e7c147365.tar.gz
plus-15a79eee1b3baa91953daf33dc021a1e7c147365.tar.bz2
plus-15a79eee1b3baa91953daf33dc021a1e7c147365.tar.xz
plus-15a79eee1b3baa91953daf33dc021a1e7c147365.zip
Change refine type to uint8_t.
-rw-r--r--src/being/playerinfo.cpp2
-rw-r--r--src/being/playerinfo.h2
-rw-r--r--src/gui/popups/itempopup.cpp10
-rw-r--r--src/gui/windows/tradewindow.cpp9
-rw-r--r--src/gui/windows/tradewindow.h4
-rw-r--r--src/inventory.cpp6
-rw-r--r--src/inventory.h4
-rw-r--r--src/item.cpp2
-rw-r--r--src/item.h12
-rw-r--r--src/net/ea/inventoryhandler.cpp10
-rw-r--r--src/net/ea/inventoryitem.h4
-rw-r--r--src/net/ea/tradehandler.cpp2
12 files changed, 38 insertions, 29 deletions
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index 5632c8d38..b84fb72a9 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -200,7 +200,7 @@ void clearInventory()
}
void setInventoryItem(const int index, const int id,
- const int amount, const int refine)
+ const int amount, const uint8_t refine)
{
bool equipment = false;
const ItemType::Type itemType = ItemDB::get(id).getType();
diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h
index 926173e21..abdc8bc69 100644
--- a/src/being/playerinfo.h
+++ b/src/being/playerinfo.h
@@ -152,7 +152,7 @@ namespace PlayerInfo
* Changes the inventory item at the given slot.
*/
void setInventoryItem(const int index, const int id,
- const int amount, const int refine);
+ const int amount, const uint8_t refine);
/**
* Returns the player's equipment.
diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp
index 99418881f..df245370c 100644
--- a/src/gui/popups/itempopup.cpp
+++ b/src/gui/popups/itempopup.cpp
@@ -117,13 +117,17 @@ void ItemPopup::setItem(const Item *const item, const bool showImage)
mLastId = item->getId();
if (serverVersion > 0)
{
- mItemName->setCaption(strprintf("%s (+%d), %d", ii.getName(
- item->getColor()).c_str(), item->getRefine(), ii.getId()));
+ mItemName->setCaption(strprintf("%s (+%u), %d",
+ ii.getName(item->getColor()).c_str(),
+ static_cast<unsigned int>(item->getRefine()),
+ ii.getId()));
}
else
{
mItemName->setCaption(strprintf("%s (+%d), %d",
- ii.getName().c_str(), item->getRefine(), ii.getId()));
+ ii.getName().c_str(),
+ static_cast<unsigned int>(item->getRefine()),
+ ii.getId()));
}
mItemName->adjustSize();
const unsigned minWidth = mItemName->getWidth() + 8;
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index 1fccb0c0b..21144b341 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -191,8 +191,11 @@ void TradeWindow::setMoney(const int amount)
mMoneyLabel->adjustSize();
}
-void TradeWindow::addItem(const int id, const bool own, const int quantity,
- const int refine, const unsigned char color) const
+void TradeWindow::addItem(const int id,
+ const bool own,
+ const int quantity,
+ const uint8_t refine,
+ const unsigned char color) const
{
if (own)
mMyInventory->addItem(id, quantity, refine, color);
@@ -201,7 +204,7 @@ void TradeWindow::addItem(const int id, const bool own, const int quantity,
}
void TradeWindow::addItem2(const int id, const bool own, const int quantity,
- const int refine, const unsigned char color,
+ const uint8_t refine, const unsigned char color,
const bool equipment) const
{
if (own)
diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h
index 447e99144..0c01c81cd 100644
--- a/src/gui/windows/tradewindow.h
+++ b/src/gui/windows/tradewindow.h
@@ -68,7 +68,7 @@ class TradeWindow final : public Window,
* Add an item to the trade window.
*/
void addItem(const int id, const bool own, const int quantity,
- const int refine, const unsigned char color) const;
+ const uint8_t refine, const unsigned char color) const;
/**
* Reset both item containers
@@ -79,7 +79,7 @@ class TradeWindow final : public Window,
* Add an item to the trade window.
*/
void addItem2(const int id, const bool own, const int quantity,
- const int refine, const unsigned char color,
+ const uint8_t refine, const unsigned char color,
const bool equipment) const;
/**
diff --git a/src/inventory.cpp b/src/inventory.cpp
index a2e890306..4248a9a73 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -103,14 +103,14 @@ Item *Inventory::findItem(const int itemId, const unsigned char color) const
return nullptr;
}
-void Inventory::addItem(const int id, const int quantity, const int refine,
- const unsigned char color, const bool equipment)
+void Inventory::addItem(const int id, const int quantity, const uint8_t refine,
+ const uint8_t color, const bool equipment)
{
setItem(getFreeSlot(), id, quantity, refine, color, equipment);
}
void Inventory::setItem(const int index, const int id, const int quantity,
- const int refine, const unsigned char color,
+ const uint8_t refine, const unsigned char color,
const bool equipment)
{
if (index < 0 || index >= static_cast<int>(mSize))
diff --git a/src/inventory.h b/src/inventory.h
index 86bdb080a..793c21286 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -87,14 +87,14 @@ class Inventory final
/**
* Adds a new item in a free slot.
*/
- void addItem(const int id, const int quantity, const int refine,
+ void addItem(const int id, const int quantity, const uint8_t refine,
const unsigned char color, const bool equipment = false);
/**
* Sets the item at the given position.
*/
void setItem(const int index, const int id, const int quantity,
- const int refine, const unsigned char color,
+ const uint8_t refine, const unsigned char color,
const bool equipment = false);
/**
diff --git a/src/item.cpp b/src/item.cpp
index 90ff716bb..ad84b724d 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -37,7 +37,7 @@ extern int serverVersion;
DragDrop dragDrop(nullptr, DRAGDROP_SOURCE_EMPTY);
-Item::Item(const int id, const int quantity, const int refine,
+Item::Item(const int id, const int quantity, const uint8_t refine,
const unsigned char color, const bool equipment,
const bool equipped) :
mId(0),
diff --git a/src/item.h b/src/item.h
index 0e8b47aef..208be2cc6 100644
--- a/src/item.h
+++ b/src/item.h
@@ -40,8 +40,10 @@ class Item notfinal
/**
* Constructor.
*/
- explicit Item(const int id = -1, const int quantity = 0,
- const int refine = 0, const unsigned char color = 1,
+ explicit Item(const int id = -1,
+ const int quantity = 0,
+ const uint8_t refine = 0,
+ const uint8_t color = 1,
const bool equipment = false,
const bool equipped = false);
@@ -114,13 +116,13 @@ class Item notfinal
/**
* Sets this item refine level.
*/
- void setRefine(const int refine)
+ void setRefine(const uint8_t refine)
{ mRefine = refine; }
/**
* Returns this item refine level.
*/
- int getRefine() const A_WARN_UNUSED
+ uint8_t getRefine() const A_WARN_UNUSED
{ return mRefine; }
/**
@@ -174,7 +176,7 @@ class Item notfinal
Image *mImage; /**< Item image. */
std::string mDescription;
std::map <int, int> mTags;
- int mRefine; /**< Item refine level. */
+ uint8_t mRefine; /**< Item refine level. */
int mInvIndex; /**< Inventory index. */
bool mEquipment; /**< Item is equipment. */
bool mEquipped; /**< Item is equipped. */
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 6788784b2..2b2d1cc9e 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -267,10 +267,10 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg)
if (mDebugInventory)
{
logger->log("Index: %d, ID: %d, Type: %d, Identified: %d, "
- "Qty: %d, Cards: %d, %d, %d, %d, Refine: %d",
- index, itemId, itemType, identified, amount,
- cards[0], cards[1], cards[2], cards[3],
- refine);
+ "Qty: %d, Cards: %d, %d, %d, %d, Refine: %u",
+ index, itemId, itemType,
+ static_cast<unsigned int>(identified), amount,
+ cards[0], cards[1], cards[2], cards[3], refine);
}
if (serverVersion < 1 && identified > 1U)
@@ -299,7 +299,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
const int itemId = msg.readInt16();
uint8_t identified = msg.readUInt8();
msg.readUInt8(); // attribute
- const int refine = msg.readUInt8();
+ const uint8_t refine = msg.readUInt8();
for (int i = 0; i < 4; i++)
msg.readInt16(); // cards[i]
const int equipType = msg.readInt16();
diff --git a/src/net/ea/inventoryitem.h b/src/net/ea/inventoryitem.h
index 2b8ac502a..f46ff48be 100644
--- a/src/net/ea/inventoryitem.h
+++ b/src/net/ea/inventoryitem.h
@@ -35,12 +35,12 @@ class InventoryItem final
int slot;
int id;
int quantity;
- int refine;
+ uint8_t refine;
unsigned char color;
bool equip;
InventoryItem(const int slot0, const int id0, const int quantity0,
- const int refine0, const unsigned char color0,
+ const uint8_t refine0, const unsigned char color0,
const bool equip0) :
slot(slot0),
id(id0),
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index 0d0fd05da..d6715d4f6 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -183,7 +183,7 @@ void TradeHandler::processTradeItemAdd(Net::MessageIn &msg)
const int type = msg.readInt16();
const uint8_t identify = msg.readUInt8(); // identified flag
msg.readUInt8(); // attribute
- const int refine = msg.readUInt8(); // refine
+ const uint8_t refine = msg.readUInt8(); // refine
msg.skip(8); // card (4 shorts)
if (tradeWindow)