Index: /code/branches/network/bin/levels/sample.oxw
===================================================================
--- /code/branches/network/bin/levels/sample.oxw	(revision 1741)
+++ /code/branches/network/bin/levels/sample.oxw	(revision 1742)
@@ -22,12 +22,4 @@
 <NPC position="0,-200,450" scale="1" mesh="razor.mesh"/>
 <NPC position="100,0,400" scale="1" mesh="razor.mesh"/>
-
-<?lua
-for i = 1, 10, 1 
-do ?>
-  <SpaceShipAI position="<?lua print(math.random() * 6000 - 3000) ?>,<?lua print(math.random() * 6000 - 3000) ?>,<?lua print(math.random() * 6000 - 3000) ?>" scale="10" yawpitchroll="0,0,0" mesh="assff.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" />
-<?lua 
-end
-?>
 
 <!--Model name="starship" position="200,0,500" scale="10" mesh="starship.mesh" yawpitchroll="-90,-90,0" />
Index: /code/branches/network/src/network/GamestateClient.cc
===================================================================
--- /code/branches/network/src/network/GamestateClient.cc	(revision 1741)
+++ /code/branches/network/src/network/GamestateClient.cc	(revision 1742)
@@ -73,5 +73,5 @@
       return 0;
     int id = GAMESTATEID_INITIAL;
-    //bool b = saveShipCache();
+    bool b = saveShipCache();
     packet::Gamestate *processed = processGamestate(tempGamestate_);
     assert(processed);
@@ -81,6 +81,6 @@
     last_diff_ = processed->getBaseID();
     last_gamestate_ = processed->getID();
-    //if(b)
-      //loadShipCache();
+    if(b)
+      loadShipCache();
     id = processed->getID();
     cleanup();
