Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9257 in orxonox.OLD for branches/proxy


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

more framework switching

Location:
branches/proxy/src
Files:
13 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
  • branches/proxy/src/story_entities/multi_player_world_data.cc

    r9235 r9257  
    110110{
    111111  const TiXmlElement* element = NULL;
    112  
    113   if( NetworkManager::getInstance()->isGameServer() )
     112
     113  if( NetworkManager::getInstance()->isMasterServer() )
    114114  {
    115115    /* load the spawning points */
     
    147147    element = element->FirstChildElement();
    148148
    149     if( NetworkManager::getInstance()->isGameServer() )
     149    if( NetworkManager::getInstance()->isMasterServer() )
    150150    {
    151151      while( element != NULL)
     
    205205
    206206
    207     if( NetworkManager::getInstance()->isGameServer())
     207    if( NetworkManager::getInstance()->isMasterServer())
    208208    {
    209209      this->localPlayer = new Player();
     
    281281
    282282  // create server playable
    283   if ( NetworkManager::getInstance()->isGameServer() )
     283  if ( NetworkManager::getInstance()->isMasterServer() )
    284284  {
    285285    NetworkGameManager::getInstance()->signalNewPlayer( 0 );
  • branches/proxy/src/util/game_rules.cc

    r9008 r9257  
    8888void GameRules::registerKill(const Kill& kill)
    8989{
    90   if ( !SharedNetworkData::getInstance()->isGameServer() )
     90  if ( !SharedNetworkData::getInstance()->isMasterServer() )
    9191    return;
    9292
  • branches/proxy/src/util/multiplayer_team_deathmatch.cc

    r9235 r9257  
    204204  assignPlayable();
    205205
    206   if ( !SharedNetworkData::getInstance()->isGameServer() )
     206  if ( !SharedNetworkData::getInstance()->isMasterServer() )
    207207    return;
    208208
     
    214214    this->killList.erase( this->killList.begin() );
    215215  }
    216  
     216
    217217
    218218
     
    268268void MultiplayerTeamDeathmatch::checkGameRules()
    269269{
    270   if ( !SharedNetworkData::getInstance()->isGameServer() )
     270  if ( !SharedNetworkData::getInstance()->isMasterServer() )
    271271    return;
    272272
     
    320320      return "maps/male_fiend.pcx";
    321321  }
    322  
     322
    323323  return "";
    324324}
     
    330330    return 10.0f;
    331331  }
    332  
     332
    333333  return 1.0f;
    334334}
     
    680680  char st[10];
    681681  int i = 0;
    682  
     682
    683683  i = 2;
    684684  for ( TeamScoreList::const_iterator it = scoreList[0].begin(); it != scoreList[0].end(); it++ )
     
    719719    return;
    720720  }
    721  
     721
    722722  int killerUserId = killer->getOwner();
    723723  int victimUserId = victim->getOwner();
    724  
     724
    725725  PRINTF(0)("%d %d %x %x %s %s\n", killerUserId, victimUserId, killer, victim, killer->getClassName(), victim->getClassName());
    726726
    727727  PlayerStats & victimStats = *PlayerStats::getStats( victimUserId );
    728728  PlayerStats & killerStats = *PlayerStats::getStats( killerUserId );
    729  
     729
    730730  if ( killerStats.getPlayable() != killer || victimStats.getPlayable() != victim )
    731731  {
  • branches/proxy/src/world_entities/creatures/fps_player.cc

    r9235 r9257  
    287287  //dealing damage
    288288
    289   if ( State::isOnline() && SharedNetworkData::getInstance()->isGameServer() )
     289  if ( State::isOnline() && SharedNetworkData::getInstance()->isMasterServer() )
    290290  {
    291291    this->damageTicker -= time;
  • branches/proxy/src/world_entities/playable.cc

    r9235 r9257  
    361361  }
    362362}
    363 /**
    364  * @brief helps us colliding Playables
    365  * @param entity the Entity to collide
    366  * @param location where the collision occured.
    367  */
    368 void Playable::collidesWith(WorldEntity* entity, const Vector& location)
    369 {
    370   if (entity == collider)
    371     return;
    372   collider = entity;
    373 
    374   if ( entity->isA(CL_PROJECTILE) && ( !State::isOnline() || SharedNetworkData::getInstance()->isGameServer() ) )
    375   {
    376     this->decreaseHealth(entity->getHealth() *(float)rand()/(float)RAND_MAX);
    377     // EXTREME HACK
    378     if (this->getHealth() <= 0.0f)
    379     {
    380 //       this->destory();
    381 
    382       if( State::getGameRules() != NULL)
    383         State::getGameRules()->registerKill(Kill(entity, this));
    384     }
    385   }
    386 }
    387363
    388364
     
    413389    }
    414390    this->bDead = true;
    415    
     391
    416392    if( State::getGameRules() != NULL)
    417393      State::getGameRules()->registerKill(Kill(killer, this));
  • branches/proxy/src/world_entities/playable.h

    r9235 r9257  
    8282  virtual void destroy(WorldEntity* killer);
    8383  virtual void respawn();
    84   virtual void collidesWith(WorldEntity* entity, const Vector& location);
    8584  virtual void process(const Event &event);
    8685  virtual void tick(float dt);
     
    9089  static const std::string& playmodeToString(Playable::Playmode playmode);
    9190  static const std::string playmodeNames[];
    92  
     91
    9392  inline bool beFire(){ return this->bFire; }
    9493  inline void fire(bool bF){ this->bFire = bF;}
  • branches/proxy/src/world_entities/spawning_point.cc

    r9235 r9257  
    4141
    4242  this->init();
    43  
     43
    4444  if (root != NULL)
    4545    this->loadParams(root);
     
    5050  this->setClassID(CL_SPAWNING_POINT, "SpawningPoint");
    5151  PRINTF(0)("Created SpawningPoint\n");
    52  
     52
    5353  this->teamId = -1;
    5454  this->localTimer = 0.0f;
    55  
     55
    5656  this->toList( OM_DEAD_TICK );
    57  
     57
    5858  MessageManager::getInstance()->registerMessageHandler( MSGID_RESPAWN, respawnMessageHandler, NULL );
    59  
     59
    6060  this->setSynchronized( true );
    6161}
     
    9494  qe.entity = entity;
    9595  qe.respawnTime = this->localTimer + delay;
    96  
     96
    9797  queue.push_back( qe );
    9898}
     
    105105{
    106106  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
    107  
     107
    108108  bool found = false;
    109  
     109
    110110  if ( !list )
    111111    return;
    112    
     112
    113113  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    114114  {
     
    119119    }
    120120  }
    121  
     121
    122122  if ( !found )
    123123    return;
     
    128128  entity->setAbsCoor( this->getAbsCoor() );
    129129  entity->setAbsDir( this->getAbsDir() );
    130  
     130
    131131  //TODO set camera (not smooth)
    132  
     132
    133133  if ( State::getGameRules() )
    134134  {
    135135    (State::getGameRules())->registerSpawn( entity );
    136136  }
    137  
     137
    138138  entity->respawn();
    139139}
     
    157157      //spawn the player
    158158      this->spawn(it->entity);
    159      
     159
    160160      const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
    161  
     161
    162162      bool found = false;
    163  
     163
    164164      if ( !list )
    165165        return;
    166    
     166
    167167      for ( std::list<BaseObject*>::const_iterator it2 = list->begin(); it2 != list->end(); it2++ )
    168168      {
     
    173173        }
    174174      }
    175  
    176       if ( found && SharedNetworkData::getInstance()->isGameServer() )
     175
     176      if ( found && SharedNetworkData::getInstance()->isMasterServer() )
    177177        this->sendRespawnMessage( it->entity->getUniqueID() );
    178178
    179179      std::list<QueueEntry>::iterator delit = it;
    180180      it++;
    181      
     181
    182182      queue.erase( delit );
    183      
     183
    184184      continue;
    185185    }
    186    
     186
    187187    it++;
    188188  }
     
    204204{
    205205  byte * buf = new byte[2*INTSIZE];
    206  
     206
    207207  assert( Converter::intToByteArray( this->getUniqueID(), buf, INTSIZE ) == INTSIZE );
    208208  assert( Converter::intToByteArray( uniqueId, buf + INTSIZE, INTSIZE ) == INTSIZE );
    209  
     209
    210210  MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
    211211}
     
    213213bool SpawningPoint::respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
    214214{
    215   if ( SharedNetworkData::getInstance()->isGameServer() )
     215  if ( SharedNetworkData::getInstance()->isMasterServer() )
    216216  {
    217217    PRINTF(2)("server received spawn message!\n");
    218218    return true;
    219219  }
    220    
     220
    221221  int spUniqueId;
    222222  int uniqueId;
    223  
     223
    224224  if ( dataLength != 2*INTSIZE )
    225225  {
     
    227227    return true;
    228228  }
    229  
     229
    230230  assert( Converter::byteArrayToInt( data, &spUniqueId ) == INTSIZE );
    231231  assert( Converter::byteArrayToInt( data+INTSIZE, &uniqueId ) == INTSIZE );
    232  
     232
    233233  PRINTF(0)("SPAWNMESSAGE %d\n", uniqueId);
    234  
     234
    235235  SpawningPoint * sp = NULL;
    236236  Playable      * playable = NULL;
    237  
     237
    238238  const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
    239  
     239
    240240  if ( list )
    241241  {
     
    250250    }
    251251  }
    252  
     252
    253253  if ( !sp )
    254254  {
     
    256256    return false;
    257257  }
    258  
     258
    259259  list = ClassList::getList( CL_PLAYABLE );
    260  
     260
    261261  if ( list )
    262262  {
     
    270270    }
    271271  }
    272  
     272
    273273  if ( !playable )
    274274  {
     
    276276    return false;
    277277  }
    278  
     278
    279279  sp->spawn( playable );
    280  
     280
    281281  return true;
    282282}
Note: See TracChangeset for help on using the changeset viewer.