[Orxonox-commit 5972] r10631 - code/trunk/src/orxonox/controllers

landauf at orxonox.net landauf at orxonox.net
Sat Oct 10 18:38:45 CEST 2015


Author: landauf
Date: 2015-10-10 18:38:44 +0200 (Sat, 10 Oct 2015)
New Revision: 10631

Modified:
   code/trunk/src/orxonox/controllers/ArtificialController.cc
   code/trunk/src/orxonox/controllers/FormationController.cc
   code/trunk/src/orxonox/controllers/FormationController.h
   code/trunk/src/orxonox/controllers/NewHumanController.cc
Log:
the AI sometimes selected its own ship as target while it was steering a rocket. after destroying the rocket, the AI would then try to hit itself which led to random crashes (because of a division by zero error which was previously fixed in r10630).
this commit does not fix the root cause, but detects this case and changes the target.

Modified: code/trunk/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/ArtificialController.cc	2015-10-10 16:36:49 UTC (rev 10630)
+++ code/trunk/src/orxonox/controllers/ArtificialController.cc	2015-10-10 16:38:44 UTC (rev 10631)
@@ -81,6 +81,8 @@
     */
     void ArtificialController::changedControllableEntity()
     {
+        FormationController::changedControllableEntity(); // super
+
         if (!this->getControllableEntity())
             this->removeFromFormation();
     }

Modified: code/trunk/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/FormationController.cc	2015-10-10 16:36:49 UTC (rev 10630)
+++ code/trunk/src/orxonox/controllers/FormationController.cc	2015-10-10 16:38:44 UTC (rev 10631)
@@ -1086,4 +1086,12 @@
         }
     }
 
+    void FormationController::changedControllableEntity()
+    {
+        Controller::changedControllableEntity(); // super
+
+        // when changing the controllable entity, ensure that the controller does not use the new entity as target
+        if (this->target_ && this->getControllableEntity() == static_cast<ControllableEntity*>(this->target_))
+            this->forgetTarget();
+    }
 }

Modified: code/trunk/src/orxonox/controllers/FormationController.h
===================================================================
--- code/trunk/src/orxonox/controllers/FormationController.h	2015-10-10 16:36:49 UTC (rev 10630)
+++ code/trunk/src/orxonox/controllers/FormationController.h	2015-10-10 16:38:44 UTC (rev 10631)
@@ -98,6 +98,8 @@
       FormationController* getController( void ) { return this; }
       FormationController* getSlave( void ) { return this->slaves_.back(); }
 
+      virtual void changedControllableEntity();
+
   protected:
       bool formationFlight_;
       bool passive_;

Modified: code/trunk/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/NewHumanController.cc	2015-10-10 16:36:49 UTC (rev 10630)
+++ code/trunk/src/orxonox/controllers/NewHumanController.cc	2015-10-10 16:38:44 UTC (rev 10631)
@@ -495,6 +495,8 @@
 
     void NewHumanController::changedControllableEntity()
     {
+        HumanController::changedControllableEntity(); // super
+
         this->controlMode_ = 0;
         this->centerCursor();
         if (this->getControllableEntity() && ((this->getControllableEntity()->isExactlyA(ClassByString("SpaceShip")) || (this->getControllableEntity()->isExactlyA(ClassByString("ModularSpaceShip")))) || this->getControllableEntity()->isExactlyA(ClassByString("Rocket"))))




More information about the Orxonox-commit mailing list