From f030154fe727e25a2afe1f78b3998c2d2dba95e4 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 18 Aug 2009 09:24:15 +0000 Subject: astyle cleanup, corrects not loading of material textures --- src/core/entity.h | 232 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 162 insertions(+), 70 deletions(-) (limited to 'src/core/entity.h') diff --git a/src/core/entity.h b/src/core/entity.h index 3002219..92cb5ab 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -39,16 +39,16 @@ class Entity public: /// Entity flags - enum Flags {Static=1, Solid=2, Bright=4, Dockable=8, ShowOnMap=16}; + enum Flags {Static = 1, Solid = 2, Bright = 4, Dockable = 8, ShowOnMap = 16}; /// Entity type constants - enum Type {Default=0, Dynamic=1, Controlable=2, Globe=3}; + enum Type {Default = 0, Dynamic = 1, Controlable = 2, Globe = 3}; /// Entity shape constants - enum Shape {Diamond=0, Sphere=1, Cube=2, Axis=3}; + enum Shape {Diamond = 0, Sphere = 1, Cube = 2, Axis = 3}; /// EntityDynamic State constants - enum State {Normal=0, NoPower=1, ImpulseInitiate=2, Impulse=3, JumpInitiate=4, Jump=5, Docked=6, Destroyed=7}; + enum State {Normal = 0, NoPower = 1, ImpulseInitiate = 2, Impulse = 3, JumpInitiate = 4, Jump = 5, Docked = 6, Destroyed = 7}; /// entity menus collection typedef typedef std::list Menus; @@ -62,76 +62,122 @@ public: /// destroy an entity virtual ~Entity(); -/*----- inspectors ------------------------------------------------ */ - + /*----- inspectors ------------------------------------------------ */ + /// entity id - inline const unsigned int id() const { return entity_id; } - + inline const unsigned int id() const { + return entity_id; + } + /// module type id - inline const unsigned int moduletype() const { return entity_moduletypeid; } + inline const unsigned int moduletype() const { + return entity_moduletypeid; + } /// core type id - virtual inline const unsigned int type() const { return Default; } + virtual inline const unsigned int type() const { + return Default; + } /// entity flags - inline const unsigned int flags() const { return entity_flags; } + inline const unsigned int flags() const { + return entity_flags; + } /// returns true of a flag is set - inline const bool flag_is_set(const Flags flag) const { return ((entity_flags & (unsigned int)flag) == (unsigned int)flag); } + inline const bool flag_is_set(const Flags flag) const { + return ((entity_flags & (unsigned int)flag) == (unsigned int)flag); + } /// entity label (can not contain double quotes ") - inline const std::string& label() const { return entity_label; } + inline const std::string& label() const { + return entity_label; + } /// entity name (can not contain double qoutes ") - inline const std::string & name() const { return entity_name; } + inline const std::string & name() const { + return entity_name; + } /// pointer to the model, is used client-side - inline model::Model * model() { return entity_model; } + inline model::Model * model() { + return entity_model; + } /// modelname - inline const std::string & modelname() const { return entity_modelname; } + inline const std::string & modelname() const { + return entity_modelname; + } /// pointer to the zone the entity belongs to - inline Zone *zone() const { return entity_zone; } + inline Zone *zone() const { + return entity_zone; + } /// the zone the entity left in case of a zone change - inline Zone *oldzone() const { return entity_oldzone; } + inline Zone *oldzone() const { + return entity_oldzone; + } /// dirty flag - inline bool dirty() const { return entity_dirty; } + inline bool dirty() const { + return entity_dirty; + } /// entity location - inline const math::Vector3f& location() const { return entity_location; } + inline const math::Vector3f& location() const { + return entity_location; + } /// local coordinate system of the entity - inline const math::Axis& axis() const { return entity_axis; } - + inline const math::Axis& axis() const { + return entity_axis; + } + /// primary color of the entity - inline const math::Color& color() const { return entity_color; } + inline const math::Color& color() const { + return entity_color; + } /// secondary - inline const math::Color& color_second() const { return entity_color_second; } + inline const math::Color& color_second() const { + return entity_color_second; + } /// base shape of the entity - inline const Shape shape() const { return entity_shape; } + inline const Shape shape() const { + return entity_shape; + } /// base radius of the entity - inline const 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; } + inline const float speed() const { + return entity_speed; + } /// indicates a server-side entity - inline const bool serverside() const { return entity_serverside; } + inline const bool serverside() const { + return entity_serverside; + } /// general visibility - inline const bool visible() const { return entity_visible; } + inline const bool visible() const { + return entity_visible; + } /// entity menus - inline Menus &menus() { return entity_menus; } + inline Menus &menus() { + return entity_menus; + } /// extensions - inline Extension *extension(size_t type) const { return entity_extension[type]; } + inline Extension *extension(size_t type) const { + return entity_extension[type]; + } /// find a menu MenuDescription *find_menu(const std::string &label); @@ -140,13 +186,19 @@ public: /* ---- mutators -------------------------------------------------- */ /// assign entity color - inline void set_color(const math::Color &color) { entity_color.assign(color); } + inline void set_color(const math::Color &color) { + entity_color.assign(color); + } /// assign entity secondary color - inline void set_color_second(const math::Color &color) { entity_color_second.assign(color); } + inline void set_color_second(const math::Color &color) { + entity_color_second.assign(color); + } /// set dirty flag - inline void set_dirty(const bool dirty = true) { entity_dirty = dirty; } + inline void set_dirty(const bool dirty = true) { + entity_dirty = dirty; + } /// mark the entity as destroyed virtual void die(); @@ -178,10 +230,14 @@ public: void set_name(const std::string &name); /// set visibility - inline void set_visible(const bool visible = true) { entity_visible = visible; } + inline void set_visible(const bool visible = true) { + entity_visible = visible; + } /// set as server-side entity - inline void set_serverside(const bool serverside = true) { entity_serverside = serverside; } + inline void set_serverside(const bool serverside = true) { + entity_serverside = serverside; + } /// set the model name and load the model void set_modelname(const std:: string &model); @@ -190,7 +246,9 @@ public: void set_model(model::Model *model); /// set entity radius - inline void set_radius(const float radius) { entity_radius = radius; } + inline void set_radius(const float radius) { + entity_radius = radius; + } /* ---- actors ---------------------------------------------------- */ @@ -198,10 +256,14 @@ public: virtual void dock(core::Entity *entity); /// set flags - inline void set_flag(Flags flag) { entity_flags |= flag; } + inline void set_flag(Flags flag) { + entity_flags |= flag; + } /// unset flags - inline void unset_flag(Flags flag) { entity_flags &= ~flag; } + inline void unset_flag(Flags flag) { + entity_flags &= ~flag; + } /// add an entity menu void add_menu(MenuDescription *menu); @@ -215,23 +277,31 @@ public: /** * @brief mutable reference to the location */ - inline math::Vector3f& get_location() { return entity_location; } + inline math::Vector3f& get_location() { + return entity_location; + } /** * @brief mutable reference to the axis */ - inline math::Axis& get_axis() { return entity_axis; } + inline math::Axis& get_axis() { + return entity_axis; + } /** * @brief mutable reference to the primary color */ - inline math::Color& get_color() { return entity_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; } + inline math::Color& get_color_second() { + return entity_color_second; + } /* ---- deserializers -------------------------------------- */ @@ -257,7 +327,7 @@ public: /* ---- static --------------------------------------------- */ - + /// type definition for the entity registry typedef std::map Registry; @@ -274,13 +344,15 @@ public: static void list(); /// the entity registry - static inline Registry & registry() { return entity_registry; } + static inline Registry & registry() { + return entity_registry; + } /* entity_ variables can be set by the module */ /// speed of the entity - float entity_speed; - Shape entity_shape; + float entity_speed; + Shape entity_shape; unsigned int entity_moduletypeid; bool entity_created; @@ -321,7 +393,7 @@ private: Extension* entity_extension[4]; - static Registry entity_registry; + static Registry entity_registry; static size_t entity_nextid; static void add(Entity *ent); @@ -340,17 +412,23 @@ public: virtual ~EntityDynamic(); -/*----- inspectors ------------------------------------------------ */ + /*----- inspectors ------------------------------------------------ */ /// core type id - virtual inline const unsigned int type() const { return Entity::Dynamic; } + virtual inline const unsigned int type() const { + return Entity::Dynamic; + } /// event state - inline const int state() const { return entity_state; } + inline const int state() const { + return entity_state; + } /// event state timer - inline const float timer() const { return entity_timer; } + inline const float timer() const { + return entity_timer; + } -/*----- serializers ----------------------------------------------- */ + /*----- serializers ----------------------------------------------- */ /// serialize the entity to a stream virtual void serialize_server_create(std::ostream & os) const; @@ -361,7 +439,7 @@ public: /// serialize a server-to-client update on a stream virtual void serialize_server_update(std::ostream & os) const; -/*----- mutators -------------------------------------------------- */ + /*----- mutators -------------------------------------------------- */ /// receive a client-to-server update from a stream virtual void receive_client_update(std::istream &is); @@ -398,24 +476,32 @@ public: /// create a controlable entity from stream data EntityControlable(std::istream & is); - + virtual ~EntityControlable(); -/*----- inspectors ------------------------------------------------ */ + /*----- inspectors ------------------------------------------------ */ /// core type id - virtual inline const unsigned int type() const { return Entity::Controlable; } + virtual inline const unsigned int type() const { + return Entity::Controlable; + } /// owner of this entity - inline Player *owner() const { return entity_owner; } + inline Player *owner() const { + return entity_owner; + } /// thrust - inline float thrust() const { return entity_thrust; } + inline float thrust() const { + return entity_thrust; + } /// movement indicator - inline float movement() const { return entity_movement; } + inline float movement() const { + return entity_movement; + } -/*----- serializers ----------------------------------------------- */ + /*----- serializers ----------------------------------------------- */ /// serialize the entity to a stream virtual void serialize_server_create(std::ostream & os) const; @@ -426,7 +512,7 @@ public: /// serialize a server-to-client update on a stream virtual void serialize_server_update(std::ostream & os) const; -/*----- mutators -------------------------------------------------- */ + /*----- mutators -------------------------------------------------- */ /// receive a client-to-server update from a stream virtual void receive_client_update(std::istream &is); @@ -442,7 +528,7 @@ public: /// set the target direction void set_direction(float direction); - + /// set the target pitch void set_pitch(float pitch); @@ -494,7 +580,7 @@ private: }; /// a Globe entity -class EntityGlobe : public Entity +class EntityGlobe : public Entity { public: EntityGlobe(const unsigned int flags = 0); @@ -502,14 +588,18 @@ public: virtual ~EntityGlobe(); -/*----- inspectors ----------------------------------------------- */ + /*----- inspectors ----------------------------------------------- */ /// texture name - inline const std::string &texture() const { return entity_texture; } + inline const std::string &texture() const { + return entity_texture; + } /// rotation speed in degrees per second - inline float rotationspeed() const { return entity_rotationspeed; } + inline float rotationspeed() const { + return entity_rotationspeed; + } -/*----- serializers ----------------------------------------------- */ + /*----- serializers ----------------------------------------------- */ /// serialize the entity to a stream virtual void serialize_server_create(std::ostream & os) const; @@ -517,10 +607,12 @@ public: /// receive a server-to-client create from a stream virtual void receive_server_create(std::istream &is); -/*----- inspectors ------------------------------------------------ */ + /*----- inspectors ------------------------------------------------ */ /// core type id - virtual inline const unsigned int type() const { return Entity::Globe; } + virtual inline const unsigned int type() const { + return Entity::Globe; + } std::string entity_texture; -- cgit v1.2.3