Index: trunk/src/world_entities/space_ships/space_ship.cc
===================================================================
--- trunk/src/world_entities/space_ships/space_ship.cc	(revision 7868)
+++ trunk/src/world_entities/space_ships/space_ship.cc	(revision 7954)
@@ -93,19 +93,4 @@
   if (root != NULL)
     this->loadParams(root);
-  else
-  {
-    //this->loadModel("models/ships/reap_#.obj");
-    //TODO HACK this is only for network multiplayer games.
-    if( this->getOwner()%2 == 0)
-    {
-      this->loadModel("models/ships/reap_#.obj");
-      this->toList(OM_GROUP_00);
-    }
-    else
-    {
-      this->loadModel( "models/ships/fighter.obj" );
-      this->toList(OM_GROUP_01);
-    }
-  }
 
 }
@@ -234,5 +219,16 @@
   this->burstSystem->setColor(0.5, .5,.5,.8,.8);
   this->burstSystem->setColor(1.0, .8,.8,.8,.0);
-
+  
+  registerVar( new SynchronizeableVector( &velocity, &velocity, "velocity" ) );
+  registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mousedir", PERMISSION_OWNER ) );
+
+  registerVar( new SynchronizeableBool( &bUp, &bUp, "bUp", PERMISSION_OWNER ) );
+  registerVar( new SynchronizeableBool( &bDown, &bDown, "bDown", PERMISSION_OWNER ) );
+  registerVar( new SynchronizeableBool( &bLeft, &bLeft, "bLeft", PERMISSION_OWNER ) );
+  registerVar( new SynchronizeableBool( &bRight, &bRight, "bRight", PERMISSION_OWNER ) );
+  registerVar( new SynchronizeableBool( &bAscend, &bAscend, "bAscend", PERMISSION_OWNER ) );
+  registerVar( new SynchronizeableBool( &bDescend, &bDescend, "bDescend", PERMISSION_OWNER ) );
+  registerVar( new SynchronizeableBool( &bRollL, &bRollL, "bRollL", PERMISSION_OWNER ) );
+  registerVar( new SynchronizeableBool( &bRollR, &bRollR, "bRollR", PERMISSION_OWNER ) );
 }
 
@@ -306,6 +302,5 @@
     if ( isServer() )
     {
-      networkCollisionList.push_back( entity->getHealth() );
-      doCollideNetwork( entity->getHealth() );
+      //TODO handle this
     }
   }
@@ -349,5 +344,5 @@
 
   // spaceship controlled movement
-  if (this->getOwner() == this->getHostID())
+  //if (this->getOwner() == this->getHostID())
     this->calculateVelocity(time);
 
