Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6095 in orxonox.OLD for branches


Ignore:
Timestamp:
Dec 14, 2005, 1:39:37 AM (19 years ago)
Author:
patrick
Message:

network: game server world loadin

Location:
branches/network/src
Files:
4 edited

Legend:

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

    r6007 r6095  
    107107{
    108108  this->tmpStream = new NetworkStream(port);
     109  this->bGameServer = true;
    109110  SDL_Delay(20);
    110111  return 1;
     
    135136  this->tmpStream = new NetworkStream(port);
    136137  this->tmpStream->connectSynchronizeable(sync);
     138  this->bGameServer = true;
    137139}
    138140
  • branches/network/src/lib/network/network_manager.h

    r6018 r6095  
    4545    void setHostID(int id);
    4646    /** Returns the hostID @return The hostID of the object */
    47     inline int getHostID() { return this->hostID; };
     47    inline int getHostID() { return this->hostID; }
     48    inline bool isGameServer() { return this->bGameServer; }
    4849
    4950
     
    5657
    5758  private:
    58     const std::list<BaseObject*>*    netStreamList;            // list with refs to all network streams
    59     const std::list<BaseObject*>*    syncList;                 // list of synchronizeables
    60     static NetworkManager* singletonRef;           //!< Pointer to the only instance of this Class
    61     NetworkStream*         tmpStream;              //!< FIXME: this is only for testing purposes
    62     int hostID;                                    //!< The Host-ID of the Manager
     59    const std::list<BaseObject*>*    netStreamList;           // list with refs to all network streams
     60    const std::list<BaseObject*>*    syncList;                // list of synchronizeables
     61    static NetworkManager*           singletonRef;            //!< Pointer to the only instance of this Class
     62    NetworkStream*                   tmpStream;               //!< FIXME: this is only for testing purposes
     63    int                              hostID;                  //!< The Host-ID of the Manager
     64    bool                             bGameServer;             //!< true if it is a server
    6365
    6466};
  • branches/network/src/orxonox.cc

    r6063 r6095  
    280280  if( this->serverName != NULL) // we are a client
    281281    NetworkManager::getInstance()->establishConnection(this->serverName, port);
    282   else if( this->port > 0)      // we are a server
     282  else if( this->port > 0) {    // we are a server
    283283    NetworkManager::getInstance()->createServer(port);
     284  }
    284285
    285286  return 0;
  • branches/network/src/story_entities/network_world.cc

    r6093 r6095  
    341341  // find WorldEntities //
    342342  ////////////////////////
    343   element = root->FirstChildElement("WorldEntities");
    344   if( element == NULL)
     343  if( NetworkManager::getInstance()->isGameServer())
     344  {
     345    element = root->FirstChildElement("WorldEntities");
     346    if( element == NULL)
    345347    {
    346348      PRINTF(1)("NetworkWorld is missing 'WorldEntities'\n");
    347349    }
    348   else
     350    else
    349351    {
    350352      element = element->FirstChildElement();
     
    352354      PRINTF(4)("Loading NetworkWorldEntities\n");
    353355      while( element != NULL)
     356      {
     357        BaseObject* created = Factory::fabricate(element);
     358        if( created != NULL )
    354359        {
    355           BaseObject* created = Factory::fabricate(element);
    356           if( created != NULL )
    357           {
    358             if(created->isA(CL_WORLD_ENTITY))
    359               this->spawn(dynamic_cast<WorldEntity*>(created));
    360             printf("Created a %s: %s\n", created->getClassName(), created->getName());
    361           }
     360          if(created->isA(CL_WORLD_ENTITY))
     361            this->spawn(dynamic_cast<WorldEntity*>(created));
     362          printf("Created a %s: %s\n", created->getClassName(), created->getName());
     363        }
    362364
    363365          // if we load a 'Player' we use it as localPlayer
     
    365367
    366368          //todo do this more elegant
    367           if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
    368             sky = dynamic_cast<SkyBox*>(created);
    369           if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
    370           {
    371             terrain = dynamic_cast<Terrain*>(created);
    372             CDEngine::getInstance()->setTerrain(terrain);
    373           }
    374           element = element->NextSiblingElement();
    375           glmis->step(); //! @todo temporary
     369        if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
     370          sky = dynamic_cast<SkyBox*>(created);
     371        if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
     372        {
     373          terrain = dynamic_cast<Terrain*>(created);
     374          CDEngine::getInstance()->setTerrain(terrain);
    376375        }
     376        element = element->NextSiblingElement();
     377        glmis->step(); //! @todo temporary
     378      }
    377379      PRINTF(4)("Done loading NetworkWorldEntities\n");
    378380    }
     381  }
    379382
    380383    //////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.