Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-10-20 16:35:26 +0000
committerStijn Buys <ingar@osirion.org>2012-10-20 16:35:26 +0000
commit75274ebd6ba90784f5aa837b7e5ea97fc6bfb720 (patch)
treea5d51a87bf3f20833df18bc40a3254b946716afb /src/core/item.h
parentf01629dc14b1ee05b44d2e38b3dffbc1441fd85f (diff)
Item id based inventory, support for weapon dealers.
Diffstat (limited to 'src/core/item.h')
-rw-r--r--src/core/item.h41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/core/item.h b/src/core/item.h
index 6c99270..ec0d6be 100644
--- a/src/core/item.h
+++ b/src/core/item.h
@@ -23,14 +23,16 @@ public:
Item(const Info *info);
- /// copy constructor
- Item(const Item &other);
-
~Item();
/* ---- inspectors --------------------------------------------- */
/**
+ * @brief returns the item id
+ * */
+ inline unsigned int id() const { return item_id; }
+
+ /**
* @brief associated amount
*/
inline long amount() const { return item_amount; }
@@ -69,6 +71,13 @@ public:
}
/**
+ * @brief returns true if the Unique flag is set
+ */
+ inline const bool unique() const {
+ return ((item_flags & (unsigned int) Unique) == (unsigned int) Unique);
+ }
+
+ /**
* @brief return true if the dirty flag is set
* */
inline const bool dirty() const {
@@ -76,6 +85,21 @@ public:
}
/* ---- mutators ----------------------------------------------- */
+
+ /**
+ * @brief set item id
+ * This should never be called from within the game module,
+ * it is used by Inventory to keep track of unique items
+ */
+ void set_id(const unsigned int id);
+
+ /**
+ * @brief set item info
+ * This should never be called from within the game module,
+ * it essentially changes the item type and is used by NetConnection
+ * for inventory householding.
+ */
+ void set_info(const Info *info);
/**
* @brief set associated amount
@@ -98,6 +122,13 @@ public:
void set_price(const long price);
/**
+ * @brief set all item flags
+ */
+ inline void set_flags(const unsigned int flags) {
+ item_flags = flags;
+ }
+
+ /**
* @brief set item flag
*/
inline void set_flag(Flags flag) {
@@ -115,7 +146,7 @@ public:
* @brief set the dirty flag
* */
inline void set_dirty(const bool dirty = true) {
- item_dirty = true;
+ item_dirty = dirty;
}
/* ---- serializers -------------------------------------------- */
@@ -136,6 +167,8 @@ private:
unsigned int item_flags;
bool item_dirty;
+
+ unsigned int item_id;
};
} // namespace core