Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6672 in orxonox.OLD for branches


Ignore:
Timestamp:
Jan 24, 2006, 3:02:19 PM (19 years ago)
Author:
patrick
Message:

network: now every entity gets a network uniqueID

Location:
branches/network/src
Files:
8 edited

Legend:

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

    r6670 r6672  
    5353  this->setClassID(CL_NETWORK_GAME_MANAGER, "NetworkGameManager");
    5454
    55   newUniqueID = MAX_CONNECTIONS + 2;
    56 
    5755  hasRequestedWorld = false;
    5856  this->setSynchronized(true);
     
    215213  if ( this->isServer() )
    216214  {
    217     if ( newUniqueID < 0 )
     215    if ( NetworkManager::getInstance()->getNewUniqueID() < 0 )
    218216    {
    219217      PRINTF(1)("Cannot create entity! There are no more uniqueIDs left!\n");
     
    221219    }
    222220
    223     return this->executeCreateEntity( classID, newUniqueID++, owner );
     221    return this->executeCreateEntity( classID, NetworkManager::getInstance()->getNewUniqueID(), owner );
    224222  }
    225223  else
     
    240238  if ( this->isServer() )
    241239  {
    242     if ( newUniqueID < 0 )
     240    if ( NetworkManager::getInstance()->getNewUniqueID() < 0 )
    243241    {
    244242      PRINTF(1)("Cannot create entity! There are no more uniqueIDs left!\n");
     
    258256    {
    259257      Synchronizeable * s = dynamic_cast<Synchronizeable*>(b);
    260       s->setUniqueID( newUniqueID++ );
     258      s->setUniqueID( NetworkManager::getInstance()->getNewUniqueID() );
    261259      s->setOwner( 0 );
    262260      // all entities created via this function are added automaticaly to the synchronizeable list
  • branches/network/src/lib/network/network_game_manager.h

    r6668 r6672  
    143143
    144144
    145 
    146145  private:
    147146    std::vector<clientBuffer>     outBuffer;
    148147    //clientBuffer                  allOutBuffer;
    149148    static NetworkGameManager*    singletonRef;
    150 
    151     int                           newUniqueID;
    152149    bool                          hasRequestedWorld;
    153150};
  • branches/network/src/lib/network/network_manager.cc

    r6665 r6672  
    5454
    5555  this->hostID = -1;
     56  this->newUniqueID = MAX_CONNECTIONS + 2;
    5657  this->bGameServer = false;
    5758
  • branches/network/src/lib/network/network_manager.h

    r6658 r6672  
    5353    inline NetworkStream* getDefaultSyncStream() { return this->defaultSyncStream; }
    5454
     55    /** @returns the next uniqueID free for an object */
     56    inline int getNewUniqueID() { return this->newUniqueID++; }
     57
    5558    void debug();
    5659
     
    6770    int                              hostID;                  //!< The Host-ID of the Manager
    6871    bool                             bGameServer;             //!< true if it is a server
     72    int                              newUniqueID;
    6973
    7074};
  • branches/network/src/lib/network/network_stream.cc

    r6661 r6672  
    448448
    449449
    450 
    451 
    452 
    453 
    454 
    455 
    456 
    457 
    458 
    459 
    460 
    461 
     450int NetworkStream::getSyncCount()
     451{
     452  int n = 0;
     453  for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++)
     454    if( (*it)->beSynchronized() == true)
     455      ++n;
     456
     457  //return synchronizeables.size();
     458  return n;
     459}
     460
     461
     462
     463
     464
     465
  • branches/network/src/lib/network/network_stream.h

    r6660 r6672  
    5656    inline SynchronizeableList::const_iterator getSyncBegin(){ return synchronizeables.begin(); }
    5757    inline SynchronizeableList::const_iterator getSyncEnd(){ return synchronizeables.end(); }
    58     inline int getSyncCount(){ return synchronizeables.size(); }
     58    int getSyncCount();
    5959
    6060    inline bool isUserIdActive( int userID ) { if (userID>=networkSockets.size()) return false; else return networkSockets[userID]!=NULL; }
  • branches/network/src/lib/network/synchronizeable.cc

    r6659 r6672  
    4343
    4444  this->bSynchronize = false;
     45
    4546  NetworkStream* nd = NetworkManager::getInstance()->getDefaultSyncStream();
    4647  assert(nd != NULL);
    4748  nd->connectSynchronizeable(*this);
     49  this->setUniqueID(NetworkManager::getInstance()->getNewUniqueID());
    4850}
    4951
  • branches/network/src/world_entities/space_ships/space_ship.cc

    r6634 r6672  
    9797  if (root != NULL)
    9898    this->loadParams(root);
     99}
     100
     101
     102/**
     103 * initializes a Spaceship
     104 */
     105void SpaceShip::init()
     106{
     107//  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
     108  this->setClassID(CL_SPACE_SHIP, "SpaceShip");
     109
     110  PRINTF(4)("SPACESHIP INIT\n");
    99111
    100112  //weapons:
     
    114126
    115127  this->getWeaponManager()->changeWeaponConfig(1);
    116 }
    117 
    118 
    119 /**
    120  * initializes a Spaceship
    121  */
    122 void SpaceShip::init()
    123 {
    124 //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    125   this->setClassID(CL_SPACE_SHIP, "SpaceShip");
    126 
    127   PRINTF(4)("SPACESHIP INIT\n");
    128128
    129129  EventHandler::getInstance()->grabEvents(true);
     
    202202  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
    203203}
     204
    204205
    205206/**
Note: See TracChangeset for help on using the changeset viewer.