Index: /trunk/src/lib/collision_detection/bounding_volume.h
===================================================================
--- /trunk/src/lib/collision_detection/bounding_volume.h	(revision 9007)
+++ /trunk/src/lib/collision_detection/bounding_volume.h	(revision 9008)
@@ -38,4 +38,6 @@
     const int*          triangleIndexes;            //!< Array with the triangle indexes in modelInfo
     int                 triangleIndexesLength;      //!< length of the indexes array
+
+    float               radius;                     //!< the radius of the box (longest axis)
 };
 
Index: /trunk/src/lib/collision_detection/obb_tree_node.cc
===================================================================
--- /trunk/src/lib/collision_detection/obb_tree_node.cc	(revision 9007)
+++ /trunk/src/lib/collision_detection/obb_tree_node.cc	(revision 9008)
@@ -364,4 +364,5 @@
     }
   }
+  this->bvElement->radius = longestAxis;
   PRINTF(4)("\nLongest Axis is: Nr %i with a half-length of:%11.2f\n", longestAxisIndex, longestAxis);
 
@@ -454,4 +455,12 @@
     return;
 
+  float distanceMax = this->bvElement->radius + ((OBBTreeNode*)treeNode)->bvElement->radius;
+  float distance = fabs((nodeA->getAbsCoor() - nodeB->getAbsCoor()).len());
+
+
+//   if( distance < distanceMax)
+//     PRINTF(0)(" %s (%s: group %i) vs %s (%s: group %i): distanceMax: %f, distance: %f\n", nodeA->getClassName(), nodeA->getName(), nodeA->getOMListNumber(), nodeB->getClassName(),  nodeB->getName(), nodeB->getOMListNumber(), distanceMax, distance);
+
+
   PRINTF(4)("collideWith\n");
   PRINTF(5)("Checking OBB %i vs %i: ", this->getIndex(), treeNode->getIndex());
@@ -482,8 +491,17 @@
       if( this->overlapTest(this->nodeLeft->bvElement, treeNode->bvElement, nodeA, nodeB))
       {
+        bool bAdvance = false;
         if( treeNode->nodeLeft != NULL)
           this->nodeLeft->collideWith(treeNode->nodeLeft, nodeA, nodeB);
+        else
+          bAdvance = true;
+
         if( treeNode->nodeRight != NULL)
           this->nodeLeft->collideWith(treeNode->nodeRight, nodeA, nodeB);
+        else
+          bAdvance = true;
+
+        if( bAdvance)
+          this->nodeLeft->collideWith(treeNode, nodeA, nodeB);  // go down the other tree also
       }
     }
@@ -494,8 +512,18 @@
       if( this->overlapTest(this->nodeRight->bvElement, treeNode->bvElement, nodeA, nodeB))
       {
+        bool bAdvance = false;
+
         if( treeNode->nodeLeft != NULL)
           this->nodeRight->collideWith(treeNode->nodeLeft, nodeA, nodeB);
+        else
+          bAdvance = true;
+
         if( treeNode->nodeRight != NULL)
           this->nodeRight->collideWith(treeNode->nodeRight, nodeA, nodeB);
+        else
+          bAdvance = true;
+
+        if( bAdvance)
+          this->nodeRight->collideWith(treeNode, nodeA, nodeB);  // go down the other tree also
       }
     }
@@ -516,4 +544,5 @@
         (treeNode->nodeRight == NULL && treeNode->nodeLeft == NULL)) )
     {
+//       PRINTF(0)("----------------------------------------------\n\n\n\n\n\n--------------------------------\n\n\n");
       nodeA->registerCollision(nodeA, nodeB, (BoundingVolume*)this->bvElement, (BoundingVolume*)treeNode->bvElement);
     }
Index: /trunk/src/lib/collision_reaction/cr_object_damage.cc
===================================================================
--- /trunk/src/lib/collision_reaction/cr_object_damage.cc	(revision 9007)
+++ /trunk/src/lib/collision_reaction/cr_object_damage.cc	(revision 9008)
@@ -56,5 +56,5 @@
   float damage = 0.0f;
 
