summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-02-10 13:44:10 +0300
committerAndrei Karas <akaras@inbox.ru>2015-02-10 22:49:59 +0300
commitf3f7879c48fe8e202c3519cd465225645949167e (patch)
tree898a86c3446d988e86d7c3f160036533bdfd6475
parent37d7bd3163ad58391df36363b6f0135c638fbeb8 (diff)
downloadmanaverse-f3f7879c48fe8e202c3519cd465225645949167e.tar.gz
manaverse-f3f7879c48fe8e202c3519cd465225645949167e.tar.bz2
manaverse-f3f7879c48fe8e202c3519cd465225645949167e.tar.xz
manaverse-f3f7879c48fe8e202c3519cd465225645949167e.zip
Add typed bool type Identified.
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/beingequipbackend.cpp3
-rw-r--r--src/enums/simpletypes.h52
-rw-r--r--src/gui/windows/itemamountwindow.cpp4
-rw-r--r--src/gui/windows/tradewindow.cpp4
-rw-r--r--src/gui/windows/tradewindow.h6
-rw-r--r--src/inventory.cpp6
-rw-r--r--src/inventory.h5
-rw-r--r--src/item.cpp2
-rw-r--r--src/item.h10
-rw-r--r--src/net/ea/inventoryitem.h6
-rw-r--r--src/net/eathena/inventoryhandler.cpp35
-rw-r--r--src/net/eathena/tradehandler.cpp5
-rw-r--r--src/net/tmwa/inventoryhandler.cpp45
-rw-r--r--src/net/tmwa/tradehandler.cpp27
-rw-r--r--src/shopitem.cpp8
17 files changed, 171 insertions, 49 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 43b4b91ad..1bd78b525 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1064,6 +1064,7 @@ SET(SRCS
soundmanager.h
sprite.h
enums/screendensity.h
+ enums/simpletypes.h
enums/state.h
statuseffect.cpp
statuseffect.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 86662b0a8..38a6753b7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1191,6 +1191,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
soundmanager.h \
sprite.h \
enums/screendensity.h \
+ enums/simpletypes.h \
enums/state.h \
statuseffect.cpp \
statuseffect.h \
diff --git a/src/beingequipbackend.cpp b/src/beingequipbackend.cpp
index 33a5dd397..2c5402970 100644
--- a/src/beingequipbackend.cpp
+++ b/src/beingequipbackend.cpp
@@ -44,7 +44,8 @@ BeingEquipBackend::BeingEquipBackend(Being *const being)
{
mEquipment[idx] = new Item(id, 0, 1, 0,
being->mSpriteColorsIds[f],
- true, false, false, true, true);
+ Identified_True,
+ false, false, true, true);
}
}
}
diff --git a/src/enums/simpletypes.h b/src/enums/simpletypes.h
new file mode 100644
index 000000000..1b930b13c
--- /dev/null
+++ b/src/enums/simpletypes.h
@@ -0,0 +1,52 @@
+/*
+ * 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_H
+#define ENUMS_SIMPLETYPES_H
+
+#include "localconsts.h"
+
+#ifdef ADVGCC
+
+#define defBoolEnum(name) \
+ enum class name : bool \
+ { \
+ False = false, \
+ True = true \
+ }; \
+ const name name##_True = name::True; \
+ const name name##_False = name::False
+#define fromBool(val, name) \
+ (val) ? name::True : name::False
+
+#else // ADVGCC
+
+#define defBoolEnum(name) \
+ const bool name##_True = true; \
+ const bool name##_False = false; \
+ typedef bool name
+#define fromBool(val, name) \
+ (val) ? true : false
+
+#endif // ADVGCC
+
+defBoolEnum(Identified);
+
+#endif // ENUMS_SIMPLETYPES_H
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index fe081a799..27c72a683 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -334,7 +334,9 @@ void ItemAmountWindow::action(const ActionEvent &event)
const int id = ItemDB::get(mItemsModal->getElementAt(
mItemDropDown->getSelected())).getId();
- mItem = new Item(id, 0, 10000, 0, 1, true, false, false, false, false);
+ mItem = new Item(id, 0, 10000, 0, 1,
+ Identified_True,
+ false, false, false, false);
if (mUsage == ShopBuyAdd)
mMax = 10000;
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index c15e56f44..b94584f4f 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -200,7 +200,7 @@ void TradeWindow::addItem(const int id,
const int quantity,
const uint8_t refine,
const unsigned char color,
- const bool identified,
+ const Identified identified,
const bool damaged,
const bool favorite) const
{
@@ -217,7 +217,7 @@ void TradeWindow::addItem2(const int id,
const int quantity,
const uint8_t refine,
const unsigned char color,
- const bool identified,
+ const Identified identified,
const bool damaged,
const bool favorite,
const bool equipment) const
diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h
index 1abe4a91f..f48002deb 100644
--- a/src/gui/windows/tradewindow.h
+++ b/src/gui/windows/tradewindow.h
@@ -23,6 +23,8 @@
#ifndef GUI_WINDOWS_TRADEWINDOW_H
#define GUI_WINDOWS_TRADEWINDOW_H
+#include "enums/simpletypes.h"
+
#include "gui/widgets/window.h"
#include "listeners/actionlistener.h"
@@ -73,7 +75,7 @@ class TradeWindow final : public Window,
const int quantity,
const uint8_t refine,
const unsigned char color,
- const bool identified,
+ const Identified identified,
const bool damaged,
const bool favorite) const;
@@ -93,7 +95,7 @@ class TradeWindow final : public Window,
const int quantity,
const uint8_t refine,
const unsigned char color,
- const bool identified,
+ const Identified identified,
const bool damaged,
const bool favorite,
const bool equipment) const;
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 13b691851..223b8d18f 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -25,6 +25,8 @@
#include "item.h"
#include "logger.h"
+#include "enums/simpletypes.h"
+
#include "net/inventoryhandler.h"
#include "resources/iteminfo.h"
@@ -108,7 +110,7 @@ int Inventory::addItem(const int id,
const int quantity,
const uint8_t refine,
const uint8_t color,
- const bool identified,
+ const Identified identified,
const bool damaged,
const bool favorite,
const bool equipment,
@@ -126,7 +128,7 @@ void Inventory::setItem(const int index,
const int quantity,
const uint8_t refine,
const unsigned char color,
- const bool identified,
+ const Identified identified,
const bool damaged,
const bool favorite,
const bool equipment,
diff --git a/src/inventory.h b/src/inventory.h
index e09fbb673..5e36503f5 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -24,6 +24,7 @@
#define INVENTORY_H
#include "enums/inventorytype.h"
+#include "enums/simpletypes.h"
#include "enums/being/gender.h"
@@ -84,7 +85,7 @@ class Inventory final
const int quantity,
const uint8_t refine,
const unsigned char color,
- const bool identified,
+ const Identified identified,
const bool damaged,
const bool favorite,
const bool equipment,
@@ -99,7 +100,7 @@ class Inventory final
const int quantity,
const uint8_t refine,
const unsigned char color,
- const bool identified,
+ const Identified identified,
const bool damaged,
const bool favorite,
const bool equipment,
diff --git a/src/item.cpp b/src/item.cpp
index a88d370db..7b545c9d7 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -42,7 +42,7 @@ Item::Item(const int id,
const int quantity,
const uint8_t refine,
const unsigned char color,
- const bool identified,
+ const Identified identified,
const bool damaged,
const bool favorite,
const bool equipment,
diff --git a/src/item.h b/src/item.h
index 500e784c6..df75729ba 100644
--- a/src/item.h
+++ b/src/item.h
@@ -23,6 +23,8 @@
#ifndef ITEM_H
#define ITEM_H
+#include "enums/simpletypes.h"
+
#include "resources/db/itemdb.h"
#include <map>
@@ -47,7 +49,7 @@ class Item notfinal
const int quantity,
const uint8_t refine,
const uint8_t color,
- const bool identified,
+ const Identified identified,
const bool damaged,
const bool favorite,
const bool equipment,
@@ -174,10 +176,10 @@ class Item notfinal
const std::string &getDescription() const A_WARN_UNUSED
{ return mDescription; }
- void setIdentified(const bool b)
+ void setIdentified(const Identified b)
{ mIdentified = b; }
- bool getIdentified() const A_WARN_UNUSED
+ Identified getIdentified() const A_WARN_UNUSED
{ return mIdentified; }
void setDamaged(const bool b)
@@ -222,7 +224,7 @@ class Item notfinal
bool mEquipment; /**< Item is equipment. */
bool mEquipped; /**< Item is equipped. */
bool mInEquipment; /**< Item is in equipment */
- bool mIdentified;
+ Identified mIdentified;
bool mDamaged;
bool mFavorite;
};
diff --git a/src/net/ea/inventoryitem.h b/src/net/ea/inventoryitem.h
index 6d059d081..5c0b86658 100644
--- a/src/net/ea/inventoryitem.h
+++ b/src/net/ea/inventoryitem.h
@@ -23,6 +23,8 @@
#ifndef NET_EA_INVENTORYITEM_H
#define NET_EA_INVENTORYITEM_H
+#include "enums/simpletypes.h"
+
#if defined(__GXX_EXPERIMENTAL_CXX0X__)
#include <cstdint>
#else
@@ -47,7 +49,7 @@ class InventoryItem final
int quantity;
uint8_t refine;
unsigned char color;
- bool identified;
+ Identified identified;
bool damaged;
bool favorite;
bool equip;
@@ -59,7 +61,7 @@ class InventoryItem final
const int quantity0,
const uint8_t refine0,
const unsigned char color0,
- const bool identified0,
+ const Identified identified0,
const bool damaged0,
const bool favorite0,
const bool equip0) :
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index bcf5806a5..0c6ef7141 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -25,6 +25,7 @@
#include "notifymanager.h"
#include "enums/equipslot.h"
+#include "enums/simpletypes.h"
#include "enums/being/attributes.h"
@@ -381,7 +382,9 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
if (inventory)
{
inventory->setItem(index, itemId, itemType, 1, refine,
- 1, flags.bits.isIdentified, flags.bits.isDamaged,
+ 1,
+ fromBool(flags.bits.isIdentified, Identified),
+ flags.bits.isDamaged,
flags.bits.isFavorite,
true, false);
inventory->setCards(index, cards, 4);
@@ -479,7 +482,9 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
amount += item->getQuantity();
inventory->setItem(index, itemId, itemType, amount, refine,
- 1, identified != 0, damaged != 0, false,
+ 1,
+ fromBool(identified, Identified),
+ damaged != 0, false,
equipType != 0, false);
inventory->setCards(index, cards, 4);
}
@@ -524,8 +529,10 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg)
if (inventory)
{
inventory->setItem(index, itemId, itemType, amount,
- 0, 1, flags.bits.isIdentified,
- flags.bits.isDamaged, flags.bits.isFavorite,
+ 0, 1,
+ fromBool(flags.bits.isIdentified, Identified),
+ flags.bits.isDamaged,
+ flags.bits.isFavorite,
false, false);
inventory->setCards(index, cards, 4);
}
@@ -558,7 +565,8 @@ void InventoryHandler::processPlayerStorage(Net::MessageIn &msg)
flags.byte = msg.readUInt8("flags");
mInventoryItems.push_back(Ea::InventoryItem(index, itemId, itemType,
- cards, amount, 0, 1, flags.bits.isIdentified,
+ cards, amount, 0, 1,
+ fromBool(flags.bits.isIdentified, Identified),
flags.bits.isDamaged, flags.bits.isFavorite, false));
}
BLOCK_END("InventoryHandler::processPlayerInventory")
@@ -656,7 +664,8 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg)
flags.byte = msg.readUInt8("flags");
mInventoryItems.push_back(Ea::InventoryItem(index, itemId, itemType,
- cards, amount, refine, 1, flags.bits.isIdentified,
+ cards, amount, refine, 1,
+ fromBool(flags.bits.isIdentified, Identified),
flags.bits.isDamaged, flags.bits.isFavorite, false));
}
BLOCK_END("InventoryHandler::processPlayerStorageEquip")
@@ -687,7 +696,9 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg)
if (mStorage)
{
mStorage->setItem(index, itemId, itemType, amount,
- refine, 1, identified != 0, false, false, false, false);
+ refine, 1,
+ fromBool(identified, Identified),
+ false, false, false, false);
mStorage->setCards(index, cards, 4);
}
}
@@ -826,7 +837,9 @@ void InventoryHandler::processPlayerCartAdd(Net::MessageIn &msg)
amount += item->getQuantity();
inventory->setItem(index, itemId, itemType, amount, refine,
- 1, identified != 0, false, false, false, false);
+ 1,
+ fromBool(identified, Identified),
+ false, false, false, false);
inventory->setCards(index, cards, 4);
}
BLOCK_END("InventoryHandler::processPlayerCartAdd")
@@ -856,7 +869,8 @@ void InventoryHandler::processPlayerCartEquip(Net::MessageIn &msg)
flags.byte = msg.readUInt8("flags");
mCartItems.push_back(Ea::InventoryItem(index, itemId, itemType,
- cards, amount, refine, 1, flags.bits.isIdentified,
+ cards, amount, refine, 1,
+ fromBool(flags.bits.isIdentified, Identified),
flags.bits.isDamaged, flags.bits.isFavorite, false));
}
BLOCK_END("InventoryHandler::processPlayerCartEquip")
@@ -885,7 +899,8 @@ void InventoryHandler::processPlayerCartItems(Net::MessageIn &msg)
flags.byte = msg.readUInt8("flags");
mCartItems.push_back(Ea::InventoryItem(index, itemId, itemType,
- cards, amount, 0, 1, flags.bits.isIdentified,
+ cards, amount, 0, 1,
+ fromBool(flags.bits.isIdentified, Identified),
flags.bits.isDamaged, flags.bits.isFavorite, false));
}
BLOCK_END("InventoryHandler::processPlayerCartItems")
diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp
index 5e1a95986..303ebd7c9 100644
--- a/src/net/eathena/tradehandler.cpp
+++ b/src/net/eathena/tradehandler.cpp
@@ -28,6 +28,8 @@
#include "being/playerinfo.h"
+#include "enums/simpletypes.h"
+
#include "gui/windows/tradewindow.h"
#include "net/eathena/messageout.h"
@@ -204,7 +206,8 @@ void TradeHandler::processTradeItemAdd(Net::MessageIn &msg)
tradeWindow->addItem2(type, itemType,
cards, 4,
false, amount,
- refine, 1, identify != 0,
+ refine, 1,
+ fromBool(identify, Identified),
false, false, false);
}
}
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index b0dcca900..efaff9567 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -25,6 +25,7 @@
#include "notifymanager.h"
#include "enums/equipslot.h"
+#include "enums/simpletypes.h"
#include "being/localplayer.h"
@@ -296,12 +297,16 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
if (serverFeatures->haveItemColors())
{
inventory->setItem(index, itemId, itemType, 1, refine,
- identified, true, false, false, true, false);
+ identified,
+ Identified_True,
+ false, false, true, false);
}
else
{
inventory->setItem(index, itemId, itemType, 1, refine,
- 1, identified != 0, false, false, true, false);
+ 1,
+ fromBool(identified, Identified),
+ false, false, true, false);
}
inventory->setCards(index, cards, 4);
}
@@ -398,12 +403,16 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
if (serverFeatures->haveItemColors())
{
inventory->setItem(index, itemId, type, amount, refine,
- identified, true, false, false, equipType != 0, false);
+ identified,
+ Identified_True,
+ false, false, equipType != 0, false);
}
else
{
inventory->setItem(index, itemId, type, amount, refine,
- 1, identified != 0, false, false, equipType != 0, false);
+ 1,
+ fromBool(identified, Identified),
+ false, false, equipType != 0, false);
}
inventory->setCards(index, cards, 4);
}
@@ -459,12 +468,16 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg)
if (serverFeatures->haveItemColors())
{
inventory->setItem(index, itemId, itemType, amount,
- 0, identified, true, false, false, isEquipment, false);
+ 0, identified,
+ Identified_True,
+ false, false, isEquipment, false);
}
else
{
inventory->setItem(index, itemId, itemType, amount,
- 0, 1, identified != 0, false, false, isEquipment, false);
+ 0, 1,
+ fromBool(identified, Identified),
+ false, false, isEquipment, false);
}
inventory->setCards(index, cards, 4);
}
@@ -504,13 +517,15 @@ void InventoryHandler::processPlayerStorage(Net::MessageIn &msg)
{
mInventoryItems.push_back(Ea::InventoryItem(index, itemId,
itemType, cards, amount, 0, identified,
- true, false, false, false));
+ Identified_True,
+ false, false, false));
}
else
{
mInventoryItems.push_back(Ea::InventoryItem(index, itemId,
itemType, cards, amount, 0, 1,
- identified != 0, false, false, false));
+ fromBool(identified, Identified),
+ false, false, false));
}
}
BLOCK_END("InventoryHandler::processPlayerInventory")
@@ -578,13 +593,15 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg)
if (serverFeatures->haveItemColors())
{
mInventoryItems.push_back(Ea::InventoryItem(index, itemId,
- itemType, cards, amount, refine, identified, true,
+ itemType, cards, amount, refine, identified,
+ Identified_True,
false, false, false));
}
else
{
mInventoryItems.push_back(Ea::InventoryItem(index, itemId,
- itemType, cards, amount, refine, 1, identified != 0,
+ itemType, cards, amount, refine, 1,
+ fromBool(identified, Identified),
false, false, false));
}
}
@@ -617,12 +634,16 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg)
if (serverFeatures->haveItemColors())
{
mStorage->setItem(index, itemId, 0, amount,
- refine, identified, true, false, false, false, false);
+ refine, identified,
+ Identified_True,
+ false, false, false, false);
}
else
{
mStorage->setItem(index, itemId, 0, amount,
- refine, 1, identified != 0, false, false, false, false);
+ refine, 1,
+ fromBool(identified, Identified),
+ false, false, false, false);
}
mStorage->setCards(index, cards, 4);
}
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index f16ee8c1f..53336bb24 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -29,6 +29,8 @@
#include "being/playerinfo.h"
#include "being/playerrelations.h"
+#include "enums/simpletypes.h"
+
#include "gui/windows/confirmdialog.h"
#include "gui/windows/tradewindow.h"
@@ -192,14 +194,18 @@ void TradeHandler::processTradeItemAdd(Net::MessageIn &msg)
tradeWindow->addItem2(type, 0,
cards, 4,
false, amount,
- refine, identify, true, false, false, false);
+ refine,
+ identify,
+ Identified_True, false, false, false);
}
else
{
tradeWindow->addItem2(type, 0,
cards, 4,
false, amount,
- refine, 1, identify != 0, false, false, false);
+ refine, 1,
+ fromBool(identify, Identified),
+ false, false, false);
}
}
}
@@ -228,11 +234,18 @@ void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg)
// Successfully added item
if (tradeWindow)
{
- tradeWindow->addItem2(item->getId(), item->getType(),
- item->getCards(), 4,
- true, quantity, item->getRefine(), item->getColor(),
- item->getIdentified(), item->getDamaged(),
- item->getFavorite(), item->isEquipment());
+ tradeWindow->addItem2(item->getId(),
+ item->getType(),
+ item->getCards(),
+ 4,
+ true,
+ quantity,
+ item->getRefine(),
+ item->getColor(),
+ item->getIdentified(),
+ item->getDamaged(),
+ item->getFavorite(),
+ item->isEquipment());
}
item->increaseQuantity(-quantity);
break;
diff --git a/src/shopitem.cpp b/src/shopitem.cpp
index 704396c87..9370b744e 100644
--- a/src/shopitem.cpp
+++ b/src/shopitem.cpp
@@ -38,7 +38,9 @@ ShopItem::ShopItem(const int inventoryIndex,
const unsigned char color,
const int quantity,
const int price) :
- Item(id, type, 0, 0, color, true, false, false, false, false),
+ Item(id, type, 0, 0, color,
+ Identified_True,
+ false, false, false, false),
mDisplayName(),
mDuplicates(),
mPrice(price),
@@ -53,7 +55,9 @@ ShopItem::ShopItem(const int id,
const int type,
const unsigned char color,
const int price) :
- Item(id, type, 0, 0, color, true, false, false, false, false),
+ Item(id, type, 0, 0, color,
+ Identified_True,
+ false, false, false, false),
mDisplayName(),
mDuplicates(),
mPrice(price),