Index: code/trunk/src/modules/pong/Pong.cc
===================================================================
--- code/trunk/src/modules/pong/Pong.cc	(revision 9939)
+++ code/trunk/src/modules/pong/Pong.cc	(revision 11071)
@@ -64,8 +64,8 @@
         RegisterObject(Pong);
 
-        this->center_ = 0;
-        this->ball_ = 0;
-        this->bat_[0] = 0;
-        this->bat_[1] = 0;
+        this->center_ = nullptr;
+        this->ball_ = nullptr;
+        this->bat_[0] = nullptr;
+        this->bat_[1] = nullptr;
 
         this->setHUDTemplate("PongHUD");
@@ -103,8 +103,8 @@
     void Pong::cleanup()
     {
-        if (this->ball_ != NULL) // Destroy the ball, if present.
+        if (this->ball_ != nullptr) // Destroy the ball, if present.
         {
             this->ball_->destroy();
-            this->ball_ = 0;
+            this->ball_ = nullptr;
         }
 
@@ -112,8 +112,8 @@
         for (size_t i = 0; i < 2; ++i)
         {
-            if (this->bat_[0] != NULL)
+            if (this->bat_[0] != nullptr)
             {
                 this->bat_[0]->destroy();
-                this->bat_[0] = 0;
+                this->bat_[0] = nullptr;
             }
         }
@@ -127,7 +127,7 @@
     void Pong::start()
     {
-        if (this->center_ != NULL) // There needs to be a PongCenterpoint, i.e. the area the game takes place.
-        {
-            if (this->ball_ == NULL) // If there is no ball, create a new ball.
+        if (this->center_ != nullptr) // There needs to be a PongCenterpoint, i.e. the area the game takes place.
+        {
+            if (this->ball_ == nullptr) // If there is no ball, create a new ball.
             {
                 this->ball_ = new PongBall(this->center_->getContext());
@@ -145,10 +145,10 @@
 
             // If one of the bats is missing, create it. Apply the template for the bats as specified in the centerpoint.
-            for (size_t i = 0; i < 2; ++i)
+            for (WeakPtr<orxonox::PongBat>& bat : this->bat_)
             {
-                if (this->bat_[i] == NULL)
+                if (bat == nullptr)
                 {
-                    this->bat_[i] = new PongBat(this->center_->getContext());
-                    this->bat_[i]->addTemplate(this->center_->getBattemplate());
+                    bat = new PongBat(this->center_->getContext());
+                    bat->addTemplate(this->center_->getBattemplate());
                 }
             }
@@ -211,11 +211,11 @@
     {
         // first spawn human players to assign always the left bat to the player in singleplayer
-        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
-            if (it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
-                this->spawnPlayer(it->first);
+        for (const auto& mapEntry : this->players_)
+            if (mapEntry.first->isHumanPlayer() && (mapEntry.first->isReadyToSpawn() || this->bForceSpawn_))
+                this->spawnPlayer(mapEntry.first);
         // now spawn bots
-        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
-            if (!it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
-                this->spawnPlayer(it->first);
+        for (const auto& mapEntry : this->players_)
+            if (!mapEntry.first->isHumanPlayer() && (mapEntry.first->isReadyToSpawn() || this->bForceSpawn_))
+                this->spawnPlayer(mapEntry.first);
     }
 
@@ -231,5 +231,5 @@
 
         // If the first (left) bat has no player.
-        if (this->bat_[0]->getPlayer() == NULL)
+        if (this->bat_[0]->getPlayer() == nullptr)
         {
             player->startControl(this->bat_[0]);
@@ -237,5 +237,5 @@
         }
         // If the second (right) bat has no player.
-        else if (this->bat_[1]->getPlayer() == NULL)
+        else if (this->bat_[1]->getPlayer() == nullptr)
         {
             player->startControl(this->bat_[1]);
@@ -247,5 +247,5 @@
 
         // If the player is an AI, it receives a pointer to the ball.
-        if (player->getController() != NULL && player->getController()->isA(Class(PongAI)))
+        if (player->getController() != nullptr && player->getController()->isA(Class(PongAI)))
         {
             PongAI* ai = orxonox_cast<PongAI*>(player->getController());
@@ -262,5 +262,5 @@
         Deathmatch::playerScored(player, score);
 
-        if (this->center_ != NULL) // If there is a centerpoint.
+        if (this->center_ != nullptr) // If there is a centerpoint.
         {
             // Fire an event for the player that has scored, to be able to react to it in the level, e.g. by displaying fireworks.
@@ -271,10 +271,10 @@
 
             // Also announce, that the player has scored.
-            if (player != NULL)
+            if (player != nullptr)
                 this->gtinfo_->sendAnnounceMessage(player->getName() + " scored");
         }
 
         // If there is a ball present, reset its position, velocity and acceleration.
-        if (this->ball_ != NULL)
+        if (this->ball_ != nullptr)
         {
             this->ball_->setPosition(Vector3::ZERO);
@@ -285,5 +285,5 @@
 
         // If there are bats reset them to the middle position.
-        if (this->bat_[0] != NULL && this->bat_[1] != NULL)
+        if (this->bat_[0] != nullptr && this->bat_[1] != nullptr)
         {
             this->bat_[0]->setPosition(-this->center_->getFieldDimension().x / 2, 0, 0);
@@ -292,5 +292,5 @@
 
         // If a player gets enough points, he won the game -> end of game
-        PlayerInfo* winningPlayer = NULL;
+        PlayerInfo* winningPlayer = nullptr;
         if (this->getLeftPlayer() && this->getScore(this->getLeftPlayer()) >= scoreLimit_)
             winningPlayer = this->getLeftPlayer();
@@ -314,5 +314,5 @@
     void Pong::startBall()
     {
-        if (this->ball_ != NULL && this->center_ != NULL)
+        if (this->ball_ != nullptr && this->center_ != nullptr)
             this->ball_->setSpeed(this->center_->getBallSpeed());
     }
@@ -322,12 +322,12 @@
         Get the left player.
     @return
-        Returns a pointer to the player playing on the left. If there is no left player, NULL is returned.
+        Returns a pointer to the player playing on the left. If there is no left player, nullptr is returned.
     */
     PlayerInfo* Pong::getLeftPlayer() const
     {
-        if (this->bat_ != NULL && this->bat_[0] != NULL)
+        if (this->bat_ != nullptr && this->bat_[0] != nullptr)
             return this->bat_[0]->getPlayer();
         else
-            return 0;
+            return nullptr;
     }
 
@@ -336,12 +336,12 @@
         Get the right player.
     @return
-        Returns a pointer to the player playing on the right. If there is no right player, NULL is returned.
+        Returns a pointer to the player playing on the right. If there is no right player, nullptr is returned.
     */
     PlayerInfo* Pong::getRightPlayer() const
     {
-        if (this->bat_ != NULL && this->bat_[1] != NULL)
+        if (this->bat_ != nullptr && this->bat_[1] != nullptr)
             return this->bat_[1]->getPlayer();
         else
-            return 0;
+            return nullptr;
     }
 }
