Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9691 in orxonox.OLD for branches/new_class_id/src/lib/network


Ignore:
Timestamp:
Aug 22, 2006, 11:45:21 PM (18 years ago)
Author:
bensch
Message:

new_class_id: adapted Network

Location:
branches/new_class_id/src/lib/network
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/network/data_stream.cc

    r9690 r9691  
    2727DataStream::DataStream()
    2828{
    29   this->setClassID(CL_DATA_STREAM, "DataStream");
    3029  this->upBuffer = new byte[DATA_STREAM_BUFFER_SIZE];
    3130  this->downBuffer = new byte[DATA_STREAM_BUFFER_SIZE];
     
    3736DataStream::DataStream(DataStream& inStream, DataStream& outStream)
    3837{
    39     this->setClassID(CL_DATA_STREAM, "DataStream");
     38  this->registerObject(this, DataStream::_objectList);
    4039    this->downStream = &outStream;
    4140    this->upStream = &inStream;
  • branches/new_class_id/src/lib/network/handshake.cc

    r9690 r9691  
    3030{
    3131  /* set the class id for the base object */
    32   this->setClassID(CL_HANDSHAKE, "Handshake");
     32  this->registerObject(this, Handshake::_objectList);
    3333
    3434
  • branches/new_class_id/src/lib/network/message_manager.cc

    r9690 r9691  
    3737MessageManager::MessageManager ()
    3838{
    39   this->setClassID( CL_MESSAGE_MANAGER, "MessageManager" );
     39  this->registerObject(this, MessageManager::_objectList);
    4040  newNumber = 1;
    4141  setSynchronized( true );
  • branches/new_class_id/src/lib/network/monitor/connection_monitor.cc

    r9690 r9691  
    3131{
    3232  /* set the class id for the base object and add ist to class list*/
    33   this->setClassID(CL_CONNECTION_MONITOR, "ConnectionMonitor");
     33  this->registerObject(this, ConnectionMonitor::_objectList);
    3434
    3535  this->userId = userId;
  • branches/new_class_id/src/lib/network/monitor/network_monitor.cc

    r9690 r9691  
    4646  : Synchronizeable()
    4747{
    48   this->setClassID(CL_NETWORK_MONITOR, "NetworkMonitor");
     48  this->registerObject(this, NetworkMonitor::_objectList);
    4949
    5050  this->networkStream = networkStream;
  • branches/new_class_id/src/lib/network/monitor/network_stats_widget.cc

    r9690 r9691  
    274274NetworkStatsWidget* NetworkStatsWidget::_statsWidget = NULL;
    275275
    276 #include "class_list.h"
    277 
    278276void NetworkStatsWidget::toggleGUI()
    279277{
    280   BaseObject* bo = NULL;
    281   const std::list<BaseObject*>* ls = ClassList::getList(CL_NETWORK_MONITOR);
    282   if (ls != NULL && !ls->empty())
    283     bo = ls->front();
    284 
    285   if (bo != NULL && NetworkStatsWidget::_statsWidget == NULL)
    286   {
    287     NetworkStatsWidget::_statsWidget = new NetworkStatsWidget(dynamic_cast<NetworkMonitor*> (bo));
     278  NetworkMonitor* monitor;
     279  if (!NetworkMonitor::objectList().empty())
     280    monitor = NetworkMonitor::objectList().front();
     281
     282  if (monitor != NULL && NetworkStatsWidget::_statsWidget == NULL)
     283  {
     284    NetworkStatsWidget::_statsWidget = new NetworkStatsWidget(monitor);
    288285    NetworkStatsWidget::_statsWidget->showAll();
    289286  }
  • branches/new_class_id/src/lib/network/monitor/network_stats_widget.h

    r9690 r9691  
    2020class HostWidget : public OrxGui::GLGuiBox
    2121{
    22   NewObjectListDeclaration(HostWidget);
    2322  public:
    2423    HostWidget(const std::string& name, const IP& ip);
     
    8281class NetworkStatsWidget : public OrxGui::GLGuiFixedpositionBox
    8382{
     83  NewObjectListDeclaration(NetworkStatsWidget);
    8484  public:
    8585    static void toggleGUI();
  • branches/new_class_id/src/lib/network/network_game_manager.cc

    r9690 r9691  
    2323#include "util/loading/factory.h"
    2424#include "state.h"
    25 #include "class_list.h"
    2625#include "debug.h"
    2726
     
    5958
    6059  /* set the class id for the base object */
    61   this->setClassID(CL_NETWORK_GAME_MANAGER, "NetworkGameManager");
     60  this->registerObject(this, NetworkGameManager::_objectList);
    6261
    6362  this->setSynchronized(true);
     
    9392  assert( SharedNetworkData::getInstance()->isMasterServer());
    9493  assert( State::getGameRules() );
    95   assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) );
     94  assert( State::getGameRules()->isA( NetworkGameRules::classID()) );
    9695
    9796  NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules()));
    9897
    9998  int          team = rules.getTeamForNewUser();
    100   ClassID      playableClassId = rules.getPlayableClassId( userId, team );
     99  NewClassID   playableClassId = rules.getPlayableClassId( userId, team );
    101100  std::string  playableModel = rules.getPlayableModelFileName( userId, team, playableClassId );
    102101  std::string  playableTexture = rules.getPlayableModelFileName( userId, team, playableClassId );
     
    106105
    107106  assert( bo != NULL );
    108   assert( bo->isA( CL_PLAYABLE ) );
     107  assert( bo->isA( Playable::classID()) );
    109108
    110109  Playable & playable = *(dynamic_cast<Playable*>(bo));
     
    131130    stats->setNickName( Preferences::getInstance()->getString( "multiplayer", "nickname", "Server" ) );
    132131
    133   if ( rules.isA( CL_MULTIPLAYER_TEAM_DEATHMATCH ) )
     132  if ( rules.isA( MultiplayerTeamDeathmatch::classID()) )
    134133    dynamic_cast<MultiplayerTeamDeathmatch*>(&rules)->respawnPlayable( &playable, team, 0.0f );
    135134
     
    187186  }
    188187
    189   const std::list<BaseObject*> * list = ClassList::getList( CL_SYNCHRONIZEABLE );
    190 
    191   for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    192   {
    193     if ( dynamic_cast<Synchronizeable*>(*it)->getUniqueID() == uniqueId )
     188  for (NewObjectList<Synchronizeable>::const_iterator it = Synchronizeable::objectList().begin();
     189       it != Synchronizeable::objectList().end();
     190      ++it)
     191  {
     192    if ( (*it)->getUniqueID() == uniqueId )
    194193    {
    195       if ( (*it)->isA(CL_PLAYABLE) )
     194      if ( (*it)->isA(Playable::classID()) )
    196195      {
    197196        getInstance()->playablesToDelete.push_back( dynamic_cast<Playable*>(*it) );
     
    199198      }
    200199
    201       delete dynamic_cast<Synchronizeable*>(*it);
     200      delete (*it);
    202201      return true;
    203202    }
     
    297296    if ( State::getPlayer()->getPlayable() != *it )
    298297    {
    299       const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
    300 
    301       if ( list && std::find( list->begin(), list->end(), *it ) != list->end() )
     298      if ( std::find( Playable::objectList().begin(), Playable::objectList().end(), *it ) != Playable::objectList().end() )
    302299      {
    303300        PRINTF(0)("Delete unused playable: %s owner: %d\n", (*it)->getClassCName(), (*it)->getOwner() );
     
    324321
    325322  assert( State::getGameRules() );
    326   assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) );
     323  assert( State::getGameRules()->isA( NetworkGameRules::classID()) );
    327324
    328325  NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules()));
  • branches/new_class_id/src/lib/network/network_manager.cc

    r9690 r9691  
    2020#define DEBUG_MODULE_NETWORK
    2121
    22 #include "class_list.h"
    2322#include "debug.h"
    2423#include "shell_command.h"
     
    5049{
    5150  /* set the class id for the base object */
    52   this->setClassID(CL_NETWORK_MANAGER, "NetworkManager");
     51  this->registerObject(this, NetworkManager::_objectList);
    5352  PRINTF(0)("START\n");
    5453
  • branches/new_class_id/src/lib/network/network_protocol.cc

    r9690 r9691  
    3535
    3636
    37 NewObjectListDefinition(NetworkManager);
     37NewObjectListDefinition(NetworkProtocol);
    3838/**
    3939  standard constructor
     
    4242{
    4343  /* set the class id for the base object */
    44   this->setClassID(CL_NETWORK_PROTOCOL, "NetworkProtocol");
     44  this->registerObject(this, NetworkProtocol::_objectList);
    4545  this->headerLength = INTSIZE+FLOATSIZE;
    4646}
  • branches/new_class_id/src/lib/network/network_stream.cc

    r9690 r9691  
    4545
    4646#include "debug.h"
    47 #include "class_list.h"
    48 #include <algorithm>
    49 
    5047
    5148#include "network_stream.h"
     
    118115{
    119116  /* set the class id for the base object */
    120   this->setClassID(CL_NETWORK_STREAM, "NetworkStream");
     117  this->registerObject(this, NetworkStream::_objectList);
    121118  this->clientSocket = NULL;
    122119  this->clientSoftSocket = NULL;
     
    970967
    971968      // if handshake not finished only sync handshake
    972       if ( peer->second.handshake && sync.getLeafClassID() != CL_HANDSHAKE )
     969      if ( peer->second.handshake && Handshake::classID() != sync.getLeafClassID())
    973970        continue;
    974971
     
    976973      if ( ( SharedNetworkData::getInstance()->isMasterServer() ||
    977974             SharedNetworkData::getInstance()->isProxyServerActive() &&  peer->second.isClient())
    978              && sync.getLeafClassID() == CL_HANDSHAKE && sync.getUniqueID() != peer->second.userId )
     975             && Handshake::classID() == sync.getLeafClassID() && sync.getUniqueID() != peer->second.userId )
    979976        continue;
    980977
    981978      /* list of synchronizeables that will never be synchronized over the network: */
    982979      // do not sync null parent
    983       if ( sync.getLeafClassID() == CL_NULL_PARENT )
     980      if ( NullParent::classID() == sync.getLeafClassID())
    984981        continue;
    985982
     
    11901187          /* These are some small exeptions in creation: Not all objects can/should be created via Factory */
    11911188          /* Exception 1: NullParent */
    1192           if( leafClassId == CL_NULL_PARENT || leafClassId == CL_SYNCHRONIZEABLE || leafClassId == CL_NETWORK_GAME_MANAGER )
     1189          if( NullParent::classID() == leafClassId || Synchronizeable::classID() == leafClassId || NetworkGameManager::classID() == leafClassId)
    11931190          {
    11941191            PRINTF(1)("Don't create Object with ID %x, ignored!\n", (int)leafClassId);
     
    11971194          }
    11981195          else
    1199             b = Factory::fabricate( (ClassID)leafClassId );
     1196            b = Factory::fabricate( leafClassId );
    12001197
    12011198          if ( !b )
     
    12061203          }
    12071204
    1208           if ( b->isA(CL_SYNCHRONIZEABLE) )
     1205          if ( b->isA(Synchronizeable::classID()) )
    12091206          {
    12101207            sync = dynamic_cast<Synchronizeable*>(b);
  • branches/new_class_id/src/lib/network/player_stats.cc

    r9690 r9691  
    1616#include "player_stats.h"
    1717
    18 #include "class_list.h"
    1918#include "src/lib/util/loading/factory.h"
    2019
    2120#include "player.h"
     21#include "playable.h"
    2222#include "state.h"
    2323#include "shared_network_data.h"
     
    5555void PlayerStats::init( )
    5656{
    57   this->setClassID( CL_PLAYER_STATS, "PlayerStats" );
     57  this->registerObject(this, PlayerStats::_objectList);
    5858
    5959  this->assignedUserId = 0;
     
    123123PlayerStats * PlayerStats::getStats( int userId )
    124124{
    125   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    126 
    127   if ( !list )
    128   {
    129     return NULL;
    130   }
    131 
    132   for ( std::list<BaseObject*>::const_iterator it = list->
    133         begin();
    134         it != list->end();
    135         it++ )
    136   {
    137 
    138 
    139     if ( dynamic_cast<PlayerStats*>(*it)->getAssignedUserId() == userId )
     125  for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin();
     126       it != PlayerStats::objectList().end();
     127       ++it)
     128  {
     129    if ( (*it)->getAssignedUserId() == userId )
    140130    {
    141       return dynamic_cast<PlayerStats*>(*it);
     131      return (*it);
    142132    }
    143133  }
     
    151141void PlayerStats::setPlayableUniqueId( int uniqueId )
    152142{
    153   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
    154 
    155   if ( !list )
    156   {
    157     this->playableUniqueId = uniqueId;
    158     return;
    159   }
    160 
    161143  this->playable = NULL;
    162   for ( std::list<BaseObject*>::const_iterator it = list->
    163         begin();
    164         it != list->end();
    165         it++ )
    166   {
    167     if ( dynamic_cast<Playable*>(*it)->
    168          getUniqueID() == uniqueId )
     144  for (NewObjectList<Playable>::const_iterator it = Playable::objectList().begin();
     145       it != Playable::objectList().end();
     146       ++it)
     147  {
     148    if ( (*it)->getUniqueID() == uniqueId )
    169149    {
    170       this->playable = dynamic_cast<Playable*>(*it);
     150      this->playable = (*it);
    171151      //TODO when OM_PLAYERS is ticked add line:
    172152      //this->playable->toList( OM_PLAYERS );
     
    175155  }
    176156
    177   if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance()
    178        ->getHostID() )
     157  if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance()->getHostID() )
    179158  {
    180159    State::getPlayer()->setPlayable( this->playable );
     
    273252void PlayerStats::deleteAllPlayerStats( )
    274253{
    275   const std::list<BaseObject*> * list;
    276 
    277   while ( (list  = ClassList::getList( CL_PLAYER_STATS )) != NULL && list->begin() != list->end() )
    278     delete *list->begin();
     254
     255  while(!PlayerStats::objectList().empty())
     256    delete PlayerStats::objectList().front();
    279257}
    280258
     
    288266  ScoreList result;
    289267
    290   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    291 
    292   if ( !list )
    293   {
    294     return result;
    295   }
    296 
    297   for ( std::list<BaseObject*>::const_iterator it = list->
    298         begin();
    299         it != list->end();
    300         it++ )
    301   {
    302     PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
     268  for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin();
     269       it != PlayerStats::objectList().end();
     270       ++it)
     271  {
     272    PlayerStats& stats = *(*it);
    303273
    304274    TeamScoreList::iterator it = result[stats.getTeamId()].begin();
  • branches/new_class_id/src/lib/network/player_stats.h

    r9690 r9691  
    5858
    5959    inline int getPlayableClassId(){ return playableClassId; }
    60     void setPlayableClassId( int classId ){ this->playableClassId = classId; };
     60    void setPlayableClassId( const NewClassID& classId ){ this->playableClassId = classId.id(); };
    6161
    6262    inline int getPlayableUniqueId(){ return playableUniqueId; }
  • branches/new_class_id/src/lib/network/proxy/network_settings.cc

    r9690 r9691  
    3737{
    3838  /* set the class id for the base object */
    39   this->setClassID(CL_NETWORK_SETTINGS, "NetworkSettings");
     39  this->registerObject(this, NetworkSettings::_objectList);
    4040
    4141  // suggest a good standard max players value
  • branches/new_class_id/src/lib/network/proxy/proxy_control.cc

    r9690 r9691  
    1515#include "proxy_control.h"
    1616
    17 #include "class_list.h"
    1817#include "shell_command.h"
    1918
     
    4847ProxyControl::ProxyControl()
    4948{
    50   this->setClassID( CL_PROXY_CONTROL, "ProxyControl" );
     49  this->registerObject(this, ProxyControl::_objectList);
    5150
    5251  this->setSynchronized(false);
  • branches/new_class_id/src/lib/network/shared_network_data.cc

    r9690 r9691  
    3434{
    3535  /* set the class id for the base object */
    36   this->setClassID(CL_SHARED_NETWORK_DATA, "SharedNetworkData");
     36  this->registerObject(this, SharedNetworkData::_objectList);
    3737
    3838  this->nodeType = NET_MASTER_SERVER;
  • branches/new_class_id/src/lib/network/synchronizeable.cc

    r9690 r9691  
    7575    // remove the message manager only by the server
    7676    if ( (SharedNetworkData::getInstance()->isMasterServer() )
    77            && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) )
     77          && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( MessageManager::classID() ) )
    7878      NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() );
    7979  }
  • branches/new_class_id/src/lib/network/tcp_server_socket.cc

    r9690 r9691  
    4949{
    5050  /* set the class id for the base object */
    51   this->setClassID(CL_SERVER_SOCKET, "TcpServerSocket");
     51  this->registerObject(this, TcpServerSocket::_objectList);
    5252
    5353  terminateThread = false;
  • branches/new_class_id/src/lib/network/tcp_socket.cc

    r9690 r9691  
    6161{
    6262  /* set the class id for the base object */
    63   this->setClassID(CL_NETWORK_SOCKET, "TcpSocket");
     63  this->registerObject(this, TcpSocket::_objectList);
    6464
    6565  tcpSocket = NULL;
  • branches/new_class_id/src/lib/network/udp_broadcast.cc

    r9690 r9691  
    1818#include "udp_broadcast.h"
    1919
    20 NewObjectListDefinition(UdpBroadcast);
    2120/**
    2221 * standard constructor
  • branches/new_class_id/src/lib/network/udp_broadcast.h

    r9690 r9691  
    1515class UdpBroadcast
    1616{
    17   NewObjectListDeclaration(UdpBroadcast);
    1817  public:
    1918    UdpBroadcast();
Note: See TracChangeset for help on using the changeset viewer.