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>2008-10-18 17:58:45 +0000
committerStijn Buys <ingar@osirion.org>2008-10-18 17:58:45 +0000
commit35613f0860a2d8cb643ca8de006de08503e48e53 (patch)
tree8a5436de643e818e68a82df2e5cb2df2145f5062 /src/core/entity.cc
parentdb287e4a5133125bb6f25ba21ea97c47b19ac67f (diff)
example module
Diffstat (limited to 'src/core/entity.cc')
-rw-r--r--src/core/entity.cc83
1 files changed, 60 insertions, 23 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc
index e74b8b5..27190a0 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -177,7 +177,7 @@ void Entity::set_label(char const *label)
aux::to_label(entity_label);
}
-void Entity::set_label(std::string const &label)
+void Entity::set_label(const std::string &label)
{
entity_label.assign(label);
aux::to_label(entity_label);
@@ -189,16 +189,35 @@ void Entity::set_name(char const *name)
aux::strip_quotes(entity_name);
}
-void Entity::set_name(std::string const &name)
+void Entity::set_name(const std::string &name)
{
entity_name.assign(name);
aux::strip_quotes(entity_name);
}
+void Entity::set_visible(bool visible)
+{
+ if (visible)
+ show();
+ else
+ hide();
+}
+
+void Entity::show()
+{
+ entity_visible = false;
+}
+
+void Entity::hide()
+{
+ entity_visible = false;
+}
+
void Entity::serialize_server_create(std::ostream & os) const
{
os << entity_moduletypeid << " "
<< entity_flags << " "
+ << (entity_visible ? 1 : 0) << " "
<< (entity_zone ? entity_zone->id() : 0) << " "
<< std::setprecision(8) << entity_location << " "
<< entity_color << " "
@@ -216,10 +235,18 @@ void Entity::receive_server_create(std::istream &is)
{
unsigned int s;
unsigned int zo;
+ unsigned int o = 0;
std::string n;
is >> entity_moduletypeid;
is >> entity_flags;
+
+ is >> o;
+ if (o)
+ entity_visible = true;
+ else
+ entity_visible = false;
+
is >> zo;
set_zone(Zone::find(zo));
@@ -363,33 +390,43 @@ void EntityDynamic::receive_client_update(std::istream &is)
void EntityDynamic::serialize_server_update(std::ostream & os) const
{
- os << std::setprecision(8)
- << entity_location << " "
- << entity_axis.forward() << " "
- << entity_axis.left() << " "
- << roundf(entity_speed * 100.0f) << " "
- << entity_eventstate << " ";
-
- if (entity_eventstate != Normal) {
- os << entity_timer << " ";
+ os << (visible() ? 1 : 0 ) << " ";
+ if (visible()) {
+ os << std::setprecision(8)
+ << entity_location << " "
+ << entity_axis.forward() << " "
+ << entity_axis.left() << " "
+ << roundf(entity_speed * 100.0f) << " "
+ << entity_eventstate << " ";
+
+ if (entity_eventstate != Normal) {
+ os << entity_timer << " ";
+ }
}
}
void EntityDynamic::receive_server_update(std::istream &is)
{
- is >> entity_location;
- // axis up vector is the crossproduct of forward and left
- is >> entity_axis[0];
- is >> entity_axis[1];
- entity_axis[2] = math::crossproduct(entity_axis.forward(), entity_axis.left());
- is >> entity_speed;
- entity_speed /= 100.0f;
- is >> entity_eventstate;
-
- if (entity_eventstate != Normal) {
- is >> entity_timer;
+ unsigned int o;
+ is >> o; // visibility
+ if (o) {
+ entity_visible = true;
+ is >> entity_location;
+ // axis up vector is the crossproduct of forward and left
+ is >> entity_axis[0];
+ is >> entity_axis[1];
+ entity_axis[2] = math::crossproduct(entity_axis.forward(), entity_axis.left());
+ is >> entity_speed;
+ entity_speed /= 100.0f;
+ is >> entity_eventstate;
+
+ if (entity_eventstate != Normal) {
+ is >> entity_timer;
+ } else {
+ entity_timer = 0;
+ }
} else {
- entity_timer = 0;
+ entity_visible = false;
}
}