@@ -134,10 +134,10 @@
     if(myShip_){
       //      unsigned char *data = new unsigned char[myShip_->getSize()];
-      int size=myShip_->getSize(0x1);
+      int size=myShip_->getSize2(0, 0x1);
       if(size==0)
         return false;
       shipCache_ = new unsigned char [size];
       unsigned char *temp = shipCache_;
-      if(!myShip_->getData2(temp, 0x1))
+      if(!myShip_->getData(temp, 0, 0x1))
         COUT(3) << "could not save shipCache" << std::endl;
       return true;
@@ -157,8 +157,6 @@
 
   packet::Gamestate *GamestateClient::processGamestate(packet::Gamestate *gs){
-    if(gs->isCompressed()){
-      bool b = gs->decompressData();
-      assert(b);
-    }
+    if(gs->isCompressed())
+      assert(gs->decompressData());
     if(gs->isDiffed()){
       packet::Gamestate *base = gamestateMap_[gs->getBaseID()];
Index: /code/branches/network/src/network/GamestateManager.cc
===================================================================
--- /code/branches/network/src/network/GamestateManager.cc	(revision 1741)
+++ /code/branches/network/src/network/GamestateManager.cc	(revision 1742)
@@ -131,6 +131,5 @@
     packet::Gamestate *gs;
     int gID = ClientInformation::findClient(clientID)->getGamestateID();
-    COUT(4) << "G.St.Man: popgamestate: sending gstate_id: " << id_ << " diffed from: " << gID << std::endl;
-//     COUT(3) << "gamestatemap: " << &gameStateMap << std::endl;
+    //COUT(4) << "G.St.Man: popgamestate: sending gstate_id: " << id_ << " diffed from: " << gID << std::endl;
     //chose wheather the next gamestate is the first or not
     if(gID != GAMESTATEID_INITIAL){
@@ -147,11 +146,4 @@
       gs = new packet::Gamestate(*reference);
     }
-#ifndef NDEBUG
-    packet::Gamestate *ns = new packet::Gamestate(*gs);
-    ns->compressData();
-    ns->decompressData();
-    assert(*gs==*ns);
-    delete ns;
-#endif
     assert(gs->compressData());
     return gs;
Index: /code/branches/network/src/network/Server.cc
===================================================================
--- /code/branches/network/src/network/Server.cc	(revision 1741)
+++ /code/branches/network/src/network/Server.cc	(revision 1742)
@@ -264,5 +264,4 @@
       //std::cout << "adding gamestate" << std::endl;
       gs->setClientID(cid);
-      assert(gs->compressData());
       if ( !gs->send() ){
         COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl; 
@@ -298,6 +297,5 @@
       return false;
     }
-    if(temp->prev()->getBegin()) { //not good if you use anything else than insertBack
-      temp->prev()->setID(0); //bugfix: not necessary but usefull
+    if(temp==ClientInformation::getBegin()) { //not good if you use anything else than insertBack
       temp->setID(1);
     }
Index: /code/branches/network/src/network/Synchronisable.cc
===================================================================
--- /code/branches/network/src/network/Synchronisable.cc	(revision 1741)
+++ /code/branches/network/src/network/Synchronisable.cc	(revision 1742)
@@ -63,4 +63,5 @@
     static int idCounter=0;
     datasize=0;
+    objectFrequency_=1;
     objectID=idCounter++;
     syncList = new std::list<synchronisableVariable *>;
@@ -94,4 +95,7 @@
     objectID = *(unsigned int*)(mem+sizeof(unsigned int));
     classID = *(unsigned int*)(mem+2*sizeof(unsigned int));
+    
+    if(size==3*sizeof(unsigned int)) //not our turn, dont do anything
+      return true;
     
     orxonox::Identifier* id = ID(classID);
@@ -141,61 +145,10 @@
     syncList->push_back(temp);
   }
-
-
-  /**
-  * This function takes all SynchronisableVariables out of the Synchronisable and saves it into a syncData struct
-  * Difference to the above function:
-  * takes a pointer to already allocated memory (must have at least getSize bytes length)
-  * structure of the bitstream:
-  * (var1_size,var1,var2_size,var2,...)
-  * varx_size: size = sizeof(int)
-  * varx: size = varx_size
-  * @return data containing all variables and their sizes
-  */
-  syncData Synchronisable::getData(unsigned char *mem, int mode){
-    //std::cout << "inside getData" << std::endl;
-    if(mode==0x0)
-      mode=state_;
-    if(classID==0)
-      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
-    this->classID=this->getIdentifier()->getNetworkID();
-    std::list<synchronisableVariable *>::iterator i;
-    syncData retVal;
-    retVal.objectID=this->objectID;
-    retVal.classID=this->classID;
-    retVal.length=getSize();
-    COUT(5) << "Synchronisable getting data from objectID: " << retVal.objectID << " classID: " << retVal.classID << " length: " << retVal.length << std::endl;
-    retVal.data=mem;
-    // copy to location
-    int n=0; //offset
-    for(i=syncList->begin(); n<datasize && i!=syncList->end(); ++i){
-      //(std::memcpy(retVal.data+n, (const void*)(&(i->size)), sizeof(int));
-      if( ((*i)->mode & mode) == 0 ){
-        COUT(5) << "not getting data: " << std::endl;
-        continue;  // this variable should only be received
-      }
-      switch((*i)->type){
-      case DATA:
-        memcpy( (void *)(retVal.data+n), (void*)((*i)->var), (*i)->size);
-        n+=(*i)->size;
-        break;
-      case STRING:
-        memcpy( (void *)(retVal.data+n), (void *)&((*i)->size), sizeof(int) );
-        n+=sizeof(int);
-        const char *data = ( ( *(std::string *) (*i)->var).c_str());
-        memcpy( retVal.data+n, (void*)data, (*i)->size);
-        COUT(5) << "synchronisable: char: " << (const char *)(retVal.data+n) << " data: " << data << " string: " << *(std::string *)((*i)->var) << std::endl;
-        n+=(*i)->size;
-        break;
-      }
-    }
-    return retVal;
-  }
   
   /**
    * This function takes all SynchronisableVariables out of the Synchronisable and saves it into a syncData struct
-  * Difference to the above function:
+   * Difference to the above function:
    * takes a pointer to already allocated memory (must have at least getSize bytes length)
-  * structure of the bitstream:
+   * structure of the bitstream:
    * (var1_size,var1,var2_size,var2,...)
    * varx_size: size = sizeof(int)
@@ -203,5 +156,5 @@
    * @return data containing all variables and their sizes
    */
-  bool Synchronisable::getData2(unsigned char*& mem, int mode){
+  bool Synchronisable::getData(unsigned char*& mem, unsigned int id, int mode){
     //std::cout << "inside getData" << std::endl;
     unsigned int tempsize = 0;
@@ -210,8 +163,8 @@
     if(classID==0)
       COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
-    this->classID=this->getIdentifier()->getNetworkID();
+    this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this
     std::list<synchronisableVariable *>::iterator i;
     unsigned int size;
-    size=getSize2(mode);
+    size=getSize2(id, mode);
     
     // start copy header
@@ -224,4 +177,8 @@
     tempsize+=12;
     // end copy header
+    
+    //if this tick is we dont synchronise, then abort now
+    if(!isMyTick(id))
+      return true;
     
     COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << " length: " << size << std::endl;
@@ -254,91 +211,4 @@
   }
 
-  /*bool Synchronisable::getData(Bytestream& bs, int mode)
-  {
-    //std::cout << "inside getData" << std::endl;
-    if(mode==0x0)
-      mode=state_;
-    if(classID==0)
-      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
-    this->classID=this->getIdentifier()->getNetworkID();
-    std::list<synchronisableVariable *>::iterator i;
-    bs << this->getSize();
-    bs << this->objectID;
-    bs << this->classID;
-    // copy to location
-    for(i=syncList->begin(); i!=syncList->end(); ++i){
-      if( ((*i)->mode & mode) == 0 ){
-        COUT(5) << "not getting data: " << std::endl;
-        continue;  // this variable should only be received
-      }
-      switch((*i)->type){
-        case DATA:
-          bs << *(*i)->var;
-          //std::memcpy( (void *)(retVal.data+n), (void*)((*i)->var), (*i)->size);
-          //n+=(*i)->size;
-          break;
-        case STRING:
-          bs << *(String *)((*i)->var);
-          //memcpy( (void *)(retVal.data+n), (void *)&((*i)->size), sizeof(int) );
-          //n+=sizeof(int);
-          //const char *data = ( ( *(std::string *) (*i)->var).c_str());
-          //std::memcpy( retVal.data+n, (void*)data, (*i)->size);
-          //COUT(5) << "synchronisable: char: " << (const char *)(retVal.data+n) << " data: " << data << " string: " << *(std::string *)((*i)->var) << std::endl;
-          //n+=(*i)->size;
-          break;
-      }
-    }
-    return true;
-  }*/
-
-  
-  /**
-  * This function takes a syncData struct and takes it to update the variables
-  * @param vars data of the variables
-  * @return true/false
-  */
-  bool Synchronisable::updateData(syncData vars, int mode){
-    if(mode==0x0)
-      mode=state_;
-    unsigned char *data=vars.data;
-    std::list<synchronisableVariable *>::iterator i;
-    if(syncList->empty()){
-      COUT(4) << "Synchronisable::updateData syncList is empty" << std::endl;
-      return false;
-    }
-    COUT(5) << "Synchronisable: objectID " << vars.objectID << ", classID " << vars.classID << " size: " << vars.length << " synchronising data" << std::endl;
-    for(i=syncList->begin(); i!=syncList->end(); i++){
-      if( ((*i)->mode ^ mode) == 0 ){
-        COUT(5) << "synchronisable: not updating variable " << std::endl;
-        continue;  // this variable should only be set
-      }
-      COUT(5) << "Synchronisable: element size: " << (*i)->size << " type: " << (*i)->type << std::endl;
-      bool callback=false;
-      switch((*i)->type){
-      case DATA:
-        if((*i)->callback) // check whether this variable changed (but only if callback was set)
-          if(strncmp((char *)(*i)->var, (char *)data, (*i)->size)!=0)
-            callback=true;
-        memcpy((void*)(*i)->var, data, (*i)->size);
-        data+=(*i)->size;
-        break;
-      case STRING:
-        (*i)->size = *(int *)data;
-        COUT(5) << "string size: " << (*i)->size << std::endl;
-        data+=sizeof(int);
-        if((*i)->callback) // check whether this string changed
-          if( *(std::string *)((*i)->var) != std::string((char *)data) )
-            callback=true;
-        *((std::string *)((*i)->var)) = std::string((const char*)data);
-        COUT(5) << "synchronisable: char: " << (const char*)data << " string: " << std::string((const char*)data) << std::endl;
-        data += (*i)->size;
-        break;
-      }
-      // call the callback function, if defined
-      if(callback && (*i)->callback)
-        (*i)->callback->call();
-    }
-    return true;
-  }
   
   /**
@@ -368,4 +238,7 @@
     assert(this->objectID==objectID);
     assert(this->classID==classID);
+    if(size==3*sizeof(unsigned int)) //if true, only the header is available
+      return true;
+      //assert(0);
     
     COUT(5) << "Synchronisable: objectID " << objectID << ", classID " << classID << " size: " << size << " synchronising data" << std::endl;
@@ -408,5 +281,7 @@
   * @return amount of bytes
   */
-  int Synchronisable::getSize(int mode){
+  int Synchronisable::getSize(unsigned int id, int mode){
+    if(!isMyTick(id))
+      return 0;
     int tsize=0;
     if(mode==0x0)
@@ -435,6 +310,11 @@
    * @return amount of bytes
    */
-  int Synchronisable::getSize2(int mode){
-    return 3*sizeof(unsigned int) + getSize( mode );
+  int Synchronisable::getSize2(unsigned int id, int mode){
+    return sizeof(synchronisableHeader) + getSize( id, mode );
+  }
+  
+  bool Synchronisable::isMyTick(unsigned int id){
+//     return true;
+    return id==0 || id%objectFrequency_==objectID%objectFrequency_;
   }
   
Index: /code/branches/network/src/network/Synchronisable.h
===================================================================
--- /code/branches/network/src/network/Synchronisable.h	(revision 1741)
+++ /code/branches/network/src/network/Synchronisable.h	(revision 1742)
@@ -43,9 +43,8 @@
   };
 
-  struct syncData{
-    unsigned int length;
+  struct synchronisableHeader{
+    unsigned int size;
     unsigned int objectID;
     unsigned int classID;
-    unsigned char *data;
   };
 
@@ -73,11 +72,6 @@
 
     void registerVar(void *var, int size, variableType t, int mode=1, NetworkCallbackBase *cb=0);
-    //  syncData getData();
-    syncData getData(unsigned char *mem, int mode=0x0);
-    bool getData2(unsigned char*& men, int mode=0x0);
-    //bool getData(Bytestream& bs, int mode=0x0);
-    int getSize(int mode=0x0);
-    int getSize2(int mode=0x0);
-    bool updateData(syncData vars, int mode=0x0);
+    bool getData(unsigned char*& men, unsigned int id, int mode=0x0);
+    int getSize2(unsigned int id, int mode=0x0);
     bool updateData(unsigned char*& mem, int mode=0x0);
     bool isMyData(unsigned char* mem);
@@ -92,10 +86,11 @@
     Synchronisable();
   private:
-    /*  bool removeObject(Iterator<Synchronisable> it);*/
-
+    int getSize(unsigned int id, int mode=0x0);
+    bool isMyTick(unsigned int id);
     std::list<synchronisableVariable *> *syncList;
     int datasize;
     static int state_; // detemines wheter we are server (default) or client
     bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server)
+    unsigned int objectFrequency_;
   };
 }
Index: /code/branches/network/src/network/packet/Gamestate.cc
===================================================================
--- /code/branches/network/src/network/packet/Gamestate.cc	(revision 1741)
+++ /code/branches/network/src/network/packet/Gamestate.cc	(revision 1742)
@@ -62,13 +62,11 @@
 {
   int tempsize=0, currentsize=0;
-  assert(data_==0 /*&& bs_==0*/);
-  int size = calcGamestateSize(mode);
+  assert(data_==0);
+  int size = calcGamestateSize(id, mode);
   
   COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
-    //retval->data = (unsigned char*)malloc(size);
   if(size==0)
     return false;
   data_ = new unsigned char[size + sizeof(GamestateHeader)];
-  //bs_ = new Bytestream(data_+sizeof(GamestateHeader), size);
   if(!data_){
     COUT(2) << "GameStateManager: could not allocate memory" << std::endl;
@@ -81,5 +79,5 @@
   orxonox::Iterator<Synchronisable> it;
   for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
-    tempsize=it->getSize2(mode);
+    tempsize=it->getSize2(id, mode);
     
     if(currentsize+tempsize > size){
@@ -89,5 +87,5 @@
       int addsize=tempsize;
       while(++temp)
-        addsize+=temp->getSize2(mode);
+        addsize+=temp->getSize2(id, mode);
       data_ = (unsigned char *)realloc(data_, sizeof(GamestateHeader) + currentsize + addsize);
       if(!data_)
@@ -96,5 +94,5 @@
     }// stop allocate additional memory
 
-    if(!it->getData2(mem, mode))
+    if(!it->getData(mem, id, mode))
       return false; // mem pointer gets automatically increased because of call by reference
     // increase size counter by size of current synchronisable
@@ -199,4 +197,5 @@
 {
   assert(HEADER);
+  assert(!HEADER->compressed);
   uLongf buffer = (uLongf)(((HEADER->normsize + 12)*1.01)+1);
   if(buffer==0)
@@ -228,4 +227,7 @@
 
   //copy and modify header
+#ifndef NDEBUG
+  HEADER->crc32 = calcCRC(data_+sizeof(GamestateHeader), HEADER->normsize);
+#endif
   *GAMESTATE_HEADER(ndata) = *HEADER;
   //delete old data
@@ -241,4 +243,5 @@
 bool Gamestate::decompressData()
 {
+  assert(HEADER);
   assert(HEADER->compressed);
   COUT(3) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", normsize: " << HEADER->normsize << ", compsize: " << HEADER->compsize << std::endl;
@@ -261,4 +264,7 @@
     case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return false;
   }
+#ifndef NDEBUG
+  assert(HEADER->crc32==calcCRC(ndata+sizeof(GamestateHeader), HEADER->normsize));
+#endif
   
   //copy over the header
@@ -276,4 +282,7 @@
 Gamestate *Gamestate::diff(Gamestate *base)
 {
+  assert(HEADER);
+  assert(!HEADER->compressed);
+  assert(!HEADER->diffed);
   //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
   unsigned char *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_);
@@ -310,5 +319,6 @@
 Gamestate *Gamestate::undiff(Gamestate *base)
 {
-  assert(this && base);
+  assert(this && base);assert(HEADER);
+  assert(HEADER->diffed);
   assert(!HEADER->compressed && !GAMESTATE_HEADER(base->data_)->compressed);
   //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
@@ -346,5 +356,5 @@
 
 
-unsigned int Gamestate::calcGamestateSize(int mode)
+unsigned int Gamestate::calcGamestateSize(unsigned int id, int mode)
 {
   int size=0;
@@ -353,5 +363,5 @@
     // get total size of gamestate
   for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it)
-    size+=it->getSize2(mode); // size of the actual data of the synchronisable
+    size+=it->getSize2(id, mode); // size of the actual data of the synchronisable
 //  size+=sizeof(GamestateHeader);
   return size;
Index: /code/branches/network/src/network/packet/Gamestate.h
===================================================================
--- /code/branches/network/src/network/packet/Gamestate.h	(revision 1741)
+++ /code/branches/network/src/network/packet/Gamestate.h	(revision 1742)
@@ -29,5 +29,7 @@
 #include "Packet.h"
 #include "network/Synchronisable.h"
-//#include "util/Bytestream.h"
+#ifndef NDEBUG
+#include "util/CRC32.h"
+#endif
 #include "core/CoreIncludes.h"
 
@@ -48,4 +50,7 @@
   bool complete; // wheter it is a complete gamestate or only partial
   bool compressed;
+#ifndef NDEBUG
+  uint32_t crc32;
+#endif
 };
 
@@ -77,5 +82,5 @@
     bool operator ==(packet::Gamestate gs);
   private:
-    unsigned int calcGamestateSize(int mode=0x0);
+    unsigned int calcGamestateSize(unsigned int id, int mode=0x0);
     void removeObject(orxonox::Iterator<Synchronisable> &it);
 
Index: /code/branches/network/src/orxonox/objects/SpaceShip.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/SpaceShip.cc	(revision 1741)
+++ /code/branches/network/src/orxonox/objects/SpaceShip.cc	(revision 1742)
@@ -243,16 +243,18 @@
 
         // START CREATING ADDITIONAL EFFECTS
-        this->backlight_ = new Backlight(this->maxSpeed_, 0.8);
-        this->attachObject(this->backlight_);
-        this->backlight_->setPosition(-2.35, 0, 0.2);
-        this->backlight_->setColour(this->getProjectileColour());
-
-        this->smoke_ = new ParticleSpawner();
-        this->smoke_->setParticle("Orxonox/smoke5", LODParticle::normal, 0, 0, 3);
-        this->attachObject(this->smoke_);
-
-        this->fire_ = new ParticleSpawner();
-        this->fire_->setParticle("Orxonox/fire3", LODParticle::normal, 0, 0, 1);
-        this->attachObject(this->fire_);
+        /*if(!network::Host::running() || network::Host::isServer()){
+          this->backlight_ = new Backlight(this->maxSpeed_, 0.8);
+          this->attachObject(this->backlight_);
+          this->backlight_->setPosition(-2.35, 0, 0.2);
+          this->backlight_->setColour(this->getProjectileColour());
+    
+          this->smoke_ = new ParticleSpawner();
+          this->smoke_->setParticle("Orxonox/smoke5", LODParticle::normal, 0, 0, 3);
+          this->attachObject(this->smoke_);
+    
+          this->fire_ = new ParticleSpawner();
+          this->fire_->setParticle("Orxonox/fire3", LODParticle::normal, 0, 0, 1);
+          this->attachObject(this->fire_);
+        }*/
         // END CREATING ADDITIONAL EFFECTS
 
Index: /code/branches/network/src/util/CMakeLists.txt
===================================================================
--- /code/branches/network/src/util/CMakeLists.txt	(revision 1741)
+++ /code/branches/network/src/util/CMakeLists.txt	(revision 1742)
@@ -2,4 +2,5 @@
   ArgReader.cc
   Clipboard.cc
+  CRC32.cc
   ExprParser.cc
   Math.cc
Index: /code/branches/network/src/util/CRC32.cc
===================================================================
--- /code/branches/network/src/util/CRC32.cc	(revision 1742)
+++ /code/branches/network/src/util/CRC32.cc	(revision 1742)
@@ -0,0 +1,56 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "CRC32.h"
+
+
+void calcCRCBit(uint32_t &crc32, int bit){
+    int hbit;
+ 
+    hbit=(crc32 & 0x80000000) ? 1 : 0;
+    if (hbit != bit)
+      crc32=(crc32<<1) ^ UTIL_CRC32POLY;
+    else
+      crc32=crc32<<1;
+  }
+
+  uint32_t calcCRC(unsigned char *data, unsigned int dataLength){
+    uint32_t crc32=0;
+    for(unsigned int i=0; i<dataLength; i++){
+      calcCRCBit(crc32, (data[i]&0x1)>>0); // 1st bit
+      calcCRCBit(crc32, (data[i]&0x2)>>1); // 2nd bit
+      calcCRCBit(crc32, (data[i]&0x3)>>2); // 3rd bit
+      calcCRCBit(crc32, (data[i]&0x4)>>3); // 4th bit
+      calcCRCBit(crc32, (data[i]&0x5)>>4); // 5th bit
+      calcCRCBit(crc32, (data[i]&0x6)>>5); // 6th bit
+      calcCRCBit(crc32, (data[i]&0x7)>>6); // 7th bit
+      calcCRCBit(crc32, (data[i]&0x8)>>7); // 8th bit
+    }
+    return crc32;
+  }
+
Index: /code/branches/network/src/util/CRC32.h
===================================================================
--- /code/branches/network/src/util/CRC32.h	(revision 1742)
+++ /code/branches/network/src/util/CRC32.h	(revision 1742)
@@ -0,0 +1,41 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Util_CRC_H__
+#define _Util_CRC_H__
+
+#include <iostream>
+
+#define UTIL_CRC32POLY 0x04C11DB7 /* CRC-32 Polynom */
+
+void calcCRCBit(uint32_t &crc32, int bit);
+
+uint32_t calcCRC(unsigned char *data, unsigned int dataLength);
+
+
+#endif /* _Util_CRC_H__ */
