Index: code/branches/FICN/src/network/ConnectionManager.cc
===================================================================
--- code/branches/FICN/src/network/ConnectionManager.cc	(revision 681)
+++ code/branches/FICN/src/network/ConnectionManager.cc	(revision 777)
@@ -1,28 +1,28 @@
 /*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Oliver Scheuss, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   This program is free software; you can redistribute it and/or
+*   modify it under the terms of the GNU General Public License
+*   as published by the Free Software Foundation; either version 2
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Oliver Scheuss, (C) 2007
+*   Co-authors:
+*      ...
+*
+*/
 
 //
@@ -37,8 +37,16 @@
 //
 
+#include <iostream>
+// boost.thread library for multithreading support
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#include "core/CoreIncludes.h"
+#include "ClientInformation.h"
 #include "ConnectionManager.h"
 
-namespace std{
-  bool operator< (ENetAddress a, ENetAddress b){
+namespace std
+{
+  bool operator< (ENetAddress a, ENetAddress b) {
     if(a.host <= b.host)
       return true;
@@ -48,9 +56,9 @@
 }
 
-namespace network{
-
+namespace network
+{
   boost::thread_group network_threads;
 
-  ConnectionManager::ConnectionManager(ClientInformation *head){
+  ConnectionManager::ConnectionManager(ClientInformation *head) {
     quit=false;
     bindAddress.host = ENET_HOST_ANY;
@@ -59,5 +67,5 @@
   }
 
-  ConnectionManager::ConnectionManager(int port, std::string address, ClientInformation *head){
+  ConnectionManager::ConnectionManager(int port, std::string address, ClientInformation *head) {
     quit=false;
     enet_address_set_host (& bindAddress, address.c_str());
@@ -66,5 +74,5 @@
   }
 
-  ConnectionManager::ConnectionManager(int port, const char *address, ClientInformation *head){
+  ConnectionManager::ConnectionManager(int port, const char *address, ClientInformation *head) {
     quit=false;
     enet_address_set_host (& bindAddress, address);
@@ -73,12 +81,12 @@
   }
 
-  ENetPacket *ConnectionManager::getPacket(ENetAddress &address){
+  ENetPacket *ConnectionManager::getPacket(ENetAddress &address) {
     if(!buffer.isEmpty())
       return buffer.pop(address);
     else
-        return NULL;
-  }
-
-  ENetPacket *ConnectionManager::getPacket(int &clientID){
+      return NULL;
+  }
+
+  ENetPacket *ConnectionManager::getPacket(int &clientID) {
     ENetAddress address;
     ENetPacket *packet=getPacket(address);
@@ -88,15 +96,15 @@
   }
 
-  bool ConnectionManager::queueEmpty(){
+  bool ConnectionManager::queueEmpty() {
     return buffer.isEmpty();
   }
 
-  void ConnectionManager::createListener(){
+  void ConnectionManager::createListener() {
     network_threads.create_thread(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
-//     boost::thread thr(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
+    //     boost::thread thr(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
     return;
   }
 
-  bool ConnectionManager::quitListener(){
+  bool ConnectionManager::quitListener() {
     quit=true;
     network_threads.join_all();
@@ -104,5 +112,5 @@
   }
 
-  bool ConnectionManager::addPacket(ENetPacket *packet, ENetPeer *peer){
+  bool ConnectionManager::addPacket(ENetPacket *packet, ENetPeer *peer) {
     if(enet_peer_send(peer, head_->findClient(&(peer->address))->getID() , packet)!=0)
       return false;
@@ -110,5 +118,5 @@
   }
 
-  bool ConnectionManager::addPacket(ENetPacket *packet, int clientID){
+  bool ConnectionManager::addPacket(ENetPacket *packet, int clientID) {
     if(enet_peer_send(head_->findClient(clientID)->getPeer(), clientID, packet)!=0)
       return false;
@@ -116,13 +124,13 @@
   }
 
-  bool ConnectionManager::addPacketAll(ENetPacket *packet){
+  bool ConnectionManager::addPacketAll(ENetPacket *packet) {
     for(ClientInformation *i=head_->next(); i!=0; i=i->next()){
       if(enet_peer_send(i->getPeer(), i->getID(), packet)!=0)
-         return false;
-    }
-    return true;
-  }
-
-  bool ConnectionManager::sendPackets(ENetEvent *event){
+        return false;
+    }
+    return true;
+  }
+
+  bool ConnectionManager::sendPackets(ENetEvent *event) {
     if(server==NULL)
       return false;
@@ -133,5 +141,5 @@
   }
 
-  bool ConnectionManager::sendPackets(){
+  bool ConnectionManager::sendPackets() {
     ENetEvent event;
     if(server==NULL)
@@ -143,5 +151,5 @@
   }
 
-  void ConnectionManager::receiverThread(){
+  void ConnectionManager::receiverThread() {
     // what about some error-handling here ?
     enet_initialize();
@@ -164,16 +172,16 @@
         // log handling ================
         case ENET_EVENT_TYPE_CONNECT:
-        addClient(&event);
-        break;
-      case ENET_EVENT_TYPE_RECEIVE:
-        //std::cout << "received data" << std::endl;
-        processData(&event);
-        break;
-      case ENET_EVENT_TYPE_DISCONNECT:
-        // add some error/log handling here
-        clientDisconnect(event.peer);
-        break;
-      case ENET_EVENT_TYPE_NONE:
-        break;
+          addClient(&event);
+          break;
+        case ENET_EVENT_TYPE_RECEIVE:
+          //std::cout << "received data" << std::endl;
+          processData(&event);
+          break;
+        case ENET_EVENT_TYPE_DISCONNECT:
+          // add some error/log handling here
+          clientDisconnect(event.peer);
+          break;
+        case ENET_EVENT_TYPE_NONE:
+          break;
       }
     }
@@ -183,5 +191,5 @@
   }
 
-  void ConnectionManager::disconnectClients(){
+  void ConnectionManager::disconnectClients() {
     ENetEvent event;
     ClientInformation *temp = head_->next();
@@ -194,14 +202,14 @@
       switch (event.type)
       {
-        case ENET_EVENT_TYPE_NONE:
-        case ENET_EVENT_TYPE_CONNECT:
-        case ENET_EVENT_TYPE_RECEIVE:
-          enet_packet_destroy(event.packet);
-          break;
-        case ENET_EVENT_TYPE_DISCONNECT:
-          std::cout << "disconnecting client" << std::endl;
-          delete head_->findClient(&(event.peer->address));
-          temp = temp->next();
-          break;
+      case ENET_EVENT_TYPE_NONE:
+      case ENET_EVENT_TYPE_CONNECT:
+      case ENET_EVENT_TYPE_RECEIVE:
+        enet_packet_destroy(event.packet);
+        break;
+      case ENET_EVENT_TYPE_DISCONNECT:
+        std::cout << "disconnecting client" << std::endl;
+        delete head_->findClient(&(event.peer->address));
+        temp = temp->next();
+        break;
       }
     }
@@ -209,5 +217,5 @@
   }
 
-  bool ConnectionManager::processData(ENetEvent *event){
+  bool ConnectionManager::processData(ENetEvent *event) {
     // just add packet to the buffer
     // this can be extended with some preprocessing
@@ -215,15 +223,13 @@
   }
 
-//   bool ConnectionManager::clientDisconnect(ENetPeer *peer){
-//     return clientDisconnect(*peer);
-//   }
-
-
-
-  bool ConnectionManager::clientDisconnect(ENetPeer *peer){
+  //bool ConnectionManager::clientDisconnect(ENetPeer *peer) {
+  //  return clientDisconnect(*peer);
+  //}
+
+  bool ConnectionManager::clientDisconnect(ENetPeer *peer) {
     return head_->removeClient(peer);
   }
 
-  bool ConnectionManager::addClient(ENetEvent *event){
+  bool ConnectionManager::addClient(ENetEvent *event) {
     ClientInformation *temp = head_->insertBack(new ClientInformation);
     if(temp->prev()->head)
@@ -238,17 +244,17 @@
   }
 
-  int ConnectionManager::getClientID(ENetPeer peer){
+  int ConnectionManager::getClientID(ENetPeer peer) {
     return getClientID(peer.address);
   }
 
-  int ConnectionManager::getClientID(ENetAddress address){
+  int ConnectionManager::getClientID(ENetAddress address) {
     return head_->findClient(&address)->getID();
   }
 
-  ENetPeer *ConnectionManager::getClientPeer(int clientID){
+  ENetPeer *ConnectionManager::getClientPeer(int clientID) {
     return head_->findClient(clientID)->getPeer();
   }
 
-  void ConnectionManager::syncClassid(int clientID){
+  void ConnectionManager::syncClassid(int clientID) {
     int i=0;
     std::string classname;
