[Orxonox-commit 6386] r11043 - code/branches/presentationHS15/src/modules/hover

landauf at orxonox.net landauf at orxonox.net
Mon Jan 4 20:59:19 CET 2016


Author: landauf
Date: 2016-01-04 20:59:19 +0100 (Mon, 04 Jan 2016)
New Revision: 11043

Modified:
   code/branches/presentationHS15/src/modules/hover/FlagHUD.cc
   code/branches/presentationHS15/src/modules/hover/Hover.cc
   code/branches/presentationHS15/src/modules/hover/Hover.h
   code/branches/presentationHS15/src/modules/hover/HoverFlag.cc
   code/branches/presentationHS15/src/modules/hover/HoverWall.cc
   code/branches/presentationHS15/src/modules/hover/MazeGenerator.cc
   code/branches/presentationHS15/src/modules/hover/MazeGenerator.h
   code/branches/presentationHS15/src/modules/hover/TimeHUD.cc
Log:
more cleanup & deleting member objects in destructor

Modified: code/branches/presentationHS15/src/modules/hover/FlagHUD.cc
===================================================================
--- code/branches/presentationHS15/src/modules/hover/FlagHUD.cc	2016-01-04 17:31:29 UTC (rev 11042)
+++ code/branches/presentationHS15/src/modules/hover/FlagHUD.cc	2016-01-04 19:59:19 UTC (rev 11043)
@@ -87,7 +87,7 @@
     {
         SUPER(FlagHUD, tick, dt);
 
-        setFlagCount(this->hoverGame_->getFlags());
+        setFlagCount(this->hoverGame_->getNumberOfFlags());
     }
 
     void FlagHUD::changedOwner()

Modified: code/branches/presentationHS15/src/modules/hover/Hover.cc
===================================================================
--- code/branches/presentationHS15/src/modules/hover/Hover.cc	2016-01-04 17:31:29 UTC (rev 11042)
+++ code/branches/presentationHS15/src/modules/hover/Hover.cc	2016-01-04 19:59:19 UTC (rev 11043)
@@ -48,7 +48,7 @@
         RegisterObject(Hover);
 
         this->origin_ = NULL;
-        this->flags_ = 1;
+        this->numberOfFlags_ = 1;
         this->firstTick_ = true;
 
         this->setHUDTemplate("HoverHUD");
@@ -98,20 +98,18 @@
             {
                 HoverFlag* flag = new HoverFlag(origin_->getContext());
                 flag->init(rand()%numCells, rand()%numCells, cellSize);
-                flagVector_.push_back(flag);
+                flags_.push_back(flag);
             }
 
-            flags_ = flagVector_.size();
-
         }//firsttick end
 
         // Check if ship collided with one of the flags
-        for ( unsigned int i = 0; i < flagVector_.size(); i++ ){
-            if(flagVector_[i]->getCollided()){
-                flagVector_[i]->destroyLater();
-                flagVector_.erase (flagVector_.begin()+i);
+        for ( unsigned int i = 0; i < flags_.size(); i++ ){
+            if(flags_[i]->getCollided()){
+                flags_[i]->destroyLater();
+                flags_.erase (flags_.begin()+i);
             }
         }
-        flags_ = flagVector_.size();
+        numberOfFlags_ = flags_.size();
     }
 }

Modified: code/branches/presentationHS15/src/modules/hover/Hover.h
===================================================================
--- code/branches/presentationHS15/src/modules/hover/Hover.h	2016-01-04 17:31:29 UTC (rev 11042)
+++ code/branches/presentationHS15/src/modules/hover/Hover.h	2016-01-04 19:59:19 UTC (rev 11043)
@@ -54,13 +54,13 @@
             void setOrigin(HoverOrigin* origin)
                 { this->origin_ = origin; }
 
-            inline int getFlags() const
-                { return this->flags_; }
+            inline int getNumberOfFlags() const
+                { return this->numberOfFlags_; }
 
         private:
             WeakPtr<HoverOrigin> origin_;
