Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 12, 2006, 5:10:09 PM (18 years ago)
Author:
patrick
Message:

more framework switching

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/player_stats.cc

    r9235 r9257  
    3838{
    3939  init();
    40  
     40
    4141  this->userId = userId;
    4242}
     
    6262  this->nickName = "Player";
    6363  this->oldNickName = "Player";
    64  
     64
    6565  userId_handle = registerVarId( new SynchronizeableInt( &userId, &userId, "userId" ) );
    6666  teamId_handle = registerVarId( new SynchronizeableInt( &teamId, &teamId, "teamId" ) );
     
    7171  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
    7272  nickName_handler = registerVarId( new SynchronizeableString( &nickName, &nickName, "nickName" ) );
    73  
     73
    7474  MessageManager::getInstance()->registerMessageHandler( MSGID_CHANGENICKNAME, changeNickHandler, NULL );
    75  
     75
    7676  PRINTF(0)("PlayerStats created\n");
    7777}
     
    9696  {
    9797    this->setPlayableUniqueId( this->playableUniqueId );
    98    
     98
    9999    PRINTF(0)("uniqueID changed %d %d %d\n", userId, SharedNetworkData::getInstance()->getHostID(), getUniqueID());
    100100  }
    101  
     101
    102102  if ( std::find( id.begin(), id.end(), nickName_handler ) != id.end() )
    103103  {
     
    115115{
    116116  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    117  
     117
    118118  if ( !list )
    119119  {
    120120    return NULL;
    121121  }
    122  
     122
    123123  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    124124  {
     
    128128    }
    129129  }
    130  
     130
    131131  return NULL;
    132132}
     
    138138{
    139139  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
    140  
     140
    141141  if ( !list )
    142142  {
     
    144144    return;
    145145  }
    146  
     146
    147147  this->playable = NULL;
    148148  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     
    156156    }
    157157  }
    158  
     158
    159159  if ( this->playable && userId == SharedNetworkData::getInstance()->getHostID() )
    160160  {
    161161    State::getPlayer()->setPlayable( this->playable );
    162162  }
    163  
     163
    164164  this->playableUniqueId = uniqueId;
    165165}
     
    173173  if ( playable )
    174174    return playable;
    175  
     175
    176176  assert( playableUniqueId > 0 );
    177  
     177
    178178  setPlayableUniqueId( playableUniqueId );
    179  
     179
    180180  assert( playable );
    181  
     181
    182182  return playable;
    183183}
     
    189189void PlayerStats::setNickName( std::string nick )
    190190{
    191   if ( SharedNetworkData::getInstance()->isGameServer() )
     191  if ( SharedNetworkData::getInstance()->isMasterServer() )
    192192  {
    193193    this->nickName = nick;
     
    199199  {
    200200    byte * data = new byte[nick.length()+INTSIZE];
    201    
     201
    202202    assert( Converter::stringToByteArray( nick, data, nick.length()+INTSIZE) == nick.length()+INTSIZE );
    203    
     203
    204204    MessageManager::getInstance()->sendMessage( MSGID_CHANGENICKNAME, data, nick.length()+INTSIZE, RT_SERVER, 0, MP_HIGHBANDWIDTH );
    205205    return;
     
    211211  std::string newNick;
    212212  int res = Converter::byteArrayToString( data, newNick, dataLength );
    213  
     213
    214214  if ( res != dataLength )
    215215  {
     
    217217    newNick = "invalid";
    218218  }
    219  
     219
    220220  if ( PlayerStats::getStats( userId ) )
    221221    PlayerStats::getStats( userId )->setNickName( newNick );
    222  
     222
    223223  return true;
    224224}
     
    228228  if ( getStats( SharedNetworkData::getInstance()->getHostID() ) )
    229229    getStats( SharedNetworkData::getInstance()->getHostID() )->setNickName( newNick );
    230    
     230
    231231  Preferences::getInstance()->setString( "multiplayer", "nickname", newNick );
    232232}
     
    237237{
    238238  const std::list<BaseObject*> * list;
    239  
     239
    240240  while ( (list  = ClassList::getList( CL_PLAYER_STATS )) != NULL && list->begin() != list->end() )
    241241    delete *list->begin();
     
    247247{
    248248  ScoreList result;
    249  
     249
    250250  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    251  
     251
    252252  if ( !list )
    253253  {
    254254    return result;
    255255  }
    256  
     256
    257257  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    258258  {
    259259    PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
    260    
     260
    261261    TeamScoreList::iterator it = result[stats.getTeamId()].begin();
    262    
     262
    263263    while (  it != result[stats.getTeamId()].end() && stats.score > it->score )
    264264    {
    265265      it++;
    266266    }
    267    
     267
    268268    PlayerScore score;
    269269    score.name = stats.getNickName();
    270270    score.score = stats.getScore();
    271    
     271
    272272    result[stats.getTeamId()].insert(it, score);
    273273  }
    274  
     274
    275275  return result;
    276276}
Note: See TracChangeset for help on using the changeset viewer.