[Orxonox-commit 7403] r12020 - in code/branches/PresentationFS18: . data/gui/layouts data/levels data/overlays src/libraries/network src/libraries/network/packet src/libraries/network/synchronisable src/modules/overlays/hud src/orxonox/graphics

patricwi at orxonox.net patricwi at orxonox.net
Wed May 30 14:56:24 CEST 2018


Author: patricwi
Date: 2018-05-30 14:56:24 +0200 (Wed, 30 May 2018)
New Revision: 12020

Added:
   code/branches/PresentationFS18/data/levels/testMultiplayerLevel.oxw
   code/branches/PresentationFS18/data/levels/testMultiplayerLevelLTS.oxw
Modified:
   code/branches/PresentationFS18/
   code/branches/PresentationFS18/data/gui/layouts/MultiplayerMenu.layout
   code/branches/PresentationFS18/data/overlays/lastTeamStandingHUD.oxo
   code/branches/PresentationFS18/src/libraries/network/Client.cc
   code/branches/PresentationFS18/src/libraries/network/Client.h
   code/branches/PresentationFS18/src/libraries/network/ClientConnection.cc
   code/branches/PresentationFS18/src/libraries/network/ClientConnection.h
   code/branches/PresentationFS18/src/libraries/network/ClientConnectionListener.cc
   code/branches/PresentationFS18/src/libraries/network/ClientConnectionListener.h
   code/branches/PresentationFS18/src/libraries/network/Connection.cc
   code/branches/PresentationFS18/src/libraries/network/Connection.h
   code/branches/PresentationFS18/src/libraries/network/FunctionCallManager.cc
   code/branches/PresentationFS18/src/libraries/network/FunctionCallManager.h
   code/branches/PresentationFS18/src/libraries/network/GamestateHandler.cc
   code/branches/PresentationFS18/src/libraries/network/GamestateHandler.h
   code/branches/PresentationFS18/src/libraries/network/GamestateManager.cc
   code/branches/PresentationFS18/src/libraries/network/GamestateManager.h
   code/branches/PresentationFS18/src/libraries/network/Host.cc
   code/branches/PresentationFS18/src/libraries/network/Host.h
   code/branches/PresentationFS18/src/libraries/network/LANDiscoverable.cc
   code/branches/PresentationFS18/src/libraries/network/LANDiscoverable.h
   code/branches/PresentationFS18/src/libraries/network/LANDiscovery.cc
   code/branches/PresentationFS18/src/libraries/network/MasterServer.cc
   code/branches/PresentationFS18/src/libraries/network/MasterServerComm.cc
   code/branches/PresentationFS18/src/libraries/network/Server.cc
   code/branches/PresentationFS18/src/libraries/network/Server.h
   code/branches/PresentationFS18/src/libraries/network/ServerConnection.cc
   code/branches/PresentationFS18/src/libraries/network/ServerConnection.h
   code/branches/PresentationFS18/src/libraries/network/packet/Acknowledgement.cc
   code/branches/PresentationFS18/src/libraries/network/packet/Acknowledgement.h
   code/branches/PresentationFS18/src/libraries/network/packet/Chat.cc
   code/branches/PresentationFS18/src/libraries/network/packet/Chat.h
   code/branches/PresentationFS18/src/libraries/network/packet/ClassID.cc
   code/branches/PresentationFS18/src/libraries/network/packet/DeleteObjects.cc
   code/branches/PresentationFS18/src/libraries/network/packet/FunctionCalls.cc
   code/branches/PresentationFS18/src/libraries/network/packet/Gamestate.cc
   code/branches/PresentationFS18/src/libraries/network/packet/Gamestate.h
   code/branches/PresentationFS18/src/libraries/network/packet/Packet.cc
   code/branches/PresentationFS18/src/libraries/network/packet/Packet.h
   code/branches/PresentationFS18/src/libraries/network/packet/ServerInformation.cc
   code/branches/PresentationFS18/src/libraries/network/synchronisable/Synchronisable.cc
   code/branches/PresentationFS18/src/libraries/network/synchronisable/Synchronisable.h
   code/branches/PresentationFS18/src/modules/overlays/hud/HUDWeaponSystem.cc
   code/branches/PresentationFS18/src/orxonox/graphics/Model.cc
Log:
Merged Masterserver

Index: code/branches/PresentationFS18
===================================================================
--- code/branches/PresentationFS18	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18	2018-05-30 12:56:24 UTC (rev 12020)

Property changes on: code/branches/PresentationFS18
___________________________________________________________________
Modified: svn:mergeinfo
## -11,6 +11,7 ##
 /code/branches/HUD_HS16:11212-11390,11392-11699
 /code/branches/Highscore_HS16:11226-11355
 /code/branches/Hover_FS18:11821-12018
+/code/branches/Masterserver_FS18:11816-12019
 /code/branches/OrxyRoad_FS18:11823-12013
 /code/branches/ParticleEffectsFS15:10309-10612
 /code/branches/Presentation_HS17_merge:11723-11782
Modified: code/branches/PresentationFS18/data/gui/layouts/MultiplayerMenu.layout
===================================================================
--- code/branches/PresentationFS18/data/gui/layouts/MultiplayerMenu.layout	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/data/gui/layouts/MultiplayerMenu.layout	2018-05-30 12:56:24 UTC (rev 12020)
@@ -22,15 +22,21 @@
             <Window Type="MenuWidgets/RadioButton" Name="orxonox/MultiplayerLanButton" >
                 <Property Name="Text" Value="LAN"/>
                 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-                <Property Name="UnifiedAreaRect" Value="{{0.2,0},{0.87,0},{0.4,0},{0.97,0}}" />
+                <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.87,0},{0.25,0},{0.97,0}}" />
                 <Event Name="SelectStateChanged" Function="MultiplayerMenu.LanButton_clicked"/>
             </Window>
             <Window Type="MenuWidgets/RadioButton" Name="orxonox/MultiplayerInternetButton" >
                 <Property Name="Text" Value="Internet" />
                 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-                <Property Name="UnifiedAreaRect" Value="{{0.6,0},{0.87,0},{0.8,0},{0.97,0}}" />
+                <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.87,0},{0.6,0},{0.97,0}}" />
                 <Event Name="SelectStateChanged" Function="MultiplayerMenu.InternetButton_clicked"/>
             </Window>
+            <Window Type="MenuWidgets/Button" Name="orxonox/MultiplayerRefreshButton" >
+                <Property Name="Text" Value="Refresh" />
+                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+                <Property Name="UnifiedAreaRect" Value="{{0.75,0},{0.87,0},{0.95,0},{0.97,0}}" />
+                <Event Name="Clicked" Function="MultiplayerMenu.showServerList" />
+            </Window>
         </Window>
          <Window Type="MenuWidgets/Button" Name="orxonox/MultiplayerBackButton" >
             <Property Name="Text" Value="Back" />

Copied: code/branches/PresentationFS18/data/levels/testMultiplayerLevel.oxw (from rev 12019, code/branches/Masterserver_FS18/data/levels/testMultiplayerLevel.oxw)
===================================================================
--- code/branches/PresentationFS18/data/levels/testMultiplayerLevel.oxw	                        (rev 0)
+++ code/branches/PresentationFS18/data/levels/testMultiplayerLevel.oxw	2018-05-30 12:56:24 UTC (rev 12020)
@@ -0,0 +1,141 @@
+<LevelInfo
+ name = "00 Team Multiplayer Level"
+ description = "Team Deathmatch."
+ tags = "test"
+ screenshot = "teamdeathmatch.png"
+/>
+<?lua
+  include("stats.oxo")
+  include("HUDTemplates3.oxo")
+  include("templates/lodInformation.oxt")
+  include("lastTeamStandingHUD.oxo")
+  include("templates/spaceshipAssff.oxt")
+  include("templates/spaceshipPirate.oxt")
+  include("templates/pickupRepresentationTemplates.oxt")
+?>
+
+<Level
+ name         = "00 Team Multiplayer Level"
+ description  = "testmap for gametype teamdeathmatch"
+ gametype     =  "TeamDeathmatch"
+>
+  <templates>
+    <Template link=lodtemplate_default />
+  </templates>
+  <?lua include("includes/notifications.oxi") ?>
+
+  <Scene
+    ambientlight = "0.8, 0.8, 0.8"
+    skybox       = "Orxonox/skyBoxBasic"
+  >
+
+    <?lua
+      include("includes/pickups.oxi")
+    ?>
+    
+    <WorldAmbientSound source="Nebula_metal.ogg" looping="true" playOnLoad="true" />
+
+<Bot />
+
+<!-- ------------ middle asteroid -------------- -->
+    <StaticEntity position="0,20,0" collisionType=static>
+       <attached>
+           <Model position="0,0,0" scale=140 mesh="asteroid_UV.mesh" shadow=true />
+           <!-- ParticleEmitter position="0,0,0" source="Orxonox/Steam" / -->
+       </attached>
+      <collisionShapes>
+        <SphereCollisionShape radius="145" />
+      </collisionShapes>
+    </StaticEntity>
+
+    <PickupSpawner pickup=hugeinvisiblepickup position="-160,60,17" triggerDistance="20" respawnTime="5" maxSpawnedItems="10" /><!--EasterEgg-->
+    <StaticEntity position="-160,60,28.4"><!--EasterEgg-Indicator-->
+      <attached>
+        <Model position="0,0,0" scale=1 mesh="sphere.mesh" />
+      </attached>
+    </StaticEntity>
+
+<!-- ---------------asteroid dome----------------- -->
+<?lua
+max = 16
+fac = 0.3
+for i = 0, max, 1
+do
+    y = math.sin(i/max*6)*750
+    z = math.cos(i/max*6)*750
+    j = 1
+    ?>
+
+
+    <TeamSpawnPoint team=0 position="<?lua print(y*1.4+z*0.2) ?>,0,<?lua print(z*1.4-y*0.2) ?>" direction="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+    <TeamSpawnPoint team=1 position="<?lua print(y*1.4*fac+z*0.2*fac) ?>,0,<?lua print(z*1.4*fac-y*0.2*fac) ?>" direction="0,0,0" spawnclass=SpaceShip pawndesign=spaceshippirate />
+
+
+    <StaticEntity position="<?lua print(y) ?>,0,<?lua print(z) ?>" scale="<?lua print(j * 2) ?>" collisionType=static >
+      <attached>
+        <Model position="0,0,0" scale=15 mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh">
+        </Model>
+      </attached>
+      <collisionShapes>
+        <BoxCollisionShape    halfExtents="<?lua print(j * 2) ?>,100,<?lua print(j * 2) ?>" position = "0,0,0" />
+      </collisionShapes>
+    </StaticEntity>
+
+    <StaticEntity position="<?lua print(y) ?>,100,<?lua print(z) ?>" scale="<?lua print(j * 2) ?>" collisionType=static >
+      <attached>
+        <Model position="0,0,0" scale=15 mesh="ast<?lua print( math.mod(i+3,6) + 1) ?>.mesh">
+        </Model>
+      </attached>
+      <collisionShapes>
+        <BoxCollisionShape    halfExtents="45,100,45" position = "0,0,0" />
+      </collisionShapes>
+    </StaticEntity>
+
+    <StaticEntity position="<?lua print(y) ?>,200,<?lua print(z) ?>" scale="<?lua print(j * 2) ?>" collisionType=static >
+      <attached>
+        <Model position="0,0,0" scale=15 mesh="ast<?lua print( math.mod(i*5,6) + 1) ?>.mesh">
+        </Model>
+      </attached>
+      <collisionShapes>
+        <BoxCollisionShape    halfExtents="45,100,45" position = "0,0,0" />
+      </collisionShapes>
+    </StaticEntity>
+
+    <StaticEntity position="<?lua print(y) ?>,-100,<?lua print(z) ?>" scale="<?lua print(j * 2) ?>" collisionType=static >
+      <attached>
+        <Model position="0,0,0" scale=15 mesh="ast<?lua print( math.mod(i*13+1,6) + 1) ?>.mesh">
+        </Model>
+      </attached>
+      <collisionShapes>
+        <BoxCollisionShape    halfExtents="45,100,45" position = "0,0,0" />
+      </collisionShapes>
+    </StaticEntity>
+
+    <StaticEntity position="<?lua print(y) ?>,-200,<?lua print(z) ?>" scale="<?lua print(j * 2) ?>" collisionType=static >
+      <attached>
+        <Model position="0,0,0" scale=15 mesh="ast<?lua print( math.mod(i*17,6) + 1) ?>.mesh">
+        </Model>
+      </attached>
+      <collisionShapes>
+        <BoxCollisionShape    halfExtents="45,100,45" position = "0,0,0" />
+      </collisionShapes>
+    </StaticEntity>
+
+<!-- ---------Top Asteroid----------- -->
+    <StaticEntity position="<?lua print(y) ?>,300,<?lua print(z) ?>" scale="<?lua print(j * 2.1) ?>" pitch="90" roll="180" yaw="<?lua print(-90+i*360/max) ?>" collisionType=static >
+      <attached>
+        <Model position="0,0,0" scale=25 mesh="ast6.mesh">
+        </Model>
+      </attached>
+      <collisionShapes>
+        <BoxCollisionShape    halfExtents="50,140,30" position="0,0,0"/>
+      </collisionShapes>
+    </StaticEntity>
+
+
+<?lua end ?>
+
+  </Scene>
+</Level>
+
+

Copied: code/branches/PresentationFS18/data/levels/testMultiplayerLevelLTS.oxw (from rev 12019, code/branches/Masterserver_FS18/data/levels/testMultiplayerLevelLTS.oxw)
===================================================================
--- code/branches/PresentationFS18/data/levels/testMultiplayerLevelLTS.oxw	                        (rev 0)
+++ code/branches/PresentationFS18/data/levels/testMultiplayerLevelLTS.oxw	2018-05-30 12:56:24 UTC (rev 12020)
@@ -0,0 +1,63 @@
+<LevelInfo
+ name = "00 Test Multiplayer Level LTS"
+ description = "Survive as a team."
+ tags = "test"
+ screenshot = "lastteamstanding.png"
+/>
+<?lua
+  include("stats.oxo")
+  include("HUDTemplates3.oxo")
+  include("templates/lodInformation.oxt")
+  include("lastTeamStandingHUD.oxo")
+  include("templates/spaceshipAssff.oxt")
+  include("templates/spaceshipPirate.oxt")
+  include("templates/pickupRepresentationTemplates.oxt")
+?>
+
+<Level
+ name         = "00 Team Multiplayer Level LTS"
+ description  = "testmap for gametype last team standing"
+ gametype     =  "LastTeamStanding"
+>
+  <templates>
+    <Template link=lodtemplate_default />
+  </templates>
+  <?lua include("includes/notifications.oxi") ?>
+
+  <Scene
+    ambientlight = "0.8, 0.8, 0.8"
+    skybox       = "Orxonox/skyBoxBasic"
+  >
+
+    <?lua
+      include("includes/pickups.oxi")
+    ?>
+    
+    <WorldAmbientSound source="Nebula_metal.ogg" looping="true" playOnLoad="true" />
+
+<Bot />
+
+<!-- ------------ middle asteroid -------------- -->
+
+
+<!-- ---------------asteroid dome----------------- -->
+<?lua
+max = 16
+for i = 0, max, 1
+do
+    y = math.sin(i/max*6)*750
+    z = math.cos(i/max*6)*750
+    j = 1
+    ?>
+
+    <TeamSpawnPoint team="<?lua print( math.mod(i,4)) ?>" position="<?lua print(y*1.4+z*0.2) ?>,0,<?lua print(z*1.4-y*0.2) ?>" direction="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+
+
+
+
+<?lua end ?>
+
+  </Scene>
+</Level>
+
+

Modified: code/branches/PresentationFS18/data/overlays/lastTeamStandingHUD.oxo
===================================================================
--- code/branches/PresentationFS18/data/overlays/lastTeamStandingHUD.oxo	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/data/overlays/lastTeamStandingHUD.oxo	2018-05-30 12:56:24 UTC (rev 12020)
@@ -1,7 +1,7 @@
 <Template name="lastTeamStandingHUD">
   <OverlayGroup name="lastTeamStandingHUD" scale = "1, 1">
     <LastTeamStandingInfos
-     position  = "0.14, 0.02"
+     position  = "0.5, 0.02"
      pickpoint = "0.0, 0.0"
      font      = "ShareTechMono"
      textsize  = 0.04
@@ -13,7 +13,7 @@
     />
 
     <OverlayText