-  PRINTF(4)("Dealing damage - Handling collision: %s vs %s\n",
+  PRINTF(0)("Dealing damage - Handling collision: %s vs %s\n",
             collision->getEntityA()->getClassName(),
             collision->getEntityB()->getClassName());
@@ -63,5 +63,5 @@
   if( collision->isEntityACollide()) {
     damage = collision->getEntityB()->getDamage();
-    collision->getEntityA()->hit(damage);
+    collision->getEntityA()->hit(damage, collision->getEntityB());
   }
   PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassName());
@@ -69,5 +69,5 @@
   if( collision->isEntityBCollide()) {
     damage = collision->getEntityA()->getDamage();
-    collision->getEntityB()->hit(damage);
+    collision->getEntityB()->hit(damage, collision->getEntityA());
   }
   PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassName());
Index: /trunk/src/lib/network/message_manager.h
===================================================================
--- /trunk/src/lib/network/message_manager.h	(revision 9007)
+++ /trunk/src/lib/network/message_manager.h	(revision 9008)
@@ -32,5 +32,6 @@
   MSGID_PREFEREDTEAM,
   MSGID_CHANGENICKNAME,
-  MSGID_CHATMESSAGE
+  MSGID_CHATMESSAGE,
+  MSGID_RESPAWN
 };
 
Index: /trunk/src/lib/network/network_game_manager.cc
===================================================================
--- /trunk/src/lib/network/network_game_manager.cc	(revision 9007)
+++ /trunk/src/lib/network/network_game_manager.cc	(revision 9008)
@@ -39,4 +39,6 @@
 
 #include "network_game_manager.h"
+
+#include "multiplayer_team_deathmatch.h"
 
 
@@ -118,4 +120,7 @@
   stats->setPlayableUniqueId( playable.getUniqueID() );
   stats->setModelFileName( playableModel );
+  
+  if ( rules.isA( CL_MULTIPLAYER_TEAM_DEATHMATCH ) )
+    dynamic_cast<MultiplayerTeamDeathmatch*>(&rules)->respawnPlayable( &playable, team, 0.0f );
   
   return true;
Index: /trunk/src/story_entities/multi_player_world.cc
===================================================================
--- /trunk/src/story_entities/multi_player_world.cc	(revision 9007)
+++ /trunk/src/story_entities/multi_player_world.cc	(revision 9008)
@@ -93,26 +93,38 @@
 void MultiPlayerWorld::collisionDetection()
 {
+  //CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), this->dataTank->objectManager->getObjectList(OM_PLAYERS));
+
+  PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_PLAYERS_PROJ\n\n");
+  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ),
+  this->dataTank->objectManager->getObjectList(OM_PLAYERS));
+  PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_GROUP_01_PROJ\n\n");
   CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS),
-    this->dataTank->objectManager->getObjectList(OM_PLAYERS));
+    this->dataTank->objectManager->getObjectList(OM_GROUP_00_PROJ));
+  PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_GROUP_01_PROJ\n\n");
   CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS),
+    this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ));
+  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS),
+    this->dataTank->objectManager->getObjectList(OM_GROUP_00));
+  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS),
+    this->dataTank->objectManager->getObjectList(OM_GROUP_01));
+
+
+
+  PRINTF(5)("\n-----------------------------------------\nchecking OM_GROUP_00 vs OM_GROUP_01_PROJ\n\n");
+  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),
+    this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ));
+  PRINTF(5)("\n-----------------------------------------\nchecking OM_GROUP_00 vs OM_GROUP_01\n\n");
+  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),
+    this->dataTank->objectManager->getObjectList(OM_GROUP_01));
+  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),
     this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ));
 
-  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS),
-  this->dataTank->objectManager->getObjectList(OM_GROUP_00_PROJ));
-  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS),
-  this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ));
-
-  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),
-    this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ));
+  PRINTF(5)("\n-----------------------------------------\nchecking OM_GROUP_01 vs OM_GROUP_00_PROJ\n\n");
   CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01),
     this->dataTank->objectManager->getObjectList(OM_GROUP_00_PROJ));
