Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9257 in orxonox.OLD for branches/proxy/src/lib


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

more framework switching

Location:
branches/proxy/src/lib/network
Files:
6 edited

Legend:

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

    r9253 r9257  
    9191bool NetworkGameManager::signalNewPlayer( int userId )
    9292{
    93   assert( SharedNetworkData::getInstance()->isGameServer() );
     93  assert( SharedNetworkData::getInstance()->isMasterServer() );
    9494  assert( State::getGameRules() );
    9595  assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) );
  • branches/proxy/src/lib/network/network_manager.cc

    r9059 r9257  
    5353  this->networkStream = NULL;
    5454  this->elapsedTime = 0.0f;
    55  
    56    
     55
     56
    5757  int port = Preferences::getInstance()->getInt( "network", "telnetport", 0 );
    58  
     58
    5959  if ( port > 0 )
    6060    NetworkLog::getInstance()->listen( port );
     
    7575    this->networkStream = NULL;
    7676  }
    77  
     77
    7878  NetworkManager::singletonRef = NULL;
    7979}
     
    118118{
    119119  SharedNetworkData::getInstance()->setHostID(0);
    120   SharedNetworkData::getInstance()->setGameServer(true);
     120  SharedNetworkData::getInstance()->setNodeType(NET_MASTER_SERVER);
    121121  this->networkStream = new NetworkStream(port);
    122122  SharedNetworkData::getInstance()->setDefaultSyncStream(this->networkStream);
     
    148148  if ( networkStream )
    149149    networkStream->processData();
    150  
     150
    151151  NetworkGameManager::getInstance()->tick( this->elapsedTime );
    152152}
  • branches/proxy/src/lib/network/network_manager.h

    r9059 r9257  
    4141    /** Returns the hostID @return The hostID of the object */
    4242    inline int getHostID() { return SharedNetworkData::getInstance()->getHostID(); }
    43     inline bool isGameServer() { return SharedNetworkData::getInstance()->isGameServer(); }
     43    inline bool isMasterServer() { return SharedNetworkData::getInstance()->isMasterServer(); }
     44    inline bool isProxyServer() { return SharedNetworkData::getInstance()->isProxyServer(); }
     45    inline bool isClient() { return SharedNetworkData::getInstance()->isClient(); }
    4446
    4547
  • 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}
  • branches/proxy/src/lib/network/shared_network_data.cc

    r9110 r9257  
    3636  this->defaultSyncStream = NULL;
    3737  this->newUniqueID = MAX_CONNECTIONS + 2;
    38   this->bGameServer = false;
     38  this->nodeType = NET_CLIENT;
    3939}
    4040
  • branches/proxy/src/lib/network/shared_network_data.h

    r6695 r9257  
    88
    99#include "base_object.h"
     10#include "netdefs.h"
    1011
    1112
     
    2526
    2627    /** @returns the next uniqueID free for an object */
    27     inline int getNewUniqueID() { return ( this->bGameServer)?this->newUniqueID++:-1; }
     28    inline int getNewUniqueID() { return ( this->nodeType != NET_CLIENT)?this->newUniqueID++:-1; }
    2829
    29     /** @returns true is this node is a game server */
    30     inline bool isGameServer() { return this->bGameServer; }
     30    /** @returns true is this node is a master server */
     31    inline bool isMasterServer() { return this->nodeType == NET_MASTER_SERVER; }
     32    /** @returns true is this node is a proxy server */
     33    inline bool isProxyServer() { return this->nodeType == NET_PROXY_SERVER; }
     34    /** @returns true is this node is a client*/
     35    inline bool isClient() { return this->nodeType == NET_CLIENT; }
    3136    /** sets the game server flag @param bGameServer true if it is a game server */
    32     inline void setGameServer(bool bGameServer) { this->bGameServer = bGameServer; }
     37    inline void setNodeType(int nodeType) { this->nodeType = nodeType; }
    3338
    3439    /** @returns the hostID of the node */
     
    4954  private:
    5055    int                             newUniqueID;             //!< next uniqueID
    51     bool                            bGameServer;             //!< true if it is a server
     56    int                             nodeType;                //!< saves the node type here
     57
    5258    int                             hostID;                  //!< The Host-ID of the Manager
    5359    NetworkStream*                  defaultSyncStream;       //!< default synchronize NetworkStream
Note: See TracChangeset for help on using the changeset viewer.