-     position  = "0.02, 0.02"
+     position  = "0.38, 0.02"
      pickpoint = "0.0, 0.0"
      font      = "ShareTechMono"
      textsize  = 0.04
@@ -23,7 +23,7 @@
     />
 
     <OverlayText
-     position  = "0.02, 0.055"
+     position  = "0.38, 0.055"
      pickpoint = "0.0, 0.0"
      font      = "ShareTechMono"
      textsize  = 0.04
@@ -33,7 +33,7 @@
     />
 
     <LastTeamStandingInfos
-     position  = "0.14, 0.055"
+     position  = "0.5, 0.055"
      pickpoint = "0.0, 0.0"
      font      = "ShareTechMono"
      textsize  = 0.04

Modified: code/branches/PresentationFS18/src/libraries/network/Client.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/Client.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/Client.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -165,17 +165,10 @@
             gamestate->send( static_cast<Host*>(this) );
           }
         }
-        //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now
-//         if(gs){
-//           orxout(verbose, context::network) << "client tick: sending gs " << gs << endl;
-//           if( !gs->send() )
-//             orxout(internal_warning, context::network) << "Problem adding partial gamestate to queue" << endl;
-//         // gs gets automatically deleted by enet callback
-//         }
+
         FunctionCallManager::sendCalls(static_cast<Host*>(this));
       }
     }
-//     sendPackets(); // flush the enet queue
 
     Connection::processQueue();
     if(GamestateManager::processGamestates())
@@ -184,9 +177,8 @@
       if(!isSynched_)
         isSynched_=true;
     }
-//     GamestateManager::cleanup();;
-//     Connection::sendPackets();
 
+
     return;
   }
 

Modified: code/branches/PresentationFS18/src/libraries/network/Client.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/Client.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/Client.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -89,7 +89,7 @@
     virtual void connectionClosed() override;
   private:
     Client(const Client& copy); // not used
-    virtual bool isServer_() override{return false;}
+    virtual bool isServer_() override { return false; }
     virtual void processPacket(packet::Packet* packet) override;
 
     static Client* singletonPtr_s;