-  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),
-    this->dataTank->objectManager->getObjectList(OM_GROUP_01));
-
-  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),
-    this->dataTank->objectManager->getObjectList(OM_COMMON));
   CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01),
-    this->dataTank->objectManager->getObjectList(OM_COMMON));
-
+    this->dataTank->objectManager->getObjectList(OM_GROUP_00));
+  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01),
+    this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ));
 }
 
Index: /trunk/src/story_entities/multi_player_world_data.cc
===================================================================
--- /trunk/src/story_entities/multi_player_world_data.cc	(revision 9007)
+++ /trunk/src/story_entities/multi_player_world_data.cc	(revision 9008)
@@ -233,4 +233,6 @@
   this->tickLists.push_back(OM_ENVIRON);
   this->tickLists.push_back(OM_COMMON);
+  this->tickLists.push_back(OM_PLAYERS);
+  this->tickLists.push_back(OM_PLAYERS_PROJ);
   this->tickLists.push_back(OM_GROUP_00);
   this->tickLists.push_back(OM_GROUP_00_PROJ);
@@ -241,4 +243,6 @@
   this->drawLists.push_back(OM_ENVIRON);
   this->drawLists.push_back(OM_COMMON);
+  this->drawLists.push_back(OM_PLAYERS);
+  this->drawLists.push_back(OM_PLAYERS_PROJ);
   this->drawLists.push_back(OM_GROUP_00);
   this->drawLists.push_back(OM_GROUP_00_PROJ);
Index: /trunk/src/util/game_rules.cc
===================================================================
--- /trunk/src/util/game_rules.cc	(revision 9007)
+++ /trunk/src/util/game_rules.cc	(revision 9008)
@@ -90,6 +90,8 @@
   if ( !SharedNetworkData::getInstance()->isGameServer() )
     return;
+
   PRINTF(0)("Received Event: Kill\n");
-  this->killList.push_back(kill);
+
+  this->killList.push_back( kill );
 }
 
Index: /trunk/src/util/game_rules.h
===================================================================
--- /trunk/src/util/game_rules.h	(revision 9007)
+++ /trunk/src/util/game_rules.h	(revision 9008)
@@ -9,4 +9,5 @@
 
 #include "base_object.h"
+#include <list>
 #include <vector>
 
@@ -54,5 +55,5 @@
     std::vector<MissionGoal*>   missionList;            //!< list of mission goals
 
-    std::vector<Kill>          killList;               //!<  list of kills in the world
+    std::list<Kill>             killList;               //!<  list of kills in the world
 };
 
Index: /trunk/src/util/multiplayer_team_deathmatch.cc
===================================================================
--- /trunk/src/util/multiplayer_team_deathmatch.cc	(revision 9007)
+++ /trunk/src/util/multiplayer_team_deathmatch.cc	(revision 9008)
@@ -68,5 +68,5 @@
   this->numTeams = 2;
   this->currentGameState = GAMESTATE_PRE_GAME;
-  this->gameStateTimer = 10.0f;
+  this->gameStateTimer = 3.0f;
   this->bShowTeamChange = false;
 
@@ -85,5 +85,5 @@
   subscribeEvent( ES_MENU, SDLK_F1 );
   subscribeEvent( ES_MENU, KeyMapper::PEV_FIRE1 );
-  
+
   this->notifier = new OrxGui::GLGuiNotifier();
   this->notifier->show();
@@ -106,5 +106,5 @@
   unsubscribeEvent( ES_MENU, SDLK_F1 );
   unsubscribeEvent( ES_MENU, KeyMapper::PEV_FIRE1 );
