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>2010-09-22 21:32:34 +0000
committerStijn Buys <ingar@osirion.org>2010-09-22 21:32:34 +0000
commita6f9773c358dd7d091ff64cbda504ab8d8066dd3 (patch)
tree226e23c4656957e908623ccda9d3d1c50240a0b4 /src/core/inventory.h
parentbbb43d1c15f2858573f5abb595aa62f8224e4d76 (diff)
full trading support for networked games
Diffstat (limited to 'src/core/inventory.h')
-rw-r--r--src/core/inventory.h24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/core/inventory.h b/src/core/inventory.h
index 7aaf299..80dbde1 100644
--- a/src/core/inventory.h
+++ b/src/core/inventory.h
@@ -45,7 +45,8 @@ public:
};
/**
- * @brief return the timestamp
+ * @brief return the timestamp of the last server update
+ * This is a client-side property and shoul not be used server-side
*/
inline const unsigned long timestamp() const {
return inventory_timestamp;
@@ -72,6 +73,10 @@ public:
return inventory_capacity - inventory_capacity_used;
}
+ inline const bool dirty() const {
+ return inventory_dirty;
+ }
+
/**
* @brief returns the number of units of an item that can be stored in this inventory
* @param credits number of player credits, limits the amount
@@ -109,21 +114,24 @@ public:
/**
* @brief mark the inventory as dirty
- * This method will set the timestamp to the current game time
- * and will recalculate the available capacity
- * @see recalculate()
*/
- void set_dirty();
+ void set_dirty(const bool dirty = true);
/**
* @brief set the maximal inventory capacity, in cubic meters
*/
void set_capacity(const float capacity);
-private:
- // recalculate inventory capacity
+ /// recalculate inventory capacity
void recalculate();
+
+ /// serialize a server-to-client update on a stream
+ void serialize_server_update(std::ostream & os) const;
+ /// receive a server-to-client update from a stream
+ void receive_server_update(std::istream &is);
+
+private:
// items in the inventory
Items inventory_items;
@@ -135,6 +143,8 @@ private:
// current capacity used, in cubic meters
float inventory_capacity_used;
+
+ bool inventory_dirty;
};
} // namsepace core