[Orxonox-commit 3159] r7852 - code/trunk/src/modules/pong

landauf at orxonox.net landauf at orxonox.net
Thu Feb 10 23:46:07 CET 2011


Author: landauf
Date: 2011-02-10 23:46:07 +0100 (Thu, 10 Feb 2011)
New Revision: 7852

Modified:
   code/trunk/src/modules/pong/Pong.h
   code/trunk/src/modules/pong/PongBall.cc
   code/trunk/src/modules/pong/PongBall.h
Log:
fixed crash in Pong gametype if the game was ended right after the ball was set back to center after a score

Modified: code/trunk/src/modules/pong/Pong.h
===================================================================
--- code/trunk/src/modules/pong/Pong.h	2011-02-10 22:34:20 UTC (rev 7851)
+++ code/trunk/src/modules/pong/Pong.h	2011-02-10 22:46:07 UTC (rev 7852)
@@ -58,9 +58,9 @@
         protected:
             void startBall();
 
-            PongCenterpoint* center_;
-            PongBall* ball_;
-            PongBat* bat_[2];
+            WeakPtr<PongCenterpoint> center_;
+            WeakPtr<PongBall> ball_;
+            WeakPtr<PongBat> bat_[2];
             Timer starttimer_;
     };
 }

Modified: code/trunk/src/modules/pong/PongBall.cc
===================================================================
--- code/trunk/src/modules/pong/PongBall.cc	2011-02-10 22:34:20 UTC (rev 7851)
+++ code/trunk/src/modules/pong/PongBall.cc	2011-02-10 22:46:07 UTC (rev 7852)
@@ -164,7 +164,7 @@
         }
     }
 
-    void PongBall::setBats(PongBat** bats)
+    void PongBall::setBats(WeakPtr<PongBat>* bats)
     {
         this->bat_ = bats;
         this->batID_[0] = this->bat_[0]->getObjectID();
@@ -174,7 +174,7 @@
     void PongBall::applyBats()
     {
         if (!this->bat_)
-            this->bat_ = new PongBat*[2];
+            this->bat_ = new WeakPtr<PongBat>[2]; // TODO: delete this somewhere
         if (this->batID_[0] != OBJECTID_UNKNOWN)
             this->bat_[0] = orxonox_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[0]));
         if (this->batID_[1] != OBJECTID_UNKNOWN)

Modified: code/trunk/src/modules/pong/PongBall.h
===================================================================
--- code/trunk/src/modules/pong/PongBall.h	2011-02-10 22:34:20 UTC (rev 7851)
+++ code/trunk/src/modules/pong/PongBall.h	2011-02-10 22:46:07 UTC (rev 7852)
@@ -65,7 +65,7 @@
             float getBatLength() const
                 { return this->batlength_; }
 
-            void setBats(PongBat** bats);
+            void setBats(WeakPtr<PongBat>* bats);
             void applyBats();
 
             static const float MAX_REL_Z_VELOCITY;
@@ -78,7 +78,7 @@
             float speed_;
             float accelerationFactor_;
             float batlength_;
-            PongBat** bat_;
+            WeakPtr<PongBat>* bat_;
             unsigned int* batID_;
             float relMercyOffset_;
     };




More information about the Orxonox-commit mailing list