[Orxonox-commit 5754] r10414 - in code/branches/core7/src/orxonox: . items worldentities/pawns

landauf at orxonox.net landauf at orxonox.net
Sun May 3 11:47:50 CEST 2015


Author: landauf
Date: 2015-05-03 11:47:50 +0200 (Sun, 03 May 2015)
New Revision: 10414

Modified:
   code/branches/core7/src/orxonox/ShipPartManager.cc
   code/branches/core7/src/orxonox/items/ShipPart.cc
   code/branches/core7/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
Log:
destroy all remaining ship parts if ModularSpaceShip is destroyed.
separate ship part death effects from object deletion. ShipPart.death() creates effects, ShipPartManager destroys the instance.

Modified: code/branches/core7/src/orxonox/ShipPartManager.cc
===================================================================
--- code/branches/core7/src/orxonox/ShipPartManager.cc	2015-05-02 21:20:45 UTC (rev 10413)
+++ code/branches/core7/src/orxonox/ShipPartManager.cc	2015-05-03 09:47:50 UTC (rev 10414)
@@ -45,9 +45,9 @@
 
     ShipPartManager::~ShipPartManager()
     {
-        // Be sure to delete all the pawns
+        // Be sure to delete all the ship parts
         for (ObjectList<ShipPart>::iterator it = ObjectList<ShipPart>::begin(); it != ObjectList<ShipPart>::end(); )
-            (it++)->death();
+            (it++)->destroy();
     }
 
     void ShipPartManager::preUpdate(const Clock& time)
@@ -55,7 +55,7 @@
         for (ObjectList<ShipPart>::iterator it = ObjectList<ShipPart>::begin(); it != ObjectList<ShipPart>::end(); )
         {
             if (!it->isAlive())
-                (it++)->death();
+                (it++)->destroy();
             else
                 ++it;
         }

Modified: code/branches/core7/src/orxonox/items/ShipPart.cc
===================================================================
--- code/branches/core7/src/orxonox/items/ShipPart.cc	2015-05-02 21:20:45 UTC (rev 10413)
+++ code/branches/core7/src/orxonox/items/ShipPart.cc	2015-05-03 09:47:50 UTC (rev 10414)
@@ -49,17 +49,21 @@
     RegisterClass(ShipPart);
 
     ShipPart::ShipPart(Context* context)
-        : Item(context)
+        : Item(context), parent_(NULL)
     {
         RegisterObject(ShipPart);
-        this->setAlive(true);
-        this->setEventExecution(true);
+        this->alive_ = true;
+        this->eventExecution_ = true;
         this->healthMem_ = 100;
     }
 
     ShipPart::~ShipPart()
     {
-
+        if (this->parent_)
+        {
+            // Remove this ShipPart from the parent.
+            this->parent_->removeShipPart(this);
+        }
     }
 
     void ShipPart::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -99,10 +103,6 @@
                 this->getDestructionEvent(i)->execute();
             }
         }
-
-        // Remove this ShipPart from the parent.
-        this->parent_->removeShipPart(this);
-        delete this;
     }
 
     void ShipPart::explode()
@@ -239,8 +239,7 @@
             }
         }
         if (this->health_ < 0)
-            this->alive_ = false;
-            //this->death();
+            this->death();
 
         // (Ugly) Chatoutput of health, until a GUI for modularspaceships-shipparts is implemented.
         if ((this->health_ < 0.2 * this->maxHealth_) && (this->healthMem_ == 40))

Modified: code/branches/core7/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
===================================================================
--- code/branches/core7/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	2015-05-02 21:20:45 UTC (rev 10413)
+++ code/branches/core7/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	2015-05-03 09:47:50 UTC (rev 10414)
@@ -68,7 +68,8 @@
     {
         if (this->isInitialized())
         {
-
+            while (!this->partList_.empty())
+                this->partList_[0]->destroy();
         }
     }
 
@@ -176,7 +177,7 @@
         {
             if (it->second->getName() == name)
             {
-                it->second->setAlive(false);
+                it->second->death();
                 return;
             }
         }
@@ -195,7 +196,7 @@
         {
             if (it->second->getName() == name)
             {
-                it->second->setAlive(false);
+                it->second->death();
                 return;
             }
         }




More information about the Orxonox-commit mailing list