summaryrefslogtreecommitdiff
path: root/src
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
parent7aa637abc8b0bca35aacdb9492e65f557ed32038 (diff)
downloadplus-41cc92f73e39cec5dfea6b1164176610cccc7df4.tar.gz
plus-41cc92f73e39cec5dfea6b1164176610cccc7df4.tar.bz2
plus-41cc92f73e39cec5dfea6b1164176610cccc7df4.tar.xz
plus-41cc92f73e39cec5dfea6b1164176610cccc7df4.zip
Add strong typed int for item color.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/actions/actions.cpp17
-rw-r--r--src/actions/commands.cpp2
-rw-r--r--src/actormanager.cpp6
-rw-r--r--src/actormanager.h2
-rw-r--r--src/being/being.cpp79
-rw-r--r--src/being/being.h17
-rw-r--r--src/being/localplayer.cpp8
-rw-r--r--src/being/localplayer.h2
-rw-r--r--src/dragdrop.h26
-rw-r--r--src/dropshortcut.cpp4
-rw-r--r--src/enums/simpletypes/intdefines.h6
-rw-r--r--src/enums/simpletypes/itemcolor.h29
-rw-r--r--src/flooritem.cpp2
-rw-r--r--src/flooritem.h8
-rw-r--r--src/gui/models/shopitems.cpp9
-rw-r--r--src/gui/models/shopitems.h10
-rw-r--r--src/gui/popups/itempopup.cpp6
-rw-r--r--src/gui/popups/itempopup.h6
-rw-r--r--src/gui/popups/popupmenu.cpp19
-rw-r--r--src/gui/popups/popupmenu.h8
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp4
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp8
-rw-r--r--src/gui/widgets/selldialog.cpp2
-rw-r--r--src/gui/widgets/selldialog.h4
-rw-r--r--src/gui/widgets/virtshortcutcontainer.cpp4
-rw-r--r--src/gui/windows/buydialog.cpp5
-rw-r--r--src/gui/windows/buydialog.h3
-rw-r--r--src/gui/windows/buyingstoreselldialog.cpp2
-rw-r--r--src/gui/windows/charcreatedialog.cpp9
-rw-r--r--src/gui/windows/itemamountwindow.cpp3
-rw-r--r--src/gui/windows/maileditwindow.cpp3
-rw-r--r--src/gui/windows/mailviewwindow.cpp3
-rw-r--r--src/gui/windows/npcdialog.cpp4
-rw-r--r--src/gui/windows/outfitwindow.cpp11
-rw-r--r--src/gui/windows/outfitwindow.h4
-rw-r--r--src/gui/windows/shopwindow.cpp25
-rw-r--r--src/gui/windows/tradewindow.cpp4
-rw-r--r--src/gui/windows/tradewindow.h5
-rw-r--r--src/inventory.cpp13
-rw-r--r--src/inventory.h7
-rw-r--r--src/item.cpp10
-rw-r--r--src/item.h11
-rw-r--r--src/itemshortcut.cpp21
-rw-r--r--src/itemshortcut.h20
-rw-r--r--src/net/adminhandler.h4
-rw-r--r--src/net/cashshophandler.h4
-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
-rw-r--r--src/net/eathena/beinghandler.cpp50
-rw-r--r--src/net/eathena/buyingstorehandler.cpp4
-rw-r--r--src/net/eathena/buysellhandler.cpp2
-rw-r--r--src/net/eathena/cashshophandler.cpp4
-rw-r--r--src/net/eathena/cashshophandler.h2
-rw-r--r--src/net/eathena/charserverhandler.cpp6
-rw-r--r--src/net/eathena/inventoryhandler.cpp91
-rw-r--r--src/net/eathena/itemhandler.cpp10
-rw-r--r--src/net/eathena/markethandler.cpp4
-rw-r--r--src/net/eathena/markethandler.h2
-rw-r--r--src/net/eathena/npchandler.cpp2
-rw-r--r--src/net/eathena/npchandler.h2
-rw-r--r--src/net/eathena/tradehandler.cpp12
-rw-r--r--src/net/eathena/vendinghandler.cpp2
-rw-r--r--src/net/markethandler.h4
-rw-r--r--src/net/npchandler.h3
-rw-r--r--src/net/tmwa/beinghandler.cpp50
-rw-r--r--src/net/tmwa/buysellhandler.cpp2
-rw-r--r--src/net/tmwa/cashshophandler.cpp2
-rw-r--r--src/net/tmwa/cashshophandler.h2
-rw-r--r--src/net/tmwa/charserverhandler.cpp7
-rw-r--r--src/net/tmwa/inventoryhandler.cpp65
-rw-r--r--src/net/tmwa/itemhandler.cpp2
-rw-r--r--src/net/tmwa/markethandler.cpp2
-rw-r--r--src/net/tmwa/markethandler.h2
-rw-r--r--src/net/tmwa/npchandler.cpp2
-rw-r--r--src/net/tmwa/npchandler.h2
-rw-r--r--src/net/tmwa/tradehandler.cpp12
-rw-r--r--src/resources/beinginfo.cpp4
-rw-r--r--src/resources/beinginfo.h7
-rw-r--r--src/resources/db/colordb.cpp36
-rw-r--r--src/resources/db/colordb.h29
-rw-r--r--src/resources/iteminfo.cpp20
-rw-r--r--src/resources/iteminfo.h17
-rw-r--r--src/shopitem.cpp4
-rw-r--r--src/shopitem.h4
-rw-r--r--src/shortcutbase.cpp16
-rw-r--r--src/shortcutbase.h13
92 files changed, 615 insertions, 373 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3610eb3e1..43a2e0c5f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1091,6 +1091,7 @@ SET(SRCS
enums/simpletypes/identified.h
enums/simpletypes/ignorerecord.h
enums/simpletypes/intdefines.h
+ enums/simpletypes/itemcolor.h
enums/simpletypes/keep.h
enums/simpletypes/modal.h
enums/simpletypes/modifiable.h
diff --git a/src/Makefile.am b/src/Makefile.am
index cf6a2a8a2..9ec08b226 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -561,6 +561,7 @@ SRC += events/actionevent.h \
enums/simpletypes/identified.h \
enums/simpletypes/ignorerecord.h \
enums/simpletypes/intdefines.h \
+ enums/simpletypes/itemcolor.h \
enums/simpletypes/keep.h \
enums/simpletypes/modal.h \
enums/simpletypes/modifiable.h \
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index 92c0029ed..014ae10f8 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -439,7 +439,8 @@ impHandler(dropItemId)
return false;
// +++ ignoring item color for now
- Item *const item = inv->findItem(atoi(event.args.c_str()), 1);
+ Item *const item = inv->findItem(atoi(event.args.c_str()),
+ ItemColor_one);
if (item && !PlayerInfo::isItemProtected(item->getId()))
{
@@ -467,7 +468,8 @@ impHandler(dropItemIdAll)
return false;
// +++ ignoring item color for now
- Item *const item = inv->findItem(atoi(event.args.c_str()), 1);
+ Item *const item = inv->findItem(atoi(event.args.c_str()),
+ ItemColor_one);
if (item && !PlayerInfo::isItemProtected(item->getId()))
PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true);
@@ -1485,14 +1487,14 @@ impHandler0(createItems)
if (!colors)
{
- dialog->addItem(id, 0, 1, 100, 0);
+ dialog->addItem(id, 0, ItemColor_one, 100, 0);
}
else
{
- for (unsigned char f = 0; f < colors; f ++)
+ for (int f = 0; f < colors; f ++)
{
- if (!info->getColor(f).empty())
- dialog->addItem(id, 0, f, 100, 0);
+ if (!info->getColor(fromInt(f, ItemColor)).empty())
+ dialog->addItem(id, 0, fromInt(f, ItemColor), 100, 0);
}
}
}
@@ -1548,7 +1550,8 @@ impHandler(useItem)
if (inv)
{
// +++ ignoring item color for now
- const Item *const item = inv->findItem(itemId, 1);
+ const Item *const item = inv->findItem(itemId,
+ ItemColor_one);
PlayerInfo::useEquipItem(item, Sfx_true);
}
}
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index 8070efcc7..0a8ef91ba 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -285,7 +285,7 @@ impHandler(chatAdd)
if (inv)
{
// +++ need add also color here
- item = inv->findItem(id, 1);
+ item = inv->findItem(id, ItemColor_one);
}
if (item)
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 8e26e2f6b..96d234327 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -300,7 +300,7 @@ FloorItem *ActorManager::createItem(const BeingId id,
const int itemId,
const int x, const int y,
const int amount,
- const unsigned char color,
+ const ItemColor color,
const int subX, const int subY)
{
FloorItem *const floorItem = new FloorItem(id, itemId,
@@ -1840,12 +1840,12 @@ Being *ActorManager::cloneBeing(const Being *const srcBeing,
for (int slot = 0; slot < sz; slot ++)
{
const int spriteId = srcBeing->getSpriteID(slot);
- const unsigned char color = srcBeing->getSpriteColor(slot);
+ const ItemColor color = srcBeing->getSpriteColor(slot);
dstBeing->setSprite(slot, spriteId, "", color, false);
}
const int hairSlot = charServerHandler->hairSprite();
const int hairStyle = -srcBeing->getSpriteID(hairSlot);
- const unsigned char hairColor = srcBeing->getHairColor();
+ const ItemColor hairColor = srcBeing->getHairColor();
dstBeing->setSprite(hairSlot, hairStyle * -1,
ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
dstBeing->setHairColor(hairColor);
diff --git a/src/actormanager.h b/src/actormanager.h
index 270530f48..af597cbfb 100644
--- a/src/actormanager.h
+++ b/src/actormanager.h
@@ -84,7 +84,7 @@ class ActorManager final: public ConfigListener
const int itemId,
const int x, const int y,
const int amount,
- const unsigned char color,
+ const ItemColor color,
const int subX, const int subY);
/**
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 4ba600294..ca5d7fd1a 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -227,7 +227,7 @@ Being::Being(const BeingId id,
mTeamId(0U),
mLook(0U),
mBadgesCount(0U),
- mHairColor(0),
+ mHairColor(ItemColor_zero),
mErased(false),
mEnemy(false),
mGotComment(false),
@@ -354,7 +354,7 @@ void Being::setSubtype(const BeingTypeId subtype,
setupSpriteDisplay(mInfo->getDisplay(),
ForceDisplay_true,
0,
- mInfo->getColor(mLook));
+ mInfo->getColor(fromInt(mLook, ItemColor)));
mYDiff = mInfo->getSortOffsetY();
}
}
@@ -368,7 +368,7 @@ void Being::setSubtype(const BeingTypeId subtype,
setupSpriteDisplay(mInfo->getDisplay(),
ForceDisplay_true,
0,
- mInfo->getColor(mLook));
+ mInfo->getColor(fromInt(mLook, ItemColor)));
mYDiff = mInfo->getSortOffsetY();
}
}
@@ -381,7 +381,7 @@ void Being::setSubtype(const BeingTypeId subtype,
setupSpriteDisplay(mInfo->getDisplay(),
ForceDisplay_true,
0,
- mInfo->getColor(mLook));
+ mInfo->getColor(fromInt(mLook, ItemColor)));
mYDiff = mInfo->getSortOffsetY();
}
}
@@ -394,7 +394,7 @@ void Being::setSubtype(const BeingTypeId subtype,
setupSpriteDisplay(mInfo->getDisplay(),
ForceDisplay_true,
0,
- mInfo->getColor(mLook));
+ mInfo->getColor(fromInt(mLook, ItemColor)));
mYDiff = mInfo->getSortOffsetY();
}
}
@@ -456,7 +456,7 @@ void Being::setSubtype(const BeingTypeId subtype,
if (charServerHandler)
{
setSprite(charServerHandler->baseSprite(),
- id, info.getColor(mLook));
+ id, info.getColor(fromInt(mLook, ItemColor)));
}
}
}
@@ -2296,9 +2296,12 @@ void Being::updateColors()
}
}
-void Being::updateSprite(const unsigned int slot, const int id,
- std::string color, const unsigned char colorId,
- const bool isWeapon, const bool isTempSprite)
+void Being::updateSprite(const unsigned int slot,
+ const int id,
+ std::string color,
+ const ItemColor colorId,
+ const bool isWeapon,
+ const bool isTempSprite)
{
if (!charServerHandler || slot >= charServerHandler->maxSprite())
return;
@@ -2311,9 +2314,12 @@ void Being::updateSprite(const unsigned int slot, const int id,
setSprite(slot, id, color, colorId, isWeapon, isTempSprite);
}
-void Being::setSprite(const unsigned int slot, const int id,
- std::string color, const unsigned char colorId,
- const bool isWeapon, const bool isTempSprite)
+void Being::setSprite(const unsigned int slot,
+ const int id,
+ std::string color,
+ const ItemColor colorId,
+ const bool isWeapon,
+ const bool isTempSprite)
{
if (!charServerHandler || slot >= charServerHandler->maxSprite())
return;
@@ -2328,7 +2334,7 @@ void Being::setSprite(const unsigned int slot, const int id,
mSpriteColors.resize(slot + 1, "");
if (slot >= static_cast<unsigned int>(mSpriteColorsIds.size()))
- mSpriteColorsIds.resize(slot + 1, 1);
+ mSpriteColorsIds.resize(slot + 1, ItemColor_one);
// disabled for now, because it may broke replace/reorder sprites logic
// if (slot && mSpriteIDs[slot] == id)
@@ -2421,7 +2427,7 @@ void Being::setHairStyle(const unsigned int slot, const int id)
// dumpSprites();
}
-void Being::setHairColor(const unsigned int slot, const unsigned char color)
+void Being::setHairColor(const unsigned int slot, const ItemColor color)
{
mHairColor = color;
setSprite(slot, mSpriteIDs[slot], ItemDB::get(
@@ -2434,15 +2440,15 @@ void Being::dumpSprites() const
const std::vector<int>::const_iterator it1_end = mSpriteIDs.end();
StringVectCIter it2 = mSpriteColors.begin();
const StringVectCIter it2_end = mSpriteColors.end();
- std::vector<unsigned char>::const_iterator it3 = mSpriteColorsIds.begin();
- const std::vector<unsigned char>::const_iterator
+ std::vector<ItemColor>::const_iterator it3 = mSpriteColorsIds.begin();
+ const std::vector<ItemColor>::const_iterator
it3_end = mSpriteColorsIds.end();
logger->log("sprites");
for (; it1 != it1_end && it2 != it2_end && it3 != it3_end;
++ it1, ++ it2, ++ it3)
{
- logger->log("%d,%s,%d", *it1, (*it2).c_str(), *it3);
+ logger->log("%d,%s,%d", *it1, (*it2).c_str(), toInt(*it3, int));
}
}
@@ -2994,14 +3000,18 @@ void Being::recalcSpritesOrder()
{
setSprite(remSprite, repIt->second,
mSpriteColors[remSprite],
- 1, false, true);
+ ItemColor_one,
+ false,
+ true);
}
else
{
setSprite(remSprite, repIt->second,
ItemDB::get(repIt->second)
.getDyeColorsString(mHairColor),
- 1, false, true);
+ ItemColor_one,
+ false,
+ true);
}
updatedSprite[remSprite] = true;
}
@@ -3023,7 +3033,9 @@ void Being::recalcSpritesOrder()
{
setSprite(slot2, repIt->second,
mSpriteColors[slot2],
- 1, false, true);
+ ItemColor_one,
+ false,
+ true);
}
else
{
@@ -3031,7 +3043,9 @@ void Being::recalcSpritesOrder()
ItemDB::get(repIt->second)
.getDyeColorsString(
mHairColor),
- 1, false, true);
+ ItemColor_one,
+ false,
+ true);
}
updatedSprite[slot2] = true;
}
@@ -3174,7 +3188,12 @@ void Being::recalcSpritesOrder()
continue;
updatedSprite[slot] = true;
- setSprite(slot, id, mSpriteColors[slot], 1, false, true);
+ setSprite(slot,
+ id,
+ mSpriteColors[slot],
+ ItemColor_one,
+ false,
+ true);
}
}
}
@@ -3183,8 +3202,16 @@ void Being::recalcSpritesOrder()
if (mSpriteHide[slot] == 0)
{
const int id = mSpriteIDs[slot];
- if (updatedSprite[slot] == false && mSpriteDraw[slot] != id)
- setSprite(slot, id, mSpriteColors[slot], 1, false, true);
+ if (updatedSprite[slot] == false &&
+ mSpriteDraw[slot] != id)
+ {
+ setSprite(slot,
+ id,
+ mSpriteColors[slot],
+ ItemColor_one,
+ false,
+ true);
+ }
}
}
}
@@ -3467,10 +3494,10 @@ int Being::getSpriteID(const int slot) const
return mSpriteIDs[slot];
}
-unsigned char Being::getSpriteColor(const int slot) const
+ItemColor Being::getSpriteColor(const int slot) const
{
if (slot < 0 || static_cast<size_t>(slot) >= mSpriteColorsIds.size())
- return 1;
+ return ItemColor_one;
return mSpriteColorsIds[slot];
}
diff --git a/src/being/being.h b/src/being/being.h
index 8926e5548..7bb7def7d 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -27,6 +27,7 @@
#include "enums/gui/usercolorid.h"
+#include "enums/simpletypes/itemcolor.h"
#include "enums/simpletypes/move.h"
#include "resources/beinginfo.h"
@@ -306,13 +307,13 @@ class Being notfinal : public ActorSprite,
*/
void setSprite(const unsigned int slot, const int id,
std::string color = "",
- const unsigned char colorId = 1,
+ const ItemColor colorId = ItemColor_one,
const bool isWeapon = false,
const bool isTempSprite = false);
void updateSprite(const unsigned int slot, const int id,
std::string color = "",
- const unsigned char colorId = 1,
+ const ItemColor colorId = ItemColor_one,
const bool isWeapon = false,
const bool isTempSprite = false);
@@ -784,17 +785,17 @@ class Being notfinal : public ActorSprite,
int getSpriteID(const int slot) const A_WARN_UNUSED;
- unsigned char getSpriteColor(const int slot) const A_WARN_UNUSED;
+ ItemColor getSpriteColor(const int slot) const A_WARN_UNUSED;
void setHairStyle(const unsigned int slot, const int id);
void setHairColor(const unsigned int slot,
- const unsigned char color);
+ const ItemColor color);
- void setHairColor(const unsigned char color)
+ void setHairColor(const ItemColor color)
{ mHairColor = color; }
- unsigned char getHairColor() const A_WARN_UNUSED
+ ItemColor getHairColor() const A_WARN_UNUSED
{ return mHairColor; }
void recalcSpritesOrder();
@@ -1007,7 +1008,7 @@ class Being notfinal : public ActorSprite,
StringVect mSpriteColors;
std::vector<int> mSpriteIDs;
- std::vector<unsigned char> mSpriteColorsIds;
+ std::vector<ItemColor> mSpriteColorsIds;
SpriteParticleInfo mSpriteParticles;
// Character guild information
@@ -1139,7 +1140,7 @@ class Being notfinal : public ActorSprite,
uint16_t mTeamId;
uint16_t mLook;
uint16_t mBadgesCount;
- unsigned char mHairColor;
+ ItemColor mHairColor;
bool mErased;
bool mEnemy;
bool mGotComment;
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index acc6e2c0e..6722d5a4b 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -813,7 +813,7 @@ void LocalPlayer::untarget()
void LocalPlayer::pickedUp(const ItemInfo &itemInfo,
const int amount,
- const unsigned char color,
+ const ItemColor color,
const BeingId floorItemId,
const PickupT fail)
{
@@ -1317,7 +1317,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
const WeaponsInfos &swords = WeaponsDB::getSwords();
FOR_EACH (WeaponsInfosIter, it, swords)
{
- item = inv->findItem(*it, 0);
+ item = inv->findItem(*it, ItemColor_zero);
if (item)
break;
}
@@ -1337,7 +1337,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
const WeaponsInfos &shields = WeaponsDB::getShields();
FOR_EACH (WeaponsInfosIter, it, shields)
{
- item = inv->findItem(*it, 0);
+ item = inv->findItem(*it, ItemColor_zero);
if (item)
break;
}
@@ -1352,7 +1352,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
const WeaponsInfos &bows = WeaponsDB::getBows();
FOR_EACH (WeaponsInfosIter, it, bows)
{
- item = inv->findItem(*it, 0);
+ item = inv->findItem(*it, ItemColor_zero);
if (item)
break;
}
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index 475101528..c258a14f1 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -176,7 +176,7 @@ class LocalPlayer final : public Being,
*/
void pickedUp(const ItemInfo &itemInfo,
const int amount,
- const unsigned char color,
+ const ItemColor color,
const BeingId floorItemId,
const PickupT fail);
diff --git a/src/dragdrop.h b/src/dragdrop.h
index 814434124..278fc7639 100644
--- a/src/dragdrop.h
+++ b/src/dragdrop.h
@@ -27,6 +27,8 @@
#include "enums/dragdropsource.h"
+#include "enums/simpletypes/itemcolor.h"
+
#include "gui/widgets/skilldata.h"
#include "gui/widgets/skillinfo.h"
@@ -44,8 +46,8 @@ class DragDrop final
mItem(item ? item->getId() : 0),
mSelItem(0),
mTag(-1),
- mItemColor(item ? item->getColor() : static_cast<uint8_t>(1U)),
- mSelItemColor(1)
+ mItemColor(item ? item->getColor() : ItemColor_one),
+ mSelItemColor(ItemColor_one)
{
if (mItemImage)
mItemImage->incRef();
@@ -62,7 +64,7 @@ class DragDrop final
int getItem() const
{ return mItem; }
- uint8_t getItemColor() const
+ ItemColor getItemColor() const
{ return mItemColor; }
Image *getItemImage()
@@ -93,7 +95,7 @@ class DragDrop final
else
{
mItem = 0;
- mItemColor = 1;
+ mItemColor = ItemColor_one;
mItemImage = nullptr;
mSource = DRAGDROP_SOURCE_EMPTY;
mTag = -1;
@@ -107,7 +109,7 @@ class DragDrop final
if (mItemImage)
mItemImage->decRef();
mItem = 0;
- mItemColor = 1;
+ mItemColor = ItemColor_one;
if (command)
{
@@ -141,7 +143,7 @@ class DragDrop final
if (mItemImage)
mItemImage->decRef();
mItem = 0;
- mItemColor = 1;
+ mItemColor = ItemColor_one;
mText.clear();
mItemImage = nullptr;
mSource = DRAGDROP_SOURCE_EMPTY;
@@ -169,7 +171,7 @@ class DragDrop final
if (mItem)
ItemSoundManager::playSfx(mItem, ItemSoundEvent::PUT);
mItem = 0;
- mItemColor = 1;
+ mItemColor = ItemColor_one;
mItemImage = nullptr;
mSource = DRAGDROP_SOURCE_EMPTY;
mText.clear();
@@ -189,20 +191,20 @@ class DragDrop final
else
{
mSelItem = 0;
- mSelItemColor = 1;
+ mSelItemColor = ItemColor_one;
}
}
void deselect()
{
mSelItem = 0;
- mSelItemColor = 1;
+ mSelItemColor = ItemColor_one;
}
int getSelected() const
{ return mSelItem; }
- uint8_t getSelectedColor() const
+ ItemColor getSelectedColor() const
{ return mSelItemColor; }
bool isSelected() const
@@ -242,8 +244,8 @@ class DragDrop final
int mItem;
int mSelItem;
int mTag;
- uint8_t mItemColor;
- uint8_t mSelItemColor;
+ ItemColor mItemColor;
+ ItemColor mSelItemColor;
};
extern DragDrop dragDrop;
diff --git a/src/dropshortcut.cpp b/src/dropshortcut.cpp
index 02e831114..96d44311e 100644
--- a/src/dropshortcut.cpp
+++ b/src/dropshortcut.cpp
@@ -58,7 +58,7 @@ void DropShortcut::dropFirst() const
return;
const int itemId = getItem(0);
- const unsigned char itemColor = getItemColor(0);
+ const ItemColor itemColor = getItemColor(0);
if (PlayerInfo::isItemProtected(itemId))
return;
@@ -116,7 +116,7 @@ bool DropShortcut::dropItem(const int cnt)
return false;
int itemId = 0;
- unsigned char itemColor = 1;
+ ItemColor itemColor = ItemColor_one;
while (mLastDropIndex < DROP_SHORTCUT_ITEMS && itemId < 1)
{
if (!PlayerInfo::isItemProtected(itemId))
diff --git a/src/enums/simpletypes/intdefines.h b/src/enums/simpletypes/intdefines.h
index 984e9d411..975c63c3f 100644
--- a/src/enums/simpletypes/intdefines.h
+++ b/src/enums/simpletypes/intdefines.h
@@ -29,7 +29,8 @@
enum class name : type \
{ \
}; \
- const name name##_zero = static_cast<name>(0)
+ const name name##_zero = static_cast<name>(0); \
+ const name name##_one = static_cast<name>(1)
#define fromInt(val, name) static_cast<name>(val)
#define toInt(val, name) static_cast<name>(val)
@@ -39,7 +40,8 @@
#define defIntEnum(name, type) \
typedef type name; \
- const name name##_zero = 0
+ const name name##_zero = 0; \
+ const name name##_one = 1
#define fromInt(val, name) (val)
#define toInt(val, name) (val)
#define defIntEnumNeg(name) const name name##_negOne = -1
diff --git a/src/enums/simpletypes/itemcolor.h b/src/enums/simpletypes/itemcolor.h
new file mode 100644
index 000000000..55966596e
--- /dev/null
+++ b/src/enums/simpletypes/itemcolor.h
@@ -0,0 +1,29 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ENUMS_SIMPLETYPES_ITEMCOLOR_H
+#define ENUMS_SIMPLETYPES_ITEMCOLOR_H
+
+#include "enums/simpletypes/intdefines.h"
+
+defIntEnum(ItemColor, uint16_t);
+defIntEnumNeg(ItemColor);
+
+#endif // ENUMS_SIMPLETYPES_ITEMCOLOR_H
diff --git a/src/flooritem.cpp b/src/flooritem.cpp
index ea4ae21d3..d846d5f9b 100644
--- a/src/flooritem.cpp
+++ b/src/flooritem.cpp
@@ -47,7 +47,7 @@ FloorItem::FloorItem(const BeingId id,
const int itemId,
const int x, const int y,
const int amount,
- const unsigned char color) :
+ const ItemColor color) :
ActorSprite(id),
mItemId(itemId),
mX(x),
diff --git a/src/flooritem.h b/src/flooritem.h
index 33c95c062..fe0bd26ad 100644
--- a/src/flooritem.h
+++ b/src/flooritem.h
@@ -23,6 +23,8 @@
#ifndef FLOORITEM_H
#define FLOORITEM_H
+#include "enums/simpletypes/itemcolor.h"
+
#include "being/actorsprite.h"
#include "resources/cursor.h"
@@ -49,7 +51,7 @@ class FloorItem final : public ActorSprite
const int itemId,
const int x, const int y,
const int amount,
- const unsigned char color);
+ const ItemColor color);
A_DELETE_COPY(FloorItem)
@@ -88,7 +90,7 @@ class FloorItem final : public ActorSprite
unsigned getPickupCount() const A_WARN_UNUSED
{ return mPickupCount; }
- unsigned char getColor() const A_WARN_UNUSED
+ ItemColor getColor() const A_WARN_UNUSED
{ return mColor; }
bool getShowMsg() const A_WARN_UNUSED
@@ -111,7 +113,7 @@ class FloorItem final : public ActorSprite
int mHeightPosDiff;
unsigned int mPickupCount;
Cursor::Cursor mCursor;
- unsigned char mColor;
+ ItemColor mColor;
bool mShowMsg;
bool mHighlight;
};
diff --git a/src/gui/models/shopitems.cpp b/src/gui/models/shopitems.cpp
index 409ca3f63..05c4a5e6c 100644
--- a/src/gui/models/shopitems.cpp
+++ b/src/gui/models/shopitems.cpp
@@ -53,7 +53,7 @@ std::string ShopItems::getElementAt(int i)
ShopItem *ShopItems::addItem(const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int amount,
const int price)
{
@@ -65,7 +65,7 @@ ShopItem *ShopItems::addItem(const int id,
ShopItem *ShopItems::addItemNoDup(const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int amount,
const int price)
{
@@ -82,7 +82,7 @@ ShopItem *ShopItems::addItemNoDup(const int id,
ShopItem *ShopItems::addItem2(const int inventoryIndex,
const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int quantity,
const int price)
{
@@ -155,7 +155,8 @@ void ShopItems::clear()
mShopItems.clear();
}
-ShopItem *ShopItems::findItem(const int id, const unsigned char color) const
+ShopItem *ShopItems::findItem(const int id,
+ const ItemColor color) const
{
std::vector<ShopItem*>::const_iterator it = mShopItems.begin();
const std::vector<ShopItem*>::const_iterator e = mShopItems.end();
diff --git a/src/gui/models/shopitems.h b/src/gui/models/shopitems.h
index b222f9385..c964bdfb9 100644
--- a/src/gui/models/shopitems.h
+++ b/src/gui/models/shopitems.h
@@ -23,6 +23,8 @@
#ifndef GUI_MODELS_SHOPITEMS_H
#define GUI_MODELS_SHOPITEMS_H
+#include "enums/simpletypes/itemcolor.h"
+
#include "gui/models/listmodel.h"
#include <vector>
@@ -60,7 +62,7 @@ class ShopItems final : public ListModel
*/
ShopItem *addItem(const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int amount,
const int price);
@@ -76,13 +78,13 @@ class ShopItems final : public ListModel
ShopItem *addItem2(const int inventoryIndex,
const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int amount,
const int price);
ShopItem *addItemNoDup(const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int amount,
const int price);
@@ -145,7 +147,7 @@ class ShopItems final : public ListModel
* @return the item found or 0
*/
ShopItem *findItem(const int id,
- const unsigned char color) const A_WARN_UNUSED;
+ const ItemColor color) const A_WARN_UNUSED;
bool findInAllItems(std::vector<ShopItem*>::iterator &it,
const ShopItem *const item);
diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp
index 33b2eba91..ceb32cdaf 100644
--- a/src/gui/popups/itempopup.cpp
+++ b/src/gui/popups/itempopup.cpp
@@ -58,7 +58,7 @@ ItemPopup::ItemPopup() :
mIcon(new Icon(this, nullptr)),
mLastName(),
mLastId(0),
- mLastColor(1)
+ mLastColor(ItemColor_one)
{
// Item name
mItemName->setFont(boldFont);
@@ -153,7 +153,7 @@ void ItemPopup::setItem(const Item *const item,
}
void ItemPopup::setItem(const ItemInfo &item,
- const unsigned char color,
+ const ItemColor color,
const bool showImage,
int id,
const int *const cards)
@@ -336,6 +336,6 @@ void ItemPopup::mouseMoved(MouseEvent &event)
void ItemPopup::resetPopup()
{
mLastName.clear();
- mLastColor = 1;
+ mLastColor = ItemColor_one;
mLastId = 0;
}
diff --git a/src/gui/popups/itempopup.h b/src/gui/popups/itempopup.h
index fb3feefa2..a66262473 100644
--- a/src/gui/popups/itempopup.h
+++ b/src/gui/popups/itempopup.h
@@ -24,6 +24,8 @@
#ifndef GUI_POPUPS_ITEMPOPUP_H
#define GUI_POPUPS_ITEMPOPUP_H
+#include "enums/simpletypes/itemcolor.h"
+
#include "gui/widgets/popup.h"
#include "resources/itemtype.h"
@@ -58,7 +60,7 @@ class ItemPopup final : public Popup
* Sets the info to be displayed given a particular item.
*/
void setItem(const ItemInfo &item,
- const unsigned char color,
+ const ItemColor color,
const bool showImage,
int id,
const int *const cards);
@@ -82,7 +84,7 @@ class ItemPopup final : public Popup
Icon *mIcon;
std::string mLastName;
int mLastId;
- unsigned char mLastColor;
+ ItemColor mLastColor;
void setLabelColor(Label *label,
const ItemType::Type type) const A_NONNULL(2);
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 9adcc7b58..71a6d81d5 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -105,7 +105,7 @@ PopupMenu::PopupMenu() :
mFloorItemId(BeingId_zero),
mItem(nullptr),
mItemId(0),
- mItemColor(1),
+ mItemColor(ItemColor_one),
mMapItem(nullptr),
mTab(nullptr),
mSpell(nullptr),
@@ -1558,7 +1558,7 @@ void PopupMenu::handleLink(const std::string &link,
replaceAll(cmd, "'BEINGID'", toString(toInt(mBeingId, int)));
replaceAll(cmd, "'FLOORID'", toString(toInt(mFloorItemId, int)));
replaceAll(cmd, "'ITEMID'", toString(mItemId));
- replaceAll(cmd, "'ITEMCOLOR'", toString(mItemColor));
+ replaceAll(cmd, "'ITEMCOLOR'", toString(toInt(mItemColor, int)));
replaceAll(cmd, "'BEINGTYPEID'", toString(static_cast<int>(mType)));
replaceAll(cmd, "'PLAYER'", localPlayer->getName());
if (mItem)
@@ -1594,7 +1594,7 @@ void PopupMenu::handleLink(const std::string &link,
mFloorItemId = BeingId_zero;
mItem = nullptr;
mItemId = 0;
- mItemColor = 1;
+ mItemColor = ItemColor_one;
mMapItem = nullptr;
mTab = nullptr;
mSpell = nullptr;
@@ -1751,8 +1751,9 @@ void PopupMenu::showPopup(Window *const parent,
showPopup(x, y);
}
-void PopupMenu::showItemPopup(const int x, const int y, const int itemId,
- const unsigned char color)
+void PopupMenu::showItemPopup(const int x, const int y,
+ const int itemId,
+ const ItemColor color)
{
const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
@@ -1788,7 +1789,8 @@ void PopupMenu::showItemPopup(const int x, const int y, const int itemId,
}
}
-void PopupMenu::showItemPopup(const int x, const int y, Item *const item)
+void PopupMenu::showItemPopup(const int x, const int y,
+ Item *const item)
{
mItem = item;
mX = x;
@@ -1801,7 +1803,7 @@ void PopupMenu::showItemPopup(const int x, const int y, Item *const item)
else
{
mItemId = 0;
- mItemColor = 1;
+ mItemColor = ItemColor_one;
}
mNick.clear();
mBrowserBox->clearRows();
@@ -2103,7 +2105,8 @@ void PopupMenu::showPickupItemPopup(const int x, const int y,
}
void PopupMenu::showUndressPopup(const int x, const int y,
- const Being *const being, Item *const item)
+ const Being *const being,
+ Item *const item)
{
if (!being || !item)
return;
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
index 727818317..3952178f2 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -28,6 +28,7 @@
#include "enums/inventorytype.h"
#include "enums/simpletypes/beingid.h"
+#include "enums/simpletypes/itemcolor.h"
#include "gui/widgets/linkhandler.h"
#include "gui/widgets/popup.h"
@@ -105,8 +106,9 @@ class PopupMenu final : public Popup, public LinkHandler
void showItemPopup(const int x, const int y, Item *const item);
- void showItemPopup(const int x, const int y, const int itemId,
- const unsigned char color);
+ void showItemPopup(const int x, const int y,
+ const int itemId,
+ const ItemColor color);
void showDropPopup(const int x, const int y, Item *const item);
@@ -208,7 +210,7 @@ class PopupMenu final : public Popup, public LinkHandler
BeingId mFloorItemId;
Item *mItem;
int mItemId;
- unsigned char mItemColor;
+ ItemColor mItemColor;
MapItem *mMapItem;
ChatTab *mTab;
TextCommand *mSpell;
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index 5a11103d9..388f563bd 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -111,9 +111,9 @@ void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event)
splitToIntVector(str, link, ',');
if (str.empty())
return;
- unsigned char color = 1;
+ ItemColor color = ItemColor_one;
if (str.size() > 1)
- color = static_cast<unsigned char>(str[1]);
+ color = fromInt(str[1], ItemColor);
const int id = str[0];
if (id > 0)
{
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 689d967c8..21fe944ac 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -124,7 +124,7 @@ void ItemShortcutContainer::draw(Graphics *graphics)
itemX + 2, itemY + 2);
const int itemId = selShortcut->getItem(i);
- const unsigned char itemColor = selShortcut->getItemColor(i);
+ const ItemColor itemColor = selShortcut->getItemColor(i);
if (itemId < 0)
continue;
@@ -261,7 +261,7 @@ void ItemShortcutContainer::safeDraw(Graphics *graphics)
itemX + 2, itemY + 2);
const int itemId = selShortcut->getItem(i);
- const unsigned char itemColor = selShortcut->getItemColor(i);
+ const ItemColor itemColor = selShortcut->getItemColor(i);
if (itemId < 0)
continue;
@@ -372,7 +372,7 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
return;
const int itemId = selShortcut->getItem(index);
- const unsigned char itemColor = selShortcut->getItemColor(index);
+ const ItemColor itemColor = selShortcut->getItemColor(index);
if (itemId < 0)
return;
@@ -540,7 +540,7 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
return;
const int itemId = selShortcut->getItem(index);
- const unsigned char itemColor = selShortcut->getItemColor(index);
+ const ItemColor itemColor = selShortcut->getItemColor(index);
if (itemId < 0)
return;
diff --git a/src/gui/widgets/selldialog.cpp b/src/gui/widgets/selldialog.cpp
index 6498c25b6..827d1c3ea 100644
--- a/src/gui/widgets/selldialog.cpp
+++ b/src/gui/widgets/selldialog.cpp
@@ -197,7 +197,7 @@ void SellDialog::addItem(const Item *const item, const int price)
void SellDialog::addItem(const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int amount,
const int price)
{
diff --git a/src/gui/widgets/selldialog.h b/src/gui/widgets/selldialog.h
index dcc92cfd2..b5e91f67d 100644
--- a/src/gui/widgets/selldialog.h
+++ b/src/gui/widgets/selldialog.h
@@ -23,6 +23,8 @@
#ifndef GUI_WIDGETS_SELLDIALOG_H
#define GUI_WIDGETS_SELLDIALOG_H
+#include "enums/simpletypes/itemcolor.h"
+
#include "gui/widgets/window.h"
#include "listeners/actionlistener.h"
@@ -92,7 +94,7 @@ class SellDialog notfinal : public Window,
void addItem(const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int amount,
const int price);
diff --git a/src/gui/widgets/virtshortcutcontainer.cpp b/src/gui/widgets/virtshortcutcontainer.cpp
index 3c28f244f..4066a915c 100644
--- a/src/gui/widgets/virtshortcutcontainer.cpp
+++ b/src/gui/widgets/virtshortcutcontainer.cpp
@@ -233,7 +233,7 @@ void VirtShortcutContainer::mouseDragged(MouseEvent &event)
return;
const int itemId = mShortcut->getItem(index);
- const unsigned char itemColor = mShortcut->getItemColor(index);
+ const ItemColor itemColor = mShortcut->getItemColor(index);
if (itemId < 0)
return;
@@ -347,7 +347,7 @@ void VirtShortcutContainer::mouseMoved(MouseEvent &event)
return;
const int itemId = mShortcut->getItem(index);
- const unsigned char itemColor = mShortcut->getItemColor(index);
+ const ItemColor itemColor = mShortcut->getItemColor(index);
if (itemId < 0)
return;
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index 84a7a1182..667867ff4 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -363,7 +363,7 @@ void BuyDialog::reset()
ShopItem *BuyDialog::addItem(const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int amount,
const int price)
{
@@ -493,7 +493,8 @@ void BuyDialog::action(const ActionEvent &event)
if (mNpcId == fromInt(Items, BeingId))
{
adminHandler->createItems(item->getId(),
- mAmountItems, item->getColor());
+ item->getColor(),
+ mAmountItems);
}
else if (mNpcId != fromInt(Nick, BeingId))
{
diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h
index 7aaa1e7c5..104b5c4ee 100644
--- a/src/gui/windows/buydialog.h
+++ b/src/gui/windows/buydialog.h
@@ -24,6 +24,7 @@
#define GUI_WINDOWS_BUYDIALOG_H
#include "enums/simpletypes/beingid.h"
+#include "enums/simpletypes/itemcolor.h"
#include "gui/widgets/window.h"
@@ -105,7 +106,7 @@ class BuyDialog final : public Window,
*/
ShopItem *addItem(const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int amount,
const int price);
diff --git a/src/gui/windows/buyingstoreselldialog.cpp b/src/gui/windows/buyingstoreselldialog.cpp
index 55b6a96fb..637bdc5bd 100644
--- a/src/gui/windows/buyingstoreselldialog.cpp
+++ b/src/gui/windows/buyingstoreselldialog.cpp
@@ -58,7 +58,7 @@ void BuyingStoreSellDialog::sellAction(const ActionEvent &event A_UNUSED)
return;
// +++ need add colors
Item *const item2 = PlayerInfo::getInventory()->findItem(
- item1->getId(), 1);
+ item1->getId(), ItemColor_one);
if (!item2)
return;
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index 2168ad0a1..6af4a6437 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -624,11 +624,13 @@ void CharCreateDialog::updateHair()
{
mHairColor = minHairColor;
}
- mHairColorNameLabel->setCaption(ColorDB::getHairColorName(mHairColor));
+ mHairColorNameLabel->setCaption(ColorDB::getHairColorName(
+ fromInt(mHairColor, ItemColor)));
mHairColorNameLabel->resizeTo(150, 150);
mPlayer->setSprite(charServerHandler->hairSprite(),
- mHairStyle * -1, item.getDyeColorsString(mHairColor));
+ mHairStyle * -1,
+ item.getDyeColorsString(fromInt(mHairColor, ItemColor)));
}
void CharCreateDialog::updateRace()
@@ -667,7 +669,8 @@ void CharCreateDialog::updateLook()
}
if (mLookNameLabel)
{
- mLookNameLabel->setCaption(item.getColorName(mLook));
+ mLookNameLabel->setCaption(item.getColorName(
+ fromInt(mLook, ItemColor)));
mLookNameLabel->resizeTo(150, 150);
}
}
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index b1c10f058..a48a6dab2 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -355,7 +355,8 @@ void ItemAmountWindow::action(const ActionEvent &event)
const int id = ItemDB::get(mItemsModal->getElementAt(
mItemDropDown->getSelected())).getId();
- mItem = new Item(id, 0, 10000, 0, 1,
+ mItem = new Item(id, 0, 10000, 0,
+ ItemColor_one,
Identified_true,
Damaged_true,
Favorite_false,
diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp
index 1699b979c..51495563d 100644
--- a/src/gui/windows/maileditwindow.cpp
+++ b/src/gui/windows/maileditwindow.cpp
@@ -138,7 +138,8 @@ void MailEditWindow::action(const ActionEvent &event)
const Inventory *const inv = PlayerInfo::getInventory();
if (inv)
{
- const Item *const item = inv->findItem(tempItem->getId(), 1);
+ const Item *const item = inv->findItem(
+ tempItem->getId(), ItemColor_one);
if (item)
{
mailHandler->setAttach(item->getInvIndex(),
diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp
index 544c80f0d..ad7eb8a88 100644
--- a/src/gui/windows/mailviewwindow.cpp
+++ b/src/gui/windows/mailviewwindow.cpp
@@ -111,7 +111,8 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
const ItemInfo &item = ItemDB::get(message->itemId);
Image *const image = resman->getImage(combineDye2(
paths.getStringValue("itemIcons").append(
- item.getDisplay().image), item.getDyeColorsString(1)));
+ item.getDisplay().image),
+ item.getDyeColorsString(ItemColor_one)));
mIcon = new Icon(this, image);
if (message->itemAmount != 1)
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index 10eb3dc8a..c0396bc06 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -369,7 +369,7 @@ void NpcDialog::action(const ActionEvent &event)
if (item)
{
str = strprintf("%d,%d", item->getId(),
- item->getColor());
+ toInt(item->getColor(), int));
}
else
{
@@ -382,7 +382,7 @@ void NpcDialog::action(const ActionEvent &event)
if (item)
{
str.append(strprintf("%d,%d", item->getId(),
- item->getColor()));
+ toInt(item->getColor(), int)));
}
else
{
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index a0a7fa7c2..7ce43333b 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -172,7 +172,7 @@ void OutfitWindow::load(const bool oldConfig)
for (size_t i = 0, sz = tokens2.size();
i < sz && i < OUTFIT_ITEM_COUNT; i++)
{
- mItemColors[o][i] = tokens2[i];
+ mItemColors[o][i] = fromInt(tokens2[i], ItemColor);
}
mItemsUnequip[o] = cfg->getValueBool("OutfitUnequip" + toString(o),
@@ -203,7 +203,7 @@ void OutfitWindow::save() const
if (i < OUTFIT_ITEM_COUNT - 1)
outfitStr.append(" ");
outfitColorsStr.append(toString(static_cast<int>(
- mItemColors[o][i])));
+ toInt(mItemColors[o][i], int))));
if (i < OUTFIT_ITEM_COUNT - 1)
outfitColorsStr.append(" ");
}
@@ -278,7 +278,8 @@ void OutfitWindow::wearOutfit(const int outfit, const bool unwearEmpty,
for (unsigned i = 0; i < OUTFIT_ITEM_COUNT; i++)
{
const Item *const item = PlayerInfo::getInventory()->findItem(
- mItems[outfit][i], mItemColors[outfit][i]);
+ mItems[outfit][i],
+ mItemColors[outfit][i]);
if (item
&& item->isEquipped() == Equipped_false
&& item->getQuantity())
@@ -453,7 +454,7 @@ void OutfitWindow::mouseDragged(MouseEvent &event)
return;
}
const int itemId = mItems[mCurrentOutfit][index];
- const unsigned char itemColor = mItemColors[mCurrentOutfit][index];
+ const ItemColor itemColor = mItemColors[mCurrentOutfit][index];
if (itemId < 0)
{
Window::mouseDragged(event);
@@ -719,7 +720,7 @@ void OutfitWindow::clearCurrentOutfit()
for (unsigned f = 0; f < OUTFIT_ITEM_COUNT; f++)
{
mItems[mCurrentOutfit][f] = -1;
- mItemColors[mCurrentOutfit][f] = 1;
+ mItemColors[mCurrentOutfit][f] = ItemColor_one;
}
save();
}
diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h
index 7033a3f13..27a3d73aa 100644
--- a/src/gui/windows/outfitwindow.h
+++ b/src/gui/windows/outfitwindow.h
@@ -23,6 +23,8 @@
#ifndef GUI_WINDOWS_OUTFITWINDOW_H
#define GUI_WINDOWS_OUTFITWINDOW_H
+#include "enums/simpletypes/itemcolor.h"
+
#include "gui/widgets/window.h"
#include "listeners/actionlistener.h"
@@ -119,7 +121,7 @@ class OutfitWindow final : public Window,
int mItems[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT];
int mAwayOutfit;
- unsigned char mItemColors[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT];
+ ItemColor mItemColors[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT];
bool mItemClicked;
bool mItemsUnequip[OUTFITS_COUNT];
};
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index b8e31ead8..c5014f902 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -348,7 +348,8 @@ void ShopWindow::action(const ActionEvent &event)
if (!item)
continue;
// +++ need add colors
- Item *const cartItem = inv->findItem(item->getId(), 1);
+ Item *const cartItem = inv->findItem(item->getId(),
+ ItemColor_one);
if (!cartItem)
continue;
item->setInvIndex(cartItem->getInvIndex());
@@ -391,7 +392,7 @@ void ShopWindow::action(const ActionEvent &event)
return;
// +++ need support for colors
- Item *const item = inv->findItem(mSelectedItem, 0);
+ Item *const item = inv->findItem(mSelectedItem, ItemColor_zero);
if (item)
{
if (eventId == "add")
@@ -551,12 +552,12 @@ void ShopWindow::loadList()
if (tokens[1] && tokens[2] && mBuyShopItems)
{
mBuyShopItems->addItem(
- tokens[0], 0, 1, tokens[1], tokens[2]);
+ tokens[0], 0, ItemColor_one, tokens[1], tokens[2]);
}
if (tokens[3] && tokens[4] && mSellShopItems)
{
mSellShopItems->addItem(
- tokens[0], 0, 1, tokens[3], tokens[4]);
+ tokens[0], 0, ItemColor_one, tokens[3], tokens[4]);
}
}
}
@@ -748,7 +749,8 @@ void ShopWindow::giveList(const std::string &nick, const int mode)
if (mode == SELL)
{
// +++ need support for colors
- const Item *const item2 = inv->findItem(item->getId(), 0);
+ const Item *const item2 = inv->findItem(item->getId(),
+ ItemColor_zero);
if (item2)
{
int amount = item->getQuantity();
@@ -844,19 +846,19 @@ void ShopWindow::showList(const std::string &nick, std::string data)
int amount = decodeStr(data.substr(f + 6, 3));
// +++ need impliment colors?
if (buyDialog && amount > 0)
- buyDialog->addItem(id, 0, 1, amount, price);
+ buyDialog->addItem(id, 0, ItemColor_one, amount, price);
if (sellDialog)
{
// +++ need support for colors
- const Item *const item = inv->findItem(id, 0);
+ const Item *const item = inv->findItem(id, ItemColor_zero);
if (item)
{
if (item->getQuantity() < amount)
amount = item->getQuantity();
if (amount > 0)
- sellDialog->addItem(id, 0, 1, amount, price);
+ sellDialog->addItem(id, 0, ItemColor_one, amount, price);
else
- sellDialog->addItem(id, 0, 1, -1, price);
+ sellDialog->addItem(id, 0, ItemColor_one, -1, price);
}
}
}
@@ -919,12 +921,13 @@ void ShopWindow::processRequest(const std::string &nick, std::string data,
delete mTradeItem;
// +++ need impliment colors?
- mTradeItem = new ShopItem(-1, id, 0, 1, amount, price);
+ mTradeItem = new ShopItem(-1, id, 0, ItemColor_one, amount, price);
if (mode == BUY)
{
// +++ need support for colors
- const Item *const item2 = inv->findItem(mTradeItem->getId(), 0);
+ const Item *const item2 = inv->findItem(mTradeItem->getId(),
+ ItemColor_zero);
if (!item2 || item2->getQuantity() < amount
|| !findShopItem(mTradeItem, SELL))
{
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index bf4963daf..7a835b686 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -196,7 +196,7 @@ void TradeWindow::addItem(const int id,
const bool own,
const int quantity,
const uint8_t refine,
- const unsigned char color,
+ const ItemColor color,
const Identified identified,
const Damaged damaged,
const Favorite favorite) const
@@ -221,7 +221,7 @@ void TradeWindow::addItem2(const int id,
const bool own,
const int quantity,
const uint8_t refine,
- const unsigned char color,
+ const ItemColor color,
const Identified identified,
const Damaged damaged,
const Favorite favorite,
diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h
index a191671d5..b1ac84045 100644
--- a/src/gui/windows/tradewindow.h
+++ b/src/gui/windows/tradewindow.h
@@ -29,6 +29,7 @@
#include "enums/simpletypes/equipm.h"
#include "enums/simpletypes/favorite.h"
#include "enums/simpletypes/identified.h"
+#include "enums/simpletypes/itemcolor.h"
#include "listeners/actionlistener.h"
#include "listeners/selectionlistener.h"
@@ -75,7 +76,7 @@ class TradeWindow final : public Window,
const bool own,
const int quantity,
const uint8_t refine,
- const unsigned char color,
+ const ItemColor color,
const Identified identified,
const Damaged damaged,
const Favorite favorite) const;
@@ -95,7 +96,7 @@ class TradeWindow final : public Window,
const bool own,
const int quantity,
const uint8_t refine,
- const unsigned char color,
+ const ItemColor color,
const Identified identified,
const Damaged damaged,
const Favorite favorite,
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 8b396e1d5..c83ea5353 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -83,15 +83,18 @@ Item *Inventory::getItem(const int index) const
return mItems[index];
}
-Item *Inventory::findItem(const int itemId, const unsigned char color) const
+Item *Inventory::findItem(const int itemId,
+ const ItemColor color) const
{
for (unsigned i = 0; i < mSize; i++)
{
Item *const item = mItems[i];
if (item && item->mId == itemId)
{
- if (color == 0 || item->mColor == color
- || (color == 1 && item->mColor <= 1))
+ if (color == ItemColor_zero ||
+ item->mColor == color ||
+ (color == ItemColor_one &&
+ item->mColor <= ItemColor_one))
{
return item;
}
@@ -105,7 +108,7 @@ int Inventory::addItem(const int id,
const int type,
const int quantity,
const uint8_t refine,
- const uint8_t color,
+ const ItemColor color,
const Identified identified,
const Damaged damaged,
const Favorite favorite,
@@ -123,7 +126,7 @@ void Inventory::setItem(const int index,
const int type,
const int quantity,
const uint8_t refine,
- const unsigned char color,
+ const ItemColor color,
const Identified identified,
const Damaged damaged,
const Favorite favorite,
diff --git a/src/inventory.h b/src/inventory.h
index 588842d70..5fe92a84f 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -31,6 +31,7 @@
#include "enums/simpletypes/equipped.h"
#include "enums/simpletypes/favorite.h"
#include "enums/simpletypes/identified.h"
+#include "enums/simpletypes/itemcolor.h"
#include "enums/being/gender.h"
@@ -81,7 +82,7 @@ class Inventory final
* @return Item found on success, NULL on failure.
*/
Item *findItem(const int itemId,
- const unsigned char color) const A_WARN_UNUSED;
+ const ItemColor color) const A_WARN_UNUSED;
/**
* Adds a new item in a free slot.
@@ -90,7 +91,7 @@ class Inventory final
const int type,
const int quantity,
const uint8_t refine,
- const unsigned char color,
+ const ItemColor color,
const Identified identified,
const Damaged damaged,
const Favorite favorite,
@@ -105,7 +106,7 @@ class Inventory final
const int type,
const int quantity,
const uint8_t refine,
- const unsigned char color,
+ const ItemColor color,
const Identified identified,
const Damaged damaged,
const Favorite favorite,
diff --git a/src/item.cpp b/src/item.cpp
index 7fa816c86..0ccfd025a 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -40,14 +40,14 @@ Item::Item(const int id,
const int type,
const int quantity,
const uint8_t refine,
- const unsigned char color,
+ const ItemColor color,
const Identified identified,
const Damaged damaged,
const Favorite favorite,
const Equipm equipment,
const Equipped equipped) :
mId(0),
- mColor(0),
+ mColor(ItemColor_zero),
mQuantity(quantity),
mImage(nullptr),
mDescription(),
@@ -78,7 +78,8 @@ Item::~Item()
dragDrop.clearItem(this);
}
-void Item::setId(const int id, const unsigned char color)
+void Item::setId(const int id,
+ const ItemColor color)
{
mId = id;
mColor = color;
@@ -114,7 +115,8 @@ bool Item::isHaveTag(const int tagId) const
return (*it).second > 0;
}
-Image *Item::getImage(const int id, const unsigned char color)
+Image *Item::getImage(const int id,
+ const ItemColor color)
{
ResourceManager *const resman = ResourceManager::getInstance();
const ItemInfo &info = ItemDB::get(id);
diff --git a/src/item.h b/src/item.h
index 815160c32..c3b22a9dc 100644
--- a/src/item.h
+++ b/src/item.h
@@ -28,6 +28,7 @@
#include "enums/simpletypes/equipped.h"
#include "enums/simpletypes/favorite.h"
#include "enums/simpletypes/identified.h"
+#include "enums/simpletypes/itemcolor.h"
#include "resources/db/itemdb.h"
@@ -50,7 +51,7 @@ class Item notfinal
const int type,
const int quantity,
const uint8_t refine,
- const uint8_t color,
+ const ItemColor color,
const Identified identified,
const Damaged damaged,
const Favorite favorite,
@@ -67,7 +68,7 @@ class Item notfinal
/**
* Sets the item id, color the item type.
*/
- void setId(const int id, const unsigned char color);
+ void setId(const int id, const ItemColor color);
/**
* Returns the item id.
@@ -168,11 +169,11 @@ class Item notfinal
std::string getName() const A_WARN_UNUSED;
static Image *getImage(const int id,
- const unsigned char color) A_WARN_UNUSED;
+ const ItemColor color) A_WARN_UNUSED;
bool isHaveTag(const int tagId) const A_WARN_UNUSED;
- unsigned char getColor() const A_WARN_UNUSED
+ ItemColor getColor() const A_WARN_UNUSED
{ return mColor; }
const std::string &getDescription() const A_WARN_UNUSED
@@ -214,7 +215,7 @@ class Item notfinal
void addCard(const int card);
int mId; /**< Item type id. */
- unsigned char mColor;
+ ItemColor mColor;
int mQuantity; /**< Number of items. */
protected:
diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp
index 05035c5d0..b9696a2a2 100644
--- a/src/itemshortcut.cpp
+++ b/src/itemshortcut.cpp
@@ -39,7 +39,7 @@ ItemShortcut *itemShortcut[SHORTCUT_TABS];
ItemShortcut::ItemShortcut(const int number) :
mItemSelected(-1),
- mItemColorSelected(1),
+ mItemColorSelected(ItemColor_one),
mNumber(number)
{
load();
@@ -74,8 +74,9 @@ void ItemShortcut::load(const bool oldConfig)
for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++)
{
const int itemId = cfg->getValue(name + toString(i), -1);
- const unsigned char itemColor = static_cast<const unsigned char>(
- cfg->getValue(color + toString(i), 1));
+ const ItemColor itemColor = fromInt(
+ cfg->getValue(color + toString(i), 1),
+ ItemColor);
mItems[i] = itemId;
mItemColors[i] = itemColor;
@@ -103,7 +104,8 @@ void ItemShortcut::save() const
for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++)
{
const int itemId = mItems[i] ? mItems[i] : -1;
- const int itemColor = mItemColors[i] ? mItemColors[i] : 1;
+ const int itemColor = (mItemColors[i] != ItemColor_zero) ?
+ toInt(mItemColors[i], int) : 1;
if (itemId != -1)
{
serverConfig.setValue(name + toString(i), itemId);
@@ -124,7 +126,7 @@ void ItemShortcut::useItem(const int index) const
return;
const int itemId = mItems[index];
- const unsigned char itemColor = mItemColors[index];
+ const ItemColor itemColor = mItemColors[index];
if (itemId >= 0)
{
if (itemId < SPELL_MIN_ID)
@@ -195,7 +197,7 @@ void ItemShortcut::setItemSelected(const Item *const item)
else
{
mItemSelected = -1;
- mItemColorSelected = 1;
+ mItemColorSelected = ItemColor_one;
}
}
@@ -206,8 +208,9 @@ void ItemShortcut::setItem(const int index)
save();
}
-void ItemShortcut::setItem(const int index, const int item,
- const unsigned char color)
+void ItemShortcut::setItem(const int index,
+ const int item,
+ const ItemColor color)
{
mItems[index] = item;
mItemColors[index] = color;
@@ -226,7 +229,7 @@ void ItemShortcut::swap(const int index1, const int index2)
const int tmpItem = mItems[index1];
mItems[index1] = mItems[index2];
mItems[index2] = tmpItem;
- const unsigned char tmpColor = mItemColors[index1];
+ const ItemColor tmpColor = mItemColors[index1];
mItemColors[index1] = mItemColors[index2];
mItemColors[index2] = tmpColor;
save();
diff --git a/src/itemshortcut.h b/src/itemshortcut.h
index 30549f0b8..7dd093abd 100644
--- a/src/itemshortcut.h
+++ b/src/itemshortcut.h
@@ -23,6 +23,8 @@
#ifndef ITEMSHORTCUT_H
#define ITEMSHORTCUT_H
+#include "enums/simpletypes/itemcolor.h"
+
#include "localconsts.h"
const unsigned int SHORTCUT_ITEMS = 20;
@@ -66,7 +68,7 @@ class ItemShortcut final
int getItem(const int index) const A_WARN_UNUSED
{ return mItems[index]; }
- unsigned char getItemColor(const int index) const A_WARN_UNUSED
+ ItemColor getItemColor(const int index) const A_WARN_UNUSED
{ return mItemColors[index]; }
/**
@@ -88,8 +90,9 @@ class ItemShortcut final
*/
void setItem(const int index);
- void setItem(const int index, const int item,
- const unsigned char color);
+ void setItem(const int index,
+ const int item,
+ const ItemColor color);
/**
* Adds an item to the items store specified by the index.
@@ -97,8 +100,9 @@ class ItemShortcut final
* @param index Index of the item.
* @param itemId ID of the item.
*/
- void setItems(const int index, const int itemId,
- const unsigned char color)
+ void setItems(const int index,
+ const int itemId,
+ const ItemColor color)
{ mItems[index] = itemId; mItemColors[index] = color; save(); }
/**
@@ -149,10 +153,10 @@ class ItemShortcut final
void swap(const int index1, const int index2);
private:
- int mItems[SHORTCUT_ITEMS]; /**< The items. */
- unsigned char mItemColors[SHORTCUT_ITEMS]; /**< The item colors. */
+ int mItems[SHORTCUT_ITEMS]; /**< The items. */
+ ItemColor mItemColors[SHORTCUT_ITEMS]; /**< The item colors. */
int mItemSelected;
- unsigned char mItemColorSelected;
+ ItemColor mItemColorSelected;
int mNumber;
};
diff --git a/src/net/adminhandler.h b/src/net/adminhandler.h
index 77f0508a8..328290ea8 100644
--- a/src/net/adminhandler.h
+++ b/src/net/adminhandler.h
@@ -24,6 +24,7 @@
#define NET_ADMINHANDLER_H
#include "enums/simpletypes/beingid.h"
+#include "enums/simpletypes/itemcolor.h"
#include <string>
@@ -69,7 +70,8 @@ class AdminHandler notfinal
virtual void warp(const std::string &map,
const int x, const int y) const = 0;
- virtual void createItems(const int id, const int color,
+ virtual void createItems(const int id,
+ const ItemColor color,
const int amount) const = 0;
virtual void gotoName(const std::string &name) const = 0;
diff --git a/src/net/cashshophandler.h b/src/net/cashshophandler.h
index 64a04d8ed..1577aa543 100644
--- a/src/net/cashshophandler.h
+++ b/src/net/cashshophandler.h
@@ -23,6 +23,8 @@
#ifdef EATHENA_SUPPORT
+#include "enums/simpletypes/itemcolor.h"
+
#include <string>
#include "localconsts.h"
@@ -38,7 +40,7 @@ class CashShopHandler notfinal
virtual void buyItem(const int points,
const int itemId,
- const unsigned char color,
+ const ItemColor color,
const int amount) const = 0;
virtual void close() const = 0;
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);
}
}
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index 35d549149..5c748915b 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -585,100 +585,101 @@ void BeingHandler::processBeingChangeLookContinue(Net::MessageIn &msg,
dstBeing->getLook());
break;
case 1: // eAthena LOOK_HAIR
- dstBeing->setHairColor(id);
+ dstBeing->setHairColor(fromInt(id, ItemColor));
dstBeing->setSpriteID(SPRITE_HAIR_COLOR, id * -1);
break;
case 2: // LOOK_WEAPON Weapon ID in id, Shield ID in id2
- dstBeing->setSprite(SPRITE_BODY, id, "", 1, true);
+ dstBeing->setSprite(SPRITE_BODY, id, "", ItemColor_one, true);
dstBeing->setSprite(SPRITE_FLOOR, id2);
if (localPlayer)
localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
break;
case 3: // LOOK_HEAD_BOTTOM
dstBeing->setSprite(SPRITE_WEAPON, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
if (localPlayer)
localPlayer->imitateOutfit(dstBeing, SPRITE_WEAPON);
break;
case 4: // LOOK_HEAD_TOP Change upper headgear for eAthena, hat for us
dstBeing->setSprite(SPRITE_CLOTHES_COLOR, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
if (localPlayer)
localPlayer->imitateOutfit(dstBeing, SPRITE_CLOTHES_COLOR);
break;
case 5: // LOOK_HEAD_MID Change middle headgear for eathena,
// armor for us
dstBeing->setSprite(SPRITE_HEAD_BOTTOM, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
if (localPlayer)
localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_BOTTOM);
break;
case 6: // eAthena LOOK_HAIR_COLOR
- dstBeing->setHairColor(id);
+ dstBeing->setHairColor(fromInt(id, ItemColor));
dstBeing->setSpriteColor(SPRITE_HAIR_COLOR,
ItemDB::get(dstBeing->getSpriteID(
- SPRITE_HAIR_COLOR)).getDyeColorsString(id));
+ SPRITE_HAIR_COLOR)).getDyeColorsString(
+ fromInt(id, ItemColor)));
break;
case 7: // Clothes color. Now used as look
dstBeing->setLook(static_cast<uint8_t>(id));
break;
case 8: // eAthena LOOK_SHIELD
dstBeing->setSprite(SPRITE_FLOOR, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
if (localPlayer)
localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
break;
case 9: // eAthena LOOK_SHOES
dstBeing->setSprite(SPRITE_HAIR, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
if (localPlayer)
localPlayer->imitateOutfit(dstBeing, SPRITE_HAIR);
break;
case 10: // LOOK_GLOVES
dstBeing->setSprite(SPRITE_SHOES, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
if (localPlayer)
localPlayer->imitateOutfit(dstBeing, SPRITE_SHOES);
break;
case 11: // LOOK_FLOOR
dstBeing->setSprite(SPRITE_SHIELD, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
if (localPlayer)
localPlayer->imitateOutfit(dstBeing, SPRITE_SHIELD);
break;
case 12: // LOOK_ROBE
dstBeing->setSprite(SPRITE_HEAD_TOP, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
if (localPlayer)
localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_TOP);
break;
case 13: // COSTUME_HEAD_TOP
dstBeing->setSprite(SPRITE_HEAD_MID, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
if (localPlayer)
localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_MID);
break;
case 14: // COSTUME_HEAD_MID
dstBeing->setSprite(SPRITE_ROBE, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
if (localPlayer)
localPlayer->imitateOutfit(dstBeing, SPRITE_ROBE);
break;
case 15: // COSTUME_HEAD_LOW
dstBeing->setSprite(SPRITE_EVOL2, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
if (localPlayer)
localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL2);
break;
case 16: // COSTUME_GARMENT
dstBeing->setSprite(SPRITE_EVOL3, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
if (localPlayer)
localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL3);
break;
case 17: // ARMOR
dstBeing->setSprite(SPRITE_EVOL4, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
if (localPlayer)
localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL4);
break;
@@ -769,7 +770,7 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
const uint16_t headTop = msg.readInt16("head top");
const uint16_t headMid = msg.readInt16("head mid");
- const int hairColor = msg.readInt16("hair color");
+ const ItemColor hairColor = fromInt(msg.readInt16("hair color"), ItemColor);
const uint16_t shoes = msg.readInt16("shoes or clothes color?");
const uint16_t gloves = msg.readInt16("head dir / gloves");
@@ -795,7 +796,7 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
setSprite(dstBeing, SPRITE_CLOTHES_COLOR, headTop);
setSprite(dstBeing, SPRITE_HAIR, shoes);
setSprite(dstBeing, SPRITE_SHOES, gloves);
- setSprite(dstBeing, SPRITE_BODY, weapon, "", 1, true);
+ setSprite(dstBeing, SPRITE_BODY, weapon, "", ItemColor_one, true);
// setSprite(dstBeing, SPRITE_FLOOR, shield);
}
else if (dstBeing->getType() == ActorType::Npc
@@ -930,7 +931,8 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
const uint16_t headTop = msg.readInt16("head top");
const uint16_t headMid = msg.readInt16("head mid");
- const int hairColor = msg.readInt16("hair color");
+ const ItemColor hairColor = fromInt(
+ msg.readInt16("hair color"), ItemColor);
const uint16_t shoes = msg.readInt16("shoes or clothes color?");
const uint16_t gloves = msg.readInt16("head dir / gloves");
@@ -958,7 +960,7 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
setSprite(dstBeing, SPRITE_CLOTHES_COLOR, headTop);
setSprite(dstBeing, SPRITE_HAIR, shoes);
setSprite(dstBeing, SPRITE_SHOES, gloves);
- setSprite(dstBeing, SPRITE_BODY, weapon, "", 1, true);
+ setSprite(dstBeing, SPRITE_BODY, weapon, "", ItemColor_one, true);
}
// setSprite(dstBeing, SPRITE_FLOOR, shield);
}
@@ -1097,9 +1099,9 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg)
const uint16_t headTop = msg.readInt16("head top");
const uint16_t headMid = msg.readInt16("head mid");
- const int hairColor = msg.readInt16("hair color");
+ const ItemColor hairColor = fromInt(
+ msg.readInt16("hair color"), ItemColor);
const uint16_t shoes = msg.readInt16("shoes or clothes color?");
-
const uint16_t gloves = msg.readInt16("head dir / gloves");
// may be use robe as gloves?
msg.readInt16("robe");
@@ -1123,7 +1125,7 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg)
setSprite(dstBeing, SPRITE_CLOTHES_COLOR, headTop);
setSprite(dstBeing, SPRITE_HAIR, shoes);
setSprite(dstBeing, SPRITE_SHOES, gloves);
- setSprite(dstBeing, SPRITE_BODY, weapon, "", 1, true);
+ setSprite(dstBeing, SPRITE_BODY, weapon, "", ItemColor_one, true);
// setSprite(dstBeing, SPRITE_FLOOR, shield);
}
else if (dstBeing->getType() == ActorType::Npc
diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp
index d42d66b07..4fcad8637 100644
--- a/src/net/eathena/buyingstorehandler.cpp
+++ b/src/net/eathena/buyingstorehandler.cpp
@@ -210,11 +210,11 @@ void BuyingStoreHandler::processBuyingStoreItemsList(Net::MessageIn &msg)
if (!inv)
continue;
- const Item *const item = inv->findItem(itemId, 1);
+ const Item *const item = inv->findItem(itemId, ItemColor_one);
if (!item)
continue;
// +++ need add colors support
- dialog->addItem(itemId, itemType, 1, amount, price);
+ dialog->addItem(itemId, itemType, ItemColor_one, amount, price);
}
}
diff --git a/src/net/eathena/buysellhandler.cpp b/src/net/eathena/buysellhandler.cpp
index da64491ed..6e145a171 100644
--- a/src/net/eathena/buysellhandler.cpp
+++ b/src/net/eathena/buysellhandler.cpp
@@ -103,7 +103,7 @@ void BuySellHandler::processNpcBuy(Net::MessageIn &msg)
msg.readInt32("dc value?");
const int type = msg.readUInt8("type");
const int itemId = msg.readInt16("item id");
- const unsigned char color = 1;
+ const ItemColor color = ItemColor_one;
mBuyDialog->addItem(itemId, type, color, 0, value);
}
mBuyDialog->sort();
diff --git a/src/net/eathena/cashshophandler.cpp b/src/net/eathena/cashshophandler.cpp
index 23d6ab66d..012923424 100644
--- a/src/net/eathena/cashshophandler.cpp
+++ b/src/net/eathena/cashshophandler.cpp
@@ -104,7 +104,7 @@ void CashShopHandler::processCashShopOpen(Net::MessageIn &msg)
const int value = msg.readInt32("discount price");
const int type = msg.readUInt8("item type");
const int itemId = msg.readInt16("item id");
- const int color = 1;
+ const ItemColor color = ItemColor_one;
mBuyDialog->addItem(itemId, type, color, 0, value);
}
mBuyDialog->sort();
@@ -168,7 +168,7 @@ void CashShopHandler::processCashShopSchedule(Net::MessageIn &msg)
void CashShopHandler::buyItem(const int points,
const int itemId,
- const unsigned char color A_UNUSED,
+ const ItemColor color A_UNUSED,
const int amount) const
{
createOutPacket(CMSG_NPC_CASH_SHOP_BUY);
diff --git a/src/net/eathena/cashshophandler.h b/src/net/eathena/cashshophandler.h
index cc8859a89..851b62527 100644
--- a/src/net/eathena/cashshophandler.h
+++ b/src/net/eathena/cashshophandler.h
@@ -43,7 +43,7 @@ class CashShopHandler final : public MessageHandler,
void buyItem(const int points,
const int itemId,
- const unsigned char color,
+ const ItemColor color,
const int amount) const override final;
void close() const override final;
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index b2310b029..960acf44d 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -235,7 +235,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
const int option A_UNUSED = (msg.readInt16("weapon") | 1) ^ 1;
const int weapon = 0;
- tempPlayer->setSprite(SPRITE_BODY, weapon, "", 1, true);
+ tempPlayer->setSprite(SPRITE_BODY, weapon, "", ItemColor_one, true);
data.mAttributes[Attributes::LEVEL] = msg.readInt16("level");
@@ -245,8 +245,8 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
const int hat = msg.readInt16("head top");
const int topClothes = msg.readInt16("head mid");
- const uint16_t color = msg.readInt16("hair color");
- tempPlayer->setHairColor(static_cast<unsigned char>(color));
+ const ItemColor color = fromInt(msg.readInt16("hair color"), ItemColor);
+ tempPlayer->setHairColor(color);
tempPlayer->setSprite(SPRITE_HAIR_COLOR, hairStyle * -1,
ItemDB::get(-hairStyle).getDyeColorsString(
color));
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index 86faea2e7..c2b01be22 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -458,8 +458,12 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
flags.byte = msg.readUInt8("flags");
if (inventory)
{
- inventory->setItem(index, itemId, itemType, 1, refine,
+ inventory->setItem(index,
+ itemId,
+ itemType,
1,
+ refine,
+ ItemColor_one,
fromBool(flags.bits.isIdentified, Identified),
fromBool(flags.bits.isDamaged, Damaged),
fromBool(flags.bits.isFavorite, Favorite),
@@ -542,14 +546,23 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
break;
}
if (localPlayer)
- localPlayer->pickedUp(itemInfo, 0, 1, floorId, pickup);
+ {
+ localPlayer->pickedUp(itemInfo,
+ 0,
+ ItemColor_one,
+ floorId,
+ pickup);
+ }
}
else
{
if (localPlayer)
{
- localPlayer->pickedUp(itemInfo, amount,
- 1, floorId, Pickup::OKAY);
+ localPlayer->pickedUp(itemInfo,
+ amount,
+ ItemColor_one,
+ floorId,
+ Pickup::OKAY);
}
if (inventory)
@@ -559,8 +572,12 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
if (item && item->getId() == itemId)
amount += item->getQuantity();
- inventory->setItem(index, itemId, itemType, amount, refine,
- 1,
+ inventory->setItem(index,
+ itemId,
+ itemType,
+ amount,
+ refine,
+ ItemColor_one,
fromBool(identified, Identified),
fromBool(damaged, Damaged),
Favorite_false,
@@ -608,8 +625,12 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg)
if (inventory)
{
- inventory->setItem(index, itemId, itemType, amount,
- 0, 1,
+ inventory->setItem(index,
+ itemId,
+ itemType,
+ amount,
+ 0,
+ ItemColor_one,
fromBool(flags.bits.isIdentified, Identified),
fromBool(flags.bits.isDamaged, Damaged),
fromBool(flags.bits.isFavorite, Favorite),
@@ -645,8 +666,13 @@ void InventoryHandler::processPlayerStorage(Net::MessageIn &msg)
ItemFlags flags;
flags.byte = msg.readUInt8("flags");
- mInventoryItems.push_back(Ea::InventoryItem(index, itemId, itemType,
- cards, amount, 0, 1,
+ mInventoryItems.push_back(Ea::InventoryItem(index,
+ itemId,
+ itemType,
+ cards,
+ amount,
+ 0,
+ ItemColor_one,
fromBool(flags.bits.isIdentified, Identified),
fromBool(flags.bits.isDamaged, Damaged),
fromBool(flags.bits.isFavorite, Favorite),
@@ -746,8 +772,13 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg)
ItemFlags flags;
flags.byte = msg.readUInt8("flags");
- mInventoryItems.push_back(Ea::InventoryItem(index, itemId, itemType,
- cards, amount, refine, 1,
+ mInventoryItems.push_back(Ea::InventoryItem(index,
+ itemId,
+ itemType,
+ cards,
+ amount,
+ refine,
+ ItemColor_one,
fromBool(flags.bits.isIdentified, Identified),
fromBool(flags.bits.isDamaged, Damaged),
fromBool(flags.bits.isFavorite, Favorite),
@@ -773,15 +804,19 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg)
if (Item *const item = mStorage->getItem(index))
{
- item->setId(itemId, 1);
+ item->setId(itemId, ItemColor_one);
item->increaseQuantity(amount);
}
else
{
if (mStorage)
{
- mStorage->setItem(index, itemId, itemType, amount,
- refine, 1,
+ mStorage->setItem(index,
+ itemId,
+ itemType,
+ amount,
+ refine,
+ ItemColor_one,
fromBool(identified, Identified),
Damaged_false,
Favorite_false,
@@ -960,8 +995,12 @@ void InventoryHandler::processPlayerCartAdd(Net::MessageIn &msg)
if (item && item->getId() == itemId)
amount += item->getQuantity();
- inventory->setItem(index, itemId, itemType, amount, refine,
- 1,
+ inventory->setItem(index,
+ itemId,
+ itemType,
+ amount,
+ refine,
+ ItemColor_one,
fromBool(identified, Identified),
Damaged_false,
Favorite_false,
@@ -995,8 +1034,13 @@ void InventoryHandler::processPlayerCartEquip(Net::MessageIn &msg)
ItemFlags flags;
flags.byte = msg.readUInt8("flags");
- mCartItems.push_back(Ea::InventoryItem(index, itemId, itemType,
- cards, amount, refine, 1,
+ mCartItems.push_back(Ea::InventoryItem(index,
+ itemId,
+ itemType,
+ cards,
+ amount,
+ refine,
+ ItemColor_one,
fromBool(flags.bits.isIdentified, Identified),
fromBool(flags.bits.isDamaged, Damaged),
fromBool(flags.bits.isFavorite, Favorite),
@@ -1027,8 +1071,13 @@ void InventoryHandler::processPlayerCartItems(Net::MessageIn &msg)
ItemFlags flags;
flags.byte = msg.readUInt8("flags");
- mCartItems.push_back(Ea::InventoryItem(index, itemId, itemType,
- cards, amount, 0, 1,
+ mCartItems.push_back(Ea::InventoryItem(index,
+ itemId,
+ itemType,
+ cards,
+ amount,
+ 0,
+ ItemColor_one,
fromBool(flags.bits.isIdentified, Identified),
fromBool(flags.bits.isDamaged, Damaged),
fromBool(flags.bits.isFavorite, Favorite),
diff --git a/src/net/eathena/itemhandler.cpp b/src/net/eathena/itemhandler.cpp
index ce5dfadfb..4fa4a7e3e 100644
--- a/src/net/eathena/itemhandler.cpp
+++ b/src/net/eathena/itemhandler.cpp
@@ -82,7 +82,7 @@ void ItemHandler::processItemDropped(Net::MessageIn &msg)
const BeingId id = msg.readBeingId("id");
const int itemId = msg.readInt16("item id");
msg.readInt16("type");
- const uint8_t identify = msg.readUInt8("identify");
+ msg.readUInt8("identify");
const int x = msg.readInt16("x");
const int y = msg.readInt16("y");
const int subX = static_cast<int>(msg.readInt8("subx"));
@@ -91,8 +91,12 @@ void ItemHandler::processItemDropped(Net::MessageIn &msg)
if (actorManager)
{
- actorManager->createItem(id, itemId,
- x, y, amount, identify, subX, subY);
+ actorManager->createItem(id,
+ itemId,
+ x, y,
+ amount,
+ ItemColor_one,
+ subX, subY);
}
}
diff --git a/src/net/eathena/markethandler.cpp b/src/net/eathena/markethandler.cpp
index 265fc7ca5..d0e8ff6ce 100644
--- a/src/net/eathena/markethandler.cpp
+++ b/src/net/eathena/markethandler.cpp
@@ -87,7 +87,7 @@ void MarketHandler::processMarketOpen(Net::MessageIn &msg)
const int value = msg.readInt32("price");
const int amount = msg.readInt32("amount");
msg.readInt16("view");
- const unsigned char color = 1;
+ const ItemColor color = ItemColor_one;
mBuyDialog->addItem(itemId, type, color, amount, value);
}
mBuyDialog->sort();
@@ -116,7 +116,7 @@ void MarketHandler::close()
void MarketHandler::buyItem(const int itemId,
const int type,
- const unsigned char color A_UNUSED,
+ const ItemColor color A_UNUSED,
const int amount) const
{
const bool nonStack = type == 4 || type == 5 || type == 7 || type == 8;
diff --git a/src/net/eathena/markethandler.h b/src/net/eathena/markethandler.h
index 42a4bcac0..e58ac1e68 100644
--- a/src/net/eathena/markethandler.h
+++ b/src/net/eathena/markethandler.h
@@ -43,7 +43,7 @@ class MarketHandler final : public MessageHandler,
void buyItem(const int itemId,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int amount) const override final;
protected:
diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp
index e8a7daf8b..7b376fbeb 100644
--- a/src/net/eathena/npchandler.cpp
+++ b/src/net/eathena/npchandler.cpp
@@ -212,7 +212,7 @@ void NpcHandler::sell(const BeingId beingId) const
void NpcHandler::buyItem(const BeingId beingId A_UNUSED,
const int itemId,
- const unsigned char color A_UNUSED,
+ const ItemColor color A_UNUSED,
const int amount) const
{
createOutPacket(CMSG_NPC_BUY_REQUEST);
diff --git a/src/net/eathena/npchandler.h b/src/net/eathena/npchandler.h
index 75d9a245d..3b35cadc5 100644
--- a/src/net/eathena/npchandler.h
+++ b/src/net/eathena/npchandler.h
@@ -60,7 +60,7 @@ class NpcHandler final : public MessageHandler, public Ea::NpcHandler
void buyItem(const BeingId beingId,
const int itemId,
- const unsigned char color,
+ const ItemColor color,
const int amount) const override final;
void sellItem(const BeingId beingId,
diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp
index 749d9343e..a76a08130 100644
--- a/src/net/eathena/tradehandler.cpp
+++ b/src/net/eathena/tradehandler.cpp
@@ -199,10 +199,14 @@ void TradeHandler::processTradeItemAdd(Net::MessageIn &msg)
}
else
{
- tradeWindow->addItem2(type, itemType,
- cards, 4,
- false, amount,
- refine, 1,
+ tradeWindow->addItem2(type,
+ itemType,
+ cards,
+ 4,
+ false,
+ amount,
+ refine,
+ ItemColor_one,
fromBool(identify, Identified),
Damaged_false,
Favorite_false,
diff --git a/src/net/eathena/vendinghandler.cpp b/src/net/eathena/vendinghandler.cpp
index 48b301a77..584aa1f23 100644
--- a/src/net/eathena/vendinghandler.cpp
+++ b/src/net/eathena/vendinghandler.cpp
@@ -158,7 +158,7 @@ void VendingHandler::processItemsList(Net::MessageIn &msg)
for (int d = 0; d < 4; d ++)
msg.readInt16("card");
- const unsigned char color = 1;
+ const ItemColor color = ItemColor_one;
ShopItem *const item = mBuyDialog->addItem(itemId, type,
color, amount, value);
if (item)
diff --git a/src/net/markethandler.h b/src/net/markethandler.h
index f98b1b18d..13027024e 100644
--- a/src/net/markethandler.h
+++ b/src/net/markethandler.h
@@ -23,6 +23,8 @@
#ifdef EATHENA_SUPPORT
+#include "enums/simpletypes/itemcolor.h"
+
#include <string>
#include "localconsts.h"
@@ -40,7 +42,7 @@ class MarketHandler notfinal
virtual void buyItem(const int itemId,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int amount) const = 0;
};
diff --git a/src/net/npchandler.h b/src/net/npchandler.h
index 1f4642b4d..29ecc5632 100644
--- a/src/net/npchandler.h
+++ b/src/net/npchandler.h
@@ -28,6 +28,7 @@
#include "enums/being/cookingtype.h"
#include "enums/simpletypes/beingid.h"
+#include "enums/simpletypes/itemcolor.h"
#include "localconsts.h"
@@ -65,7 +66,7 @@ class NpcHandler notfinal
virtual void buyItem(const BeingId beingId,
const int itemId,
- const unsigned char color,
+ const ItemColor color,
const int amount) const = 0;
virtual void sellItem(const BeingId beingId,
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 8092a519f..d336bdf47 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -339,70 +339,70 @@ void BeingHandler::processBeingChangeLookContinue(Net::MessageIn &msg,
break;
}
case 2: // Weapon ID in id, Shield ID in id2
- dstBeing->setSprite(SPRITE_BODY, id, "", 1, true);
+ dstBeing->setSprite(SPRITE_BODY, id, "", ItemColor_one, true);
dstBeing->setSprite(SPRITE_FLOOR, id2);
localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
break;
case 3: // Change lower headgear for eAthena, pants for us
dstBeing->setSprite(SPRITE_WEAPON, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
localPlayer->imitateOutfit(dstBeing, SPRITE_WEAPON);
break;
case 4: // Change upper headgear for eAthena, hat for us
dstBeing->setSprite(SPRITE_CLOTHES_COLOR, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
localPlayer->imitateOutfit(dstBeing, SPRITE_CLOTHES_COLOR);
break;
case 5: // Change middle headgear for eathena, armor for us
dstBeing->setSprite(SPRITE_HEAD_BOTTOM, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_BOTTOM);
break;
case 6: // eAthena LOOK_HAIR_COLOR
dstBeing->setHairColor(SPRITE_HAIR_COLOR,
- static_cast<uint8_t>(id));
+ fromInt(id, ItemColor));
break;
case 7: // Clothes color
// ignoring it
break;
case 8: // eAthena LOOK_SHIELD
dstBeing->setSprite(SPRITE_FLOOR, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
break;
case 9: // eAthena LOOK_SHOES
dstBeing->setSprite(SPRITE_HAIR, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
localPlayer->imitateOutfit(dstBeing, SPRITE_HAIR);
break;
case 10: // LOOK_GLOVES
dstBeing->setSprite(SPRITE_SHOES, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
localPlayer->imitateOutfit(dstBeing, SPRITE_SHOES);
break;
case 11: // LOOK_CAPE
dstBeing->setSprite(SPRITE_SHIELD, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
localPlayer->imitateOutfit(dstBeing, SPRITE_SHIELD);
break;
case 12:
dstBeing->setSprite(SPRITE_HEAD_TOP, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_TOP);
break;
case 13:
dstBeing->setSprite(SPRITE_HEAD_MID, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_MID);
break;
case 14:
dstBeing->setSprite(SPRITE_ROBE, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
localPlayer->imitateOutfit(dstBeing, SPRITE_ROBE);
break;
case 15:
dstBeing->setSprite(SPRITE_EVOL2, id, color,
- static_cast<unsigned char>(id2));
+ fromInt(id2, ItemColor));
localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL2);
break;
case 16:
@@ -483,7 +483,8 @@ void BeingHandler::processPlayerUpdate1(Net::MessageIn &msg)
const uint16_t headTop = msg.readInt16("head top");
const uint16_t headMid = msg.readInt16("head mid");
- const uint8_t hairColor = msg.readUInt8("hair color");
+ const ItemColor hairColor = fromInt(
+ msg.readUInt8("hair color"), ItemColor);
msg.readUInt8("unused");
msg.readInt32("unused");
@@ -508,7 +509,7 @@ void BeingHandler::processPlayerUpdate1(Net::MessageIn &msg)
if (!disguiseId)
{
// Set these after the gender, as the sprites may be gender-specific
- dstBeing->updateSprite(SPRITE_BODY, weapon, "", 1, true);
+ dstBeing->updateSprite(SPRITE_BODY, weapon, "", ItemColor_one, true);
dstBeing->updateSprite(SPRITE_FLOOR, shield);
dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
@@ -617,7 +618,8 @@ void BeingHandler::processPlayerUpdate2(Net::MessageIn &msg)
const uint16_t headBottom = msg.readInt16("head bottom");
const uint16_t headTop = msg.readInt16("head top");
const uint16_t headMid = msg.readInt16("head mid");
- const uint8_t hairColor = msg.readUInt8("hair color");
+ const ItemColor hairColor = fromInt(
+ msg.readUInt8("hair color"), ItemColor);
msg.readUInt8("unused");
msg.readInt32("unused");
@@ -642,7 +644,7 @@ void BeingHandler::processPlayerUpdate2(Net::MessageIn &msg)
if (!disguiseId)
{
// Set these after the gender, as the sprites may be gender-specific
- dstBeing->updateSprite(SPRITE_BODY, weapon, "", 1, true);
+ dstBeing->updateSprite(SPRITE_BODY, weapon, "", ItemColor_one, true);
dstBeing->updateSprite(SPRITE_FLOOR, shield);
dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
@@ -751,7 +753,8 @@ void BeingHandler::processPlayerMove(Net::MessageIn &msg)
const uint16_t headTop = msg.readInt16("head top");
const uint16_t headMid = msg.readInt16("head mid");
- const uint8_t hairColor = msg.readUInt8("hair color");
+ const ItemColor hairColor = fromInt(
+ msg.readUInt8("hair color"), ItemColor);
msg.readUInt8("unused");
msg.readInt32("unused");
@@ -776,7 +779,7 @@ void BeingHandler::processPlayerMove(Net::MessageIn &msg)
if (!disguiseId)
{
// Set these after the gender, as the sprites may be gender-specific
- dstBeing->updateSprite(SPRITE_BODY, weapon, "", 1, true);
+ dstBeing->updateSprite(SPRITE_BODY, weapon, "", ItemColor_one, true);
dstBeing->updateSprite(SPRITE_FLOOR, shield);
dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
@@ -942,7 +945,7 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
const uint16_t shield = msg.readInt16("shield");
const uint16_t headTop = msg.readInt16("head top");
const uint16_t headMid = msg.readInt16("head mid");
- const uint8_t hairColor = msg.readUInt8("hair color");
+ const ItemColor hairColor = fromInt(msg.readUInt8("hair color"), ItemColor);
msg.readUInt8("unused");
const uint16_t shoes = msg.readInt16("shoes / clothes color");
@@ -1004,7 +1007,7 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
setSprite(dstBeing, SPRITE_CLOTHES_COLOR, headTop);
setSprite(dstBeing, SPRITE_HAIR, shoes);
setSprite(dstBeing, SPRITE_SHOES, gloves);
- setSprite(dstBeing, SPRITE_BODY, weapon, "", 1, true);
+ setSprite(dstBeing, SPRITE_BODY, weapon, "", ItemColor_one, true);
setSprite(dstBeing, SPRITE_FLOOR, shield);
}
else if (dstBeing->getType() == ActorType::Npc
@@ -1143,7 +1146,8 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
const uint16_t shield = msg.readInt16("shield");
const uint16_t headTop = msg.readInt16("head top");
const uint16_t headMid = msg.readInt16("head mid");
- const uint8_t hairColor = msg.readUInt8("hair color");
+ const ItemColor hairColor = fromInt(
+ msg.readUInt8("hair color"), ItemColor);
msg.readUInt8("unused");
const uint16_t shoes = msg.readInt16("shoes / clothes color");
@@ -1205,7 +1209,7 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
setSprite(dstBeing, SPRITE_CLOTHES_COLOR, headTop);
setSprite(dstBeing, SPRITE_HAIR, shoes);
setSprite(dstBeing, SPRITE_SHOES, gloves);
- setSprite(dstBeing, SPRITE_BODY, weapon, "", 1, true);
+ setSprite(dstBeing, SPRITE_BODY, weapon, "", ItemColor_one, true);
setSprite(dstBeing, SPRITE_FLOOR, shield);
}
else if (dstBeing->getType() == ActorType::Npc
diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp
index e09fd2ae8..e41b1580e 100644
--- a/src/net/tmwa/buysellhandler.cpp
+++ b/src/net/tmwa/buysellhandler.cpp
@@ -110,7 +110,7 @@ void BuySellHandler::processNpcBuy(Net::MessageIn &msg)
msg.readInt32("dc value?");
const int type = msg.readUInt8("type");
const int itemId = msg.readInt16("item id");
- uint8_t color = 1;
+ const ItemColor color = ItemColor_one;
mBuyDialog->addItem(itemId, type, color, 0, value);
}
mBuyDialog->sort();
diff --git a/src/net/tmwa/cashshophandler.cpp b/src/net/tmwa/cashshophandler.cpp
index c9fecd9fb..45a4aaacb 100644
--- a/src/net/tmwa/cashshophandler.cpp
+++ b/src/net/tmwa/cashshophandler.cpp
@@ -44,7 +44,7 @@ void CashShopHandler::handleMessage(Net::MessageIn &msg A_UNUSED)
void CashShopHandler::buyItem(const int points A_UNUSED,
const int itemId A_UNUSED,
- const unsigned char color A_UNUSED,
+ const ItemColor color A_UNUSED,
const int amount A_UNUSED) const
{
}
diff --git a/src/net/tmwa/cashshophandler.h b/src/net/tmwa/cashshophandler.h
index 588aba087..3b4c668ec 100644
--- a/src/net/tmwa/cashshophandler.h
+++ b/src/net/tmwa/cashshophandler.h
@@ -42,7 +42,7 @@ class CashShopHandler final : public MessageHandler,
void buyItem(const int points,
const int itemId,
- const unsigned char color,
+ const ItemColor color,
const int amount) const override final;
void close() const override final;
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 12d698186..229339ef4 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -168,7 +168,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
const uint16_t look = msg.readUInt8("look");
tempPlayer->setSubtype(fromInt(race, BeingTypeId), look);
const uint16_t weapon = msg.readInt16("weapon");
- tempPlayer->setSprite(SPRITE_BODY, weapon, "", 1, true);
+ tempPlayer->setSprite(SPRITE_BODY, weapon, "", ItemColor_one, true);
data.mAttributes[Attributes::LEVEL] = msg.readInt16("level");
@@ -179,11 +179,12 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
const int hat = msg.readInt16("hat");
const int topClothes = msg.readInt16("top clothes");
- const uint8_t hairColor = msg.readUInt8("hair color");
+ const ItemColor hairColor = fromInt(
+ msg.readUInt8("hair color"), ItemColor);
msg.readUInt8("unused");
tempPlayer->setSprite(SPRITE_HAIR_COLOR, hairStyle * -1,
ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
- tempPlayer->setHairColor(static_cast<unsigned char>(hairColor));
+ tempPlayer->setHairColor(hairColor);
const int misc2 = msg.readInt16("misc2");
tempPlayer->setName(msg.readString(24, "name"));
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 5ff9325ae..05ed6e40d 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -292,8 +292,12 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
if (inventory)
{
- inventory->setItem(index, itemId, itemType, 1, refine,
+ inventory->setItem(index,
+ itemId,
+ itemType,
1,
+ refine,
+ ItemColor_one,
fromBool(identified, Identified),
Damaged_false,
Favorite_false,
@@ -374,14 +378,23 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
break;
}
if (localPlayer)
- localPlayer->pickedUp(itemInfo, 0, identified, floorId, pickup);
+ {
+ localPlayer->pickedUp(itemInfo,
+ 0,
+ fromInt(identified, ItemColor),
+ floorId,
+ pickup);
+ }
}
else
{
if (localPlayer)
{
- localPlayer->pickedUp(itemInfo, amount,
- identified, floorId, Pickup::OKAY);
+ localPlayer->pickedUp(itemInfo,
+ amount,
+ fromInt(identified, ItemColor),
+ floorId,
+ Pickup::OKAY);
}
if (inventory)
@@ -391,8 +404,12 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
if (item && item->getId() == itemId)
amount += item->getQuantity();
- inventory->setItem(index, itemId, type, amount, refine,
- 1,
+ inventory->setItem(index,
+ itemId,
+ type,
+ amount,
+ refine,
+ ItemColor_one,
fromBool(identified, Identified),
Damaged_false,
Favorite_false,
@@ -449,8 +466,12 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg)
if (inventory)
{
- inventory->setItem(index, itemId, itemType, amount,
- 0, 1,
+ inventory->setItem(index,
+ itemId,
+ itemType,
+ amount,
+ 0,
+ ItemColor_one,
fromBool(identified, Identified),
Damaged_false,
Favorite_false,
@@ -490,8 +511,13 @@ void InventoryHandler::processPlayerStorage(Net::MessageIn &msg)
cards[0], cards[1], cards[2], cards[3]);
}
- mInventoryItems.push_back(Ea::InventoryItem(index, itemId,
- itemType, cards, amount, 0, 1,
+ mInventoryItems.push_back(Ea::InventoryItem(index,
+ itemId,
+ itemType,
+ cards,
+ amount,
+ 0,
+ ItemColor_one,
fromBool(identified, Identified),
Damaged_false,
Favorite_false,
@@ -559,8 +585,13 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg)
static_cast<unsigned int>(refine));
}
- mInventoryItems.push_back(Ea::InventoryItem(index, itemId,
- itemType, cards, amount, refine, 1,
+ mInventoryItems.push_back(Ea::InventoryItem(index,
+ itemId,
+ itemType,
+ cards,
+ amount,
+ refine,
+ ItemColor_one,
fromBool(identified, Identified),
Damaged_false,
Favorite_false,
@@ -585,15 +616,19 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg)
if (Item *const item = mStorage->getItem(index))
{
- item->setId(itemId, identified);
+ item->setId(itemId, ItemColor_one);
item->increaseQuantity(amount);
}
else
{
if (mStorage)
{
- mStorage->setItem(index, itemId, 0, amount,
- refine, 1,
+ mStorage->setItem(index,
+ itemId,
+ 0,
+ amount,
+ refine,
+ ItemColor_one,
fromBool(identified, Identified),
Damaged_false,
Favorite_false,
diff --git a/src/net/tmwa/itemhandler.cpp b/src/net/tmwa/itemhandler.cpp
index 7ad3f733a..745c79865 100644
--- a/src/net/tmwa/itemhandler.cpp
+++ b/src/net/tmwa/itemhandler.cpp
@@ -72,7 +72,7 @@ void ItemHandler::processItemDropped(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 subX = static_cast<int>(msg.readInt8("sub x"));
diff --git a/src/net/tmwa/markethandler.cpp b/src/net/tmwa/markethandler.cpp
index 6fff692c8..4e322b1cf 100644
--- a/src/net/tmwa/markethandler.cpp
+++ b/src/net/tmwa/markethandler.cpp
@@ -53,7 +53,7 @@ void MarketHandler::close()
void MarketHandler::buyItem(const int itemId A_UNUSED,
const int type A_UNUSED,
- const unsigned char color A_UNUSED,
+ const ItemColor color A_UNUSED,
const int amount A_UNUSED) const
{
}
diff --git a/src/net/tmwa/markethandler.h b/src/net/tmwa/markethandler.h
index bf817ac04..65d299251 100644
--- a/src/net/tmwa/markethandler.h
+++ b/src/net/tmwa/markethandler.h
@@ -43,7 +43,7 @@ class MarketHandler final : public MessageHandler,
void buyItem(const int itemId,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int amount) const override final;
};
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index 60d41a7ef..b01c3277f 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -178,7 +178,7 @@ void NpcHandler::sell(const BeingId beingId) const
void NpcHandler::buyItem(const BeingId beingId A_UNUSED,
const int itemId,
- const unsigned char color A_UNUSED,
+ const ItemColor color A_UNUSED,
const int amount) const
{
createOutPacket(CMSG_NPC_BUY_REQUEST);
diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h
index c8da3fd42..35a6f9459 100644
--- a/src/net/tmwa/npchandler.h
+++ b/src/net/tmwa/npchandler.h
@@ -60,7 +60,7 @@ class NpcHandler final : public MessageHandler, public Ea::NpcHandler
void buyItem(const BeingId beingId,
const int itemId,
- const unsigned char color,
+ const ItemColor color,
const int amount) const override final;
void sellItem(const BeingId beingId,
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index c445f8d06..845a7af6b 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -184,10 +184,14 @@ void TradeHandler::processTradeItemAdd(Net::MessageIn &msg)
}
else
{
- tradeWindow->addItem2(type, 0,
- cards, 4,
- false, amount,
- refine, 1,
+ tradeWindow->addItem2(type,
+ 0,
+ cards,
+ 4,
+ false,
+ amount,
+ refine,
+ ItemColor_one,
fromBool(identify, Identified),
Damaged_false,
Favorite_false,
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index f63e65134..1f1033e3c 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -206,12 +206,12 @@ void BeingInfo::setColorsList(const std::string &name)
mColors = ColorDB::getColorsList(name);
}
-std::string BeingInfo::getColor(const int idx) const
+std::string BeingInfo::getColor(const ItemColor idx) const
{
if (!mColors)
return std::string();
- const std::map <int, ColorDB::ItemColor>::const_iterator
+ const std::map <ItemColor, ColorDB::ItemColorData>::const_iterator
it = mColors->find(idx);
if (it == mColors->end())
return std::string();
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index 0a6330470..3429515e0 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -28,6 +28,7 @@
#include "enums/resources/map/blocktype.h"
#include "enums/simpletypes/beingtypeid.h"
+#include "enums/simpletypes/itemcolor.h"
#include "resources/beingmenuitem.h"
#include "resources/cursor.h"
@@ -38,7 +39,7 @@ struct Attack;
namespace ColorDB
{
- class ItemColor;
+ class ItemColorData;
}
typedef std::map<int, Attack*> Attacks;
@@ -312,7 +313,7 @@ class BeingInfo final
void setColorsList(const std::string &name);
- std::string getColor(const int idx) const A_WARN_UNUSED;
+ std::string getColor(const ItemColor idx) const A_WARN_UNUSED;
void addMenu(const std::string &name, const std::string &command);
@@ -332,7 +333,7 @@ class BeingInfo final
std::vector<BeingMenuItem> mMenu;
unsigned char mBlockWalkMask;
BlockType::BlockType mBlockType;
- const std::map <int, ColorDB::ItemColor> *mColors;
+ const std::map <ItemColor, ColorDB::ItemColorData> *mColors;
int mTargetOffsetX;
int mTargetOffsetY;
int mNameOffsetX;
diff --git a/src/resources/db/colordb.cpp b/src/resources/db/colordb.cpp
index 1b636e407..62f7beef6 100644
--- a/src/resources/db/colordb.cpp
+++ b/src/resources/db/colordb.cpp
@@ -41,7 +41,7 @@ void ColorDB::load()
if (mLoaded)
unload();
- std::map<int, ItemColor> colors;
+ std::map<ItemColor, ItemColorData> colors;
ColorListsIterator it = mColorLists.find("hair");
if (it != mColorLists.end())
colors = it->second;
@@ -68,7 +68,7 @@ void ColorDB::load()
}
void ColorDB::loadHair(const std::string &fileName,
- std::map<int, ItemColor> &colors)
+ std::map<ItemColor, ItemColorData> &colors)
{
XML::Document *doc = new XML::Document(fileName,
UseResman_true,
@@ -78,8 +78,8 @@ void ColorDB::loadHair(const std::string &fileName,
if (!root || !xmlNameEqual(root, "colors"))
{
logger->log("ColorDB: Failed to find hair colors file.");
- if (colors.find(0) == colors.end())
- colors[0] = ItemColor(0, "", "");
+ if (colors.find(ItemColor_zero) == colors.end())
+ colors[ItemColor_zero] = ItemColorData(ItemColor_zero, "", "");
delete doc;
return;
}
@@ -95,12 +95,13 @@ void ColorDB::loadHair(const std::string &fileName,
}
else if (xmlNameEqual(node, "color"))
{
- const int id = XML::getProperty(node, "id", 0);
+ const ItemColor id = fromInt(XML::getProperty(
+ node, "id", 0), ItemColor);
if (colors.find(id) != colors.end())
- logger->log("ColorDB: Redefinition of dye ID %d", id);
+ logger->log("ColorDB: Redefinition of dye ID %d", toInt(id, int));
- colors[id] = ItemColor(id, XML::langProperty(node, "name", ""),
+ colors[id] = ItemColorData(id, XML::langProperty(node, "name", ""),
XML::getProperty(node, "value", "#FFFFFF"));
}
}
@@ -135,7 +136,7 @@ void ColorDB::loadColorLists(const std::string &fileName)
if (name.empty())
continue;
- std::map <int, ItemColor> colors;
+ std::map <ItemColor, ItemColorData> colors;
const ColorListsIterator it = mColorLists.find(name);
if (it != mColorLists.end())
@@ -145,11 +146,14 @@ void ColorDB::loadColorLists(const std::string &fileName)
{
if (xmlNameEqual(colorNode, "color"))
{
- ItemColor c(XML::getProperty(colorNode, "id", -1),
- XML::langProperty(colorNode, "name", ""),
- XML::getProperty(colorNode, "value", ""));
- if (c.id > -1)
- colors[c.id] = c;
+ const int id = XML::getProperty(colorNode, "id", -1);
+ if (id > -1)
+ {
+ ItemColorData c(fromInt(id, ItemColor),
+ XML::langProperty(colorNode, "name", ""),
+ XML::getProperty(colorNode, "value", ""));
+ colors[c.id] = c;
+ }
}
}
mColorLists[name] = colors;
@@ -166,7 +170,7 @@ void ColorDB::unload()
mLoaded = false;
}
-std::string &ColorDB::getHairColorName(const int id)
+std::string &ColorDB::getHairColorName(const ItemColor id)
{
if (!mLoaded)
load();
@@ -182,7 +186,7 @@ std::string &ColorDB::getHairColorName(const int id)
if (i == (*it).second.end())
{
- logger->log("ColorDB: Error, unknown dye ID# %d", id);
+ logger->log("ColorDB: Error, unknown dye ID# %d", toInt(id, int));
return mFail;
}
else
@@ -196,7 +200,7 @@ int ColorDB::getHairSize()
return mHairColorsSize;
}
-const std::map <int, ColorDB::ItemColor>
+const std::map <ItemColor, ColorDB::ItemColorData>
*ColorDB::getColorsList(const std::string &name)
{
const ColorListsIterator it = mColorLists.find(name);
diff --git a/src/resources/db/colordb.h b/src/resources/db/colordb.h
index c2923f382..6468b76e3 100644
--- a/src/resources/db/colordb.h
+++ b/src/resources/db/colordb.h
@@ -22,6 +22,8 @@
#ifndef RESOURCES_DB_COLORDB_H
#define RESOURCES_DB_COLORDB_H
+#include "enums/simpletypes/itemcolor.h"
+
#include <map>
#include <string>
@@ -32,24 +34,25 @@
*/
namespace ColorDB
{
- class ItemColor final
+ class ItemColorData final
{
public:
- ItemColor() :
- id(0),
+ ItemColorData() :
+ id(ItemColor_zero),
name(),
color()
{ }
- ItemColor(const int id0, const std::string &name0,
- const std::string &color0) :
+ ItemColorData(const ItemColor id0,
+ const std::string &name0,
+ const std::string &color0) :
id(id0),
name(name0),
color(color0)
{
}
- int id;
+ ItemColor id;
std::string name;
std::string color;
};
@@ -63,7 +66,7 @@ namespace ColorDB
* Loads the color data from <code>colors.xml</code>.
*/
void loadHair(const std::string &fileName,
- std::map<int, ItemColor> &colors);
+ std::map<ItemColor, ItemColorData> &colors);
void loadColorLists(const std::string &fileName);
@@ -72,17 +75,19 @@ namespace ColorDB
*/
void unload();
- std::string &getHairColorName(const int id) A_WARN_UNUSED;
+ std::string &getHairColorName(const ItemColor id) A_WARN_UNUSED;
int getHairSize() A_WARN_UNUSED;
- const std::map <int, ItemColor> *getColorsList(const std::string
- &name) A_WARN_UNUSED;
+ const std::map <ItemColor, ItemColorData> *getColorsList(const std::string
+ &name)
+ A_WARN_UNUSED;
// Color DB
- typedef std::map<int, ItemColor> Colors;
+ typedef std::map<ItemColor, ItemColorData> Colors;
typedef Colors::iterator ColorIterator;
- typedef std::map <std::string, std::map <int, ItemColor> > ColorLists;
+ typedef std::map <std::string, std::map <ItemColor, ItemColorData> >
+ ColorLists;
typedef ColorLists::iterator ColorListsIterator;
} // namespace ColorDB
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 768825f44..c439be5c5 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -201,12 +201,12 @@ void ItemInfo::setColorsList(const std::string &name)
}
}
-std::string ItemInfo::getDyeColorsString(const int color) const
+std::string ItemInfo::getDyeColorsString(const ItemColor color) const
{
if (!mColors || mColorList.empty())
return "";
- const std::map <int, ColorDB::ItemColor>::const_iterator
+ const std::map <ItemColor, ColorDB::ItemColorData>::const_iterator
it = mColors->find(color);
if (it == mColors->end())
return "";
@@ -214,23 +214,23 @@ std::string ItemInfo::getDyeColorsString(const int color) const
return it->second.color;
}
-const std::string ItemInfo::getDescription(const unsigned char color) const
+const std::string ItemInfo::getDescription(const ItemColor color) const
{
return replaceColors(mDescription, color);
}
-const std::string ItemInfo::getName(const unsigned char color) const
+const std::string ItemInfo::getName(const ItemColor color) const
{
return replaceColors(mName, color);
}
const std::string ItemInfo::replaceColors(std::string str,
- const unsigned char color) const
+ const ItemColor color) const
{
std::string name;
if (mColors && !mColorList.empty())
{
- const std::map <int, ColorDB::ItemColor>::const_iterator
+ const std::map <ItemColor, ColorDB::ItemColorData>::const_iterator
it = mColors->find(color);
if (it == mColors->end())
name = "unknown";
@@ -369,24 +369,24 @@ void ItemInfo::setSprite(const std::string &animationFile,
mAnimationFiles[static_cast<int>(gender) + race * 4] = animationFile;
}
-std::string ItemInfo::getColorName(const int idx) const
+std::string ItemInfo::getColorName(const ItemColor idx) const
{
if (!mColors)
return std::string();
- const std::map <int, ColorDB::ItemColor>::const_iterator
+ const std::map <ItemColor, ColorDB::ItemColorData>::const_iterator
it = mColors->find(idx);
if (it == mColors->end())
return std::string();
return it->second.name;
}
-std::string ItemInfo::getColor(const int idx) const
+std::string ItemInfo::getColor(const ItemColor idx) const
{
if (!mColors)
return std::string();
- const std::map <int, ColorDB::ItemColor>::const_iterator
+ const std::map <ItemColor, ColorDB::ItemColorData>::const_iterator
it = mColors->find(idx);
if (it == mColors->end())
return std::string();
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 4d40390d9..976d30c1d 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -26,6 +26,7 @@
#include "enums/being/gender.h"
#include "enums/simpletypes/beingtypeid.h"
+#include "enums/simpletypes/itemcolor.h"
#include "resources/cursor.h"
#include "resources/itemtype.h"
@@ -34,7 +35,7 @@
namespace ColorDB
{
- class ItemColor;
+ class ItemColorData;
}
// sprite, <itemfrom, itemto>
@@ -69,7 +70,7 @@ class ItemInfo final
const std::string &getName() const A_WARN_UNUSED
{ return mName; }
- const std::string getName(const unsigned char color)
+ const std::string getName(const ItemColor color)
const A_WARN_UNUSED;
void setDisplay(const SpriteDisplay &display)
@@ -84,7 +85,7 @@ class ItemInfo final
const std::string &getDescription() const A_WARN_UNUSED
{ return mDescription; }
- const std::string getDescription(const unsigned char color)
+ const std::string getDescription(const ItemColor color)
const A_WARN_UNUSED;
void setEffect(const std::string &effect)
@@ -238,7 +239,7 @@ class ItemInfo final
const SpriteToItemMap *getSpriteToItemReplaceMap(const int directions)
const A_WARN_UNUSED;
- std::string getDyeColorsString(const int color) const A_WARN_UNUSED;
+ std::string getDyeColorsString(const ItemColor color) const A_WARN_UNUSED;
void setColorsList(const std::string &name);
@@ -246,7 +247,7 @@ class ItemInfo final
{ return !mColorList.empty(); }
const std::string replaceColors(std::string str,
- const unsigned char color)
+ const ItemColor color)
const A_WARN_UNUSED;
void setPickupCursor(const std::string &cursor)
@@ -267,9 +268,9 @@ class ItemInfo final
int getColorsSize() const
{ return mColors ? static_cast<int>(mColors->size()) : 0; }
- std::string getColorName(const int idx) const;
+ std::string getColorName(const ItemColor idx) const;
- std::string getColor(const int idx) const;
+ std::string getColor(const ItemColor idx) const;
int mDrawBefore[10];
int mDrawAfter[10];
@@ -317,7 +318,7 @@ class ItemInfo final
/** Stores the names of sounds to be played at certain event. */
std::map <ItemSoundEvent::Type, SoundInfoVect> mSounds;
std::map <int, int> mTags;
- const std::map <int, ColorDB::ItemColor> *mColors;
+ const std::map <ItemColor, ColorDB::ItemColorData> *mColors;
std::string mColorList;
int mHitEffectId;
int mCriticalHitEffectId;
diff --git a/src/shopitem.cpp b/src/shopitem.cpp
index 3fa7c6480..faf635fbd 100644
--- a/src/shopitem.cpp
+++ b/src/shopitem.cpp
@@ -35,7 +35,7 @@
ShopItem::ShopItem(const int inventoryIndex,
const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int quantity,
const int price) :
Item(id, type, 0, 0, color,
@@ -57,7 +57,7 @@ ShopItem::ShopItem(const int inventoryIndex,
ShopItem::ShopItem(const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int price) :
Item(id, type, 0, 0, color,
Identified_true,
diff --git a/src/shopitem.h b/src/shopitem.h
index 68bdc51b5..a1c3d5649 100644
--- a/src/shopitem.h
+++ b/src/shopitem.h
@@ -47,7 +47,7 @@ class ShopItem final : public Item
ShopItem(const int inventoryIndex,
const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int quantity,
const int price);
@@ -60,7 +60,7 @@ class ShopItem final : public Item
*/
ShopItem(const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int price);
A_DELETE_COPY(ShopItem)
diff --git a/src/shortcutbase.cpp b/src/shortcutbase.cpp
index 0b076b16b..8bb0b3a54 100644
--- a/src/shortcutbase.cpp
+++ b/src/shortcutbase.cpp
@@ -31,12 +31,12 @@ ShortcutBase::ShortcutBase(const std::string &itemName,
const std::string &colorName,
const int maxSize) :
mItems(new int[maxSize]),
- mItemColors(new unsigned char[maxSize]),
+ mItemColors(new ItemColor[maxSize]),
mItemName(itemName),
mColorName(colorName),
mItemSelected(-1),
mMaxSize(maxSize),
- mItemColorSelected(1)
+ mItemColorSelected(ItemColor_one)
{
clear(false);
load();
@@ -61,8 +61,9 @@ void ShortcutBase::load(const bool oldConfig)
for (int i = 0; i < mMaxSize; i++)
{
const int itemId = cfg->getValue(mItemName + toString(i), -1);
- const unsigned char itemColor = static_cast<const unsigned char>(
- cfg->getValue(mColorName + toString(i), -1));
+ const ItemColor itemColor = fromInt(
+ cfg->getValue(mColorName + toString(i), -1),
+ ItemColor);
if (itemId != -1)
{
@@ -77,7 +78,8 @@ void ShortcutBase::save() const
for (int i = 0; i < mMaxSize; i++)
{
const int itemId = mItems[i] ? mItems[i] : -1;
- const int itemColor = mItemColors[i] ? mItemColors[i] : 1;
+ const int itemColor = (mItemColors[i] != ItemColor_zero)
+ ? toInt(mItemColors[i], int) : 1;
if (itemId != -1)
{
serverConfig.setValue(mItemName + toString(i), itemId);
@@ -101,7 +103,7 @@ void ShortcutBase::setItemSelected(const Item *const item)
else
{
mItemSelected = -1;
- mItemColorSelected = 1;
+ mItemColorSelected = ItemColor_one;
}
}
@@ -120,7 +122,7 @@ void ShortcutBase::clear(const bool isSave)
for (int i = 0; i < mMaxSize; i++)
{
mItems[i] = -1;
- mItemColors[i] = 1;
+ mItemColors[i] = ItemColor_one;
}
if (isSave)
save();
diff --git a/src/shortcutbase.h b/src/shortcutbase.h
index e742b6b18..58520a8ad 100644
--- a/src/shortcutbase.h
+++ b/src/shortcutbase.h
@@ -23,6 +23,8 @@
#ifndef SHORTCUTBASE_H
#define SHORTCUTBASE_H
+#include "enums/simpletypes/itemcolor.h"
+
#include <string>
#include "localconsts.h"
@@ -67,7 +69,7 @@ class ShortcutBase notfinal
int getItem(const int index) const A_WARN_UNUSED
{ return mItems[index]; }
- unsigned char getItemColor(const int index) const A_WARN_UNUSED
+ ItemColor getItemColor(const int index) const A_WARN_UNUSED
{ return mItemColors[index]; }
/**
@@ -95,8 +97,9 @@ class ShortcutBase notfinal
* @param index Index of the item.
* @param itemId ID of the item.
*/
- void setItems(const int index, const int itemId,
- const unsigned char color)
+ void setItems(const int index,
+ const int itemId,
+ const ItemColor color)
{ mItems[index] = itemId; mItemColors[index] = color; save(); }
/**
@@ -125,12 +128,12 @@ class ShortcutBase notfinal
private:
int *mItems A_NONNULLPOINTER;
- unsigned char *mItemColors A_NONNULLPOINTER;
+ ItemColor *mItemColors A_NONNULLPOINTER;
std::string mItemName;
std::string mColorName;
int mItemSelected;
int mMaxSize;
- unsigned char mItemColorSelected;
+ ItemColor mItemColorSelected;
};
#endif // SHORTCUTBASE_H