-  
+
   if ( this->notifier )
   {
@@ -219,16 +219,14 @@
   if ( !SharedNetworkData::getInstance()->isGameServer() )
     return;
-    
+
   //handle kills
-  for ( std::vector<Kill>::iterator it = this->killList.begin(); it != this->killList.end();  )
-  {
-    std::vector<Kill>::iterator delit = it;
-    
-    onKill( it->getKiller()->getOwner(), it->getVictim()->getOwner() );
-    
-    it++;
-    killList.erase( delit );
+  while ( this->killList.begin() != this->killList.end() )
+  {
+    onKill( this->killList.begin()->getVictim(), this->killList.begin()->getKiller() );
+    this->killList.erase( this->killList.begin() );
   }
   
+
+
   gameStateTimer -= dt;
   //PRINTF(0)("TICK %f\n", gameStateTimer);
@@ -488,4 +486,6 @@
   stats.setModelFileName( playableModel );
 
+  this->respawnPlayable( &playable, stats.getPreferedTeamId(), 0.0f );
+
   if ( oldPlayable )
   {
@@ -558,5 +558,5 @@
   else if ( event.type == SDLK_TAB )
   {
-    if ( !event.bPressed )
+    if ( currentGameState == GAMESTATE_GAME && event.bPressed && !EventHandler::getInstance()->isPressed( SDLK_RALT ) && !EventHandler::getInstance()->isPressed( SDLK_LALT ) )
     {
       EventHandler::getInstance()->pushState( ES_MENU );
@@ -627,5 +627,5 @@
   statsBox = new OrxGui::GLGuiBox();
   statsBox->setAbsCoor2D( 300, 100 );
-  
+
   this->table = new OrxGui::GLGuiTable(0,0);
 
@@ -645,5 +645,5 @@
       statsBox = NULL;
     }
-      
+
     EventHandler::getInstance()->popState();
 }
@@ -664,17 +664,17 @@
   headers.push_back("");
   this->table->setHeader(headers);
-  
+
   std::map<int,std::string> fragsTeam0;
   std::map<int,std::string> fragsTeam1;
-  
+
   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
-  
+
   if ( !list )
     return;
-  
+
   for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
   {
     PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
-    
+
     if ( stats.getTeamId() == 0 || stats.getTeamId() == 1 )
     {
@@ -685,9 +685,9 @@
     }
   }
-  
+
   char st[10];
   int i = 0;
-  
-  
+
+
   i = 2;
   for ( std::map<int,std::string>::const_iterator it = fragsTeam0.begin(); it != fragsTeam0.end(); it++ )
@@ -699,5 +699,5 @@
     i++;
   }
-  
+
   i = 2;
   for ( std::map<int,std::string>::const_iterator it = fragsTeam1.begin(); it != fragsTeam1.end(); it++ )
@@ -712,48 +712,51 @@
 /**
  * this function is called when a player kills another one or himself
- * @param killedUserId 
- * @param userId 
- */
-void MultiplayerTeamDeathmatch::onKill( int killedUserId, int userId )
-{
-  assert( PlayerStats::getStats( killedUserId ) );
-  assert( PlayerStats::getStats( userId ) );
+ * @param killedUserId
+ * @param userId
+ */
+void MultiplayerTeamDeathmatch::onKill( WorldEntity * victim, WorldEntity * killer )
+{
+  if ( !victim )
+    return;
+  if ( !killer )
+    return;
   
-  PlayerStats & killedStats = *PlayerStats::getStats( killedUserId );
-  PlayerStats & stats = *PlayerStats::getStats( userId );
+  int killerUserId = killer->getOwner();
+  int victimUserId = victim->getOwner();
+
+  PlayerStats & victimStats = *PlayerStats::getStats( victimUserId );
+  PlayerStats & killerStats = *PlayerStats::getStats( killerUserId );
   
-  if ( killedUserId != userId )
-    stats.setScore( stats.getScore() + 1 );
+  if ( killerStats.getPlayable() != killer || victimStats.getPlayable() != victim )
+    return;
+
+  //check for suicide
+  if ( killerUserId != victimUserId )
+  {
+    //check for teamkill
+    if ( victimStats.getTeamId() != killerStats.getTeamId() )
+    {
+      killerStats.setScore( killerStats.getScore() + 1 );
+    }
+    else
+    {
+      killerStats.setScore( killerStats.getScore() - 1 );
+    }
+  }
   else
-    stats.setScore( stats.getScore() - 1 );
-  
-  if ( killedUserId == SharedNetworkData::getInstance()->getHostID() )
+    killerStats.setScore( killerStats.getScore() - 1 );
+
+  if ( victimUserId == SharedNetworkData::getInstance()->getHostID() )
   {
     this->bLocalPlayerDead = true;
     this->showStats();
   }
-  
-  const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
-  
-  assert( list );
-  
-  std::vector<SpawningPoint*> spList;
-  
-  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
-  {
-    SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it);
-    
-    if ( sp->getTeamId() < 0 || sp->getTeamId() == killedStats.getTeamId() )
-      spList.push_back( sp );
-  }
- 
-  int n = spList.size()*rand();
-  
-  spList[n]->pushEntity( killedStats.getPlayable(), 3 );
+
+  this->respawnPlayable( victimStats.getPlayable(), victimStats.getTeamId(), 3.0f );
 }
 
 /**
  * this function is called on player respawn
- * @param userId 
+ * @param userId
  */
 void MultiplayerTeamDeathmatch::onRespawn( int userId )
@@ -768,5 +771,5 @@
 /**
  * this function is called on player respawn
- * @param we 
+ * @param we
  */
 void MultiplayerTeamDeathmatch::registerSpawn( WorldEntity * we )
@@ -775,2 +778,37 @@
 }
 
+
+void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay )
+{
+  const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
+
+  assert( list );
+
+  std::vector<SpawningPoint*> spList;
+
+  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
+  {
+    SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it);
+
+    if ( sp->getTeamId() == teamId )
+      spList.push_back( sp );
+  }
+
+  if ( spList.size() == 0 )
+  {
+    for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
+    {
+      SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it);
+
+      if ( sp->getTeamId() < 0 )
+        spList.push_back( sp );
+    }
+  }
+
+  assert( spList.size() != 0 );
+
+  int n = (int)((float)spList.size() * (float)rand()/(float)RAND_MAX);
+
+  spList[n]->pushEntity( playable, delay );
+}
+
Index: /trunk/src/util/multiplayer_team_deathmatch.h
===================================================================
--- /trunk/src/util/multiplayer_team_deathmatch.h	(revision 9007)
+++ /trunk/src/util/multiplayer_team_deathmatch.h	(revision 9008)
@@ -56,8 +56,10 @@
     virtual void process(const Event &event);
     
