Index: code/trunk/src/libraries/network/GamestateManager.cc
===================================================================
--- code/trunk/src/libraries/network/GamestateManager.cc	(revision 8858)
+++ code/trunk/src/libraries/network/GamestateManager.cc	(revision 11071)
@@ -60,5 +60,5 @@
 { 
   GamestateManager::GamestateManager() :
-  currentGamestate_(0), id_(0)
+  currentGamestate_(nullptr), id_(0)
   {
 //     trafficControl_ = new TrafficControl();
@@ -70,13 +70,11 @@
   {
     if( this->currentGamestate_ )
-        delete this->currentGamestate_;std::map<unsigned int, packet::Gamestate*>::iterator it;
-    for( it = gamestateQueue.begin(); it != gamestateQueue.end(); ++it )
-      delete it->second;
-    std::map<uint32_t, peerInfo>::iterator peerIt;
-    std::map<uint32_t, packet::Gamestate*>::iterator gamestateIt;
-    for( peerIt = peerMap_.begin(); peerIt != peerMap_.end(); ++peerIt )
-    {
-      for( gamestateIt = peerIt->second.gamestates.begin(); gamestateIt != peerIt->second.gamestates.end(); ++gamestateIt )
-        delete gamestateIt->second;
+        delete this->currentGamestate_;
+    for( const auto& mapEntry : gamestateQueue )
+      delete mapEntry.second;
+    for( const auto& mapEntryPeer : peerMap_ )
+    {
+      for( const auto& mapEntryGamestate : mapEntryPeer.second.gamestates )
+        delete mapEntryGamestate.second;
     }
 //     this->trafficControl_->destroy();
@@ -107,11 +105,10 @@
     if( this->gamestateQueue.empty() )
         return true;
-    std::map<unsigned int, packet::Gamestate*>::iterator it;
     // now push only the most recent gamestates we received (ignore obsolete ones)
-    for(it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++)
-    {
-      OrxVerify(processGamestate(it->second), "ERROR: could not process Gamestate");
-      sendAck( it->second->getID(), it->second->getPeerID() );
-      delete it->second;
+    for(const auto& mapEntry : gamestateQueue)
+    {
+      OrxVerify(processGamestate(mapEntry.second), "ERROR: could not process Gamestate");
+      sendAck( mapEntry.second->getID(), mapEntry.second->getPeerID() );
+      delete mapEntry.second;
     }
     // now clear the queue
@@ -140,5 +137,5 @@
 
   bool GamestateManager::getSnapshot(){
-    if ( currentGamestate_ != 0 )
+    if ( currentGamestate_ != nullptr )
       delete currentGamestate_;
     uint8_t gsMode;
@@ -165,5 +162,5 @@
     { //we have no data to send
       delete currentGamestate_;
-      currentGamestate_=0;
+      currentGamestate_=nullptr;
       return false;
     }
@@ -177,19 +174,18 @@
     std::vector<packet::Gamestate*> peerGamestates;
     
-    std::map<uint32_t, peerInfo>::iterator peerIt;
-    for( peerIt=peerMap_.begin(); peerIt!=peerMap_.end(); ++peerIt )
-    {
-      if( !peerIt->second.isSynched )
+    for( const auto& mapEntry : peerMap_ )
+    {
+      if( !mapEntry.second.isSynched )
       {
         orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl;
         continue;
       }
-      orxout(verbose_more, context::network) << "client id: " << peerIt->first << endl;
+      orxout(verbose_more, context::network) << "client id: " << mapEntry.first << endl;
       orxout(verbose_more, context::network) << "Server: doing gamestate gamestate preparation" << endl;
-      int peerID = peerIt->first; //get client id
-
-      unsigned int lastAckedGamestateID = peerIt->second.lastAckedGamestateID;
-
-      packet::Gamestate* baseGamestate=0;
+      int peerID = mapEntry.first; //get client id
+
+      unsigned int lastAckedGamestateID = mapEntry.second.lastAckedGamestateID;
+
+      packet::Gamestate* baseGamestate=nullptr;
       if(lastAckedGamestateID != GAMESTATEID_INITIAL)
       {
@@ -200,7 +196,7 @@
       }
 
-      peerGamestates.push_back(0);  // insert an empty gamestate* to be changed
+      peerGamestates.push_back(nullptr);  // insert an empty gamestate* to be changed
       finishGamestate( peerID, peerGamestates.back(), baseGamestate, currentGamestate_ );
-      if( peerGamestates.back()==0 )
+      if( peerGamestates.back()==nullptr )
         // nothing to send to remove pointer from vector
         peerGamestates.pop_back();
@@ -243,5 +239,5 @@
       {
         delete diffed1;
-        destgamestate = 0;
+        destgamestate = nullptr;
         return;
       }
@@ -340,8 +336,7 @@
   {
     assert(peerMap_.find(peerID)!=peerMap_.end());
-    std::map<uint32_t, packet::Gamestate*>::iterator peerIt;
-    for( peerIt = peerMap_[peerID].gamestates.begin(); peerIt!=peerMap_[peerID].gamestates.end(); ++peerIt )
-    {
-      delete peerIt->second;
+    for( const auto& mapEntry : peerMap_[peerID].gamestates )
+    {
+      delete mapEntry.second;
     }
     peerMap_.erase(peerMap_.find(peerID));
@@ -351,5 +346,5 @@
 //   void GamestateManager::removeClient(ClientInformation* client){
 //     assert(client);
-//     std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(client->getID());
+//     std::map<unsigned int, std::map<unsigned int, packet::Gamestate*>>::iterator clientMap = gamestateMap_.find(client->getID());
 //     // first delete all remained gamestates
 //     std::map<unsigned int, packet::Gamestate*>::iterator it;
