Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-09-18 18:50:55 +0000
committerStijn Buys <ingar@osirion.org>2010-09-18 18:50:55 +0000
commit9c91a9767b570fdc3c3e19e1f452f9a8257f9999 (patch)
tree9ac10114a3378134ea19dac3d7f7639532c3bf5a /src/core
parentfc4809e41bc5694231046eb2fd4c324c4daba13f (diff)
trade updates
Diffstat (limited to 'src/core')
-rw-r--r--src/core/entity.h5
-rw-r--r--src/core/inventory.cc14
-rw-r--r--src/core/inventory.h23
-rw-r--r--src/core/item.cc16
-rw-r--r--src/core/item.h37
5 files changed, 68 insertions, 27 deletions
diff --git a/src/core/entity.h b/src/core/entity.h
index 8bf637d..f00e192 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -234,6 +234,11 @@ public:
*/
virtual void set_zone(Zone *zone);
+ /// current speed of the entity in game units per second
+ inline void set_speed(const float speed) {
+ entity_speed = speed;
+ }
+
/// set visibility
inline void set_visible(const bool visible = true) {
entity_visible = visible;
diff --git a/src/core/inventory.cc b/src/core/inventory.cc
index e1a74dc..6afa76f 100644
--- a/src/core/inventory.cc
+++ b/src/core/inventory.cc
@@ -4,6 +4,7 @@
the terms of the GNU General Public License version 2
*/
+#include "core/application.h"
#include "core/inventory.h"
#include "sys/sys.h"
@@ -14,12 +15,23 @@ namespace core
Inventory::Inventory()
{
-
+ inventory_timestamp = 0;
}
Inventory::~Inventory()
{
clear();
+ inventory_timestamp = 0;
+}
+
+void Inventory::set_timestamp(const unsigned long timestamp)
+{
+ inventory_timestamp = timestamp;
+}
+
+void Inventory::mark()
+{
+ inventory_timestamp = core::game()->timestamp();
}
void Inventory::add(Item *item)
diff --git a/src/core/inventory.h b/src/core/inventory.h
index c924683..c715116 100644
--- a/src/core/inventory.h
+++ b/src/core/inventory.h
@@ -55,12 +55,31 @@ public:
*/
Item *find(const Info *info);
- inline Items &items() {
+ inline Items &items() {
return inventory_items;
};
+
+ /**
+ * @brief return the timestamp
+ */
+ inline const unsigned long timestamp() const {
+ return inventory_timestamp;
+ }
+
+ /**
+ * @brief set the timestamp
+ */
+ void set_timestamp(const unsigned long timestamp);
+
+ /**
+ * @brief set the timestamp to the current game time
+ */
+ void mark();
private:
- Items inventory_items;
+ Items inventory_items;
+ // timestamp when inventory was last updated
+ unsigned long inventory_timestamp;
};
} // namsepace core
diff --git a/src/core/item.cc b/src/core/item.cc
index a6cc89f..3528c1a 100644
--- a/src/core/item.cc
+++ b/src/core/item.cc
@@ -16,6 +16,7 @@ Item::Item(const Info *info)
{
item_info = info;
item_amount = 0;
+ item_price = 0;
}
Item::~Item()
@@ -29,5 +30,20 @@ void Item::set_amount(const int amount)
item_amount = amount;
}
+void Item::inc_amount(const int amount)
+{
+ item_amount += amount;
+}
+
+void Item::dec_amount(const int amount)
+{
+ item_amount -= amount;
+}
+
+void Item::set_price(const long price)
+{
+ item_price = price;
+}
+
} // namespace core
diff --git a/src/core/item.h b/src/core/item.h
index f1d6bb5..cc81249 100644
--- a/src/core/item.h
+++ b/src/core/item.h
@@ -19,8 +19,6 @@ namespace core
class Item
{
public:
- enum Flags { Mount = 1, Trade = 2 };
-
Item(const Info *info);
~Item();
@@ -35,12 +33,12 @@ public:
/**
* @brief information card
*/
- inline const Info *info() const { return item_info; }
+ inline const Info *info() const { return item_info; }
- /**
- * @brief flags
- */
- inline int flags() const { return item_flags; }
+
+ inline const long price() const {
+ return item_price;
+ }
/* ---- mutators ----------------------------------------------- */
@@ -49,25 +47,16 @@ public:
*/
void set_amount(const int amount);
- /**
- * @brief set specified flags
- */
- inline void set_flag(Flags flag) {
- item_flags |= flag;
- }
-
- /**
- * @brief unset specified flags
- */
- inline void unset_flag(Flags flag) {
- item_flags &= ~flag;
- }
+ void inc_amount(const int amount);
+
+ void dec_amount(const int amount);
+
+ void set_price(const long price);
private:
- const Info *item_info;
- int item_amount;
-
- int item_flags;
+ const Info *item_info;
+ long item_price;
+ int item_amount;
};
} // namespace core