@@ -509,273 +504,4 @@
 
 
-#define MASK_bUp         1
-#define MASK_bDown       2
-#define MASK_bLeft       4
-#define MASK_bRight      8
-#define MASK_bAscend    16
-#define MASK_bDescend   32
-#define MASK_bRollL     64
-#define MASK_bRollR    128
-
-#define DATA_state       1
-#define DATA_flags       2
-#define DATA_mouse       3
-#define DATA_sync        4
-#define DATA_velocity    5
-#define DATA_playables   6
-#define DATA_collision   7
-
-int SpaceShip::writeBytes( const byte * data, int length, int sender )
-{
-  SYNCHELP_READ_BEGIN();
-
-  byte b;
-
-  while ( SYNCHELP_READ_REMAINING()>0 )
-  {
-    SYNCHELP_READ_BYTE( b, NWT_SS_B );
-
-    if ( b == DATA_state )
-    {
-      setRequestedSync( false );
-      setIsOutOfSync( false );
-      SYNCHELP_READ_FKT( WorldEntity::writeState, NWT_SS_WE_STATE );
-
-      continue;
-    }
-
-    if ( b == DATA_flags )
-    {
-      if ( this->getOwner() != this->getHostID() )
-      {
-        byte flags = 0;
-        SYNCHELP_READ_BYTE( flags, NWT_SS_FLAGS );
-
-        bUp = (flags & MASK_bUp) != 0;
-        bDown = (flags & MASK_bDown) != 0;
-        bLeft = (flags & MASK_bLeft) != 0;
-        bRight = (flags & MASK_bRight) != 0;
-        bAscend = (flags & MASK_bAscend) != 0;
-        bDescend = (flags & MASK_bDescend) != 0;
-        bRollL = (flags & MASK_bRollL) != 0;
-        bRollR = (flags & MASK_bRollR) != 0;
-
-      }
-      else
-        assert(false);
-
-      continue;
-    }
-
-    if ( b == DATA_mouse )
-    {
-      if ( this->getOwner() != this->getHostID() )
-      {
-        SYNCHELP_READ_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW );
-        SYNCHELP_READ_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX );
-        SYNCHELP_READ_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY );
-        SYNCHELP_READ_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ );
-      }
-      else
-        assert(false);
-
-      continue;
-    }
-
-    if ( b == DATA_sync )
-    {
-      if ( this->getOwner() != this->getHostID() )
-      {
-        SYNCHELP_READ_FKT( PNode::writeSync, NWT_SS_PN_SYNC );
-      }
-      else
-        assert(false);
-
-      continue;
-    }
-
-    if ( b == DATA_velocity )
-    {
-      if ( this->getOwner() != this->getHostID() )
-      {
-        SYNCHELP_READ_FLOAT( velocity.x, NWT_SS_VELX );
-        SYNCHELP_READ_FLOAT( velocity.y, NWT_SS_VELY );
-        SYNCHELP_READ_FLOAT( velocity.z, NWT_SS_VELZ );
-      }
-      else
-        assert(false);
-
-      continue;
-    }
-
-    if ( b == DATA_playables )
-    {
-      if ( this->getOwner() != this->getHostID() )
-      {
-        SYNCHELP_READ_FKT( Playable::writeSync, NWT_SS_PL_SYNC );
-      }
-      else
-        assert(false);
-    }
-
-    if ( b == DATA_collision )
-    {
-      int n;
-      float energy;
-      SYNCHELP_READ_INT( n, NWT_SS_CO_N );
-
-      for ( int i = 0; i<n; i++ )
-      {
-        SYNCHELP_READ_FLOAT( energy, NWT_SS_CO_CLID );
-        doCollideNetwork( energy );
-      }
-    }
-  }
-
-  return SYNCHELP_READ_N;
-}
-
-
-
-int SpaceShip::readBytes( byte * data, int maxLength, int * reciever )
-{
-  SYNCHELP_WRITE_BEGIN();
-
-  if ( isOutOfSync() && !requestedSync() /*&& this->getHostID()!=this->getOwner()*/ )
-  {
-    (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
-    setRequestedSync( true );
-    PRINTF(0)("REQUESTED STATE %d\n", this->getUniqueID());
-  }
-
-  int rec = this->getRequestSync();
-  if ( rec > 0 )
-  {
-    *reciever = rec;
-
-    PRINTF(0)("SEND STATE %d %d\n", this->getUniqueID(), rec);
-
-    SYNCHELP_WRITE_BYTE( (byte)DATA_state, NWT_SS_B );
-
-    SYNCHELP_WRITE_FKT( WorldEntity::readState, NWT_SS_WE_STATE );
-
-    return SYNCHELP_WRITE_N;
-  }
-
-  *reciever = 0 - this->getOwner();
-  //TODO: implement with SYNCHELP_WRITE_SENT()
-  bool sentSomething = false;
-
-  if ( PNode::needsReadSync() && ( this->getHostID()==0 || this->getOwner() == this->getHostID() ) )
-  {
-    PRINTF(0)("sending PNode::readSync\n");
-    SYNCHELP_WRITE_BYTE( DATA_sync, NWT_SS_B );
-    SYNCHELP_WRITE_FKT( PNode::readSync, NWT_SS_PN_SYNC );
-    sentSomething = true;
-  }
-
-  if ( this->getHostID()==0 || this->getHostID()==this->getOwner() )
-  {
-    byte mask = 0;
-
-    if ( bUp )
-      mask |= MASK_bUp;
-    if ( bDown )
-      mask |= MASK_bDown;
-    if ( bLeft )
-      mask |= MASK_bLeft;
-    if ( bRight )
-      mask |= MASK_bRight;
-    if ( bAscend )
-      mask |= MASK_bAscend;
-    if ( bRollL )
-      mask |= MASK_bRollL;
-    if ( bRollR )
-      mask |= MASK_bRollR;
-
-
-    if ( mask != oldMask )
-    {
-      oldMask = mask;
-      PRINTF(0)("sending mask\n");
-      sentSomething = true;
-      SYNCHELP_WRITE_BYTE( DATA_flags, NWT_SS_B );
-      SYNCHELP_WRITE_BYTE( mask, NWT_SS_FLAGS );
-    }
-#define __OFFSET_MDIR_W 0.01
-#define __OFFSET_MDIR_V 0.01
-    if ( fabs( oldMouseDir.w - mouseDir.w ) > __OFFSET_MDIR_W ||
-         fabs( oldMouseDir.v.x - mouseDir.v.x ) > __OFFSET_MDIR_V ||
-         fabs( oldMouseDir.v.y - mouseDir.v.y ) > __OFFSET_MDIR_V ||
-         fabs( oldMouseDir.v.z - mouseDir.v.z ) > __OFFSET_MDIR_V )
-    {
-      oldMouseDir = mouseDir;
-
-      SYNCHELP_WRITE_BYTE( DATA_mouse, NWT_SS_B );
-      PRINTF(0)("SENDING mousedir\n");
-      sentSomething = true;
-      SYNCHELP_WRITE_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW );
-      SYNCHELP_WRITE_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX );
-      SYNCHELP_WRITE_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY );
-      SYNCHELP_WRITE_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ );
-    }
-#define __OFFSET_VEL 0.05
-    if ( fabs( oldVelocity.x - velocity.x ) > __OFFSET_VEL*fabs(oldVelocity.x)+0.1 ||
-         fabs( oldVelocity.y - velocity.y ) > __OFFSET_VEL*fabs(oldVelocity.y)+0.1 ||
-         fabs( oldVelocity.z - velocity.z ) > __OFFSET_VEL*fabs(oldVelocity.z)+0.1 )
-    {
-      oldVelocity.x = velocity.x;
-      oldVelocity.y = velocity.y;
-      oldVelocity.z = velocity.z;
-      PRINTF(0)("SENDING velocity\n");
-      sentSomething = true;
-      SYNCHELP_WRITE_BYTE( DATA_velocity, NWT_SS_B );
-      SYNCHELP_WRITE_FLOAT( velocity.x, NWT_SS_VELX );
-      SYNCHELP_WRITE_FLOAT( velocity.y, NWT_SS_VELY );
-      SYNCHELP_WRITE_FLOAT( velocity.z, NWT_SS_VELZ );
-    }
-
-    while ( Playable::needsReadSync() )
-    {
-      sentSomething = true;
-      PRINTF(0)("SYNCHELP_WRITE_FKT( Playable::readSync, NWT_SS_PL_SYNC )\n");
-      SYNCHELP_WRITE_BYTE( DATA_playables, NWT_SS_B );
-      SYNCHELP_WRITE_FKT( Playable::readSync, NWT_SS_PL_SYNC );
-    }
-
-  }
-
-  if ( !sentSomething )
-  {
-    *reciever = 0;
-
-    if ( networkCollisionList.size()>0 )
-    {
-      SYNCHELP_WRITE_BYTE( DATA_collision, NWT_SS_B );
-
-      SYNCHELP_WRITE_INT( networkCollisionList.size(), NWT_SS_CO_N );
-
-      for ( std::list<float>::iterator it = networkCollisionList.begin(); it!=networkCollisionList.end(); it++ )
-      {
-        SYNCHELP_WRITE_FLOAT( *it, NWT_SS_CO_CLID );
-      }
-
-      networkCollisionList.clear();
-    }
-  }
-
-  return SYNCHELP_WRITE_N;
-}
-
-
-void SpaceShip::doCollideNetwork( float energy )
-{
-  this->decreaseHealth( energy );
-  if( this->getHealth() <= 0)
-  {
-    this->die();
-  }
-}
-
-
-
+
+
