From 95cc140404c6524ea16e193e1421e826b239114f Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 16 Aug 2009 16:32:38 +0000 Subject: more constness, initial patchDef2 support in MapFile, reverse engine disables impulse drive, r_axis support --- src/core/entity.cc | 72 +++++++++++++++++------------------------------------- 1 file changed, 22 insertions(+), 50 deletions(-) (limited to 'src/core/entity.cc') diff --git a/src/core/entity.cc b/src/core/entity.cc index 2b3c482..0ead5f4 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -87,7 +87,7 @@ void Entity::list() /* ---- class Entity ----------------------------------------------- */ -Entity::Entity(unsigned int flags) : +Entity::Entity(const unsigned int flags) : entity_location(0.0f, 0.0f, 0.0f), entity_color(1.0f, 1.0f, 1.0f, 1.0f), entity_color_second(1.0f, 1.0f, 1.0f, 1.0f) @@ -186,7 +186,7 @@ void Entity::set_zone(Zone *zone) entity_zone->add(this); } -void Entity::set_label(char const *label) +void Entity::set_label(const char *label) { entity_label.assign(label); aux::to_label(entity_label); @@ -198,7 +198,7 @@ void Entity::set_label(const std::string &label) aux::to_label(entity_label); } -void Entity::set_name(char const *name) +void Entity::set_name(const char *name) { entity_name.assign(name); aux::strip_quotes(entity_name); @@ -210,34 +210,6 @@ void Entity::set_name(const std::string &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::set_flag(Flags flag) -{ - entity_flags |= flag; -} - -void Entity::unset_flag(Flags flag) -{ - entity_flags &= ~flag; -} - void Entity::set_model(model::Model *model) { entity_model = model; @@ -408,9 +380,9 @@ EntityDynamic::~EntityDynamic() void EntityDynamic::set_state(int state) { - if (entity_state != state) { + if (this->state() != state) { entity_state = state; - entity_dirty = true; + set_dirty(); } } @@ -422,9 +394,9 @@ void EntityDynamic::frame(float seconds) if (entity_speed == 0) return; - entity_location += entity_axis.forward() * entity_speed * seconds; + get_location() += axis().forward() * entity_speed * seconds; - entity_dirty = true; + set_dirty(); } void EntityDynamic::serialize_server_create(std::ostream & os) const @@ -465,9 +437,9 @@ void EntityDynamic::serialize_server_update(std::ostream & os) const os << (visible() ? 1 : 0 ) << " "; if (visible()) { os << std::setprecision(8) - << entity_location << " " - << entity_axis.forward() << " " - << entity_axis.left() << " " + << location() << " " + << axis().forward() << " " + << axis().left() << " " << roundf(entity_speed * 100.0f) << " " << entity_state << " "; @@ -482,12 +454,12 @@ void EntityDynamic::receive_server_update(std::istream &is) unsigned int o = 0; is >> o; // visibility if (o) { - entity_visible = true; - is >> entity_location; + set_visible(); + is >> get_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 >> get_axis()[0]; + is >> get_axis()[1]; + get_axis()[2] = math::crossproduct(axis().forward(), axis().left()); is >> entity_speed; entity_speed /= 100.0f; is >> entity_state; @@ -498,7 +470,7 @@ void EntityDynamic::receive_server_update(std::istream &is) entity_timer = 0; } } else { - entity_visible = false; + set_visible(false); } } @@ -632,7 +604,7 @@ void EntityControlable::set_thrust(float thrust) if (thrust != target_thrust) { target_thrust = thrust; - entity_dirty = true; + set_dirty(); } } @@ -643,7 +615,7 @@ void EntityControlable::set_direction(float direction) if (target_direction != direction) { target_direction = direction; - entity_dirty = true; + set_dirty(); } } @@ -654,7 +626,7 @@ void EntityControlable::set_pitch(float pitch) if (target_pitch != pitch) { target_pitch = pitch; - entity_dirty = true; + set_dirty(); } } @@ -665,7 +637,7 @@ void EntityControlable::set_roll(float roll) if (target_roll != roll) { target_roll = roll; - entity_dirty = true; + set_dirty(); } } @@ -676,7 +648,7 @@ void EntityControlable::set_strafe(float strafe) if (target_strafe != strafe) { target_strafe = strafe; - entity_dirty = true; + set_dirty(); } } @@ -687,7 +659,7 @@ void EntityControlable::set_afterburner(float afterburner) if (target_afterburner != afterburner) { target_afterburner = afterburner; - entity_dirty = true; + set_dirty(); } } -- cgit v1.2.3