From 8039544940b6145dcc8c63bcd4e06073ed61801e Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 10 Nov 2013 22:23:50 +0000 Subject: Renamed entity_destroyed to entity_died to prevent confusion with the Entity::Destroyed state, fixed a potential memory leak. --- src/core/entity.h | 60 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 17 deletions(-) (limited to 'src/core/entity.h') diff --git a/src/core/entity.h b/src/core/entity.h index f5a6d52..5a028bf 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -36,7 +36,9 @@ class EntityControlable; namespace core { -/// The base world entity. All gameworld entities must derive from this class. +/** + * @brief The base world entity. All gameworld entities must derive from this class. + * */ class Entity : public Label { friend class Extension; @@ -52,28 +54,49 @@ public: * */ enum Flags { NonSolid = 2, Bright = 4, Dockable = 8, ShowOnMap = 16, KeepAlive = 32 }; - /// Entity type constants + /** + * @brief Entity type constants + * @see Entity::type() + * */ enum Type { Default = 0, Dynamic = 1, Controlable = 2, Globe = 3, Projectile = 4 }; - /// Entity shape constants + /** + * @brief Entity shape constants + * @see Entity::shape() + * */ enum Shape { Diamond = 0, Sphere = 1, Cube = 2, Axis = 3 }; - /// EntityDynamic State constants + /** + * @brief EntityDynamic state constants + * @see EntityDynamic::state() + * */ enum State { Normal = 0, NoPower = 1, ImpulseInitiate = 2, Impulse = 3, JumpInitiate = 4, Jump = 5, Docked = 6, Destroyed = 7 }; - /// entity menus collection typedef + /** + * @brief entity menu collection type definition + * */ typedef std::list Menus; - /// type definition for entity bullet shapes collection + /** + * @brief entity bullet shapes collection type definition + * */ typedef std::list CollisionShapes; - /// create a new entity and add it to the registry + /** + * @brief server-side constructor + * create a new entity and add it to the registry + * */ Entity(); - /// create an entity from stream data + /** + * @brief client-side constructor + * create an entity from stream data + * */ Entity(std::istream & is); - /// destroy an entity + /** + * @brief destructor + * */ virtual ~Entity(); /** @@ -241,12 +264,12 @@ public: MenuDescription *find_menu(const std::string &label); /// true if the entity is to be deleted - inline bool destroyed() const { - return entity_destroyed; + inline const bool died() const { + return entity_died; } /// time when the entity was last alive - inline unsigned long keepalive() const { + inline const unsigned long keepalive() const { return entity_keepalive; } @@ -283,10 +306,10 @@ public: } /** - * @brief mark the entity as destroyed + * @brief mark the entity as dead * die() should be called by the game module when it needs to destroy an entity, * the game server will broadcast the delete event to the clients. - * The game module should not delete an entity directly. + * The game module should not delete entities directly. */ virtual void die(); @@ -513,12 +536,15 @@ public: return entity_registry; } - /* entity_ variables can be set by the module */ - + /** + * @brief game module type id + * this id can be assigned by the game module + * */ unsigned int entity_moduletypeid; bool entity_created; - bool entity_destroyed; + + bool entity_died; /// timestamp when entity data was received from the server float entity_servertimestamp; -- cgit v1.2.3