Modified: code/branches/PresentationFS18/src/libraries/network/ClientConnection.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/ClientConnection.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/ClientConnection.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -104,8 +104,8 @@
       if( enet_host_service(this->host_, &event, NETWORK_CLIENT_WAIT_TIME)>=0 && event.type == ENET_EVENT_TYPE_CONNECT )
       {
         // manually add server to list of peers
-        /*incomingEvent inEvent = */Connection::preprocessConnectEvent(event);
-//         addPeer(inEvent.peerID);
+        Connection::preprocessConnectEvent(event);
+
         // start communication thread
         this->established_=true;
         Connection::startCommunicationThread();
@@ -154,7 +154,6 @@
   void ClientConnection::addPacket(ENetPacket *packet, uint8_t channelID) {
     assert( this->server_ );
     assert( packet );
-//     return Connection::addPacket( packet, NETWORK_PEER_ID_SERVER, channelID );
     // HACK: actually there should be a way to do this using addPacket and the correct peerID
     return Connection::broadcastPacket(packet, channelID);
   }
@@ -167,7 +166,7 @@
   {
     this->established_=false;
     orxout(internal_error, context::network) << "Received disconnect Packet from Server!" << endl;
-        // server closed the connection
+    // server closed the connection
     this->stopCommunicationThread();
     this->connectionClosed();
   }

Modified: code/branches/PresentationFS18/src/libraries/network/ClientConnection.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/ClientConnection.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/ClientConnection.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -35,7 +35,7 @@
 namespace orxonox
 {
 
-  class _NetworkExport ClientConnection: public Connection{
+  class _NetworkExport ClientConnection: public Connection {
   public:
     ClientConnection();
     virtual ~ClientConnection();
@@ -43,9 +43,6 @@
     void setServerAddress( const std::string& serverAddress );
     void setPort( unsigned int port );
 
-//     ENetEvent *getEvent();
-    // check wheter the packet queue is empty
-//     bool queueEmpty();
     // create a new listener thread
     virtual bool establishConnection();
     virtual bool closeConnection();

Modified: code/branches/PresentationFS18/src/libraries/network/ClientConnectionListener.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/ClientConnectionListener.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/ClientConnectionListener.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -30,17 +30,24 @@
 
 #include "core/CoreIncludes.h"
 #include "core/GameMode.h"
-// #include "ClientInformation.h"
 
 namespace orxonox
 {
     RegisterAbstractClass(ClientConnectionListener).inheritsFrom<Listable>();
 
+    /**
+     * Constructor
+     * Register the object
+     */
     ClientConnectionListener::ClientConnectionListener()
     {
         RegisterObject(ClientConnectionListener);
     }
 
+    /**
+     * Call clientConnected() on all ClientConnectionListeners.
+     * @param clientID The ID of the newly connected client
+     */
     void ClientConnectionListener::broadcastClientConnected(unsigned int clientID)
     {
         for (ClientConnectionListener* listener : ObjectList<ClientConnectionListener>())
@@ -47,21 +54,15 @@
             listener->clientConnected(clientID);
     }
 
+    /**
+     * Call clientDisconnected() on all ClientConnectionListeners.
+     * @param clientID The ID of the newly disconnected client
+     */
     void ClientConnectionListener::broadcastClientDisconnected(unsigned int clientID)
     {
         for (ClientConnectionListener* listener : ObjectList<ClientConnectionListener>())
             listener->clientDisconnected(clientID);
     }
-
-//     void ClientConnectionListener::getConnectedClients()
-//     {
-//         ClientInformation* client = ClientInformation::getBegin();
-//         while (client)
-//         {
-//             this->clientConnected(client->getID());
-//             client = client->next();
-//         }
-//     }
 }
 
 

Modified: code/branches/PresentationFS18/src/libraries/network/ClientConnectionListener.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/ClientConnectionListener.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/ClientConnectionListener.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -34,6 +34,9 @@
 
 namespace orxonox
 {
+    /**
+     * An abstract base class. Derived classes must implement clientConnected() and clientDisconnected().
+     */
     class _NetworkExport ClientConnectionListener : virtual public Listable
     {
         public:
@@ -45,9 +48,6 @@
 
             virtual void clientConnected(unsigned int clientID) = 0;
             virtual void clientDisconnected(unsigned int clientID) = 0;
-
-        protected:
-//             void getConnectedClients();
     };
 }
 

Modified: code/branches/PresentationFS18/src/libraries/network/Connection.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/Connection.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/Connection.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -37,6 +37,7 @@
 #include <boost/date_time.hpp>
 
 #include "packet/Packet.h"
+#include "util/Output.h"
 #include <util/Sleep.h>
 
 namespace orxonox
@@ -44,22 +45,37 @@
   const boost::posix_time::millisec NETWORK_COMMUNICATION_THREAD_WAIT_TIME(200);
   const unsigned int                NETWORK_DISCONNECT_TIMEOUT = 500;
 
+  /**
+   * Constructor
+   * @param firstPeerId The initial value of nextPeerID_
+   */
   Connection::Connection(uint32_t firstPeerID):
     host_(nullptr), bCommunicationThreadRunning_(false), nextPeerID_(firstPeerID)
   {
+    // Global initialization of ENet
     enet_initialize();
+
+    // Register enet_deinitialize to be executed when the program exits normally
     atexit(enet_deinitialize);
+
+    // Create mutexes for incoming and outgoing events
     this->incomingEventsMutex_ = new boost::mutex;
     this->outgoingEventsMutex_ = new boost::mutex;
-//     this->overallMutex_ = new boost::mutex;
   }
 
+  /**
+   * Destructor
+   */
   Connection::~Connection()
   {
+    // Delete the mutexes
     delete this->incomingEventsMutex_;
     delete this->outgoingEventsMutex_;
   }
 
+  /**
+   * Start the main communication thread.
+   */
   void Connection::startCommunicationThread()
   {
     this->bCommunicationThreadRunning_ = true;
@@ -66,28 +82,37 @@
     this->communicationThread_ = new boost::thread(&Connection::communicationThread, this);
   }
   
+  /**
+   * Stop the main communication thread.
+   */
   void Connection::stopCommunicationThread()
   {
     this->bCommunicationThreadRunning_ = false;
-    if( !this->communicationThread_->timed_join(NETWORK_COMMUNICATION_THREAD_WAIT_TIME) )
+    // Wait for peaceful termination
+    if(!this->communicationThread_->timed_join(NETWORK_COMMUNICATION_THREAD_WAIT_TIME))
     {
-      // force thread to stop
+      // Force thread to stop if the waiting time runs out.
       this->communicationThread_->interrupt();
     }
     delete this->communicationThread_;
   }
 
+  /**
+   * Send an outgoing event of type 'disconnectPeer'.
+   * @param peerID The peer to which the event is sent
+   */
   void Connection::disconnectPeer(uint32_t peerID)
   {
-//     this->overallMutex_->lock();
     outgoingEvent outEvent = { peerID, OutgoingEventType::disconnectPeer, nullptr, 0 };
     
     this->outgoingEventsMutex_->lock();
     this->outgoingEvents_.push_back(outEvent);
     this->outgoingEventsMutex_->unlock();
-//     this->overallMutex_->unlock();
   }
-  
+
+  /**
+   * Send an outgoing event of type 'disconnectPeers'.
+   */
   void Connection::disconnectPeers()
   {
     outgoingEvent outEvent = { 0, OutgoingEventType::disconnectPeers, nullptr, 0 };
@@ -97,59 +122,67 @@
     this->outgoingEventsMutex_->unlock();
   }
 
+  /**
+   * Send a packet.
+   * @param packet Pointer to the packet to send
+   * @param peerID The peer to which the event is sent
+   * @param channelId The channel ID
+   */
   void Connection::addPacket(ENetPacket* packet, uint32_t peerID, uint8_t channelID)
   {
-//     this->overallMutex_->lock();
     outgoingEvent outEvent = { peerID, OutgoingEventType::sendPacket, packet, channelID };
     
     this->outgoingEventsMutex_->lock();
     this->outgoingEvents_.push_back(outEvent);
     this->outgoingEventsMutex_->unlock();
-//     this->overallMutex_->unlock();
   }
   
+  /**
+   * Send a broadcast packet.
+   * @param packet Pointer to the packet to send
+   * @param channelId The channel ID
+   */
   void Connection::broadcastPacket(ENetPacket* packet, uint8_t channelID)
   {
-//     this->overallMutex_->lock();
     outgoingEvent outEvent = { 0, OutgoingEventType::broadcastPacket, packet, channelID };
     
     this->outgoingEventsMutex_->lock();
     this->outgoingEvents_.push_back(outEvent);
     this->outgoingEventsMutex_->unlock();
-//     this->overallMutex_->unlock();
   }
 
   
+  /**
+   * Main communication thread
+   */
   void Connection::communicationThread()
   {
     ENetEvent event;
     
-//     this->overallMutex_->lock();
-    while( bCommunicationThreadRunning_ )
+    while(this->bCommunicationThreadRunning_)
     {
       // Receive all pending incoming Events (such as packets, connects and disconnects)
-      while( enet_host_check_events( this->host_, &event ) > 0 )
+      while(enet_host_check_events(this->host_, &event ) > 0)
       {
-        processIncomingEvent(event);
+        this->processIncomingEvent(event);
       }
       
-//       this->overallMutex_->unlock();
+      // Sleep for 1ms
       msleep(1);
-//       this->overallMutex_->lock();
       
       // Send all waiting outgoing packets
       this->outgoingEventsMutex_->lock();
       uint32_t outgoingEventsCount = this->outgoingEvents_.size();
       this->outgoingEventsMutex_->unlock();
-      while( outgoingEventsCount > 0 )
+
+      while(outgoingEventsCount > 0)
       {
-//         orxout(verbose, context::network) << "outgoing event" << endl;
         this->outgoingEventsMutex_->lock();
         outgoingEvent outEvent = this->outgoingEvents_.front();
         this->outgoingEvents_.pop_front();
         this->outgoingEventsMutex_->unlock();
         
-        processOutgoingEvent(outEvent);
+        this->processOutgoingEvent(outEvent);
         
         this->outgoingEventsMutex_->lock();
         outgoingEventsCount = this->outgoingEvents_.size();
@@ -157,19 +190,22 @@
       }
       
       // Wait for incoming events (at most NETWORK_WAIT_TIMEOUT ms)
-      if( enet_host_service( this->host_, &event, NETWORK_WAIT_TIMEOUT ) > 0 )
+      if(enet_host_service(this->host_, &event, NETWORK_WAIT_TIMEOUT) > 0)
       {
-        processIncomingEvent(event);
+        this->processIncomingEvent(event);
       }
     }
-//     this->overallMutex_->unlock();
   }
   
+  /**
+   * Handle an incoming event.
+   * @param event The incoming event
+   */
   void Connection::processIncomingEvent(ENetEvent& event)
   {
     incomingEvent inEvent;
     // preprocess event
-    switch( event.type )
+    switch(event.type)
     {
       case ENET_EVENT_TYPE_CONNECT:
         inEvent = preprocessConnectEvent(event);
@@ -191,27 +227,31 @@
     this->incomingEventsMutex_->unlock();
   }
   
+  /**
+   * Send an event.
+   * @param event The event to send
+   */
   void Connection::processOutgoingEvent(outgoingEvent& event)
   {
     ENetPeer* peer;
-    switch( event.type )
+    switch(event.type)
     {
       case OutgoingEventType::sendPacket:
         // check whether the peer is still/already in the peer list
-        if( this->peerMap_.find(event.peerID) != this->peerMap_.end() )
+        if(this->peerMap_.find(event.peerID) != this->peerMap_.end())
         {
           peer = this->peerMap_[event.peerID];
-          enet_peer_send( peer, event.channelID, event.packet );
+          enet_peer_send(peer, event.channelID, event.packet);
         }
         else
         {
           // peer probably already disconnected so just discard packet
-          assert(event.peerID<this->nextPeerID_);
+          orxout(message) << "Trying to send packet to peer that is not in peer list. Ignoring packet." << endl;
           enet_packet_destroy(event.packet);
         }
         break;
       case OutgoingEventType::disconnectPeer:
-        if( this->peerMap_.find(event.peerID) != this->peerMap_.end() )
+        if(this->peerMap_.find(event.peerID) != this->peerMap_.end())
         {
           peer = this->peerMap_[event.peerID];
           enet_peer_disconnect(peer, 0);
@@ -219,11 +259,11 @@
         else
         {
           // peer probably already disconnected so just discard disconnect event
-          assert(event.peerID<this->nextPeerID_);
+          assert(event.peerID < this->nextPeerID_);
         }
         break;
       case OutgoingEventType::disconnectPeers:
-        disconnectPeersInternal();
+        this->disconnectPeersInternal();
         break;
       case OutgoingEventType::broadcastPacket:
         enet_host_broadcast( this->host_, event.channelID, event.packet );
@@ -233,7 +273,6 @@
     }
   }
 
-
   void Connection::disconnectPeersInternal()
   {
     for( const auto& mapEntry : this->peerMap_ )
@@ -240,7 +279,7 @@
     {
       enet_peer_disconnect(mapEntry.second, 0);
     }
-    uint32_t iterations = NETWORK_DISCONNECT_TIMEOUT/NETWORK_WAIT_TIMEOUT;
+    uint32_t iterations = NETWORK_DISCONNECT_TIMEOUT / NETWORK_WAIT_TIMEOUT;
     uint32_t i = 0;
     while( this->peerMap_.size() && i++ < iterations )
     {
@@ -360,5 +399,4 @@
     enet_host_compress_with_range_coder( this->host_ );
   }
 
-
 }

Modified: code/branches/PresentationFS18/src/libraries/network/Connection.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/Connection.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/Connection.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -95,7 +95,7 @@
     virtual ~Connection();
 
   protected:
-    Connection(uint32_t firstPeerID = NETWORK_PEER_ID_SERVER+1);
+    Connection(uint32_t firstPeerID = NETWORK_PEER_ID_SERVER + 1);
     
     void startCommunicationThread();
     void stopCommunicationThread();
@@ -109,9 +109,9 @@
 
     void processQueue();
     void waitOutgoingQueue();     // wait for the outgoing queue to become empty (everything processed by communication thread)
-    virtual void addPeer(uint32_t peerID)=0;
-    virtual void removePeer(uint32_t peerID)=0;
-    virtual void processPacket( packet::Packet* packet)=0;
+    virtual void addPeer(uint32_t peerID) = 0;
+    virtual void removePeer(uint32_t peerID) = 0;
+    virtual void processPacket( packet::Packet* packet) = 0;
     
     incomingEvent preprocessConnectEvent(ENetEvent& event);
     incomingEvent preprocessDisconnectEvent(ENetEvent& event);
@@ -123,6 +123,7 @@
     void disconnectPeersInternal();
 
     ENetHost*                     host_;
+
   private:
     void communicationThread();
     
@@ -129,8 +130,13 @@
     boost::thread*                communicationThread_;
     bool                          bCommunicationThreadRunning_;
     ENetAddress*                  bindAddress_;
+
+    // Queue for incoming events
     std::deque<incomingEvent>     incomingEvents_;
+
+    // Queue for outgoing events
     std::deque<outgoingEvent>     outgoingEvents_;
+
     boost::mutex*                 incomingEventsMutex_;
     boost::mutex*                 outgoingEventsMutex_;
     boost::mutex*                 overallMutex_;

Modified: code/branches/PresentationFS18/src/libraries/network/FunctionCallManager.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/FunctionCallManager.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/FunctionCallManager.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -41,16 +41,22 @@
 
 void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
 {
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
+  // If the peerID doesn't exist yet in the map...
+  if(sPeerMap_.find(peerID) == sPeerMap_.end())
   {
+    // ... add a new FunctionCalls packet for the peer
     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
   }
+
+  // Add a new function call to the peer
   FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, mt1, mt2, mt3, mt4, mt5);
 }
 
-// Send calls
-
+/**
+ * Send all function calls in sPeerMap_ to a given host, then clear sPeerMap_
+ * @param host The host to send the function calls to
+ */
 void FunctionCallManager::sendCalls(orxonox::Host* host)
 {
   for (const auto& mapEntry : FunctionCallManager::sPeerMap_ )
@@ -61,15 +67,21 @@
   FunctionCallManager::sPeerMap_.clear();
 }
 
+/**
+ * Place an incoming function call in the queue for processing.
+ */
 void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall, uint32_t minGamestateID, uint32_t peerID)
 {
   FunctionCallManager::sIncomingFunctionCallBuffer_.emplace_back(fctCall, std::make_pair(minGamestateID, peerID));
 }
 
+/**
+ * Process queue of incoming function calls.
+ */
 void FunctionCallManager::processBufferedFunctionCalls()
 {
   std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t>>>::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin();
-  while( it!=FunctionCallManager::sIncomingFunctionCallBuffer_.end() )
+  while( it != FunctionCallManager::sIncomingFunctionCallBuffer_.end() )
   {
     OrxAssert( Host::getActiveInstance(), "No Host class existing" );
     if( it->second.first <= Host::getActiveInstance()->getLastReceivedGamestateID(it->second.second) && it->first.execute() )

Modified: code/branches/PresentationFS18/src/libraries/network/FunctionCallManager.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/FunctionCallManager.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/FunctionCallManager.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -52,8 +52,11 @@
   static void bufferIncomingFunctionCall( const FunctionCall& fctCall, uint32_t minGamestateID, uint32_t peerID );
   static void processBufferedFunctionCalls();
 
+  // Maps peer IDs to function calls
   static std::map<uint32_t, packet::FunctionCalls*>                           sPeerMap_;
+
   static std::vector<std::pair<FunctionCall,std::pair<uint32_t, uint32_t>>> sIncomingFunctionCallBuffer_;
+
 protected:
   FunctionCallManager();
   ~FunctionCallManager();

Modified: code/branches/PresentationFS18/src/libraries/network/GamestateHandler.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/GamestateHandler.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/GamestateHandler.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -31,8 +31,6 @@
 
 namespace orxonox {
 
-// GamestateHandler *GamestateHandler::instance_=nullptr;
-
 GamestateHandler::GamestateHandler()
 {
 }

Modified: code/branches/PresentationFS18/src/libraries/network/GamestateHandler.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/GamestateHandler.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/GamestateHandler.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -36,7 +36,8 @@
 namespace orxonox {
 
 /**
-    @author Oliver Scheuss
+ * An interface for any class that wants to handle gamestates.
+ * @author Oliver Scheuss
 */
 class _NetworkExport GamestateHandler
 {
@@ -50,8 +51,8 @@
   public:
     virtual bool      addGamestate(packet::Gamestate* gs, unsigned int clientID) = 0;
     virtual bool      ackGamestate(unsigned int gamestateID, unsigned int clientID) = 0;
-    virtual uint32_t  getLastReceivedGamestateID( unsigned int clientID )=0;
-    virtual uint32_t  getCurrentGamestateID()=0;
+    virtual uint32_t  getLastReceivedGamestateID( unsigned int clientID ) = 0;
+    virtual uint32_t  getCurrentGamestateID() = 0;
 };
 
 }

Modified: code/branches/PresentationFS18/src/libraries/network/GamestateManager.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/GamestateManager.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/GamestateManager.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -42,7 +42,6 @@
 
 #include <cassert>
 #include <queue>
-// #include <boost/thread/mutex.hpp>
 
 #include "packet/Acknowledgement.h"
 #include "packet/Gamestate.h"
@@ -54,7 +53,6 @@
 #include "util/Output.h"
 #include "util/Clock.h"
 #include "util/OrxAssert.h"
-// #include "TrafficControl.h"
 
 namespace orxonox
 { 
@@ -61,68 +59,88 @@
   GamestateManager::GamestateManager() :
   currentGamestate_(nullptr), id_(0)
   {
-//     trafficControl_ = new TrafficControl();
-//     threadMutex_ = new boost::mutex();
-//     threadPool_ = new ThreadPool();
   }
 
   GamestateManager::~GamestateManager()
   {
-    if( this->currentGamestate_ )
-        delete this->currentGamestate_;
-    for( const auto& mapEntry : gamestateQueue )
-      delete mapEntry.second;
-    for( const auto& mapEntryPeer : peerMap_ )
+    if(this->currentGamestate_)
     {
-      for( const auto& mapEntryGamestate : mapEntryPeer.second.gamestates )
-        delete mapEntryGamestate.second;
+      delete this->currentGamestate_;
+      this->currentGamestate_ = nullptr;
     }
-//     this->trafficControl_->destroy();
-//     delete this->threadMutex_;
-//     delete this->threadPool_;
+
+    for(const auto& gsPair : this->gamestateQueue)
+    {
+      delete gsPair.second;
+    }
+
+    for(const auto& peerPair : this->peerMap_)
+    {
+      for(const auto& gsPair : peerPair.second.gamestates)
+      {
+        delete gsPair.second;
+      }
+    }
   }
 
-  bool GamestateManager::update(){
-//     cleanup();
-    return getSnapshot();
+  bool GamestateManager::update()
+  {
+    return this->getSnapshot();
   }
 
   bool GamestateManager::addGamestate(packet::Gamestate *gs, unsigned int clientID)
   {
     assert(gs);
-    std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateQueue.find(clientID);
-    if(it!=gamestateQueue.end())
+    // Search the queue for a gamestate for the client
+    std::map<unsigned int, packet::Gamestate*>::iterator it = this->gamestateQueue.find(clientID);
+    if(it != this->gamestateQueue.end())
     {
       // delete obsolete gamestate
       delete it->second;
     }
-    gamestateQueue[clientID] = gs;
+    // update the client's gamestate
+    this->gamestateQueue[clientID] = gs;
+
     return true;
   }
 
+  /**
+   * Process the queued gamestates.
+   */
   bool GamestateManager::processGamestates()
   {
-    if( this->gamestateQueue.empty() )
+    // Queue is empty, nothing to do
+    if(this->gamestateQueue.empty())
+    {
         return true;
+    }
+
     // now push only the most recent gamestates we received (ignore obsolete ones)
-    for(const auto& mapEntry : gamestateQueue)
+    for(const auto& gsPair : this->gamestateQueue)
     {
-      OrxVerify(processGamestate(mapEntry.second), "ERROR: could not process Gamestate");
-      sendAck( mapEntry.second->getID(), mapEntry.second->getPeerID() );
-      delete mapEntry.second;
+      OrxVerify(this->processGamestate(gsPair.second), "ERROR: could not process Gamestate");
+      this->sendAck(gsPair.second->getID(), gsPair.second->getPeerID());
+      delete gsPair.second;
     }
     // now clear the queue
-    gamestateQueue.clear();
+    this->gamestateQueue.clear();
+
     //and call all queued callbacks
     NetworkCallbackManager::callCallbacks();
+
     return true;
   }
   
+  /**
+   * Send Acknowledgement packet.
+   * @param gamestateId The gamestate ID we want to acknowledge
+   * @param peerID The ID of the peer we want to send the Acknowledgement to
+   */
   bool GamestateManager::sendAck(unsigned int gamestateID, uint32_t peerID)
   {
-    assert( gamestateID != ACKID_NACK );
+    assert(gamestateID != ACKID_NACK);
     packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, peerID);
-    if( !this->sendPacket(ack))
+    if(!this->sendPacket(ack))
     {
       orxout(internal_warning, context::network) << "could not ack gamestate: " << gamestateID << endl;
       return false;
@@ -134,48 +152,70 @@
     }
   }
 
+  /**
+   * Update the current gamestate.
+   */
+  bool GamestateManager::getSnapshot()
+  {
+    // Delete current gamestate
+    if (this->currentGamestate_)
+    {
+      delete this->currentGamestate_;
+      this->currentGamestate_ = nullptr;
+    }
 
-  bool GamestateManager::getSnapshot(){
-    if ( currentGamestate_ != nullptr )
-      delete currentGamestate_;
     uint8_t gsMode;
-    if( GameMode::isMaster() )
+    if(GameMode::isMaster())
+    {
       gsMode = packet::GAMESTATE_MODE_SERVER;
+    }
     else
+    {
       gsMode = packet::GAMESTATE_MODE_CLIENT;
+    }
+
     uint32_t newID;
-    if( GameMode::isMaster() )
-      newID = ++id_;
+    if(GameMode::isMaster())
+    {
+      newID = ++this->id_;
+    }
     else
     {
-      assert(peerMap_.size()!=0);
-      newID = peerMap_[NETWORK_PEER_ID_SERVER].lastReceivedGamestateID;
-      if( newID == GAMESTATEID_INITIAL )
+      assert(this->peerMap_.size() != 0);
+      newID = this->peerMap_[NETWORK_PEER_ID_SERVER].lastReceivedGamestateID;
+      if(newID == GAMESTATEID_INITIAL)
       {
         return false;
       }
     }
     
-    currentGamestate_ = new packet::Gamestate();
-    
-    if(!currentGamestate_->collectData(newID, gsMode))
-    { //we have no data to send
-      delete currentGamestate_;
-      currentGamestate_=nullptr;
+    // Create a new gamestate
+    this->currentGamestate_ = new packet::Gamestate();
+    if(!this->currentGamestate_->collectData(newID, gsMode))
+    {
+      // we have no data to send
+      delete this->currentGamestate_;
+      this->currentGamestate_ = nullptr;
       return false;
     }
+
     return true;
   }
 
+  /**
+   * Return a vector with the gamestates of all peers.
+   */
   std::vector<packet::Gamestate*> GamestateManager::getGamestates()
   {
-    if(!currentGamestate_)
+    // Current gamestate is empty
+    if(!this->currentGamestate_){
       return std::vector<packet::Gamestate*>();
+    }
+
     std::vector<packet::Gamestate*> peerGamestates;
-    
-    for( const auto& mapEntry : peerMap_ )
+    for(const auto& mapEntry : this->peerMap_)
     {
-      if( !mapEntry.second.isSynched )
+      if(!mapEntry.second.isSynched)
       {
         orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl;
         continue;
@@ -197,38 +237,27 @@
 
       peerGamestates.push_back(nullptr);  // insert an empty gamestate* to be changed
       finishGamestate( peerID, peerGamestates.back(), baseGamestate, currentGamestate_ );
-      if( peerGamestates.back()==nullptr )
+      if(peerGamestates.back() == nullptr)
+      {
         // nothing to send to remove pointer from vector
         peerGamestates.pop_back();
-      //FunctorMember<GamestateManager>* functor =
-//       ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate, this) );
-//       executor->setDefaultValues( cid, &clientGamestates.back(), client, currentGamestate_ );
-//       (*static_cast<Executor*>(executor))();
-//       this->threadPool_->passFunction( executor, true );
-//       (*functor)( cid, &(clientGamestates.back()), client, currentGamestate_ );
+      }
     }
 
-//     threadPool_->synchronise();
-
     return peerGamestates;
   }
 
 
-  void GamestateManager::finishGamestate( unsigned int peerID, packet::Gamestate*& destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate ) {
-    //why are we searching the same client's gamestate id as we searched in
-    //Server::sendGameState?
+  void GamestateManager::finishGamestate(unsigned int peerID, packet::Gamestate*& destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate)
+  {
     // save the (undiffed) gamestate in the clients gamestate map
-    //chose wheather the next gamestate is the first or not
+    // choose whether the next gamestate is the first or not
 
-//     packet::Gamestate *gs = gamestate->doSelection(clientID, 20000);
-//       packet::Gamestate* gs = new packet::Gamestate(*gamestate);
-//     packet::Gamestate* gs = gamestate;
+    // Create a copy of the gamestate
     packet::Gamestate *gs = new packet::Gamestate(*gamestate); //this is neccessary because the gamestate are being kept (to diff them later on) for each client seperately
-//     packet::Gamestate *gs = new packet::Gamestate();
-//     gs->collectData( id_, 0x1 );
-//     this->threadMutex_->lock();
-    peerMap_[peerID].gamestates[gamestate->getID()]=gs;
-//     this->threadMutex_->unlock();
+    this->peerMap_[peerID].gamestates[gamestate->getID()] = gs;
+
+    // Start the clock
     Clock clock;
     clock.capture();
 
@@ -235,7 +264,7 @@
     if(base)
     {
       packet::Gamestate *diffed1 = gs->diffVariables(base);
-      if( diffed1->getDataSize() == 0 )
+      if(diffed1->getDataSize() == 0)
       {
         delete diffed1;
         destgamestate = nullptr;
@@ -248,131 +277,145 @@
       gs = new packet::Gamestate(*gs);
     }
 
-
-//     OrxVerify(gs->compressData(), "");
+    // Stop the clock
     clock.capture();
     orxout(verbose_more, context::network) << "diff and compress time: " << clock.getDeltaTime() << endl;
-//     orxout(verbose_more, context::network) << "sending gamestate with id " << gs->getID();
-//     if(gamestate->isDiffed())
-//       orxout(verbose_more, context::network) << " and baseid " << gs->getBaseID() << endl;
-//     else
-//       orxout(verbose_more, context::network) << endl;
+
+
     gs->setPeerID(peerID);
     destgamestate = gs;
   }
 
 
+  /**
+   * Acknowledge a received gamestate.
+   * @param gamestateID The ID of the gamestate to be acknowledged
+   * @param peerID The ID of the peer to send the Acknowledgement to
+   */
   bool GamestateManager::ackGamestate(unsigned int gamestateID, unsigned int peerID)
   {
-//     ClientInformation *temp = ClientInformation::findClient(peerID);
-//     assert(temp);
+    // Search for the peer in the peer map
     std::map<uint32_t, peerInfo>::iterator it = this->peerMap_.find(peerID);
-    assert(it!=this->peerMap_.end());
+    assert(it != this->peerMap_.end());
+
     unsigned int curid = it->second.lastAckedGamestateID;
 
     assert(gamestateID != ACKID_NACK);
-//     if(gamestateID == ACKID_NACK){
-//       it->second.lastAckedGamestateID = GAMESTATEID_INITIAL;
-// //       temp->setGamestateID(GAMESTATEID_INITIAL);
-//       // now delete all saved gamestates for this client
-//       std::map<uint32_t, packet::Gamestate*>::iterator it2;
-//       for(it2 = it->second.gamestates.begin(); it2!=it->second.gamestates.end(); ++it2 ){
-//         delete it2->second;
-//       }
-//       it->second.gamestates.clear();
-//       return true;
-//     }
 
-//    assert(curid==GAMESTATEID_INITIAL || curid<=gamestateID); // this line is commented out because acknowledgements are unreliable and may arrive in distorted order
-    if( gamestateID <= curid && curid != GAMESTATEID_INITIAL )
+    // The gamestate has already been acknowledged, nothing to do
+    if(gamestateID <= curid && curid != GAMESTATEID_INITIAL)
+    {
         return true;
-orxout(verbose, context::network) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << endl;
+    }
+
+    orxout(verbose, context::network) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << endl;
     std::map<uint32_t, packet::Gamestate*>::iterator it2;
-    for( it2=it->second.gamestates.begin(); it2!=it->second.gamestates.end(); )
+    for (it2 = it->second.gamestates.begin(); it2 != it->second.gamestates.end();)
     {
-      if( it2->second->getID() < gamestateID )
+      if(it2->second->getID() < gamestateID)
       {
         delete it2->second;
         it->second.gamestates.erase(it2++);
       }
       else
+      {
         ++it2;
+      }
     }
     
-//     std::map<unsigned int, packet::Gamestate*>::iterator it;
-//     for(it = gamestateMap_[peerID].begin(); it!=gamestateMap_[peerID].end() && it->first<gamestateID; ){
-//       delete it->second;
-//       gamestateMap_[peerID].erase(it++);
-//     }
+    // update the last acked gamestate
     it->second.lastAckedGamestateID = gamestateID;
-//     temp->setGamestateID(gamestateID);
-//     TrafficControl::processAck(peerID, gamestateID);
+
     return true;
   }
   
+  /**
+   * Return the ID of the last received gamestate for a certain peer
+   * @param peerID The ID of the peer\
+   */
   uint32_t GamestateManager::getLastReceivedGamestateID(unsigned int peerID)
   {
-    assert( this->peerMap_.find(peerID)!=this->peerMap_.end() );
-    if( this->peerMap_.find(peerID) != this->peerMap_.end() )
+    if(this->peerMap_.find(peerID) != this->peerMap_.end())
+    {
       return this->peerMap_[peerID].lastReceivedGamestateID;
+    }
     else
+    {
       return GAMESTATEID_INITIAL;
+    }
   }
   
-  
+  /**
+   * Add a peer to the game.
+   * @param peerID The ID of the peer to add.
+   */
   void GamestateManager::addPeer(uint32_t peerID)
   {
-    assert(peerMap_.find(peerID)==peerMap_.end());
-    peerMap_[peerID].peerID = peerID;
-    peerMap_[peerID].lastReceivedGamestateID = GAMESTATEID_INITIAL;
-    peerMap_[peerID].lastAckedGamestateID = GAMESTATEID_INITIAL;
-    if( GameMode::isMaster() )
-      peerMap_[peerID].isSynched = false;
+    // Ensure that the peer doesn't already exist.
+    assert(this->peerMap_.find(peerID) == this->peerMap_.end());
+
+    // Create the peerInfo struct for the peer
+    this->peerMap_[peerID].peerID = peerID;
+    this->peerMap_[peerID].lastReceivedGamestateID = GAMESTATEID_INITIAL;
+    this->peerMap_[peerID].lastAckedGamestateID = GAMESTATEID_INITIAL;
+    if(GameMode::isMaster())
+    {
+      this->peerMap_[peerID].isSynched = false;
+    }
     else
-      peerMap_[peerID].isSynched = true;
+    {
+      this->peerMap_[peerID].isSynched = true;
+    }
   }
 
+  /**
+   * Remove a peer from the game.
+   * @param peerID The ID of the peer to be removed
+   */
   void GamestateManager::removePeer(uint32_t peerID)
   {
-    assert(peerMap_.find(peerID)!=peerMap_.end());
-    for( const auto& mapEntry : peerMap_[peerID].gamestates )
+    // Make sure that the peer exists
+    assert(this->peerMap_.find(peerID) != this->peerMap_.end());
+
+    for (const auto& mapEntry : this->peerMap_[peerID].gamestates)
     {
       delete mapEntry.second;
     }
-    peerMap_.erase(peerMap_.find(peerID));
+    this->peerMap_.erase(this->peerMap_.find(peerID));
   }
 
-
-//   void GamestateManager::removeClient(ClientInformation* client){
-//     assert(client);
-//     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;
-//     for(it=clientMap->second.begin(); it!=clientMap->second.end(); it++)
-//       delete it->second;
-//     // now delete the clients gamestatemap
-//     gamestateMap_.erase(clientMap);
-//   }
-
+  /**
+   * Process an incoming Gamestate packet.
+   * @param gs Pointer to the incoming Gamestate packet
+   */
   bool GamestateManager::processGamestate(packet::Gamestate *gs)
   {
+    // Decompress if necessary
     if(gs->isCompressed())
     {
        OrxVerify(gs->decompressData(), "ERROR: could not decompress Gamestate");
     }
     assert(!gs->isDiffed());
+
     uint8_t gsMode;
-    if( GameMode::isMaster() )
+    if(GameMode::isMaster())
+    {
       gsMode = packet::GAMESTATE_MODE_SERVER;
+    }
     else
+    {
       gsMode = packet::GAMESTATE_MODE_CLIENT;
-    if( gs->spreadData(gsMode) )
+    }
+
+    if(gs->spreadData(gsMode))
     {
       this->peerMap_[gs->getPeerID()].lastReceivedGamestateID = gs->getID();
       return true;
     }
     else
+    {
       return false;
+    }
   }
 
 }

Modified: code/branches/PresentationFS18/src/libraries/network/GamestateManager.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/GamestateManager.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/GamestateManager.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -57,13 +57,16 @@
   * - creating snapshots of gamestates
   * - writing gamestates to universe
   * - diffing gamestates
+  *
+  * Inherited by Host
+  *
   * EN/DECODATION:
   * a: last Gamestate a client has received
   * b: new Gamestate
   * x: diffed and compressed gamestate
-  * x=(a^b)
-  * b=(a^x)
-  * diff(a,diff(a,x))=x (hope this is correct)
+  * x = (a ^ b)
+  * b = (a ^ x)
+  * diff(a, diff(a, x)) = x (hope this is correct)
   * @author Oliver Scheuss
   */
   class _NetworkExport GamestateManager: public GamestateHandler
@@ -74,7 +77,7 @@
       uint32_t  lastReceivedGamestateID;  //!< id of the last gamestate which was received (and processed) from the peer
       uint32_t  lastAckedGamestateID;     //!< id of the last gamestate on which we received an ack from the peer
       bool      isSynched;
-      std::map< uint32_t, packet::Gamestate* > gamestates;
+      std::map<uint32_t, packet::Gamestate*> gamestates;
     };
 
   public:
@@ -85,7 +88,7 @@
     virtual bool      addGamestate(packet::Gamestate *gs, unsigned int peerID) override;
     virtual bool      ackGamestate(unsigned int gamestateID, unsigned int peerID) override;
     virtual uint32_t  getLastReceivedGamestateID( unsigned int peerID ) override;
-    virtual uint32_t  getCurrentGamestateID() override{ if( currentGamestate_) return currentGamestate_->getID(); else return GAMESTATEID_INITIAL; }
+    virtual uint32_t  getCurrentGamestateID() override { if(currentGamestate_) return currentGamestate_->getID(); else return GAMESTATEID_INITIAL; }
 
     bool processGamestates();
     bool sendAck(unsigned int gamestateID, uint32_t peerID);
@@ -97,24 +100,25 @@
 
     void addPeer( uint32_t peerID );
     void setSynched( uint32_t peerID )
-      { assert(peerMap_.find(peerID)!=peerMap_.end()); peerMap_[peerID].isSynched = true; }
+      { assert(peerMap_.find(peerID) != peerMap_.end()); peerMap_[peerID].isSynched = true; }
     void removePeer( uint32_t peerID );
-    bool hasPeers(){ return this->peerMap_.size()!=0; }
-//     void removeClient(ClientInformation *client);
+    bool hasPeers(){ return this->peerMap_.size() != 0; }
+
   protected:
     virtual bool sendPacket( packet::Packet* packet ) = 0;
+
   private:
     bool processGamestate(packet::Gamestate *gs);
 
-//     std::map<unsigned int, std::map<unsigned int, packet::Gamestate*>> gamestateMap_;
     std::map<unsigned int, packet::Gamestate*> gamestateQueue;
-//     std::map<unsigned int, uint32_t> lastProcessedGamestateID_;
+
+    // Each peerID maps to a peerInfo struct
     std::map<uint32_t, peerInfo> peerMap_;
+
+    // always contains the latest gamestate
     packet::Gamestate* currentGamestate_;
-//     TrafficControl *trafficControl_;
     unsigned int id_;
-//     boost::mutex* threadMutex_;
-    ThreadPool*   /*thread*/Pool_;
+    ThreadPool* Pool_;
   };
 
 }

Modified: code/branches/PresentationFS18/src/libraries/network/Host.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/Host.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/Host.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -43,9 +43,7 @@
 
   SetConsoleCommand(__CC_printRTT_group, __CC_printRTT_name, &Host::printRTT);
 
-  // Host*               Host::instance_=nullptr;
-  uint32_t            Host::clientID_s=0;
-//   uint32_t            Host::shipID_s=-1;
+  uint32_t            Host::clientID_s = 0;
   std::vector<Host*>  Host::instances_s;
 
   /**
@@ -53,9 +51,10 @@
   */
   Host::Host()
   {
-  //   assert(instance_==nullptr);
-    instances_s.push_back(this);
+    Host::instances_s.push_back(this);
+
     ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(this);
+
     this->bIsActive_ = false;
   }
 
@@ -65,8 +64,8 @@
   */
   Host::~Host()
   {
-    assert( std::find( instances_s.begin(), instances_s.end(), this )!=instances_s.end() );
-    instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this ));
+    assert(std::find( instances_s.begin(), instances_s.end(), this ) != instances_s.end());
+    Host::instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this ));
     ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(nullptr);
   }
 
@@ -79,9 +78,9 @@
   */
   void Host::addPacket(ENetPacket *packet, int clientID, uint8_t channelID)
   {
-    for(Host* host : instances_s)
+    for (Host* host : instances_s)
     {
-      if( host->isActive() )
+      if (host->isActive())
       {
         host->queuePacket(packet, clientID, channelID);
       }
@@ -96,9 +95,13 @@
    */
   void Host::sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
   {
-    for(Host* host : instances_s)
-      if( host->isActive() )
+    for (Host* host : instances_s)
+    {
+      if (host->isActive())
+      {
         host->doSendChat(message, sourceID, targetID);
+      }
+    }
   }
 
   /**
@@ -107,32 +110,43 @@
   void Host::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
   {
     for (NetworkChatListener* listener : ObjectList<NetworkChatListener>())
+    {
       listener->incomingChat(message, sourceID);
+    }
   }
 
 
   bool Host::isServer()
   {
-    for (Host* host : instances_s)
+    for (Host* host : Host::instances_s)
     {
-      if( host->isActive() )
+      if (host->isActive())
       {
-        if( host->isServer_() )
+        if (host->isServer_())
+        {
           return true;
+        }
       }
     }
     return false;
   }
 
+  /**
+   * Singleton implementation. Return the first active instance.
+   */
   Host* Host::getActiveInstance()
   {
     std::vector<Host*>::iterator it = Host::instances_s.begin();
-    while( it != Host::instances_s.end() )
+    while (it != Host::instances_s.end())
     {
-      if( (*it)->isActive() )
+      if ((*it)->isActive())
+      {
         return *it;
+      }
       else
+      {
         ++it;
+      }
     }
     return nullptr;
   }

Modified: code/branches/PresentationFS18/src/libraries/network/Host.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/Host.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/Host.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -39,7 +39,7 @@
 
   const unsigned int CLIENTID_SERVER = 0;
   const unsigned int NETWORK_FREQUENCY = 25;
-  const float NETWORK_PERIOD = 1.0f/NETWORK_FREQUENCY;
+  const float NETWORK_PERIOD = 1.0f / NETWORK_FREQUENCY;
 
 /**
 *       @brief Base class of Server and Client
@@ -54,7 +54,7 @@
   friend class packet::Chat;
 
   private:
-    virtual void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID)=0;
+    virtual void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID) = 0;
     virtual bool isServer_()=0;
 
   protected:
@@ -62,8 +62,8 @@
     virtual ~Host();
     void setActive( bool bActive ){ bIsActive_ = bActive; }
 
-    virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)=0;
-    virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID)=0;
+    virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) = 0;
+    virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) = 0;
 
   public:
     static Host* getActiveInstance();
@@ -73,8 +73,9 @@
     static void setClientID(unsigned int id){ clientID_s = id; }
     static bool isServer();
     static void sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID);
-    virtual void printRTT()=0;
+    virtual void printRTT() = 0;
     bool isActive(){ return bIsActive_; }
+    
   private:
     static uint32_t clientID_s;
     static std::vector<Host*> instances_s;

Modified: code/branches/PresentationFS18/src/libraries/network/LANDiscoverable.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/LANDiscoverable.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/LANDiscoverable.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -120,8 +120,6 @@
             info.setServerName(this->ownName);
             info.setClientNumber(this->clientNumber);
             info.send(event.peer);
-//             ENetPacket* packet = enet_packet_create( LAN_DISCOVERY_ACK, strlen(LAN_DISCOVERY_ACK)+1, ENET_PACKET_FLAG_RELIABLE );
-//             enet_peer_send(event.peer, 0, packet );
             enet_host_flush(this->host_);
           }
           break;

Modified: code/branches/PresentationFS18/src/libraries/network/LANDiscoverable.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/LANDiscoverable.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/LANDiscoverable.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -42,8 +42,7 @@
       virtual ~LANDiscoverable();
       void setActivity( bool bActive );
       void update();
-      void updateClientNumber(int clientNumber) {this->clientNumber = clientNumber;}
-;
+      void updateClientNumber(int clientNumber) { this->clientNumber = clientNumber; }
       /** Function used for the configuration file parameter update */
       void setConfigValues();
 

Modified: code/branches/PresentationFS18/src/libraries/network/LANDiscovery.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/LANDiscovery.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/LANDiscovery.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -60,7 +60,6 @@
     memset(&address, 0, sizeof(ENetAddress));
     address.port = LAN_DISCOVERY_PORT;
 
-    /* TODO: check for availability of each protocol */
     /* IPv4 */
     address.host = ENET_HOST_BROADCAST;
     peer = enet_host_connect(this->host_, &address, 0, 0);
@@ -101,8 +100,6 @@
             if( it==this->servers_.end() )
               this->servers_.push_back(info);
           }
-//           enet_address_get_host_ip(&event.peer->address, buffer, buflen );
-//           serverIPs.push_back(std::string(buffer));
           break;
         default:
           break;

Modified: code/branches/PresentationFS18/src/libraries/network/MasterServer.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/MasterServer.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/MasterServer.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -39,7 +39,6 @@
   /* commands for the terminal interface */
   SetConsoleCommand( "ms-listservers", &MasterServer::listServers );
   SetConsoleCommand( "ms-delserver", &MasterServer::delServer );
-  //SetConsoleCommand( "ms-serverinfo", &MasterServer::serverInfo );
 
   /* forward declaration so the linker doesn't complain */
   MasterServer *MasterServer::instance = nullptr;
@@ -356,7 +355,9 @@
         eventDisconnect( event ); break;
 
         /* incoming data */
-      case ENET_EVENT_TYPE_RECEIVE: eventData( event ); break;
+      case ENET_EVENT_TYPE_RECEIVE:
+        eventData( event ); break;
+        
       default: break;
     }
 

Modified: code/branches/PresentationFS18/src/libraries/network/MasterServerComm.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/MasterServerComm.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/MasterServerComm.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -37,7 +37,6 @@
   { /* nothing anymore, everything's been outsourced to 
      * the initialize method to facilitate debugging
      */
-    /* register object in orxonox */
   } 
 
   int MasterServerComm::initialize()
@@ -48,10 +47,6 @@
       return 1;
     }
 
-    /* initialize the event holder */
-//     this->event = (ENetEvent *)calloc( sizeof(ENetEvent), 1 );
-    
-
     /* initiate the client */
     this->client = enet_host_create( nullptr /* create a client host */,
         1,
@@ -225,10 +220,6 @@
 
     /* One could just use enet_host_service() instead. */
     enet_host_flush( this->client );
-   
-    /* free the packet */
-    // PLEASE: never do this, because enet will free the packet once it's delivered. this will cause double frees
-//     enet_packet_destroy( packet );
 
     /* all done. */
     return 0;
@@ -247,8 +238,6 @@
 
     /* One could just use enet_host_service() instead. */
     enet_host_flush( this->client );
-    // PLEASE: never do this, because enet will free the packet once it's delivered. this will cause double frees
-//     enet_packet_destroy( packet );
 
     /* all done. */
     return 0;

Modified: code/branches/PresentationFS18/src/libraries/network/Server.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/Server.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/Server.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -54,7 +54,6 @@
 #include "packet/FunctionIDs.h"
 #include "packet/Gamestate.h"
 #include "packet/Welcome.h"
-// #include "ClientInformation.h"
 #include "FunctionCallManager.h"
 #include "GamestateManager.h"
 
@@ -68,21 +67,19 @@
   */
   Server::Server()
   {
-    this->timeSinceLastUpdate_=0;
+    this->timeSinceLastUpdate_ = 0;
   }
 
+  /**
+  * Constructor
+  * @param port Port to listen on
+  */
   Server::Server(int port)
   {
-    this->setPort( port );
-    this->timeSinceLastUpdate_=0;
+    this->setPort(port);
+    this->timeSinceLastUpdate_ = 0;
   }
-/*
-  Server::Server(int port, const std::string name)
-  {
-    this->setPort( port );
-    this->timeSinceLastUpdate_=0;
-    this->serverName_=name;
-  }*/
+
   /**
   * Constructor
   * @param port Port to listen on
@@ -90,9 +87,9 @@
   */
   Server::Server(int port, const std::string& bindAddress)
   {
-    this->setPort( port );
-    this->setBindAddress( bindAddress );
-    this->timeSinceLastUpdate_=0;
+    this->setPort(port);
+    this->setBindAddress(bindAddress);
+    this->timeSinceLastUpdate_ = 0;
   }
 
   /**
@@ -155,7 +152,7 @@
     // receive and process incoming discovery packets
     LANDiscoverable::update();
 
-    if ( GamestateManager::hasPeers() )
+    if (GamestateManager::hasPeers())
     {
       // process incoming gamestates
       GamestateManager::processGamestates();
@@ -162,16 +159,15 @@
       FunctionCallManager::processBufferedFunctionCalls();
 
       // send function calls to clients
-      FunctionCallManager::sendCalls( static_cast<Host*>(this) );
+      FunctionCallManager::sendCalls(static_cast<Host*>(this));
 
-      //this steers our network frequency
-      timeSinceLastUpdate_+=time.getDeltaTime();
-      if(timeSinceLastUpdate_>=NETWORK_PERIOD)
+      // this steers our network frequency
+      timeSinceLastUpdate_ += time.getDeltaTime();
+      if(timeSinceLastUpdate_ >= NETWORK_PERIOD)
       {
-        timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
-        updateGamestate();
+        timeSinceLastUpdate_ -= static_cast<unsigned int>(timeSinceLastUpdate_ / NETWORK_PERIOD) * NETWORK_PERIOD;
+        this->updateGamestate();
       }
-//       sendPackets(); // flush the enet queue
     }
   }
 
@@ -181,57 +177,35 @@
   }
 
   /**
-   * @brief: returns ping time to client in milliseconds
+   * Print ping time to client in milliseconds.
    */
-  unsigned int Server::getRTT(unsigned int clientID)
-  {
-//     assert(ClientInformation::findClient(clientID));
-//     return ClientInformation::findClient(clientID)->getRTT();
-    // TODO: reimplement
-    return 0;
-  }
-
   void Server::printRTT()
   {
-//     for( ClientInformation* temp=ClientInformation::getBegin(); temp!=nullptr; temp=temp->next() )
-//       orxout(message) << "Round trip time to client with ID: " << temp->getID() << " is " << temp->getRTT() << " ms" << endl;
+    // TODO: Implement
   }
 
   /**
-   * @brief: return packet loss ratio to client (scales from 0 to 1)
+   * Take a new snapshot of the gamestate and send it to the clients.
    */
-  float Server::getPacketLoss(unsigned int clientID)
-  {
-//     assert(ClientInformation::findClient(clientID));
-//     return ClientInformation::findClient(clientID)->getPacketLoss();
-    return 0.;
-  }
-
-  /**
-  * takes a new snapshot of the gamestate and sends it to the clients
-  */
   void Server::updateGamestate()
   {
-    if( this->clientIDs_.size()==0 )
-      //no client connected
+    if(this->clientIDs_.size() == 0)
+    {
+      // no client connected
       return;
+    }
     GamestateManager::update();
-//     orxout(verbose_more, context::network) << "Server: one gamestate update complete, goig to sendGameState" << endl;
-    //orxout(verbose_more, context::network) << "updated gamestate, sending it" << endl;
-    //if(clients->getGamestateID()!=GAMESTATEID_INITIAL)
-    sendGameStates();
-    sendObjectDeletes();
-//     orxout(verbose_more, context::network) << "Server: one sendGameState turn complete, repeat in next tick" << endl;
-    //orxout(verbose_more, context::network) << "sent gamestate" << endl;
+    this->sendGameStates();
+    this->sendObjectDeletes();
   }
 
   /**
-  * sends the current gamestate to all peers
-  */
+   * Send the current gamestate to all peers.
+   */
   bool Server::sendGameStates()
   {
     std::vector<packet::Gamestate*> gamestates = GamestateManager::getGamestates();
-    for( packet::Gamestate* gamestate : gamestates )
+    for(packet::Gamestate* gamestate : gamestates)
     {
       gamestate->send(static_cast<Host*>(this));
     }
@@ -239,13 +213,17 @@
   }
 
 
+  /**
+   * Send 'DeleteObjects' packet
+   */
   bool Server::sendObjectDeletes()
   {
-//     ClientInformation *temp = ClientInformation::getBegin();
-//     if( temp == nullptr )
-      //no client connected
-    if( this->clientIDs_.size()==0 )
+    // no client connected
+    if(this->clientIDs_.size() == 0)
+    {
       return true;
+    }
+
     packet::DeleteObjects *del = new packet::DeleteObjects();
     if(!del->fetchIDs())
     {
@@ -252,41 +230,21 @@
       delete del;
       return true;  //everything ok (no deletes this tick)
     }
-//     orxout(verbose, context::network) << "sending DeleteObjects" << endl;
-//     while(temp != nullptr){
-//       if( !(temp->getSynched()) )
-//       {
-//         orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl;
-//         temp=temp->next();
-//         continue;
-//       }
-//       int cid = temp->getID(); //get client id
-//       packet::DeleteObjects *cd = new packet::DeleteObjects(*del);
-//       assert(cd);
+
     del->setPeerID(NETWORK_PEER_ID_BROADCAST);
-    if ( !del->send( static_cast<Host*>(this) ) )
+    if (!del->send( static_cast<Host*>(this)))
+    {
       orxout(internal_warning, context::network) << "Server: could not broadcast deleteObjects packet" << endl;
-//       temp=temp->next();
-      // gs gets automatically deleted by enet callback
-//     }
-//     delete del;
+    }
+
     return true;
   }
 
-
+  /**
+   * Add a new peer to the server.
+   */
   void Server::addPeer(uint32_t peerID)
   {
-//     static unsigned int newid=1;
-//
-//     orxout(internal_info, context::network) << "Server: adding client" << endl;
-//     ClientInformation *temp = ClientInformation::insertBack(new ClientInformation);
-//     if(!temp)
-//     {
-//       orxout(internal_warning, context::network) << "Server: could not add client" << endl;
-//     }
-//     temp->setID(newid);
-//     temp->setPeer(event->peer);
-
     // inform all the listeners
     this->clientIDs_.push_back(peerID);
     WANDiscoverable::updateClientNumber(this->clientIDs_.size());
@@ -295,102 +253,95 @@
     ClientConnectionListener::broadcastClientConnected(peerID);
     GamestateManager::addPeer(peerID);
 
-//     ++newid;
-
     orxout(internal_info, context::network) << "Server: added client id: " << peerID << endl;
 
-    createClient(peerID);
-}
+    this->createClient(peerID);
+  }
 
+  /**
+   * Remove a peer from the server.
+   */
   void Server::removePeer(uint32_t peerID)
   {
     orxout(verbose, context::network) << "removing client from list" << endl;
-//     ClientInformation *client = ClientInformation::findClient(&event->peer->address);
-//     if(!client)
-//       return;
-//     else
-//     {
-  std::vector<uint32_t>::iterator it;
-  for( it=this->clientIDs_.begin(); it!=this->clientIDs_.end(); ++it )
-  {
-    if( *it == peerID )
+
+    // erase the peer from the list
+    std::vector<uint32_t>::iterator it;
+    for(it=this->clientIDs_.begin(); it!=this->clientIDs_.end(); ++it)
     {
-      this->clientIDs_.erase(it);
-      break;
+      if(*it == peerID)
+      {
+        this->clientIDs_.erase(it);
+        break;
+      }
     }
-  }
-  WANDiscoverable::updateClientNumber(this->clientIDs_.size());
-  LANDiscoverable::updateClientNumber(this->clientIDs_.size());
 
-  ClientConnectionListener::broadcastClientDisconnected(peerID);
-  GamestateManager::removePeer(peerID);
-      //ServerConnection::disconnectClient( client );
-      //ClientConnectionListener::broadcastClientDisconnected( client->getID() ); //this is done in ClientInformation now
-//       delete client;
-//     }
+    WANDiscoverable::updateClientNumber(this->clientIDs_.size());
+    LANDiscoverable::updateClientNumber(this->clientIDs_.size());
+
+    // Send 'clientDisconnected' message
+    ClientConnectionListener::broadcastClientDisconnected(peerID);
+
+    GamestateManager::removePeer(peerID);
   }
 
+  /**
+   * Process an incoming packet.
+   */
   void Server::processPacket(packet::Packet* packet)
   {
-    if( packet->isReliable() )
+    if(packet->isReliable())
     {
-      if( this->getLastReceivedGamestateID(packet->getPeerID()) >= packet->getRequiredGamestateID() )
+      if(this->getLastReceivedGamestateID(packet->getPeerID()) >= packet->getRequiredGamestateID())
+      {
         packet->process(static_cast<Host*>(this));
+      }
       else
+      {
         this->packetQueue_.push_back(packet);
+      }
     }
     else
+    {
       packet->process(static_cast<Host*>(this));
+    }
   }
 
-
+  /**
+   * Create a client.
+   */
   bool Server::createClient(int clientID)
   {
-//     ClientInformation *temp = ClientInformation::findClient(clientID);
-//     if(!temp)
-//     {
-//       orxout(internal_error, context::network) << "Server. could not create client with id: " << clientID << endl;
-//       return false;
-//     }
-//     orxout(verbose, context::network) << "Con.Man: creating client id: " << temp->getID() << endl;
 
     // synchronise class ids
-    syncClassid(clientID);
+    this->syncClassid(clientID);
 
     // now synchronise functionIDs
     packet::FunctionIDs *fIDs = new packet::FunctionIDs();
     fIDs->setPeerID(clientID);
-    bool b = fIDs->send( static_cast<Host*>(this) );
+    bool b = fIDs->send(static_cast<Host*>(this));
     assert(b);
 
-//     temp->setSynched(true);
     GamestateManager::setSynched(clientID);
 
+    // Send 'Welcome' packet to client
     orxout(verbose, context::network) << "sending welcome" << endl;
     packet::Welcome *w = new packet::Welcome(clientID);
     w->setPeerID(clientID);
-    b = w->send( static_cast<Host*>(this) );
+    b = w->send(static_cast<Host*>(this));
     assert(b);
+
     (void)b; // avoid compiler warning
-//     packet::Gamestate *g = new packet::Gamestate();
-//     g->setPeerID(clientID);
-//     b = g->collectData(0,packet::GAMESTATE_MODE_SERVER);
-//     assert(b);
-//     if(!b)
-//       return false; //no data for the client
-// //     b = g->compressData();
-// //     assert(b);
-//     b = g->send( static_cast<Host*>(this) );
-//     assert(b);
     return true;
   }
 
-  void Server::disconnectClient( uint32_t clientID )
+  /**
+   * Disconnect a client.
+   */
+  void Server::disconnectClient(uint32_t clientID)
   {
-    ServerConnection::disconnectClient( clientID );
-    GamestateManager::removePeer( clientID );
-    // inform all the listeners
-    // ClientConnectionListener::broadcastClientDisconnected(client->getID()); // this is done in ClientInformation now
+    ServerConnection::disconnectClient(clientID);
+    GamestateManager::removePeer(clientID);
   }
 
   /**
@@ -402,17 +353,21 @@
   void Server::doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
   {
     // check if the target exists. just ignore the message otherwise
-    if (!this->isValidTarget(targetID)) // TODO: remove this if an invalid clientIDs don't trigger assertions anymore
+    if (!this->isValidTarget(targetID))
+    {
       return;
+    }
 
     // send the message to the target
     packet::Chat* packet = new packet::Chat(message, sourceID, targetID);
     packet->setPeerID(targetID);
-    packet->send( static_cast<Host*>(this) );
+    packet->send(static_cast<Host*>(this));
 
     // if the target is (or includes) this host as well, call the parent function which passes the message to the listeners
     if (targetID == NETWORK_PEER_ID_BROADCAST || targetID == Host::getPlayerID())
+    {
       Host::doReceiveChat(message, sourceID, targetID);
+    }
   }
 
   /**
@@ -430,12 +385,20 @@
    */
   bool Server::isValidTarget(unsigned int targetID)
   {
+    // Broadcast or server ID are okay
     if (targetID == NETWORK_PEER_ID_BROADCAST || targetID == NETWORK_PEER_ID_SERVER)
+    {
       return true;
+    }
 
-    for( uint32_t id : this->clientIDs_ )
-      if( id == targetID )
+    // IDs in the client list are okay also
+    for(uint32_t id : this->clientIDs_)
+    {
+      if(id == targetID)
+      {
         return true;
+      }
+    }
 
     return false;
   }
@@ -442,10 +405,12 @@
 
   void Server::syncClassid(unsigned int clientID)
   {
-    int failures=0;
     packet::ClassID *classid = new packet::ClassID();
     classid->setPeerID(clientID);
-    while(!classid->send( static_cast<Host*>(this) ) && failures < 10){
+
+    int failures = 0;
+    while(!classid->send(static_cast<Host*>(this)) && failures < 10)\
+    {
       failures++;
     }
     assert(failures<10);

Modified: code/branches/PresentationFS18/src/libraries/network/Server.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/Server.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/Server.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -37,7 +37,6 @@
 #include "util/UtilPrereqs.h"
 #include "core/CorePrereqs.h"
 #include "Host.h"
-// #include "GamestateManager.h"
 #include "ServerConnection.h"
 #include "LANDiscoverable.h"
 #include "WANDiscoverable.h"
@@ -61,19 +60,17 @@
     void open();
     void close();
     virtual void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID) override;
-    virtual bool sendPacket( packet::Packet* packet ) override{ return packet->send( static_cast<Host*>(this) ); }
+    virtual bool sendPacket( packet::Packet* packet ) override { return packet->send( static_cast<Host*>(this) ); }
     void update(const Clock& time);
-    unsigned int getRTT(unsigned int clientID);
     virtual void printRTT() override;
-    float getPacketLoss(unsigned int clientID);
-    int getClientCount() { return this->clientIDs_.size();}
-    std::string getServerName() { return this->serverName_;}
+    int getClientCount() { return this->clientIDs_.size(); }
+    std::string getServerName() { return this->serverName_; }
 
   protected:
     void updateGamestate();
   private:
-    virtual bool isServer_() override{return true;}
-    unsigned int playerID(){return 0;}
+    virtual bool isServer_() override { return true; }
+    unsigned int playerID() { return 0; }
 
     virtual void addPeer(uint32_t peerID) override;
     virtual void removePeer(uint32_t peerID) override;

Modified: code/branches/PresentationFS18/src/libraries/network/ServerConnection.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/ServerConnection.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/ServerConnection.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -35,35 +35,50 @@
 
 #include "util/Output.h"
 #include <util/Sleep.h>
-// #include "ClientInformation.h"
 
 namespace orxonox
 {
-
+  /**
+   * Constructor
+   */
   ServerConnection::ServerConnection():
     bListening_(false)
   {
     this->bindAddress_ = new ENetAddress();
-//     memset(this->bindAddress_, 0, sizeof(ENetAddress));
     this->bindAddress_->host = ENET_HOST_ANY;
     this->bindAddress_->port = NETWORK_PORT;
     this->bindAddress_->scopeID = 0;
   }
 
+  /**
+   * Destructor
+   */
   ServerConnection::~ServerConnection()
   {
-    if ( this->bListening_ )
-      closeListener();
+    if (this->bListening_)
+    {
+      this->closeListener();
+    }
     delete this->bindAddress_;
   }
 
-  void ServerConnection::setBindAddress( const std::string& bindAddress )
+  /**
+   * Set address on which to listen.
+   * @param bindAddress The address on which to listen
+   */
+  void ServerConnection::setBindAddress(const std::string& bindAddress)
   {
-    if (enet_address_set_host (this->bindAddress_, bindAddress.c_str()) < 0)
-        orxout(internal_error, context::network) << "Could not resolve \"" << bindAddress << "\"." << endl;
+    if (enet_address_set_host(this->bindAddress_, bindAddress.c_str()) < 0)
+    {
+      orxout(internal_error, context::network) << "Could not resolve \"" << bindAddress << "\"." << endl;
+    }
   }
 
-  void ServerConnection::setPort( unsigned int port ) {
+  /**
+   * Set port on which to listen on.
+   * @param port The port on which to listen on.
+   */
+  void ServerConnection::setPort(unsigned int port) {
       this->bindAddress_->port = port;
   }
 
@@ -72,7 +87,7 @@
     // create host
     this->host_ = enet_host_create(this->bindAddress_, NETWORK_MAX_CONNECTIONS, NETWORK_CHANNEL_COUNT, 0, 0);
     
-    if ( this->host_ == nullptr )
+    if (this->host_ == nullptr)
     {
         orxout(internal_error, context::network) << "ServerConnection: host_ == nullptr" << endl;
         return false;
@@ -80,13 +95,22 @@
     
     // enable compression
     this->enableCompression();
+
+    // ensure that either IPv4 or IPv6 succeeded
     assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL );
+
     if (this->host_->socket4 == ENET_SOCKET_NULL)
+    {
         orxout(internal_warning, context::network) << "IPv4 Socket failed." << endl;
+    }
     else if (this->host_->socket6 == ENET_SOCKET_NULL)
+    {
         orxout(internal_warning, context::network) << "IPv6 Socket failed." << endl;
+    }
     else
+    {
         orxout(internal_info, context::network) << "Using IPv4 and IPv6 Sockets." << endl;
+    }
     
     // start communication thread
     Connection::startCommunicationThread();
@@ -94,43 +118,48 @@
     return true;
   }
 
+  /**
+   * Stop listening.
+   */
   bool ServerConnection::closeListener()
   {
-    this->bListening_=false;
-    disconnectClients();
+    this->bListening_ = false;
+    this->disconnectClients();
     Connection::stopCommunicationThread();
     enet_host_destroy(this->host_);
     return true;
   }
 
+  /**
+   * Add outgoing packet to queue.
+   * @param packet The packet to send
+   * @param clientID The ID of the recipient
+   * @param channelID The channel ID
+   */
   void ServerConnection::addPacket(ENetPacket *packet, unsigned int clientID, uint8_t channelID)
   {
-    if ( clientID == NETWORK_PEER_ID_BROADCAST )
+    if (clientID == NETWORK_PEER_ID_BROADCAST)
     {
-      broadcastPacket(packet, channelID);
+      this->broadcastPacket(packet, channelID);
     }
     else
     {
-//       ClientInformation *temp = ClientInformation::findClient(clientID);
-//       if(!temp){
-//         orxout(internal_warning, context::network) << "C.Man: addPacket findClient failed" << endl;
-//       }
       Connection::addPacket(packet, clientID, channelID);
     }
   }
 
-//   void ServerConnection::disconnectClient(ClientInformation *client)
-//   {
-//     Connection::disconnectPeer( client->getPeer() );
-//   }
-
+  /**
+   * Terminate connection with a peer.
+   * @param clientID The peer with which to terminate the connection.
+   */
   void ServerConnection::disconnectClient(int clientID)
   {
-//     ClientInformation *client = ClientInformation::findClient(clientID);
-//     if(client)
     Connection::disconnectPeer(clientID);
   }
 
+  /**
+   * Disconnect all peers.
+   */
   void ServerConnection::disconnectClients()
   {
     Connection::disconnectPeers();
@@ -137,22 +166,4 @@
     Connection::waitOutgoingQueue();
     return;
   }
-
-
-//   int ServerConnection::getClientID(ENetPeer* peer)
-//   {
-//     return getClientID(&(peer->address));
-//   }
-
-//   int ServerConnection::getClientID(ENetAddress* address)
-//   {
-//     return ClientInformation::findClient(address)->getID();
-//   }
-// 
-//   ENetPeer *ServerConnection::getClientPeer(int clientID)
-//   {
-//     return ClientInformation::findClient(clientID)->getPeer();
-//   }
-
-
 }

Modified: code/branches/PresentationFS18/src/libraries/network/ServerConnection.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/ServerConnection.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/ServerConnection.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -46,7 +46,8 @@
 namespace orxonox
 {
 
-  class _NetworkExport ServerConnection : public Connection{
+  class _NetworkExport ServerConnection : public Connection
+  {
   public:
     ~ServerConnection();
 
@@ -56,19 +57,14 @@
     bool openListener();
     bool closeListener();
     void addPacket(ENetPacket *packet, unsigned int ID, uint8_t channelID);
-//     virtual void disconnectClient(ClientInformation *client);
     void disconnectClient(int clientID);
+
   protected:
     ServerConnection();
     void disconnectClients();
 
   private:
-//     int getClientID(ENetPeer* peer);
-//     int getClientID(ENetAddress* address);
-//     ENetPeer* getClientPeer(int clientID);
-
     ENetAddress* bindAddress_;
-
     bool bListening_;
 
   };

Modified: code/branches/PresentationFS18/src/libraries/network/packet/Acknowledgement.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Acknowledgement.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Acknowledgement.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -36,17 +36,25 @@
 namespace packet {
 
 #define PACKET_FLAGS_ACK    0
+// Offset to start of packet ID
 #define _PACKETID           0
+// Offset to start of ACK ID
 #define _ACKID              _PACKETID + sizeof(packet::Type)
 
+/**
+ * Constructor
+ * Acknowledgement.data_ is 40 bits in size:
+ * [0, 7]:   Packet Type
+ * [8, 39]:  Acknowledgement ID
+ */
 Acknowledgement::Acknowledgement( unsigned int id, unsigned int peerID )
  : Packet()
 {
-  flags_ = flags_ | PACKET_FLAGS_ACK;
-  data_=new uint8_t[ getSize() ];
-  *(Type *)(data_ + _PACKETID ) = Type::Acknowledgement;
-  *(uint32_t *)(data_ + _ACKID ) = id;
-  peerID_=peerID;
+  this->flags_ |= PACKET_FLAGS_ACK;
+  this->data_ = new uint8_t[ this->getSize() ];
+  *(Type *)(this->data_ + _PACKETID) = Type::Acknowledgement;
+  *(uint32_t *)(this->data_ + _ACKID) = id;
+  this->peerID_ = peerID;
 }
 
 Acknowledgement::Acknowledgement( uint8_t *data, unsigned int peerID )
@@ -58,11 +66,11 @@
 {
 }
 
-unsigned int Acknowledgement::getSize() const{
+unsigned int Acknowledgement::getSize() const {
   return _ACKID + sizeof(uint32_t);
 }
 
-bool Acknowledgement::process(orxonox::Host* host){
+bool Acknowledgement::process(orxonox::Host* host) {
   orxout(verbose_more, context::packets) << "processing ACK with ID: " << getAckID() << endl;
   bool b = host->ackGamestate(getAckID(), peerID_);
   delete this;
@@ -69,7 +77,7 @@
   return b;
 }
 
-unsigned int Acknowledgement::getAckID(){
+unsigned int Acknowledgement::getAckID() {
   return *(uint32_t *)(data_ + _ACKID);
 }
 

Modified: code/branches/PresentationFS18/src/libraries/network/packet/Acknowledgement.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Acknowledgement.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Acknowledgement.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -33,11 +33,11 @@
 #include "Packet.h"
 
 namespace orxonox {
+	
 const unsigned int ACKID_NACK = 0;
+
 namespace packet {
-/**
-    @author
-*/
+
 class _NetworkExport Acknowledgement : public Packet
 {
 public:

Modified: code/branches/PresentationFS18/src/libraries/network/packet/Chat.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Chat.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Chat.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -37,7 +37,7 @@
 
 #define   PACKET_FLAGS_CHAT PacketFlag::Reliable
 
-/* Some lengths */
+/* Some lengths / offsets */
 #define _PACKETID         0
 #define _SOURCEID         _PACKETID + sizeof(Type)
 #define _TARGETID         _SOURCEID + sizeof(uint32_t)
@@ -48,29 +48,29 @@
  : Packet()
 {
   /* Add chat flag to packet flags */
-  flags_ = flags_ | PACKET_FLAGS_CHAT;
+  this->flags_ |= PACKET_FLAGS_CHAT;
 
   /* set message length to length of input string + 1 */
-  messageLength_ = message.length()+1;
+  this->messageLength_ = message.length() + 1;
 
   /* allocate memory for the data */
-  data_=new unsigned char[ getSize() ];
+  this->data_ = new unsigned char[ getSize() ];
 
   *(Type *)(data_ + _PACKETID ) = Type::Chat;
   *(unsigned int *)(data_ + _SOURCEID ) = sourceID;
   *(unsigned int *)(data_ + _TARGETID ) = targetID;
-  *(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_;
+  *(unsigned int *)(data_ + _MESSAGELENGTH ) = this->messageLength_;
 
   /* cast the hell out of the message string, and copy it into the
    * data buffer.
    */
-  memcpy( data_+_MESSAGE, static_cast<void*>(const_cast<char*>(message.c_str())), messageLength_ );
+  memcpy( this->data_ + _MESSAGE, static_cast<void*>(const_cast<char*>(message.c_str())), this->messageLength_ );
 }
 
 Chat::Chat( uint8_t* data, unsigned int clientID )
   : Packet(data, clientID)
 {
-  messageLength_ = *(uint32_t *)(data + _MESSAGELENGTH );
+  this->messageLength_ = *(uint32_t *)(data + _MESSAGELENGTH );
 }
 
 Chat::~Chat()
@@ -78,17 +78,19 @@
 }
 
 unsigned int Chat::getSize() const{
-  return _MESSAGE + messageLength_;
+  return _MESSAGE + this->messageLength_;
 }
 
 bool Chat::process(orxonox::Host* host){
-  host->doReceiveChat(std::string((const char*)data_+_MESSAGE), *(uint32_t *)(data_+_SOURCEID), *(uint32_t *)(data_+_TARGETID));
+  host->doReceiveChat(std::string((const char*)this->data_ + _MESSAGE),
+                                  *(uint32_t *)(this->data_+_SOURCEID),
+                                  *(uint32_t *)(this->data_+_TARGETID));
   delete this;
   return true;
 }
 
-unsigned char *Chat::getMessage(){
-  return data_ + _MESSAGE;
+unsigned char *Chat::getMessage() {
+  return this->data_ + _MESSAGE;
 }
 
 } //namespace packet

Modified: code/branches/PresentationFS18/src/libraries/network/packet/Chat.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Chat.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Chat.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -54,7 +54,7 @@
   virtual bool process(orxonox::Host* host) override;
 
   /* Get the length of the message (not the full size of the packet) */
-  unsigned int getMessageLength(){ return messageLength_; };
+  unsigned int getMessageLength() { return this->messageLength_; };
 
   /* return message content */
   unsigned char *getMessage();

Modified: code/branches/PresentationFS18/src/libraries/network/packet/ClassID.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/ClassID.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/packet/ClassID.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -45,16 +45,16 @@
 #define _PACKETID             0
 
 
-ClassID::ClassID( ) : Packet(){
+ClassID::ClassID() : Packet() {
   Identifier *id;
-  unsigned int nrOfClasses=0;
-  unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nrofclasses
+  unsigned int nrOfClasses = 0;
+  unsigned int packetSize = 2 * sizeof(uint32_t); //space for the packetID and for the nrofclasses
   uint32_t network_id;
-  flags_ = flags_ | PACKET_FLAGS_CLASSID;
+  this->flags_ |= PACKET_FLAGS_CLASSID;
   std::queue<std::pair<uint32_t, std::string>> tempQueue;
 
-  //calculate total needed size (for all strings and integers)
-  for(const auto& mapEntry : IdentifierManager::getInstance().getIdentifierByStringMap()){
+  // calculate total needed size (for all strings and integers)
+  for(const auto& mapEntry : IdentifierManager::getInstance().getIdentifierByStringMap()) {
     id = mapEntry.second;
     if(id == nullptr || !id->hasFactory())
       continue;
@@ -63,32 +63,32 @@
     // now push the network id and the classname to the stack
     tempQueue.push( std::pair<unsigned int, std::string>(network_id, classname) );
     ++nrOfClasses;
-    packetSize += (classname.size()+1)+sizeof(network_id)+sizeof(uint32_t);
+    packetSize += (classname.size() + 1) + sizeof(network_id) + sizeof(uint32_t);
   }
 
-  this->data_=new uint8_t[ packetSize ];
+  this->data_ = new uint8_t[ packetSize ];
   //set the appropriate packet id
   assert(this->data_);
   *(Type *)(this->data_ + _PACKETID ) = Type::ClassID;
 
-  uint8_t *temp=data_+sizeof(uint32_t);
+  uint8_t *temp = this->data_ + sizeof(uint32_t);
   // save the number of all classes
-  *(uint32_t*)temp = nrOfClasses;
+  *(uint32_t*) temp = nrOfClasses;
   temp += sizeof(uint32_t);
 
   // now save all classids and classnames
   std::pair<uint32_t, std::string> tempPair;
-  uint32_t tempsize = 2*sizeof(uint32_t); // packetid and nrOfClasses
+  uint32_t tempsize = 2 * sizeof(uint32_t); // packetid and nrOfClasses
   while( !tempQueue.empty() ){
     tempPair = tempQueue.front();
     tempQueue.pop();
-    *(uint32_t*)temp = tempPair.first;
-    *(uint32_t*)(temp+sizeof(uint32_t)) = tempPair.second.size()+1;
-    memcpy(temp+2*sizeof(uint32_t), tempPair.second.c_str(), tempPair.second.size()+1);
-    temp+=2*sizeof(uint32_t)+tempPair.second.size()+1;
-    tempsize+=2*sizeof(uint32_t)+tempPair.second.size()+1;
+    *(uint32_t*) temp = tempPair.first;
+    *(uint32_t*) (temp+sizeof(uint32_t)) = tempPair.second.size() + 1;
+    memcpy(temp + 2 * sizeof(uint32_t), tempPair.second.c_str(), tempPair.second.size() + 1);
+    temp += 2 * sizeof(uint32_t) + tempPair.second.size() + 1;
+    tempsize += 2 * sizeof(uint32_t) + tempPair.second.size() + 1;
   }
-  assert(tempsize==packetSize);
+  assert(tempsize == packetSize);
 
   orxout(verbose_more, context::packets) << "classid packetSize is " << packetSize << endl;
 
@@ -103,29 +103,27 @@
 {
 }
 
-uint32_t ClassID::getSize() const{
-  uint8_t *temp = data_+sizeof(uint32_t); // packet identification
+uint32_t ClassID::getSize() const {
+  uint8_t *temp = this->data_ + sizeof(uint32_t); // packet identification
   uint32_t totalsize = sizeof(uint32_t); // packet identification
-  uint32_t nrOfClasses = *(uint32_t*)temp;
+  uint32_t nrOfClasses = *(uint32_t*) temp;
   temp += sizeof(uint32_t);
   totalsize += sizeof(uint32_t); // storage size for nr of all classes
 
-  for(unsigned int i=0; i<nrOfClasses; i++){
-    totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t));
-    temp += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t));
+  for(unsigned int i=0; i < nrOfClasses; i++) {
+    totalsize += 2 * sizeof(uint32_t) + *(uint32_t*) (temp + sizeof(uint32_t));
+    temp += 2 * sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t));
   }
   return totalsize;
 }
 
-
-bool ClassID::process(orxonox::Host* host){
+bool ClassID::process(orxonox::Host* host) {
   int nrOfClasses;
-  uint8_t *temp = data_+sizeof(uint32_t); //skip the packetid
+  uint8_t *temp = this->data_ + sizeof(uint32_t); //skip the packetid
   uint32_t networkID;
   uint32_t stringsize;
   unsigned char *classname;
 
-
   //clear the map of network ids
   IdentifierManager::getInstance().clearNetworkIDs();
 
@@ -133,21 +131,21 @@
   std::pair<uint32_t, std::string> tempPair;
   Identifier *id;
   // read the total number of classes
-  nrOfClasses = *(uint32_t*)temp;
+  nrOfClasses = *(uint32_t*) temp;
   temp += sizeof(uint32_t);
 
-  for( int i=0; i<nrOfClasses; i++){
-    networkID = *(uint32_t*)temp;
-    stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
-    classname = temp+2*sizeof(uint32_t);
-    id=ClassByString( std::string((const char*)classname) );
+  for( int i = 0; i < nrOfClasses; i++) {
+    networkID = *(uint32_t*) temp;
+    stringsize = *(uint32_t*) (temp + sizeof(uint32_t));
+    classname = temp + 2 * sizeof(uint32_t);
+    id = ClassByString( std::string((const char*) classname) );
     orxout(internal_info, context::packets) << "processing classid: " << networkID << " name: " << classname << " id: " << id << endl;
-    if(id==nullptr){
+    if(id == nullptr) {
       orxout(user_error, context::packets) << "Received a bad classname" << endl;
       abort();
     }
     id->setNetworkID( networkID );
-    temp += 2*sizeof(uint32_t) + stringsize;
+    temp += 2 * sizeof(uint32_t) + stringsize;
   }
   delete this;
   return true;

Modified: code/branches/PresentationFS18/src/libraries/network/packet/DeleteObjects.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/DeleteObjects.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/packet/DeleteObjects.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -44,7 +44,7 @@
 DeleteObjects::DeleteObjects()
  : Packet()
 {
-  flags_ = flags_ | PACKET_FLAG_DELETE;
+  this->flags_ |= PACKET_FLAG_DELETE;
 }
 
 DeleteObjects::DeleteObjects( uint8_t *data, unsigned int clientID )
@@ -59,7 +59,7 @@
 bool DeleteObjects::fetchIDs()
 {
   unsigned int number = Synchronisable::getNumberOfDeletedObject();
-  if(number==0)
+  if(number == 0)
     return false;
   orxout(verbose, context::packets) << "sending DeleteObjects: ";
   unsigned int size = sizeof(Type) + sizeof(uint32_t)*(number+1);
@@ -82,15 +82,15 @@
 unsigned int DeleteObjects::getSize() const
 {
   assert(data_);
-  return _OBJECTIDS + *(uint32_t*)(data_+_QUANTITY)*sizeof(uint32_t);
+  return _OBJECTIDS + *(uint32_t*) (this->data_ + _QUANTITY) * sizeof(uint32_t);
 }
 
 bool DeleteObjects::process(orxonox::Host* host)
 {
-  for(unsigned int i=0; i<*(unsigned int *)(data_+_QUANTITY); i++)
+  for(unsigned int i = 0; i < *(unsigned int *) (this->data_+_QUANTITY); i++)
   {
     orxout(verbose, context::packets) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << endl;
-    Synchronisable::deleteObject( *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) );
+    Synchronisable::deleteObject( *(uint32_t*)(this->data_ + _OBJECTIDS + i * sizeof(uint32_t)) );
   }
   delete this;
   return true;

Modified: code/branches/PresentationFS18/src/libraries/network/packet/FunctionCalls.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/FunctionCalls.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/packet/FunctionCalls.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -62,12 +62,12 @@
 {
   assert(isDataENetAllocated());
   
-  uint8_t* temp = data_+sizeof(uint32_t); //skip packetid
-  uint32_t nrOfCalls = *(uint32_t*)temp;
+  uint8_t* temp = data_ + sizeof(uint32_t); //skip packetid
+  uint32_t nrOfCalls = *(uint32_t*) temp;
   temp += sizeof(uint32_t);
-  this->minGamestateID_ = *(uint32_t*)temp;
+  this->minGamestateID_ = *(uint32_t*) temp;
   temp += sizeof(uint32_t);
-  for( unsigned int i = 0; i<nrOfCalls; i++ )
+  for( unsigned int i = 0; i < nrOfCalls; i++ )
   {
     FunctionCall fctCall;
     fctCall.loadData(temp);
@@ -94,11 +94,11 @@
 {
   this->minGamestateID_ = host->getCurrentGamestateID();
   assert(this->functionCalls_.size());
-  data_=new uint8_t[ currentSize_ ];
-  *(Type *)(data_ + _PACKETID ) = Type::FunctionCalls; // Set the Packet ID
-  *(uint32_t*)(data_+sizeof(uint32_t)) = this->functionCalls_.size(); // set nrOfCalls
-  *(uint32_t*)(data_+2*sizeof(uint32_t)) = this->minGamestateID_; // set minGamestateID_
-  uint8_t* temp = data_+3*sizeof(uint32_t);
+  this->data_ = new uint8_t[ currentSize_ ];
+  *(Type *)(this->data_ + _PACKETID ) = Type::FunctionCalls; // Set the Packet ID
+  *(uint32_t*)(this->data_ + sizeof(uint32_t)) = this->functionCalls_.size(); // set nrOfCalls
+  *(uint32_t*)(this->data_ + 2 * sizeof(uint32_t)) = this->minGamestateID_; // set minGamestateID_
+  uint8_t* temp = this->data_ + 3 * sizeof(uint32_t);
   
   while( this->functionCalls_.size() )
   {
@@ -106,7 +106,7 @@
     this->functionCalls_.pop();
   }
   
-  assert( temp==data_+currentSize_ );
+  assert( temp == this->data_ + currentSize_ );
   
   Packet::send(host);
   return true;

Modified: code/branches/PresentationFS18/src/libraries/network/packet/Gamestate.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Gamestate.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Gamestate.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -45,7 +45,6 @@
 
 #define GAMESTATE_START(data) (data + GamestateHeader::getSize())
 
-// #define PACKET_FLAG_GAMESTATE  PacketFlag::Reliable
 #define PACKET_FLAG_GAMESTATE  0
 
 inline bool memzero( uint8_t* data, uint32_t datalength)
@@ -101,7 +100,7 @@
 {
 }
 
-
+//AV: This takes all synchronisables and packs it in a GameState, to be sent over the network
 bool Gamestate::collectData(int id, uint8_t mode)
 {
   uint32_t tempsize=0, currentsize=0;
@@ -128,8 +127,6 @@
   for(it = ObjectList<Synchronisable>().begin(); it; ++it)
   {
 
-//     tempsize=it->getSize(id, mode);
-
     tempsize = it->getData(mem, this->sizes_, id, mode);
     if ( tempsize != 0 )
       dataVector_.emplace_back(it->getObjectID(), it->getContextID(), tempsize, mem-data_);
@@ -172,7 +169,7 @@
   return true;
 }
 
-
+//AV: This takes the Gamestate received from the network and "unpacks" it back to a list of Objects/Synchronisables, thus updating the data
 bool Gamestate::spreadData(uint8_t mode)
 {
   orxout(verbose_more, context::packets) << "processing gamestate with id " << header_.getID() << endl;
@@ -195,52 +192,15 @@
       }
       else
       {
-//         orxout(verbose, context::packets) << "not creating object of classid " << objectheader.getClassID() << endl;
         mem += objectheader.getDataSize() + ( objectheader.isDiffed() ? SynchronisableHeaderLight::getSize() : SynchronisableHeader::getSize() );
       }
     }
     else
     {
-//       orxout(verbose, context::packets) << "updating object of classid " << objectheader.getClassID() << endl;
       OrxVerify(s->updateData(mem, mode), "ERROR: could not update Synchronisable with Gamestate data");
     }
   }
   assert((uintptr_t)(mem-data_) == GamestateHeader::getSize()+header_.getDataSize());
-  
-   // In debug mode, check first, whether there are no duplicate objectIDs
-#ifndef NDEBUG
-  if(this->getID()%1000==1)
-  {
-    std::list<uint32_t> v1;
-    for (Synchronisable* synchronisable : ObjectList<Synchronisable>())
-    {
-      if (synchronisable->getObjectID() == OBJECTID_UNKNOWN)
-      {
-        if (synchronisable->objectMode_ != 0x0)
-        {
-          orxout(user_error, context::packets) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << endl;
-          orxout(user_error, context::packets) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << endl;
-          orxout(user_error, context::packets) << "Objects class: " << synchronisable->getIdentifier()->getName() << endl;
-          assert(false);
-        }
-      }
-      else
-      {
-        for (uint32_t id : v1)
-        {
-          if (synchronisable->getObjectID() == id)
-          {
-            orxout(user_error, context::packets) << "Found duplicate objectIDs on the client!" << endl
-                                                 << "Are you sure you don't create a Sychnronisable objcect with 'new' \
-                                                     that doesn't have objectMode = 0x0?" << endl;
-            assert(false);
-          }
-        }
-        v1.push_back(synchronisable->getObjectID());
-      }
-    }
-  }
-#endif
   return true;
 }
 
@@ -275,7 +235,7 @@
   return host->addGamestate(this, getPeerID());
 }
 
-
+//AV: This function takes the Gamestate and compresses it for transmission over the network
 bool Gamestate::compressData()
 {
   assert(data_);
@@ -312,7 +272,7 @@
   return true;
 }
 
-
+//AV: This function takes the compressed Gamestate received from the network and decompresses it for further unpacking
 bool Gamestate::decompressData()
 {
   assert(data_);
@@ -373,7 +333,6 @@
   // Check whether the whole object stayed the same
   if( memcmp( origDataPtr+objectOffset, baseDataPtr+objectOffset, objectHeader.getDataSize()) == 0 )
   {
-//     orxout(verbose, context::packets) << "skip object " << Synchronisable::getSynchronisable(objectHeader.getObjectID())->getIdentifier()->getName() << endl;
     origDataPtr += objectOffset + objectHeader.getDataSize(); // skip the whole object
     baseDataPtr += objectOffset + objectHeader.getDataSize();
     sizes += Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables();
@@ -429,7 +388,6 @@
 
 inline void /*Gamestate::*/copyObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes )
 {
-  //       orxout(verbose, context::packets) << "docopy" << endl;
   // Just copy over the whole Object
   memcpy( newData, origData, objectHeader.getDataSize()+SynchronisableHeader::getSize() );
   SynchronisableHeader(newData).setDiffed(false);
@@ -436,17 +394,9 @@
   
   newData += objectHeader.getDataSize()+SynchronisableHeader::getSize();
   origData += objectHeader.getDataSize()+SynchronisableHeader::getSize();
-//   SynchronisableHeader baseHeader( baseData );
-//   baseData += baseHeader.getDataSize()+SynchronisableHeader::getSize();
-  //       orxout(verbose, context::packets) << "copy " << h.getObjectID() << endl;
-  //       orxout(verbose, context::packets) << "copy " << h.getObjectID() << ":";
+
   sizes += Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables();
-//   for( unsigned int i = 0; i < Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables(); ++i )
-//   {
-//     //         orxout(verbose, context::packets) << " " << *sizes;
-//     ++sizes;
-//   }
-    //       orxout(verbose, context::packets) << endl;
+
 }
 
 inline bool findObject(uint8_t*& dataPtr, uint8_t* endPtr, SynchronisableHeader& objectHeader)
@@ -500,9 +450,8 @@
   uint8_t *origDataPtr = GAMESTATE_START(this->data_);
   uint8_t *origDataEnd = origDataPtr + header_.getDataSize();
   uint8_t *baseDataEnd = baseDataPtr + base->header_.getDataSize();
-//   uint32_t origLength = header_.getDataSize();
-//   uint32_t baseLength = base->header_.getDataSize();
 
+
   // Allocate new space for diffed gamestate
   uint32_t newDataSize = header_.getDataSize() + GamestateHeader::getSize() + sizeof(uint32_t)*this->nrOfVariables_;
   uint8_t *newData = new uint8_t[newDataSize]; // this is the maximum size needed in the worst case
@@ -594,167 +543,6 @@
 }
 
 
-/*Gamestate* Gamestate::diffData(Gamestate *base)
-{
-  assert(this && base); assert(data_ && base->data_);
-  assert(!header_.isCompressed() && !base->header_.isCompressed());
-  assert(!header_.isDiffed());
-
-  uint8_t *basep = GAMESTATE_START(base->data_);
-  uint8_t *gs = GAMESTATE_START(this->data_);
-  uint32_t dest_length = header_.getDataSize();
-
-  if(dest_length==0)
-    return nullptr;
-
-  uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
-  uint8_t *dest = GAMESTATE_START(ndata);
-
-  rawDiff( dest, gs, basep, header_.getDataSize(), base->header_.getDataSize() );
-#ifndef NDEBUG
-  uint8_t *dest2 = new uint8_t[dest_length];
-  rawDiff( dest2, dest, basep, header_.getDataSize(), base->header_.getDataSize() );
-  assert( memcmp( dest2, gs, dest_length) == 0 );
-  delete dest2;
-#endif
-
-  Gamestate *g = new Gamestate(ndata, getClientID());
-  assert(g->header_);
-  *(g->header_) = *header_;
-  g->header_.setDiffed( true );
-  g->header_.setBaseID( base->getID() );
-  g->flags_=flags_;
-  g->packetDirection_ = packetDirection_;
-  assert(g->isDiffed());
-  assert(!g->isCompressed());
-  return g;
-}
-
-
-Gamestate* Gamestate::undiff(Gamestate *base)
-{
-  assert(this && base); assert(data_ && base->data_);
-  assert(!header_.isCompressed() && !base->header_.isCompressed());
-  assert(header_.isDiffed());
-
-  uint8_t *basep = GAMESTATE_START(base->data_);
-  uint8_t *gs = GAMESTATE_START(this->data_);
-  uint32_t dest_length = header_.getDataSize();
-
-  if(dest_length==0)
-    return nullptr;
-
-  uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
-  uint8_t *dest = ndata + GamestateHeader::getSize();
-
-  rawDiff( dest, gs, basep, header_.getDataSize(), base->header_.getDataSize() );
-
-  Gamestate *g = new Gamestate(ndata, getClientID());
-  assert(g->header_);
-  *(g->header_) = *header_;
-  g->header_.setDiffed( false );
-  g->flags_=flags_;
-  g->packetDirection_ = packetDirection_;
-  assert(!g->isDiffed());
-  assert(!g->isCompressed());
-  return g;
-}
-
-
-void Gamestate::rawDiff( uint8_t* newdata, uint8_t* data, uint8_t* basedata, uint32_t datalength, uint32_t baselength)
-{
-  uint64_t* gd = (uint64_t*)data;
-  uint64_t* bd = (uint64_t*)basedata;
-  uint64_t* nd = (uint64_t*)newdata;
-
-  unsigned int i;
-  for( i=0; i<datalength/8; i++ )
-  {
-    if( i<baselength/8 )
-      *(nd+i) = *(gd+i) ^ *(bd+i);  // xor the data
-    else
-      *(nd+i) = *(gd+i); // just copy over the data
-  }
-  unsigned int j;
-  // now process the rest (when datalength isn't a multiple of 4)
-  for( j = 8*(datalength/8); j<datalength; j++ )
-  {
-    if( j<baselength )
-      *(newdata+j) = *(data+j) ^ *(basedata+j); // xor
-    else
-      *(newdata+j) = *(data+j); // just copy
-  }
-  assert(j==datalength);
-}*/
-
-
-/*Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){
-  assert(data_);
-  std::list<obj>::iterator it;
-
-  // allocate memory for new data
-  uint8_t *gdata = new uint8_t[header_.getDataSize()+GamestateHeader::getSize()];
-  // create a gamestate out of it
-  Gamestate *gs = new Gamestate(gdata);
-  uint8_t *newdata = gdata + GamestateHeader::getSize();
-  uint8_t *origdata = GAMESTATE_START(data_);
-
-  //copy the GamestateHeader
-  assert(gs->header_);
-  *(gs->header_) = *header_;
-
-  uint32_t objectOffset;
-  unsigned int objectsize, destsize=0;
-  // TODO: Why is this variable not used?
-  //Synchronisable *object;
-
-  //call TrafficControl
-  TrafficControl::getInstance()->processObjectList( clientID, header_.getID(), dataVector_ );
-
-  //copy in the zeros
-//   std::list<obj>::iterator itt;
-//   orxout() << "myvector contains:";
-//   for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ )
-//     orxout() << " " << (*itt).objID;
-//   orxout() << endl;
-  for(it=dataVector_.begin(); it!=dataVector_.end();){
-    SynchronisableHeader oldobjectheader(origdata);
-    SynchronisableHeader newobjectheader(newdata);
-    if ( (*it).objSize == 0 )
-    {
-      ++it;
-      continue;
-    }
-    objectsize = oldobjectheader.getDataSize()+SynchronisableHeader::getSize();
-    objectOffset=SynchronisableHeader::getSize(); //skip the size and the availableData variables in the objectheader
-    if ( (*it).objID == oldobjectheader.getObjectID() ){
-      memcpy(newdata, origdata, objectsize);
-      ++it;
-    }else{
-      newobjectheader = oldobjectheader;
-      memset(newdata+objectOffset, 0, objectsize-objectOffset);
-    }
-    newdata += objectsize;
-    origdata += objectsize;
-    destsize += objectsize;
-  }
-#ifndef NDEBUG
-  uint32_t origsize = destsize;
-  while ( origsize < header_.getDataSize() )
-  {
-    SynchronisableHeader oldobjectheader(origdata);
-    objectsize = oldobjectheader.getDataSize()+SynchronisableHeader::getSize();
-    origdata += objectsize;
-    origsize += objectsize;
-  }
-  assert(origsize==header_.getDataSize());
-  assert(destsize!=0);
-#endif
-  gs->header_.setDataSize( destsize );
-  return gs;
-}*/
-
-
 uint32_t Gamestate::calcGamestateSize(uint32_t id, uint8_t mode)
 {
   uint32_t size = 0;

Modified: code/branches/PresentationFS18/src/libraries/network/packet/Gamestate.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Gamestate.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Gamestate.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -56,8 +56,6 @@
     GamestateHeader(){ data_=nullptr; }
     GamestateHeader(uint8_t* data)
       { assert(data); data_ = data; *(Type*)data_ = Type::Gamestate; }
-    /*GamestateHeader(uint8_t* data, GamestateHeader* h)
-      { assert(data); data_=data; memcpy(data_, h->data_, getSize()); }*/
     void setData(uint8_t* data)
       { assert(data); data_ = data; *(Type*)data_ = Type::Gamestate; }
     static inline uint32_t getSize()
@@ -126,9 +124,7 @@
     inline int32_t getBaseID() const { return header_.getBaseID(); }
     inline uint32_t getDataSize() const { return header_.getDataSize(); }
     Gamestate* diffVariables(Gamestate *base);
-//     Gamestate* diffData(Gamestate *base);
-//     Gamestate *undiff(Gamestate *base);
-//     Gamestate* doSelection(unsigned int clientID, unsigned int targetSize);
+
     bool compressData();
     bool decompressData();
     bool operator ==(packet::Gamestate gs);
@@ -135,14 +131,11 @@
 
     // Packet functions
   private:
-//     void rawDiff( uint8_t* newdata, uint8_t* data, uint8_t* basedata, uint32_t datalength, uint32_t baselength);
-//     inline uint32_t findObject( const SynchronisableHeader& header, uint8_t* mem, uint32_t dataLength, uint32_t startPosition = 0 );
+
     virtual uint32_t getSize() const override;
     virtual bool process(orxonox::Host* host) override;
     uint32_t calcGamestateSize(uint32_t id, uint8_t mode=0x0);
-//     inline void diffObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes );
-//     inline void copyObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes );
-    
+   
     std::list<obj>          dataVector_;
     GamestateHeader         header_;
     std::vector<uint32_t>   sizes_;

Modified: code/branches/PresentationFS18/src/libraries/network/packet/Packet.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Packet.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Packet.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -128,16 +128,23 @@
   }
 }
 
+/**
+ * Send the Packet.
+ * @param host The host which sends the packet
+ */
 bool Packet::send(orxonox::Host* host)
 {
+  // Deny sending incoming packets
   if(packetDirection_ != Direction::Outgoing && packetDirection_ != Direction::Bidirectional )
   {
     assert(0);
     return false;
   }
+
   if(!enetPacket_)
   {
-    if(!data_){
+    // Deny sending empty packets
+    if(!data_) {
       assert(0);
       return false;
     }
@@ -151,7 +158,7 @@
       // Assures we don't create a packet and destroy it right after in another thread
       // without having a reference in the packetMap_
       Packet::packetMapMutex_.lock();
-      packetMap_[reinterpret_cast<size_t>(enetPacket_)] = this;
+      Packet::packetMap_[reinterpret_cast<size_t>(enetPacket_)] = this;
       Packet::packetMapMutex_.unlock();
     }
   }
@@ -172,57 +179,49 @@
       break;
   }
 #endif
-//  ENetPacket *temp = enetPacket_;
-//  enetPacket_ = nullptr; // otherwise we have a double free because enet already handles the deallocation of the packet
+
+  // Send via reliable or standard channel respectively
   if( this->flags_ & PacketFlag::Reliable )
     host->addPacket( enetPacket_, peerID_, NETWORK_CHANNEL_DEFAULT);
   else
     host->addPacket( enetPacket_, peerID_, NETWORK_CHANNEL_UNRELIABLE);
+
   return true;
 }
 
+/**
+ * Given an ENetPacket, create an Orxonox packet
+ * @param packet The ENetPacket
+ * @param peerID The sender
+ */
 Packet *Packet::createPacket(ENetPacket* packet, uint32_t peerID)
 {
   uint8_t *data = packet->data;
-//   assert(ClientInformation::findClient(&peer->address)->getID() != static_cast<unsigned int>(-2) || !Host::isServer());
-//   unsigned int peerID = ClientInformation::findClient(&peer->address)->getID();
-  // HACK
-//   if( peerID==static_cast<unsigned int>(-2))
-//     peerID = NETWORK_PEER_ID_SERVER;
   Packet *p = nullptr;
-//   orxout(verbose_ultra, context::packets) << "packet type: " << *(Type *)&data[_PACKETID] << endl;
   switch( *(Type *)(data + _PACKETID) )
   {
     case Type::Acknowledgement:
-//       orxout(verbose_more, context::packets) << "ack" << endl;
-    p = new Acknowledgement( data, peerID );
+      p = new Acknowledgement( data, peerID );
       break;
     case Type::Chat:
-//       orxout(verbose_more, context::packets) << "chat" << endl;
       p = new Chat( data, peerID );
       break;
     case Type::ClassID:
-//       orxout(verbose_more, context::packets) << "classid" << endl;
       p = new ClassID( data, peerID );
       break;
     case Type::Gamestate:
-//       orxout(verbose_more, context::packets) << "gamestate" << endl;
       p = new Gamestate( data, peerID );
       break;
     case Type::Welcome:
-//       orxout(verbose_more, context::packets) << "welcome" << endl;
       p = new Welcome( data, peerID );
       break;
     case Type::DeleteObjects:
-//       orxout(verbose_more, context::packets) << "deleteobjects" << endl;
       p = new DeleteObjects( data, peerID );
       break;
     case Type::FunctionCalls:
-//       orxout(verbose_more, context::packets) << "functionCalls" << endl;
       p = new FunctionCalls( data, peerID );
       break;
     case Type::FunctionIDs:
-//       orxout(verbose_more, context::packets) << "functionIDs" << endl;
       p = new FunctionIDs( data, peerID );
       break;
     default:
@@ -246,14 +245,16 @@
 {
   // Get our Packet from a global map with all Packets created in the send() method of Packet.
   Packet::packetMapMutex_.lock();
-  std::map<size_t, Packet*>::iterator it = packetMap_.find(reinterpret_cast<size_t>(enetPacket));
+
+  std::map<size_t, Packet*>::iterator it = Packet::packetMap_.find(reinterpret_cast<size_t>(enetPacket));
   assert(it != packetMap_.end());
+
   // Make sure we don't delete it again in the destructor
   it->second->enetPacket_ = nullptr;
   delete it->second;
   packetMap_.erase(it);
+
   Packet::packetMapMutex_.unlock();
-//   orxout(verbose_ultra, context::packets) << "PacketMap size: " << packetMap_.size() << endl;
 }
 
 } // namespace packet

Modified: code/branches/PresentationFS18/src/libraries/network/packet/Packet.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Packet.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Packet.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -67,8 +67,11 @@
     static void deletePacket(ENetPacket* packet);
 
     virtual unsigned char* getData(){ return data_; };
-    virtual unsigned int getSize() const =0;
-    virtual bool process(orxonox::Host* host)=0;
+    virtual unsigned int getSize() const = 0;
+
+    // Invoke some sort of action associated with the packet
+    virtual bool process(orxonox::Host* host) = 0;
+    
     inline uint32_t getFlags()
       { return flags_; }
     inline int getPeerID()
@@ -81,10 +84,10 @@
       { return this->requiredGamestateID_; }
 
     virtual bool send(orxonox::Host* host);
+
   protected:
     Packet();
     Packet(uint8_t *data, unsigned int peerID);
-//    Packet(ENetPacket *packet, ENetPeer *peer);
     inline bool isDataENetAllocated() const
       { return bDataENetAllocated_; }
 
@@ -99,7 +102,9 @@
     /** Tells whether data_ was allocated by ENet or ourselves.
         data_ might no correlate with enetPacket_->data. */
     bool bDataENetAllocated_;
+
   private:
+    // All Packets are contained in this map
     static std::map<size_t, Packet *> packetMap_;
     static boost::mutex               packetMapMutex_;
     ENetPacket *enetPacket_;

Modified: code/branches/PresentationFS18/src/libraries/network/packet/ServerInformation.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/ServerInformation.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/packet/ServerInformation.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -49,18 +49,15 @@
 
       // Save Server Round Trip Time
       this->serverRTT_ = event->peer->roundTripTime;
+
       // Save Server Address, leave some space for scope ID
       enet_address_get_host_ip(&event->peer->address, serverIP, 64);
+
       this->serverIP_ = std::string(serverIP);
       // Save ACK
       uint8_t* temp = event->packet->data;
       char* ack = nullptr;
       loadAndIncrease((char*&)ack, temp);
-
-      /* Fabian, what is this used for? it crashes the masterserver, hence commenting it */
-      // written by Oli: this is just to make sure that loadAndIncrease really writes the whole ACK string into char* ack
-//       assert(strcmp(ack, (const char*)LAN_DISCOVERY_ACK)==0);
-
       // Save Server Name
       loadAndIncrease(this->serverName_, temp);
       delete[] ack;
@@ -73,7 +70,7 @@
 
     void ServerInformation::send(ENetPeer* peer)
     {
-      std::string payload = this->serverName_ + Ogre::StringConverter::toString(this->clientNumber_);
+      std::string payload = this->serverName_ + std::to_string(this->clientNumber_);
       uint32_t size = returnSize(LAN_DISCOVERY_ACK) + returnSize(payload);
       uint8_t* temp = new uint8_t[size];
       uint8_t* temp2 = temp;

Modified: code/branches/PresentationFS18/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/synchronisable/Synchronisable.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/synchronisable/Synchronisable.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -42,7 +42,7 @@
   std::map<uint32_t, Synchronisable *> Synchronisable::objectMap_;
   std::queue<uint32_t> Synchronisable::deletedObjects_;
 
-  uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
+  uint8_t Synchronisable::state_=0x1; // determines wheter we are server (default) or client
 
   RegisterAbstractClass(Synchronisable).inheritsFrom<OrxonoxInterface>();
 
@@ -52,7 +52,7 @@
   */
   Synchronisable::Synchronisable(Context* context)
   {
-      RegisterObject(Synchronisable);
+    RegisterObject(Synchronisable);
     static uint32_t idCounter=0;
     objectMode_=0x1; // by default do not send data to server
     if ( GameMode::isMaster()/* || ( Host::running() && Host::isServer() )*/ )
@@ -178,10 +178,8 @@
     assert(no);
     assert( Synchronisable::objectMap_.find(header.getObjectID()) == Synchronisable::objectMap_.end() );
     no->setObjectID(header.getObjectID());
-    //no->contextID=header.getContextID(); //TODO: remove this
     no->setClassID(header.getClassID());
     assert(no->contextID_ == header.getContextID());
-    //assert(no->classID_ == header.getClassID());
     orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl;
           // update data and create object/entity...
     bool b = no->updateData(mem, mode, true);
@@ -188,7 +186,6 @@
     assert(b);
     if (b)
     {
-//        b = no->create();
         assert(b);
     }
     return no;
@@ -272,19 +269,15 @@
     // end copy header
 
     orxout(verbose_more, context::network) << "getting data from objectID_: " << objectID_ << ", classID_: " << classID_ << endl;
-//     orxout(verbose, context::network) << "objectid: " << this->objectID_ << ":";
     // copy to location
     for(SynchronisableVariableBase* variable : syncList_)
     {
       uint32_t varsize = variable->getData( mem, mode );
-//       orxout(verbose, context::network) << " " << varsize;
       tempsize += varsize;
       sizes.push_back(varsize);
       ++test;
-      //tempsize += (*i)->getSize( mode );
     }
     assert(tempsize!=0);  // if this happens an empty object (with no variables) would be transmitted
-//     orxout(verbose, context::network) << endl;
 
     header.setObjectID( this->objectID_ );
     header.setContextID( this->contextID_ );
@@ -339,7 +332,6 @@
       return true;
     }
 
-    //orxout(verbose_more, context::network) << "Synchronisable: objectID_ " << syncHeader.getObjectID() << ", classID_ " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << endl;
     if( !syncHeaderLight.isDiffed() )
     {
       SynchronisableHeader syncHeader2(mem);
@@ -356,11 +348,9 @@
     else
     {
       mem += SynchronisableHeaderLight::getSize();
-//       orxout(debug_output, context::network) << "objectID: " << this->objectID_ << endl;
       while( mem < data+syncHeaderLight.getDataSize()+SynchronisableHeaderLight::getSize() )
       {
         VariableID varID = *(VariableID*)mem;
-//         orxout(debug_output, context::network) << "varID: " << varID << endl;
         assert( varID < syncList_.size() );
         mem += sizeof(VariableID);
         syncList_[varID]->putData( mem, mode, forceCallback );
@@ -399,8 +389,6 @@
    */
   bool Synchronisable::doSync(/*int32_t id,*/ uint8_t mode)
   {
-//     if(mode==0x0)
-//       mode=state_;
     assert(mode!=0x0);
     return ( (this->objectMode_ & mode)!=0 && (!syncList_.empty() ) );
   }

Modified: code/branches/PresentationFS18/src/libraries/network/synchronisable/Synchronisable.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/synchronisable/Synchronisable.h	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/libraries/network/synchronisable/Synchronisable.h	2018-05-30 12:56:24 UTC (rev 12020)
@@ -133,11 +133,6 @@
       inline void operator=(SynchronisableHeader& h)
         { memcpy(data_, h.data_, getSize()); }
   };
-  
-//   inline void operator=(SynchronisableHeaderLight& h1, SynchronisableHeader& h2)
-//   {
-//     memcpy(h1.data_, h2.data_, h1.getSize());
-//   }
 
   /**
   * This class is the base class of all the Objects in the universe that need to be synchronised over the network

Modified: code/branches/PresentationFS18/src/modules/overlays/hud/HUDWeaponSystem.cc
===================================================================
--- code/branches/PresentationFS18/src/modules/overlays/hud/HUDWeaponSystem.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/modules/overlays/hud/HUDWeaponSystem.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -125,6 +125,9 @@
 
         destroyHUDChilds();
 
+        // TODO:
+        // On network clients, owner_->getWeaponSystem() returns a nullpointer
+        // This causes the overlay to not be shown on clients.
         if (owner_->getWeaponSystem())
         {
             const std::vector<WeaponPack*>& weaponPacks = owner_->getWeaponSystem()->getAllWeaponPacks();

Modified: code/branches/PresentationFS18/src/orxonox/graphics/Model.cc
===================================================================
--- code/branches/PresentationFS18/src/orxonox/graphics/Model.cc	2018-05-30 12:48:17 UTC (rev 12019)
+++ code/branches/PresentationFS18/src/orxonox/graphics/Model.cc	2018-05-30 12:56:24 UTC (rev 12020)
@@ -103,7 +103,8 @@
     {
         registerVariable(this->meshSrc_,    VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedMesh));
         registerVariable(this->renderQueueGroup_,    VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedRenderQueueGroup));
-        registerVariable(this->materialName_,    VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedMaterial));
+        //Commented out, since this causes texture load failures on client side
+        //registerVariable(this->materialName_,    VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedMaterial));
         registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedShadows));
     }
 
@@ -124,7 +125,9 @@
             if (this->mesh_.getEntity())
                 this->detachOgreObject(this->mesh_.getEntity());
 
-            this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
+                // Refuse to set empty mesh sources
+                if (this->meshSrc_ != "")
+                    this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
 
             if (this->mesh_.getEntity())
             {



More information about the Orxonox-commit mailing list