-            std::vector<HoverFlag*> flagVector_;
-            int flags_;
+            std::vector<HoverFlag*> flags_;
+            int numberOfFlags_;
             bool firstTick_;
     };
 }

Modified: code/branches/presentationHS15/src/modules/hover/HoverFlag.cc
===================================================================
--- code/branches/presentationHS15/src/modules/hover/HoverFlag.cc	2016-01-04 17:31:29 UTC (rev 11042)
+++ code/branches/presentationHS15/src/modules/hover/HoverFlag.cc	2016-01-04 19:59:19 UTC (rev 11043)
@@ -59,6 +59,21 @@
 
     /**
     @brief
+        Destructor.
+    */
+    HoverFlag::~HoverFlag()
+    {
+        if (this->isInitialized())
+        {
+            if (this->model_)
+                this->model_->destroy();
+            if (this->cs_)
+                this->cs_->destroy();
+        }
+    }
+
+    /**
+    @brief
         Initializes the flag.
     @param xCoordinate
         X-Coordinate of the flage, 0-9, origin is bottom left
@@ -83,15 +98,6 @@
 
     /**
     @brief
-        Destructor.
-    */
-    HoverFlag::~HoverFlag()
-    {
-
-    }
-
-    /**
-    @brief
         Checks if the Hovership collided with the flag
     */
     bool HoverFlag::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)

Modified: code/branches/presentationHS15/src/modules/hover/HoverWall.cc
===================================================================
--- code/branches/presentationHS15/src/modules/hover/HoverWall.cc	2016-01-04 17:31:29 UTC (rev 11042)
+++ code/branches/presentationHS15/src/modules/hover/HoverWall.cc	2016-01-04 19:59:19 UTC (rev 11043)
@@ -59,7 +59,13 @@
     */
     HoverWall::~HoverWall()
     {
-
+        if (this->isInitialized())
+        {
+            if (this->model_)
+                this->model_->destroy();
+            if (this->cs_)
+                this->cs_->destroy();
+        }
     }
 
     /**

Modified: code/branches/presentationHS15/src/modules/hover/MazeGenerator.cc
===================================================================
--- code/branches/presentationHS15/src/modules/hover/MazeGenerator.cc	2016-01-04 17:31:29 UTC (rev 11042)
+++ code/branches/presentationHS15/src/modules/hover/MazeGenerator.cc	2016-01-04 19:59:19 UTC (rev 11043)
@@ -83,6 +83,12 @@
         std::copy(mask,     mask + 9,     this->mask_);
     }
 
+    MazeGenerator::~MazeGenerator()
+    {
+        delete[] this->levelcode_;
+        delete[] this->maze_;
+    }
+
     /**
     @brief
         Checks if Direction is valid (for Maze-Generator)

Modified: code/branches/presentationHS15/src/modules/hover/MazeGenerator.h
===================================================================
--- code/branches/presentationHS15/src/modules/hover/MazeGenerator.h	2016-01-04 17:31:29 UTC (rev 11042)
+++ code/branches/presentationHS15/src/modules/hover/MazeGenerator.h	2016-01-04 19:59:19 UTC (rev 11043)
@@ -51,6 +51,7 @@
     {
         public:
             MazeGenerator(int numCells);
+            ~MazeGenerator();
 
             void generateMaze();
             void renderMaze();

Modified: code/branches/presentationHS15/src/modules/hover/TimeHUD.cc
===================================================================
--- code/branches/presentationHS15/src/modules/hover/TimeHUD.cc	2016-01-04 17:31:29 UTC (rev 11042)
+++ code/branches/presentationHS15/src/modules/hover/TimeHUD.cc	2016-01-04 19:59:19 UTC (rev 11043)
@@ -82,7 +82,7 @@
         {
             this->setCaption(getTimeString(this->time_));
         }
-        if(this->hoverGame_->getFlags() == 0)
+        if(this->hoverGame_->getNumberOfFlags() == 0)
             setRunning(false);
         
     }




More information about the Orxonox-commit mailing list