Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3531 in orxonox.OLD for orxonox/trunk/src


Ignore:
Timestamp:
Mar 13, 2005, 10:50:43 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: all WorldEntities/PWodes now destroy all date they alocate.

this is done with a virtual destructor:
if PNode is deleted it calls for the delete of the virtual destructor, and deletes the data of it.

Location:
orxonox/trunk/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/coord/p_node.cc

    r3529 r3531  
    110110  this->parent = NULL;
    111111  /* there is currently a problem with cleaning up - fix*/
     112
     113  this->destroy();
    112114}
    113115
     
    128130  /* this deletes all children in the list */
    129131  this->children->destroy ();
     132
     133  static_cast<BaseObject*>(this)->destroy();
    130134}
    131135
  • orxonox/trunk/src/lib/lang/base_object.cc

    r3484 r3531  
    2626   \brief standard constructor
    2727*/
    28 BaseObject::BaseObject () {}
     28BaseObject::BaseObject ()
     29{
     30  this->className = NULL;
     31}
    2932
    3033
     
    3235   \brief standard deconstructor
    3336*/
    34 BaseObject::~BaseObject () {}
     37BaseObject::~BaseObject ()
     38{
     39  this->destroy();
     40}
    3541
     42/**
     43    \brief destorys everything BaseObject allocated
     44*/
     45void BaseObject::destroy(void)
     46{
     47  //  delete []this->className;
     48}
    3649
    3750void BaseObject::setClassName (char* className)
  • orxonox/trunk/src/lib/lang/base_object.h

    r3484 r3531  
    1515 public:
    1616  BaseObject ();
    17   ~BaseObject ();
     17  virtual ~BaseObject ();
     18
     19  void destroy(void);
    1820
    1921  void setClassName (char* className);
  • orxonox/trunk/src/world_entities/npc.h

    r3472 r3531  
    1212  NPC ();
    1313  ~NPC ();
     14  void destroy(void);
    1415
    1516  /* collision control */
  • orxonox/trunk/src/world_entities/player.cc

    r3526 r3531  
    3737Player::~Player ()
    3838{
     39  this->destroy();
     40}
     41
     42/**
     43   \brief deletes all allocated memory of the Player
     44*/
     45void Player::destroy ()
     46{
    3947  delete this->model;
     48
     49  static_cast<WorldEntity*>(this)->destroy();
    4050}
    4151
     
    7282}
    7383
    74 /**
    75    \brief action that happens when the player is destroyed.
    76 */
    77 void Player::destroy ()
    78 {
    79 }
    8084
    8185/**
  • orxonox/trunk/src/world_entities/player.h

    r3471 r3531  
    1818 public:
    1919  Player(bool isFree = false);
    20   ~Player();
     20  virtual ~Player();
     21  void destroy();
    2122 
    2223  virtual void postSpawn();
    2324  virtual void tick(float time);
    2425  virtual void hit(WorldEntity* weapon, Vector loc);
    25   virtual void destroy();
    2626  virtual void collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags);
    2727  virtual void command(Command* cmd);
  • orxonox/trunk/src/world_entities/primitive.cc

    r3526 r3531  
    3939}
    4040
     41void Primitive::destroy ()
     42{
     43
     44
     45  static_cast<WorldEntity*>(this)->destroy();
     46}
     47
     48
    4149void Primitive::tick (float time)
    4250{
     
    4856void Primitive::hit (WorldEntity* weapon, Vector loc) {}
    4957
    50 void Primitive::destroy () {}
    5158
    5259void Primitive::collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags) {}
  • orxonox/trunk/src/world_entities/primitive.h

    r3524 r3531  
    1212 public:
    1313  Primitive (PRIMITIVE_FORM form);
    14   ~Primitive ();
    15  
     14  virtual ~Primitive ();
     15  void destroy(void);
     16
    1617  virtual void tick (float time);
    1718  virtual void hit (WorldEntity* weapon, Vector loc);
    18   virtual void destroy ();
    1919  virtual void collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags);
    2020  virtual void draw ();
  • orxonox/trunk/src/world_entities/skysphere.cc

    r3526 r3531  
    5757Skysphere::~Skysphere()
    5858{
     59  this->destroy();
     60}
     61
     62void Skysphere::destroy(void)
     63{
     64
    5965  PRINTF(3)("Deleting the SkySphere\n");
    6066  delete skyMaterial;
    6167  free(sphereObj);
     68 
     69  static_cast<WorldEntity*>(this)->destroy();
    6270}
    63 
    6471
    6572/**
  • orxonox/trunk/src/world_entities/skysphere.h

    r3507 r3531  
    2828  Skysphere();
    2929  Skysphere(char* fileName);
    30   ~Skysphere();
     30  virtual ~Skysphere();
     31  void destroy();
    3132
    3233  void setRadius(float radius);
  • orxonox/trunk/src/world_entities/world_entity.cc

    r3474 r3531  
    4747{
    4848  // if( collisioncluster != NULL) delete collisioncluster;
    49 }
     49  this->destroy();
     50}
     51
     52/**
     53   \brief Function to call if a WorldEntity is destroyed. deletes all alocated memory.
     54   */
     55void WorldEntity::destroy()
     56{
     57
     58  // delete everything of pNode.
     59  static_cast<PNode*>(this)->destroy();
     60}
     61
    5062
    5163/**
     
    156168void WorldEntity::hit(WorldEntity* weapon, Vector loc) {}
    157169
    158 /**
    159    \brief this function is called when the entity is to be destroied
    160    
    161    This can be called, if eg. something realy bad happens :)
    162 */
    163 void WorldEntity::destroy() {}
    164170
    165171
  • orxonox/trunk/src/world_entities/world_entity.h

    r3474 r3531  
    2121  WorldEntity (bool isFree = false);
    2222  virtual ~WorldEntity ();
     23  void destroy ();
     24
    2325
    2426  OBJModel* model;                  //!< The model that should be loaded for this entity.
     
    3436  virtual void tick (float time);
    3537  virtual void hit (WorldEntity* weapon, Vector loc);
    36   virtual void destroy ();
    3738  virtual void collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags);
    3839  virtual void command (Command* cmd);
Note: See TracChangeset for help on using the changeset viewer.