summaryrefslogtreecommitdiff
path: root/src/net/tmwa
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-15 13:58:32 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-16 01:52:14 +0300
commit41cc92f73e39cec5dfea6b1164176610cccc7df4 (patch)
tree22fd3d388084d2c61fe80f0441c3c30ab8ffd33c /src/net/tmwa
parent7aa637abc8b0bca35aacdb9492e65f557ed32038 (diff)
downloadmanaverse-41cc92f73e39cec5dfea6b1164176610cccc7df4.tar.gz
manaverse-41cc92f73e39cec5dfea6b1164176610cccc7df4.tar.bz2
manaverse-41cc92f73e39cec5dfea6b1164176610cccc7df4.tar.xz
manaverse-41cc92f73e39cec5dfea6b1164176610cccc7df4.zip
Add strong typed int for item color.
Diffstat (limited to 'src/net/tmwa')
-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
12 files changed, 97 insertions, 53 deletions
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,