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>2012-03-03 23:15:39 +0000
committerStijn Buys <ingar@osirion.org>2012-03-03 23:15:39 +0000
commit8fbb2425220389ee69749ccd93407a0db73678fd (patch)
tree3ef7b7615711f9dd552760fbf0c26a801421082b /src/core
parentf0a4a7d7213b61714542d64a7559648a086df26a (diff)
Added core::Slots class template, replaced Entity::set_inventory() with Entity::add_inventory().
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Makefile.am2
-rw-r--r--src/core/entity.cc10
-rw-r--r--src/core/entity.h24
-rw-r--r--src/core/slots.cc23
-rw-r--r--src/core/slots.h22
5 files changed, 67 insertions, 14 deletions
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 0c8036e..1f1619e 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -31,6 +31,7 @@ noinst_HEADERS = \
player.h \
range.h \
signals.h \
+ slots.h \
stats.h \
uid.h \
zone.h
@@ -60,6 +61,7 @@ libcore_la_SOURCES = \
physics.cc \
player.cc \
signals.cc \
+ slots.cc \
stats.cc \
uid.cc \
zone.cc
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 4a6528f..2f23444 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -271,12 +271,12 @@ void Entity::set_info(const Info *info)
entity_info = info;
}
-void Entity::set_inventory(Inventory *inventory)
+Inventory *Entity::add_inventory()
{
- if (entity_inventory && (entity_inventory != inventory)) {
- delete entity_inventory;
- }
- entity_inventory = inventory;
+ if (!entity_inventory) {
+ entity_inventory = new Inventory();
+ }
+ return(entity_inventory);
}
void Entity::set_zone(Zone *zone)
diff --git a/src/core/entity.h b/src/core/entity.h
index 94cd09f..d071c06 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -190,7 +190,7 @@ public:
return entity_visible;
}
- ///entity inventory
+ /// entity inventory
inline Inventory *inventory() const {
return entity_inventory;
}
@@ -327,11 +327,12 @@ public:
/**
* @brief add an inventory to this entity
- * Entity takes ownership over the inventory pointer
+ * If this entity already has an inventory,
+ * the current inventory will be return
*/
- void set_inventory(Inventory *inventory);
-
- void set_info(const Info *info);
+ Inventory *add_inventory();
+
+ void set_info(const Info *info);
/// set the timestamp when the entity was last alive
void set_keepalive(unsigned long timestamp) {
@@ -617,7 +618,7 @@ class EntityControlable : public EntityDynamic
public:
/// control flags
- enum ControlFlags {ControlFlagNone = 0, ControlFlagImpulse = 1};
+ enum ControlFlags {ControlFlagNone = 0, ControlFlagFire = 1};
/// bullet action interface class
class ActionInterface: public btActionInterface {
@@ -659,9 +660,14 @@ public:
}
/// control flags
- inline unsigned int control_flags() const {
+ inline int control_flags() const {
return entity_control_flags;
}
+
+ /// returns true if the specified control flag is set
+ inline bool control_flag_is_set(ControlFlags flag) const {
+ return ((flag && entity_control_flags) == flag);
+ }
/// physics action
inline ActionInterface *actioninterface() {
@@ -682,7 +688,7 @@ public:
/*----- mutators -------------------------------------------------- */
/// set all control flags
- inline void set_control_flags(unsigned int control_flags) {
+ inline void set_control_flags(int control_flags) {
entity_control_flags = control_flags;
}
@@ -788,7 +794,7 @@ protected:
float target_vstrafe;
- unsigned int entity_control_flags;
+ int entity_control_flags;
ActionInterface *entity_actioninterface;
diff --git a/src/core/slots.cc b/src/core/slots.cc
new file mode 100644
index 0000000..6ef1d29
--- /dev/null
+++ b/src/core/slots.cc
@@ -0,0 +1,23 @@
+/*
+ core/slots.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2.
+*/
+
+#include "core/slots.h"
+
+namespace core
+{
+
+Slots::Slots()
+{
+}
+
+Slots::~Slots()
+{
+}
+
+} // namespace core
+
+
+
diff --git a/src/core/slots.h b/src/core/slots.h
new file mode 100644
index 0000000..ef1af77
--- /dev/null
+++ b/src/core/slots.h
@@ -0,0 +1,22 @@
+/*
+ core/slots.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2.
+*/
+
+#ifndef __INCLUDED_CORE_SLOTS_H__
+#define __INCLUDED_CORE_SLOTS_H__
+
+namespace core
+{
+
+class Slots {
+public:
+ Slots();
+ ~Slots();
+};
+
+} // namespace core
+
+#endif // __INCLUDED_CORE_SLOTS_H__
+