Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5972 in orxonox.OLD


Ignore:
Timestamp:
Dec 7, 2005, 4:59:24 PM (18 years ago)
Author:
patrick
Message:

network: started renice work on the game_load, making it network friendly:D

Location:
branches/network/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/orxonox.cc

    r5971 r5972  
    8383
    8484  /* this way, there is no network enabled: */
    85   this->clientName = NULL;
     85  this->serverName = NULL;
    8686  this->port = -1;
    8787
     
    190190  this->argv = argv;
    191191
    192   this->clientName = name;
     192  this->serverName = name;
    193193  this->port = port;
    194194
     
    278278  PRINT(3)("> Initializing networking\n");
    279279
    280   if( this->clientName != NULL) // we are a client
    281     NetworkManager::getInstance()->establishConnection(this->clientName, port);
     280  if( this->serverName != NULL) // we are a client
     281    NetworkManager::getInstance()->establishConnection(this->serverName, port);
    282282  else if( this->port > 0)      // we are a server
    283283    NetworkManager::getInstance()->createServer(port);
     
    351351
    352352  this->gameLoader = GameLoader::getInstance();
    353   this->gameLoader->loadCampaign("worlds/DefaultCampaign.oxc");
     353 
     354  if( this->port == -1 || this->serverName != NULL)
     355    this->gameLoader->loadNetworkCampaign("worlds/DefaultNetworkCampaign.oxc");
     356  else
     357    this->gameLoader->loadCampaign("worlds/DefaultCampaign.oxc");
     358 
    354359  //  this->gameLoader->loadDebugCampaign(DEBUG_CAMPAIGN_0);
    355360  this->gameLoader->init();
  • branches/network/src/orxonox.h

    r5829 r5972  
    5353  char**            argv;                    //!< Values of th Arguments of orxonox.
    5454
    55   const char*       clientName;              //!< Name of the Orxonox client if == NULL -> server
     55  const char*       serverName;              //!< Name of the Orxonox client if == NULL -> server
    5656  int               port;                    //!< number of the network port of the server/client if == -1 no network
    5757};
  • branches/network/src/util/loading/game_loader.cc

    r5819 r5972  
    4646/**
    4747 *  simple constructor
    48 */
     48 */
    4949GameLoader::GameLoader ()
    5050{
     
    5555
    5656
     57
    5758/**
    5859 *  simple deconstructor
    59 */
     60 */
    6061GameLoader::~GameLoader ()
    6162{
     
    6667
    6768
    68 /**
    69  *  this class is a singleton class
    70  * @returns an instance of itself
    71 
    72    if you are unsure about singleton classes, check the theory out on the internet :)
    73 */
    74 GameLoader* GameLoader::getInstance()
    75 {
    76   if(singletonRef == NULL)
    77     singletonRef = new GameLoader();
    78   return singletonRef;
    79 }
    8069
    8170/**
    8271 *  initializes the GameLoader
    83 */
     72 */
    8473ErrorMessage GameLoader::init()
    8574{
     
    9685
    9786
     87
    9888/**
    9989 *  reads a campaign definition file into a campaign class
    10090 * @param fileName to be loaded
    10191 * @returns the loaded campaign
    102 
    103    this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
    104 */
     92 *
     93 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
     94 */
    10595ErrorMessage GameLoader::loadCampaign(const char* fileName)
    10696{
     
    117107}
    118108
     109
     110
     111/**
     112 *  reads a campaign definition file into a campaign class
     113 * @param fileName to be loaded
     114 * @returns the loaded campaign
     115 *
     116 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
     117 */
     118ErrorMessage loadNetworkCampaign(const char* name)
     119{}
     120
     121
     122
    119123/**
    120124 *  loads a debug campaign for test purposes only.
    121125 * @param campaignID the identifier of the campaign.
    122126 * @returns error message if not able to do so.
    123 */
     127 */
    124128ErrorMessage GameLoader::loadDebugCampaign(Uint32 campaignID)
    125129{
     
    156160
    157161/**
    158   *  starts the current entity
    159   * @returns error code if this action has caused a error
    160 */
     162 *  starts the current entity
     163 * @returns error code if this action has caused a error
     164 */
    161165ErrorMessage GameLoader::start()
    162166{
     
    167171
    168172/**
    169   *  stops the current entity
    170   * @returns error code if this action has caused a error
    171 
    172    ATTENTION: this function shouldn't call other functions, or if so, they must return
    173    after finishing. If you ignore or forget to do so, the current entity is not able to
    174    terminate and it will run in the background or the ressources can't be freed or even
    175    worse: are freed and the program will end in a segmentation fault!
    176     hehehe, have ya seen it... :)
    177 */
     173 *  stops the current entity
     174 * @returns error code if this action has caused a error
     175 *
     176 * ATTENTION: this function shouldn't call other functions, or if so, they must return
     177 * after finishing. If you ignore or forget to do so, the current entity is not able to
     178 * terminate and it will run in the background or the ressources can't be freed or even
     179 * worse: are freed and the program will end in a segmentation fault!
     180 * hehehe, have dja seen it... :)
     181 */
    178182void GameLoader::stop()
    179183{
     
    184188
    185189/**
    186   *  pause the current entity
    187   * @returns error code if this action has caused a error
    188 
    189    this pauses the current entity or passes this call forth to the running entity.
    190 */
     190 *  pause the current entity
     191 * @returns error code if this action has caused a error
     192 *
     193 * this pauses the current entity or passes this call forth to the running entity.
     194 */
    191195ErrorMessage GameLoader::pause()
    192196{
     
    198202
    199203/**
    200   *  resumes a pause
    201   * @returns error code if this action has caused a error
    202 
    203    this resumess the current entity or passes this call forth to the running entity.
    204 */
     204 *  resumes a pause
     205 * @returns error code if this action has caused a error
     206 *
     207 * this resumess the current entity or passes this call forth to the running entity.
     208 */
    205209ErrorMessage GameLoader::resume()
    206210{
     
    224228 * @param fileName to be loaded
    225229 * @returns the loaded campaign
    226 
    227    this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
    228 */
     230 *
     231 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
     232 */
    229233Campaign* GameLoader::fileToCampaign(const char* fileName)
    230234{
     
    312316
    313317/**
    314   \brief this changes to the next level
    315 */
     318 * this changes to the next level
     319 */
    316320void GameLoader::nextLevel()
    317321{
     
    322326
    323327/**
    324   \brief change to the previous level - not implemented
    325 
    326   this propably useless
    327 */
     328 * change to the previous level - not implemented
     329 *
     330 * this propably useless
     331 */
    328332void GameLoader::previousLevel()
    329333{
     
    335339 *  load a StoryEntity
    336340 * @param element a XMLElement containing all the needed info
    337 */
     341 */
    338342BaseObject* GameLoader::fabricate(const TiXmlElement* element)
    339343{
  • branches/network/src/util/loading/game_loader.h

    r5819 r5972  
    4040{
    4141
     42 
    4243 public:
    4344  ~GameLoader ();
    4445
    45   static GameLoader* getInstance();
     46  /**  this class is a singleton class @returns an instance of itself  */
     47  static GameLoader* getInstance() { if(singletonRef == NULL) singletonRef = new GameLoader();  return singletonRef; }
    4648
    4749  ErrorMessage init();
    48   ErrorMessage loadCampaign(const char* name);
    4950  ErrorMessage start();
    5051  void stop();
     
    5657  void previousLevel();
    5758
    58   /** \brief a world command to send to the GameLoader @param cmd the command */
    59   bool worldCommand(Command* cmd);
    6059  ErrorMessage loadDebugCampaign(Uint32 campaignID);
     60  ErrorMessage loadCampaign(const char* name);
     61  ErrorMessage loadNetworkCampaign(const char* name);
     62 
    6163
    6264  void registerFactory( Factory* factory );
     
    6567  void process(const Event &event);
    6668
     69 
    6770 private:
    6871  GameLoader ();
     
    7073  Campaign* fileToCampaign(const char* name);
    7174
     75 
    7276 private:
    7377  static GameLoader*     singletonRef;         //!< The singleton-reference to this object
Note: See TracChangeset for help on using the changeset viewer.