Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9059 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Jul 3, 2006, 6:30:42 PM (18 years ago)
Author:
patrick
Message:

merged the network branche with the trunk

Location:
trunk/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/message_manager.cc

    r8708 r9059  
    5858 
    5959  messageQueue.clear();
     60 
     61  this->messageHandlerMap.clear();
     62 
     63  MessageManager::singletonRef = NULL;
    6064}
    6165
  • trunk/src/lib/network/network_game_manager.cc

    r9008 r9059  
    7777 
    7878  PlayerStats::deleteAllPlayerStats();
     79 
     80  NetworkGameManager::singletonRef = NULL;
    7981}
    8082
     
    274276    if ( State::getPlayer()->getPlayable() != *it )
    275277    {
    276       PRINTF(0)("Delete unused playable: %s owner: %d\n", (*it)->getClassName(), (*it)->getOwner() );
    277       std::list<Playable*>::iterator delit = it;
    278       it++;
    279       delete *delit;
    280       playablesToDelete.erase( delit );
    281       continue;
     278      const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
     279       
     280      if ( list && std::find( list->begin(), list->end(), *it ) != list->end() )
     281      {     
     282        PRINTF(0)("Delete unused playable: %s owner: %d\n", (*it)->getClassName(), (*it)->getOwner() );
     283        std::list<Playable*>::iterator delit = it;
     284        it++;
     285        delete *delit;
     286        playablesToDelete.erase( delit );
     287        continue;
     288      }
    282289    }
    283290    it++;
  • trunk/src/lib/network/network_manager.cc

    r8708 r9059  
    5252  /* initialize the references */
    5353  this->networkStream = NULL;
    54   this->sharedNetworkData = SharedNetworkData::getInstance();
    5554  this->elapsedTime = 0.0f;
    5655 
     
    7069NetworkManager::~NetworkManager()
    7170{
     71  PRINTF(0)("NetworkManager destructor\n");
    7272  if ( this->networkStream )
    7373  {
     
    7575    this->networkStream = NULL;
    7676  }
     77 
     78  NetworkManager::singletonRef = NULL;
    7779}
    7880
     
    103105{
    104106  this->networkStream = new NetworkStream( name, port );
    105   this->sharedNetworkData->setDefaultSyncStream(this->networkStream);
     107  SharedNetworkData::getInstance()->setDefaultSyncStream(this->networkStream);
    106108  this->networkStream->startHandshake();
    107109  return 1;
     
    115117int NetworkManager::createServer(unsigned int port)
    116118{
    117   this->sharedNetworkData->setHostID(0);
    118   this->sharedNetworkData->setGameServer(true);
     119  SharedNetworkData::getInstance()->setHostID(0);
     120  SharedNetworkData::getInstance()->setGameServer(true);
    119121  this->networkStream = new NetworkStream(port);
    120   this->sharedNetworkData->setDefaultSyncStream(this->networkStream);
     122  SharedNetworkData::getInstance()->setDefaultSyncStream(this->networkStream);
    121123  this->networkStream->createNetworkGameManager();
    122124  PRINTF(0)("CREATE SERVER\n");
     
    144146  this->elapsedTime = 0.0f;
    145147
    146 //  if ( networkStream->isActive() )
     148  if ( networkStream )
    147149    networkStream->processData();
    148150 
  • trunk/src/lib/network/network_manager.h

    r8228 r9059  
    4040
    4141    /** Returns the hostID @return The hostID of the object */
    42     inline int getHostID() { return this->sharedNetworkData->getHostID(); }
    43     inline bool isGameServer() { return this->sharedNetworkData->isGameServer(); }
     42    inline int getHostID() { return SharedNetworkData::getInstance()->getHostID(); }
     43    inline bool isGameServer() { return SharedNetworkData::getInstance()->isGameServer(); }
    4444
    4545
     
    5858    NetworkStream*                   networkStream;       //!< pointer to network stream
    5959
    60     SharedNetworkData*               sharedNetworkData;       //!< reference to the shared data
    6160    float                            elapsedTime;             //!< elapsed time since the last network update
    6261};
  • trunk/src/lib/network/network_stream.cc

    r8623 r9059  
    111111    serverSocket = NULL;
    112112  }
    113 
    114113  for ( PeerList::iterator i = peers.begin(); i!=peers.end(); i++)
    115114  {
     
    133132    }
    134133  }
    135  
    136134  for ( SynchronizeableList::const_iterator it = getSyncBegin(); it != getSyncEnd(); it ++ )
    137135    (*it)->setNetworkStream( NULL );
  • trunk/src/story_entities/menu/game_menu.cc

    r9015 r9059  
    3636#include "glgui.h"
    3737#include "menu/glgui_imagebutton.h"
     38
     39#include "glgui_text.h"
     40
     41#include "network_manager.h"
    3842
    3943//! This creates a Factory to fabricate a GameMenu
     
    122126  this->levelsBox = NULL;
    123127  this->networkBox = NULL;
     128 
     129  this->clientNetworkBox = NULL;
     130  this->serverNetworkBox = NULL;
    124131
    125132  this->optionsBox = NULL;
     
    233240      OrxGui::GLGuiButton* clientButton = new OrxGui::GLGuiPushButton("Client");
    234241      networkBox->pack(clientButton);
     242      clientButton->connect(SIGNAL(clientButton, released), this, SLOT(GameMenu, showClientMenu));
    235243
    236244      OrxGui::GLGuiButton* serverButton = new OrxGui::GLGuiPushButton("Server");
    237245      networkBox->pack(serverButton);
     246      serverButton->connect(SIGNAL(serverButton, released), this, SLOT(GameMenu, showServerMenu));
    238247
    239248
     
    495504}
    496505
    497 
    498 
     506/**
     507 * show controls to join network game
     508 */
     509void GameMenu::showClientMenu( )
     510{
     511  if ( this->serverNetworkBox )
     512  {
     513    delete this->serverNetworkBox;
     514    this->serverNetworkBox = NULL;
     515  }
     516 
     517  if ( !this->clientNetworkBox )
     518  {
     519    this->clientNetworkBox = new OrxGui::GLGuiBox();
     520    {
     521      OrxGui::GLGuiText * text = new OrxGui::GLGuiText();
     522      text->setText( "Host:" );
     523      this->clientNetworkBox->pack( text );
     524     
     525      this->ipInputLine = new OrxGui::GLGuiInputLine( );
     526      this->ipInputLine->setText( "tardis-d08" );
     527      this->clientNetworkBox->pack( this->ipInputLine );
     528      this->ipInputLine->connect(SIGNAL(ipInputLine, enterPushed), this, SLOT(GameMenu, connectToServer));
     529      this->ipInputLine->select();
     530     
     531      OrxGui::GLGuiButton* connectButton = new OrxGui::GLGuiPushButton("Connect");
     532      clientNetworkBox->pack(connectButton);
     533      connectButton->connect(SIGNAL(connectButton, released), this, SLOT(GameMenu, connectToServer));
     534    }
     535  }
     536 
     537  this->clientNetworkBox->showAll();
     538 
     539  this->clientNetworkBox->setAbsCoor2D( 300.0f, 100.0f );
     540}
     541
     542/**
     543 * show controls to create new network game
     544 */
     545void GameMenu::showServerMenu( )
     546{
     547  if ( this->clientNetworkBox )
     548  {
     549    delete this->clientNetworkBox;
     550    this->clientNetworkBox = NULL;
     551  }
     552 
     553  if ( !this->serverNetworkBox )
     554  {
     555    this->serverNetworkBox = new OrxGui::GLGuiBox();
     556    {
     557      OrxGui::GLGuiText * text = new OrxGui::GLGuiText();
     558      text->setText( "Map:" );
     559      this->serverNetworkBox->pack( text );
     560     
     561      OrxGui::GLGuiText * text2 = new OrxGui::GLGuiText();
     562      text2->setText( "Multiplayer TeamDeathMatch Arena" );
     563      this->serverNetworkBox->pack( text2 );
     564     
     565      OrxGui::GLGuiButton* createButton = new OrxGui::GLGuiPushButton("Create Server");
     566      serverNetworkBox->pack(createButton);
     567      createButton->connect(SIGNAL(createButton, released), this, SLOT(GameMenu, createServer));
     568    }
     569  }
     570 
     571  this->serverNetworkBox->showAll();
     572 
     573  this->serverNetworkBox->setAbsCoor2D( 300.0f, 100.0f );
     574}
     575
     576/**
     577 * connect to host
     578 */
     579void GameMenu::connectToServer( )
     580{
     581  PRINTF(0)("Connecting to %s\n", this->ipInputLine->_getText().c_str() );
     582 
     583  State::setOnline(true);
     584  NetworkManager::getInstance()->establishConnection( this->ipInputLine->_getText(), 9999 );
     585 
     586  this->startLevel( 5 );
     587}
     588
     589void GameMenu::createServer( )
     590{
     591  PRINTF(0)("Create server\n" );
     592 
     593  State::setOnline(true);
     594  NetworkManager::getInstance()->createServer( 9999 );
     595 
     596  this->startLevel( 5 );
     597}
     598
     599
     600
  • trunk/src/story_entities/menu/game_menu.h

    r8717 r9059  
    4545    void showMultiPlayer();
    4646    void showOptionsMenu();
     47   
     48    void showClientMenu();
     49    void connectToServer();
     50   
     51    void showServerMenu();
     52    void createServer();
    4753
    4854
     
    6369    void setSelectorSound(const std::string& selectorSound);
    6470
     71   
     72
    6573
    6674  private:
     
    6876    OrxGui::GLGuiBox*                 levelsBox;
    6977    OrxGui::GLGuiBox*                 networkBox;
     78   
     79    OrxGui::GLGuiBox*                 clientNetworkBox;
     80    OrxGui::GLGuiInputLine*           ipInputLine;
     81   
     82    OrxGui::GLGuiBox*                 serverNetworkBox;
    7083
    7184    OrxGui::GLGuiBox*                 optionsBox;
  • trunk/src/story_entities/multi_player_world.cc

    r9008 r9059  
    2727#include "network_manager.h"
    2828#include "network_game_manager.h"
     29
     30#include "state.h"
    2931
    3032
     
    150152  delete NetworkGameManager::getInstance();
    151153
     154  State::setOnline( false );
     155 
    152156  return ErrorMessage();
    153157}
  • trunk/src/util/multiplayer_team_deathmatch.cc

    r9008 r9059  
    8383  subscribeEvent( ES_GAME, SDLK_TAB );
    8484  subscribeEvent( ES_GAME, SDLK_F1 );
    85   subscribeEvent( ES_MENU, SDLK_F1 );
    8685  subscribeEvent( ES_MENU, KeyMapper::PEV_FIRE1 );
    8786
    88   this->notifier = new OrxGui::GLGuiNotifier();
    89   this->notifier->show();
    90   this->notifier->setAbsCoor2D(5, 30);
    91   this->notifier->setFadeAge( 6.0 );
    92   this->notifier->setHideAge( 8.0 );
    9387  this->input = new OrxGui::GLGuiInputLine();
    9488  this->input->setAbsCoor2D(180, 5);
     
    10498  unsubscribeEvent( ES_GAME, SDLK_TAB );
    10599  unsubscribeEvent( ES_GAME, SDLK_F1 );
    106   unsubscribeEvent( ES_MENU, SDLK_F1 );
    107100  unsubscribeEvent( ES_MENU, KeyMapper::PEV_FIRE1 );
    108 
    109   if ( this->notifier )
    110   {
    111     delete this->notifier;
    112     this->notifier = NULL;
    113   }
    114101
    115102  if ( this->input )
     
    308295
    309296  if ( team == 0 || team == 1 )
    310     return CL_SPACE_SHIP;
     297    return CL_FPS_PLAYER;
    311298
    312299  assert( false );
     
    316303{
    317304  if ( team == 0 )
    318     return "models/ships/reap_#.obj";
     305    return "models/creatures/doom_guy.md2";
    319306  else if ( team == 1 )
    320     return "models/ships/fighter.obj";
     307    return "models/creatures/doom_guy.md2";
    321308  else
    322309    return "";
     
    545532  } else if ( event.type == SDLK_F1 )
    546533  {
     534    if ( this->statsBox && !this->bLocalPlayerDead && event.bPressed )
     535    {
     536      PRINTF(0)("hide stats\n");
     537      this->hideStats();
     538    }
    547539    if ( !this->statsBox && event.bPressed )
    548540    {
    549541      PRINTF(0)("show stats\n");
    550542      this->showStats();
    551     }
    552     if ( this->statsBox && !this->bLocalPlayerDead && event.bPressed && this->table->rowCount() != 0 && this->table->columnCount() != 0 )
    553     {
    554       PRINTF(0)("hide stats\n");
    555       this->hideStats();
    556543    }
    557544  }
     
    597584
    598585  PRINTF(0)("CHATMESSAGE %s (%d): %s\n", name.c_str(), userId, message.c_str() );
    599   notifier->pushNotifyMessage(name + ": " + message);
     586  State::getPlayer()->hud().notifyUser(name + ": " + message);
    600587}
    601588
     
    624611void MultiplayerTeamDeathmatch::showStats( )
    625612{
    626   EventHandler::getInstance()->pushState( ES_MENU );
    627613  statsBox = new OrxGui::GLGuiBox();
    628614  statsBox->setAbsCoor2D( 300, 100 );
    629615
    630   this->table = new OrxGui::GLGuiTable(0,0);
     616  this->table = new OrxGui::GLGuiTable(5,5);
    631617
    632618  statsBox->pack( this->table );
     
    645631      statsBox = NULL;
    646632    }
    647 
    648     EventHandler::getInstance()->popState();
    649633}
    650634
  • trunk/src/util/multiplayer_team_deathmatch.h

    r9008 r9059  
    8383    OrxGui::GLGuiBox* box;
    8484   
    85     OrxGui::GLGuiNotifier* notifier;
    8685    OrxGui::GLGuiInputLine* input;
    8786   
  • trunk/src/world_entities/bsp_entity.cc

    r9003 r9059  
    5353
    5454  this->bspManager = NULL;
    55   /**
    56    * @todo: Write CL_BSP_ENTITY INTO THE src/defs/class_id.h (your own definition)
    57    */
     55 
     56  this->name_handle = registerVarId( new SynchronizeableString( &this->name, &this->name_write, "name" ) );
     57 
     58  this->setSynchronized( true );
    5859}
    5960
     
    6263{
    6364  PRINTF(0)("+++++++++++ LOADING NAME %s\n", name.c_str());
     65 
     66  this->name = name;
    6467
    6568  // Check wether file exists....
     
    130133void BspEntity::collidesWith (WorldEntity* entity, const Vector& location)
    131134{}
     135
     136void BspEntity::varChangeHandler( std::list< int > & id )
     137{
     138  if ( std::find( id.begin(), id.end(), this->name_handle ) != id.end() )
     139  {
     140    this->setName( this->name_write );
     141  }
     142}
  • trunk/src/world_entities/bsp_entity.h

    r8490 r9059  
    2828
    2929  void init();
     30 
     31  virtual void varChangeHandler( std::list<int> & id );
    3032
    3133  virtual void draw() const;
     
    3840 private:
    3941   BspManager* bspManager;
     42   
     43   std::string name;                   //!< store name
     44   std::string name_write;             //!< temp variable to store name
     45   int name_handle;                    //!< handle for name
    4046
    4147};
  • trunk/src/world_entities/player.h

    r9019 r9059  
    3131    bool              eject();
    3232    inline Playable*  getPlayable() const  { return this->playable; };
     33   
    3334
    3435     inline Hud& hud() { return this->_hud; };
  • trunk/src/world_entities/world_entity.cc

    r9008 r9059  
    738738  this->decreaseHealth(damage);
    739739
    740   PRINTF(5)("Hit me: %s now only %f/%f health\n", this->getClassName(), this->getHealth(), this->getHealthMax());
     740  PRINTF(0)("Hit me: %s now only %f/%f health\n", this->getClassName(), this->getHealth(), this->getHealthMax());
    741741
    742742  if( this->getHealth() > 0)
Note: See TracChangeset for help on using the changeset viewer.