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>2009-08-15 13:25:37 +0000
committerStijn Buys <ingar@osirion.org>2009-08-15 13:25:37 +0000
commita3cfb9c4634e3ce7e052e72ce564d25e5367a430 (patch)
treed0efd558c108b674fbfd367bdc1f2fc68682c04a /src/core
parent4ca453e2272beed121b957244408a61b0b0d8b9b (diff)
API cleanups, const optimizations, submodel lights/flares/particles import
Diffstat (limited to 'src/core')
-rw-r--r--src/core/entity.h52
-rw-r--r--src/core/parser.cc35
2 files changed, 65 insertions, 22 deletions
diff --git a/src/core/entity.h b/src/core/entity.h
index da58d86..41c56b4 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -101,37 +101,37 @@ public:
inline bool dirty() const { return entity_dirty; }
/// entity location
- inline math::Vector3f & location() { return entity_location; }
+ inline const math::Vector3f& location() const { return entity_location; }
/// local coordinate system of the entity
- inline math::Axis & axis() { return entity_axis; }
+ inline const math::Axis& axis() const { return entity_axis; }
/// primary color of the entity
- inline math::Color const & color() const { return entity_color; }
+ inline const math::Color& color() const { return entity_color; }
/// secondary
- inline math::Color const & color_second() const { return entity_color_second; }
+ inline const math::Color& color_second() const { return entity_color_second; }
/// base shape of the entity
- inline Shape shape() const { return entity_shape; }
+ inline const Shape shape() const { return entity_shape; }
/// base radius of the entity
- inline float radius() const { return entity_radius; }
+ inline const float radius() const { return entity_radius; }
/// current speed of the entity in game units per second
inline const float speed() const { return entity_speed; }
/// indicates a server-side entity
- inline bool serverside() const { return entity_serverside; }
+ inline const bool serverside() const { return entity_serverside; }
/// general visibility
- inline bool visible() const { return entity_visible; }
+ inline const bool visible() const { return entity_visible; }
/// entity menus
inline Menus &menus() { return entity_menus; }
/// extensions
- inline Extension *extension(size_t type) { return entity_extension[type]; }
+ inline Extension *extension(size_t type) const { return entity_extension[type]; }
/// find a menu
MenuDescription *find_menu(std::string const &label);
@@ -228,6 +228,29 @@ public:
/// clear all update flags
virtual void clear_updates();
+/*----- actors ---------------------------------------------------- */
+
+ /**
+ * @brief mutable reference to the location
+ */
+ inline math::Vector3f& get_location() { return entity_location; }
+
+ /**
+ * @brief mutable reference to the axis
+ */
+ inline math::Axis& get_axis() { return entity_axis; }
+
+ /**
+ * @brief mutable reference to the primary color
+ */
+ inline math::Color& get_color() { return entity_color; }
+
+ /**
+ * @brief mutable reference to the secondary color
+ */
+
+ inline math::Color& get_color_second() { return entity_color_second; }
+
/*----- static ---------------------------------------------------- */
/// type definition for the entity registry
@@ -249,17 +272,11 @@ public:
static inline Registry & registry() { return entity_registry; }
/* entity_ variables can be set by the module */
- math::Vector3f entity_location;
- math::Axis entity_axis;
/// speed of the entity
float entity_speed;
-
-
float entity_radius;
Shape entity_shape;
- math::Color entity_color;
- math::Color entity_color_second;
unsigned int entity_moduletypeid;
bool entity_dirty;
@@ -278,6 +295,11 @@ protected:
bool entity_visible;
bool entity_serverside;
+ math::Vector3f entity_location;
+ math::Axis entity_axis;
+ math::Color entity_color;
+ math::Color entity_color_second;
+
private:
unsigned int entity_id;
unsigned int entity_flags;
diff --git a/src/core/parser.cc b/src/core/parser.cc
index 0cee506..fcca2e1 100644
--- a/src/core/parser.cc
+++ b/src/core/parser.cc
@@ -13,11 +13,18 @@ namespace core {
bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity)
{
+ math::Vector3f v;
+ math::Color color;
+
std::string shapename;
std::string strval;
+
float direction;
float pitch;
float roll;
+
+ float f;
+
bool blnval;
if (inifile.got_key_string("shape", shapename)) {
@@ -42,34 +49,48 @@ bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity)
} else if (inifile.got_key_string("label", strval)) {
entity->set_label(strval);
return true;
+
} else if (inifile.got_key_string("name", strval)) {
entity->set_name(strval);
return true;
+
} else if (inifile.got_key_string("model", strval)) {
entity->set_modelname(strval);
return true;
+
} else if (inifile.got_key_bool("showonmap", blnval)) {
if (blnval)
entity->set_flag(Entity::ShowOnMap);
else
entity->unset_flag(Entity::ShowOnMap);
return true;
+
} else if (inifile.got_key_angle("direction", direction)) {
- entity->axis().change_direction(direction);
+ entity->get_axis().change_direction(direction);
return true;
+
} else if (inifile.got_key_angle("pitch", pitch)) {
- entity->axis().change_pitch(pitch);
+ entity->get_axis().change_pitch(pitch);
return true;
+
} else if (inifile.got_key_angle("roll", roll)) {
- entity->axis().change_roll(roll);
+ entity->get_axis().change_roll(roll);
return true;
- } else if (inifile.got_key_angle("radius", entity->entity_radius)) {
+
+ } else if (inifile.got_key_angle("radius", f)) {
+ entity->entity_radius = f;
return true;
- } else if (inifile.got_key_vector3f("location", entity->entity_location)) {
+
+ } else if (inifile.got_key_vector3f("location", v)) {
+ entity->get_location().assign(v);
return true;
- } else if (inifile.got_key_color("colorsecond", entity->entity_color_second)) {
+
+ } else if (inifile.got_key_color("colorsecond", color)) {
+ entity->get_color_second().assign(color);
return true;
- } else if (inifile.got_key_color("color", entity->entity_color)) {
+
+ } else if (inifile.got_key_color("color", color)) {
+ entity->get_color().assign(color);
return true;
}