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-10-08 19:58:08 +0000
committerStijn Buys <ingar@osirion.org>2012-10-08 19:58:08 +0000
commit14ea3d9d037175d4d5326ac9c83fe69ddcd0d9c4 (patch)
treeace65b7504daa0791a8dd79e4278db1ea1ef304b /src/core
parent66c776cc66d5c91ed3e798b0f5c5a30baf1f1d69 (diff)
added zone flags,
renamed Entity::flag_is_set() to Entity::has_flag()
Diffstat (limited to 'src/core')
-rw-r--r--src/core/entity.cc6
-rw-r--r--src/core/entity.h23
-rw-r--r--src/core/gameserver.cc2
-rw-r--r--src/core/zone.h29
4 files changed, 49 insertions, 11 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 3094208..7bb5278 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -550,7 +550,7 @@ void Entity::frame(const unsigned long elapsed)
void Entity::reset()
{
- if (!radius() || flag_is_set(NonSolid)) {
+ if (!radius() || has_flag(NonSolid)) {
return;
}
@@ -695,7 +695,7 @@ void EntityDynamic::set_state(int state)
void EntityDynamic::reset()
{
- if (!radius() || flag_is_set(NonSolid)) {
+ if (!radius() || has_flag(NonSolid)) {
return;
}
@@ -1169,7 +1169,7 @@ void EntityControlable::set_zone(Zone *zone)
void EntityControlable::reset()
{
- if (!radius() || flag_is_set(NonSolid)) {
+ if (!radius() || has_flag(NonSolid)) {
return;
}
diff --git a/src/core/entity.h b/src/core/entity.h
index 07a3bec..19e47bc 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -44,7 +44,12 @@ class Entity : public Label
public:
/**
* @brief entity flags
- */
+ * NonSolid will exclude the entity from the bullet physics world
+ * Bright is used by EntityGlobe, where a bright sphere is a light source
+ * Dockable means the entity can be docked by a player
+ * ShowOnMap will make the entity appear on the map
+ * KeepAlive is used by EntityDynamic and marks the entity as deletable in the keepalive run
+ * */
enum Flags {NonSolid = 2, Bright = 4, Dockable = 8, ShowOnMap = 16, KeepAlive = 32};
/// Entity type constants
@@ -94,7 +99,7 @@ public:
}
/// returns true of a flag is set
- inline const bool flag_is_set(const Flags flag) const {
+ inline const bool has_flag(const Flags flag) const {
return ((entity_flags & (unsigned int)flag) == (unsigned int)flag);
}
@@ -321,14 +326,18 @@ public:
entity_axis.assign(axis);
}
- /// set flag
+ /**
+ * @brief set flag
+ * */
inline void set_flag(Flags flag) {
- entity_flags |= flag;
+ entity_flags |= (unsigned int) flag;
}
- /// unset flag
+ /**
+ * @brief unset flag
+ * */
inline void unset_flag(Flags flag) {
- entity_flags &= ~flag;
+ entity_flags &= ~((unsigned int) flag);
}
/**
@@ -684,7 +693,7 @@ public:
}
/// returns true if the specified control flag is set
- inline bool control_flag_is_set(ControlFlags flag) const {
+ inline bool control_has_flag(ControlFlags flag) const {
return ((flag && entity_control_flags) == flag);
}
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index f9cc061..579f65d 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -641,7 +641,7 @@ void GameServer::frame(const unsigned long timestamp)
for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); it++) {
Entity *entity = (*it).second;
Zone *zone = entity->zone();
- if (zone && entity->flag_is_set(Entity::KeepAlive)) {
+ if (zone && entity->has_flag(Entity::KeepAlive)) {
if (zone->keepalive_run() && zone->keepalive_box().inside(entity->location())) {
entity->set_keepalive(this->timestamp());
diff --git a/src/core/zone.h b/src/core/zone.h
index 644620d..22440c4 100644
--- a/src/core/zone.h
+++ b/src/core/zone.h
@@ -76,6 +76,8 @@ public:
}
/* ---- Zone class ----------------------------------------- */
+
+ enum Flags { Hidden = 1 };
/**
* @brief create a new zone
@@ -103,6 +105,18 @@ public:
inline unsigned int id() const {
return zone_id;
}
+
+ /// zone flags
+ inline const unsigned int flags() const {
+ return zone_flags;
+ }
+
+ /**
+ * @brief returns true if a specified flag is set
+ * */
+ inline const bool has_flag(const Flags flag) const {
+ return ((zone_flags & (unsigned int) flag) == (unsigned int) flag);
+ }
/// ambient light color
inline math::Color const & ambient_color() {
@@ -144,6 +158,20 @@ public:
Entity *search_entity(const std::string & label);
/* ---- mutators ------------------------------------------- */
+
+ /**
+ * @brief set flag
+ * */
+ inline void set_flag(Flags flag) {
+ zone_flags |= (unsigned int) flag;
+ }
+
+ /**
+ * @brief unset flag
+ * */
+ inline void unset_flag(Flags flag) {
+ zone_flags &= ~((unsigned int) flag);
+ }
/**
* @brief set the skybox name
@@ -244,6 +272,7 @@ public:
private:
unsigned int zone_id;
+ unsigned int zone_flags;
std::string zone_sky;
math::Color zone_ambient_color;