-    void onKill( int killedUserId, int userId );
+    void onKill( WorldEntity * victim, WorldEntity * killer );
     void onRespawn( int userId );
     
     virtual void handleChatMessage( int userId, const std::string & message, int messageType );
+    
+    void respawnPlayable( Playable * playable, int teamId, float delay );
 
   protected:
Index: /trunk/src/util/object_manager.cc
===================================================================
--- /trunk/src/util/object_manager.cc	(revision 9007)
+++ /trunk/src/util/object_manager.cc	(revision 9008)
@@ -212,4 +212,7 @@
     "background",
     "common",
+
+    "players",
+    "players-proj",
 
     "group00",
Index: /trunk/src/world_entities/playable.cc
===================================================================
--- /trunk/src/world_entities/playable.cc	(revision 9007)
+++ /trunk/src/world_entities/playable.cc	(revision 9008)
@@ -65,5 +65,5 @@
 
   this->bDead = false;
-  
+
   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
 
@@ -392,17 +392,4 @@
     State::getGameRules()->onPlayerSpawn();
 
-
-  if( this->getOwner() % 2 == 0)
-  {
-    //     this->toList(OM_GROUP_00);
-    this->setAbsCoor(213.37, 57.71, -47.98);
-    this->setAbsDir(0, 0, 1, 0);
-  }
-  else
-  { // red team
-    //     this->toList(OM_GROUP_01);
-    this->setAbsCoor(-314.450, 40.701, 83.554);
-    this->setAbsDir(1.0, -0.015, -0.012, 0.011);
-  }
   this->reset();
   this->bDead = false;
Index: /trunk/src/world_entities/space_ships/space_ship.cc
===================================================================
--- /trunk/src/world_entities/space_ships/space_ship.cc	(revision 9007)
+++ /trunk/src/world_entities/space_ships/space_ship.cc	(revision 9008)
@@ -220,5 +220,5 @@
   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 ) );
@@ -384,4 +384,5 @@
   this->shiftCoor(move);
 
