Index: /branches/network/src/lib/network/player_stats.h
===================================================================
--- /branches/network/src/lib/network/player_stats.h	(revision 8187)
+++ /branches/network/src/lib/network/player_stats.h	(revision 8188)
@@ -1,166 +1,81 @@
-/*
-   orxonox - the future of 3D-vertical-scrollers
+/*!
+ * @file player_stats.h
+ * @brief Definition of PlayerStats
+ */
 
-   Copyright (C) 2004 orx
+#ifndef _PLAYER_STATS_H
+#define _PLAYER_STATS_H
 
-   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, or (at your option)
-   any later version.
+#include "synchronizeable.h"
+#include "playable.h"
 
-### File Specific:
-   main-programmer: Christoph Renner
-   co-programmer: ...
-*/
+#include <string>
+#include <list>
 
-#include "player_stats.h"
+enum
+{
+  TEAM_NOTEAM = -3,
+  TEAM_RANDOM = -2,
+  TEAM_SPECTATOR = -1
+};
 
-#include "class_list.h"
-#include "src/lib/util/loading/factory.h"
+//! A class for storing player information
+class PlayerStats : public Synchronizeable 
+{
 
-#include "player.h"
-#include "state.h"
-#include "shared_network_data.h"
+  public:
+    PlayerStats( const TiXmlElement* root = NULL );
+    PlayerStats( int userId );
+    virtual ~PlayerStats();
+    
+    virtual void varChangeHandler( std::list<int> & id );
+    
+    static PlayerStats * getStats( int userId );
+    
+    inline int getUserId(){ return userId; }
+    
+    inline int getTeamId(){ return teamId; }
+    inline void setTeamId( int teamId ){ this->teamId = teamId; }
+    
+    inline int getPreferedTeamId(){ return preferedTeamId; }
+    inline void setPreferedTeamId( int preferedTeamId ){ this->preferedTeamId = preferedTeamId; }
+    
+    inline int getScore(){ return score; }
+    inline void setScore( int score ){ this->score = score; }
+    
+    inline int getPlayableClassId(){ return playableClassId; }
+    void setPlayableClassId( int classId ){ this->playableClassId = classId; };
+    
+    inline int getPlayableUniqueId(){ return playableUniqueId; }
+    void setPlayableUniqueId( int uniqueId );
+    
+    inline std::string getModelFileName(){ return modelFileName; }
+    inline void setModelFileName( std::string filename ){ modelFileName = filename; }
+    
+    Playable * getPlayable();
 
+  private:
+    int userId;                //!< userId
+    int teamId;                //!< teamId
+    int preferedTeamId;        //!< preferedTeamId
 
-CREATE_FACTORY(PlayerStats, CL_PLAYER_STATS);
+    int score;                 //!< users score points
+    int playableClassId;       //!< players playable class id
+    int playableUniqueId;      //!< playable's uniqueId
+    std::string modelFileName; //!< model filename
 
-/**
- * constructor
- */
-PlayerStats::PlayerStats( int userId )
-{
-  init();
-  
-  this->userId = userId;
-}
+    Playable * playable;       //!< pointer to players playable
 
-/**
- * constructor
- */
-PlayerStats::PlayerStats( const TiXmlElement* root )
-{
-  init();
-}
+    // handles for SynchronizeableVars
+    int userId_handle;
+    int teamId_handle;
+    int preferedTeamId_handle;
+    int score_handle;
+    int playableClassId_handle;
+    int playableUniqueId_handle;
+    int modelFileName_handle;
+    
+    void init();
+};
 
-void PlayerStats::init( )
-{
-  this->setClassID( CL_PLAYER_STATS, "PlayerStats" );
-
-  this->userId = 0;
-  this->teamId = TEAM_NOTEAM;
-  this->preferedTeamId = TEAM_NOTEAM;
-  this->score = 0;
-  this->playableClassId = 0;
-  this->modelFileName = "";
-  
-  userId_handle = registerVarId( new SynchronizeableInt( &userId, &userId, "userId" ) );
-  teamId_handle = registerVarId( new SynchronizeableInt( &teamId, &teamId, "teamId" ) );
-  preferedTeamId_handle = registerVarId( new SynchronizeableInt( &preferedTeamId, &preferedTeamId, "preferedUserId" ) );
-  score_handle = registerVarId( new SynchronizeableInt( &score, &score, "score" ) );
-  playableClassId_handle = registerVarId( new SynchronizeableInt( &playableClassId, &playableClassId, "playableClassId") );
-  playableUniqueId_handle = registerVarId( new SynchronizeableInt( &playableUniqueId, &playableUniqueId, "playableUniqueId" ) );
-  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
-  
-  PRINTF(0)("PlayerStats created\n");
-}
-
-
-/**
- * standard deconstructor
- */
-PlayerStats::~PlayerStats()
-{
-}
-
-
- /**
- * override this function to be notified on change
- * of your registred variables.
- * @param id id's which have changed
-  */
-void PlayerStats::varChangeHandler( std::list< int > & id )
-{
-  if ( std::find( id.begin(), id.end(), playableUniqueId_handle ) != id.end() )
-  {
-    this->setPlayableUniqueId( this->playableUniqueId );
-    
-    PRINTF(0)("uniqueID changed %d %d %d\n", userId, getHostID(), getUniqueID());
-  }
-}
-
-/**
- * get stats for user userId
- * @param userId user's id
- * @return stats assigned to user
- */
-PlayerStats * PlayerStats::getStats( int userId )
-{
-  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
-  
-  if ( !list )
-  {
-    return NULL;
-  }
-  
-  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
-  {
-    if ( dynamic_cast<PlayerStats*>(*it)->getUserId() == userId )
-    {
-      return dynamic_cast<PlayerStats*>(*it);
-    }
-  }
-  
-  return NULL;
-}
-
-/**
- * set playable class id and set playable
- */
-void PlayerStats::setPlayableUniqueId( int uniqueId )
-{
-  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
-  
-  if ( !list )
-  {
-    this->playableUniqueId = uniqueId;
-    return;
-  }
-  
-  this->playable = NULL;
-  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
-  {
-    if ( dynamic_cast<Playable*>(*it)->getUniqueID() == uniqueId )
-    {
-      this->playable = dynamic_cast<Playable*>(*it);
-      break;
-    }
-  }
-  
-  if ( this->playable && userId == getHostID() )
-  {
-    State::getPlayer()->setPlayable( this->playable );
-  }
-  
-  this->playableUniqueId = uniqueId;
-}
-
-/**
- * get playable associated to player
- * @return playable associated to player
- */
-Playable * PlayerStats::getPlayable()
-{
-  if ( playable )
-    return playable;
-  
-  assert( playableUniqueId > 0 );
-  
-  setPlayableUniqueId( playableUniqueId );
-  
-  assert( playable );
-  
-  return playable;
-}
-
-
+#endif /* _PLAYER_STATS_H */