+//   PRINTF(0)("id of %s is: %i\n", this->getName(), this->getOMListNumber());
 
 }
@@ -504,5 +505,15 @@
 }
 
-
-
-
+void SpaceShip::destroy( )
+{
+  PRINTF(0)("spaceship destroy\n");
+}
+
+void SpaceShip::respawn( )
+{
+  toList( OM_PLAYERS );
+}
+
+
+
+
Index: /trunk/src/world_entities/space_ships/space_ship.h
===================================================================
--- /trunk/src/world_entities/space_ships/space_ship.h	(revision 9007)
+++ /trunk/src/world_entities/space_ships/space_ship.h	(revision 9008)
@@ -36,4 +36,7 @@
     virtual void postSpawn();
     virtual void leftWorld();
+    
+    virtual void destroy();
+    virtual void respawn();
 
     virtual void collidesWith(WorldEntity* entity, const Vector& location);
Index: /trunk/src/world_entities/spawning_point.cc
===================================================================
--- /trunk/src/world_entities/spawning_point.cc	(revision 9007)
+++ /trunk/src/world_entities/spawning_point.cc	(revision 9008)
@@ -22,4 +22,6 @@
 #include "world_entity.h"
 
+#include "class_list.h"
+
 #include "compiler.h"
 
@@ -27,39 +29,32 @@
 #include "game_rules.h"
 
+#include "shared_network_data.h"
+
+CREATE_FACTORY( SpawningPoint, CL_SPAWNING_POINT );
 
 /**
  *  constructor
  */
-SpawningPoint::SpawningPoint (ClassID classid, const Vector& position)
-{
-  this->setAbsCoor(position);
-  this->classid = classid;
-  this->mode = SPT_ALL_AT_ONCE;
-  this->delay = 0;
+SpawningPoint::SpawningPoint( const TiXmlElement * root )
+{
+  this->setAbsCoor( 0, 0, 0 );
 
   this->init();
-}
-
-
-/**
- *  standard constructor
- */
-SpawningPoint::SpawningPoint (const Vector& position, ClassID classid, SpawningPointMode mode, float delay)
-{
-  this->setAbsCoor(position);
-  this->classid = classid;
-  this->mode = mode;
-  this->delay = delay;
-
-  this->init();
-}
-
-
+  
+  if (root != NULL)
+    this->loadParams(root);
+}
 
 void SpawningPoint::init()
 {
   this->setClassID(CL_SPAWNING_POINT, "SpawningPoint");
+  PRINTF(0)("Created SpawningPoint\n");
   
   this->teamId = -1;
+  this->localTimer = 0.0f;
+  
+  this->toList( OM_DEAD_TICK );
+  
+  MessageManager::getInstance()->registerMessageHandler( MSGID_RESPAWN, respawnMessageHandler, NULL );
 }
 
@@ -81,21 +76,7 @@
   WorldEntity::loadParams(root);
 
-  /* now load the frequency */
-  LoadParam(root, "delay", this, SpawningPoint, setSpawningDelay)
-      .describe("sets the delay of the spawning point");
-      
   /* load teamId */
   LoadParam(root, "teamId", this, SpawningPoint, setTeamId)
       .describe("sets teamId");
-
-
-  /* now load the seed */
-//   LoadParam(root, "entity", this, SpawningPoint, setSpawningEntity)
-//       .describe("sets the spawning entity");
-
-  /* now load the seed */
-/*  LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity)
-      .describe("sets the class id of the entity to spawn")
-      .defaultValues(CL_WORLD_ENTITY);*/
 }
 
@@ -106,9 +87,8 @@
  *  @param entity WorldEntity to be added
  */
-void SpawningPoint::pushEntity(WorldEntity* entity, float delay)
+void SpawningPoint::pushEntity(Playable* entity, float delay)
 {
   QueueEntry qe;
   qe.entity = entity;
-  qe.list = entity->getOMListNumber();
   qe.respawnTime = this->localTimer + delay;
   
@@ -120,7 +100,7 @@
  *  spawn the entity
  */
-void SpawningPoint::spawn(WorldEntity* entity)
-{
-  PRINTF(1)("Spawningpoint spawns new Entity (%s)\n", entity->getClassName());
+void SpawningPoint::spawn(Playable* entity)
+{
+  PRINTF(0)("Spawningpoint spawns Entity (%s)\n", entity->getClassName());
 
 
@@ -129,4 +109,11 @@
   
   //TODO set camera (not smooth)
+  
+  if ( State::getGameRules() )
+  {
+    (State::getGameRules())->registerSpawn( entity );
+  }
+  
+  entity->respawn();
 }
 
@@ -141,9 +128,8 @@
 {
   this->localTimer += dt;
-
   std::list<QueueEntry>::iterator it = this->queue.begin();
   for( ; it != this->queue.end(); )
   {
-    
+    //PRINTF(0)("%f <= %f\n", it->respawnTime, this->localTimer);
     if( it->respawnTime <= this->localTimer)
     {
@@ -151,11 +137,7 @@
       this->spawn(it->entity);
       
-      it->entity->toList( it->list );
-      
-      if ( State::getGameRules() )
-      {
-        (State::getGameRules())->registerSpawn( it->entity );
-      }
-      
+      if ( SharedNetworkData::getInstance()->isGameServer() )
+        this->sendRespawnMessage( it->entity->getUniqueID() );
+
       std::list<QueueEntry>::iterator delit = it;
       it++;
@@ -179,3 +161,83 @@
  */
 void SpawningPoint::draw()
-{}
+{
+}
+
+void SpawningPoint::sendRespawnMessage( int uniqueId )
+{
+  byte * buf = new byte[2*INTSIZE];
+  
+  assert( Converter::intToByteArray( this->getUniqueID(), buf, INTSIZE ) == INTSIZE );
+  assert( Converter::intToByteArray( uniqueId, buf + INTSIZE, INTSIZE ) == INTSIZE );
+  
+  MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
+}
+
+bool SpawningPoint::respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
+{
+  if ( SharedNetworkData::getInstance()->isGameServer() )
+  {
+    PRINTF(2)("server received spawn message!\n");
+    return true;
+  }
+    
+  int spUniqueId;
+  int uniqueId;
+  
+  if ( dataLength != 2*INTSIZE )
+  {
+    PRINTF(2)("spawn message has wrong size: %d\n", dataLength );
+    return true;
+  }
+  
+  assert( Converter::byteArrayToInt( data, &spUniqueId ) == INTSIZE );
+  assert( Converter::byteArrayToInt( data+INTSIZE, &uniqueId ) == INTSIZE );
+  
+  SpawningPoint * sp = NULL;
+  Playable      * playable = NULL;
+  
+  const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
+  
+  if ( list )
+  {
+    for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
+    {
+      if ( dynamic_cast<SpawningPoint*>(*it)->getUniqueID() == uniqueId )
+      {
+        sp = dynamic_cast<SpawningPoint*>(*it);
+        break;
+      }
+    }
+  }
+  
+  if ( !sp )
+  {
+    PRINTF(2)("could not find spawning point\n");
+    return false;
+  }
+  
+  list = ClassList::getList( CL_PLAYABLE );
+  
+  if ( list )
+  {
+    for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
+    {
+      if ( dynamic_cast<Playable*>(*it)->getUniqueID() == uniqueId )
+      {
+        playable = dynamic_cast<Playable*>(*it);
+        break;
+      }
+    }
+  }
+  
+  if ( !playable )
+  {
+    PRINTF(2)("could not find playable\n");
+    return false;
+  }
+  
+  sp->spawn( playable );
+  
+  return true;
+}
+
Index: /trunk/src/world_entities/spawning_point.h
===================================================================
--- /trunk/src/world_entities/spawning_point.h	(revision 9007)
+++ /trunk/src/world_entities/spawning_point.h	(revision 9008)
@@ -10,4 +10,6 @@
 #include "playable.h"
 
+#include "message_manager.h"
+
 #include <list>
 
@@ -18,6 +20,5 @@
 {
   float respawnTime;
-  WorldEntity * entity;
-  OM_LIST list;
+  Playable * entity;
 };
 
@@ -43,6 +44,5 @@
 
   public:
-    SpawningPoint (ClassID classID, const Vector& position = Vector(0.0, 0.0, 0.0));
-    SpawningPoint (const Vector& position, ClassID classID, SpawningPointMode type, float delay);
+    SpawningPoint(const TiXmlElement* root = NULL);
     virtual ~SpawningPoint ();
     void init();
@@ -50,15 +50,8 @@
     virtual void loadParams(const TiXmlElement* root);
 
-    /**  sets the entity that is going to be spawned by this point @param classID: the id from the class_id.h file */
-    void SpawningPoint::setSpawningEntity(ClassID classid) { this->classid = classid; }
-    /** sets the frequency with which the point is going to spawn entities (1/sec) @param frequency: the frequency */
-    void SpawningPoint::setSpawningDelay(float delay) { this->delay = delay; }
-    /** sets the spawning point mode @param mode: the mode */
-    void SpawningPoint::setSpawningMode(int mode) { this->mode = (SpawningPointMode)mode; }
-    
     inline int getTeamId(){ return this->teamId; }
     inline void setTeamId( int teamId ){ this->teamId = teamId; }
 
-    void pushEntity(WorldEntity* entity, float delay = 0);
+    void pushEntity(Playable* entity, float delay = 0);
 
     /** activates the spawning point */
@@ -74,14 +67,13 @@
 
   private:
-    void spawn(WorldEntity* entity);
+    void spawn(Playable* entity);
+    
+    void sendRespawnMessage( int uniqueId );
+    static bool respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
 
 
   private:
-    float                           delay;                          //!< the timer that counts down until the next spawn
     float                           localTimer;                     //!< the local timer
-    float                           seed;                           //!< the random seed of the position
     int                             teamId;                         //!< only spawn players of this team
-    ClassID                         classid;                        //!< the classid of the entity to spawn
-    SpawningPointMode               mode;                           //!< the mode of the spawning point
     std::list<QueueEntry>           queue;                          //!< queue of waiting WorldEntities to be spawned
     bool                            bSpawning;                      //!< flag to indicate if this spawning point is active or not
Index: /trunk/src/world_entities/world_entity.cc
===================================================================
--- /trunk/src/world_entities/world_entity.cc	(revision 9007)
+++ /trunk/src/world_entities/world_entity.cc	(revision 9008)
@@ -88,4 +88,5 @@
   modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
   scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling" ) );
+  list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list" ) );
 }
 
@@ -733,5 +734,5 @@
  *  @param damage damage to be dealt
  */
-void WorldEntity::hit(float damage)
+void WorldEntity::hit(float damage, WorldEntity* killer)
 {
   this->decreaseHealth(damage);
@@ -748,5 +749,5 @@
 
     if( State::getGameRules() != NULL)
-      State::getGameRules()->registerKill(Kill(NULL, this));
+      State::getGameRules()->registerKill(Kill(killer, this));
   }
 }
@@ -832,4 +833,9 @@
   }
 
+  if ( std::find( id.begin(), id.end(), list_handle ) != id.end() )
+  {
+    this->toList( (OM_LIST)list_write );
+  }
+
   PNode::varChangeHandler( id );
 }
Index: /trunk/src/world_entities/world_entity.h
===================================================================
--- /trunk/src/world_entities/world_entity.h	(revision 9007)
+++ /trunk/src/world_entities/world_entity.h	(revision 9008)
@@ -99,5 +99,6 @@
   void setOnGround(bool flag) { this->bOnGround = flag; }
 
-  virtual void hit(float damage);
+  virtual void hit(float damage, WorldEntity* killer);
+
   virtual void destroy();
 
@@ -195,4 +196,7 @@
   int                     modelFileName_handle;            //!< handle for syncing var
 
+  int                     list_write;                      //!< entity's list
+  int                     list_handle;                     //!< handle for list changes
+
   CollisionHandle*        collisionHandles[CREngine::CR_NUMBER];  //!< the list of the collision reactions
   bool                    bReactive;                              //!< true if there is at least one collision reaction subscibed
