Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD for trunk/src/lib/network


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

Location:
trunk/src/lib/network
Files:
49 edited

Legend:

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

    r9406 r9869  
    2828SHELL_COMMAND_STATIC(debug, Converter, Converter::debug);
    2929
    30 
     30ObjectListDefinition(Converter);
    3131/* using namespace std is default, this needs to be here */
    3232
  • trunk/src/lib/network/converter.h

    r7230 r9869  
    2424class Converter : public BaseObject
    2525{
     26  ObjectListDeclaration(Converter);
    2627  public:
    2728    static byte* intToByteArray(int x);
  • trunk/src/lib/network/data_stream.cc

    r9406 r9869  
    2020/* using namespace std is default, this needs to be here */
    2121
    22 
    23 
     22ObjectListDefinition(DataStream);
    2423
    2524/**
     
    2827DataStream::DataStream()
    2928{
    30   this->setClassID(CL_DATA_STREAM, "DataStream");
    3129  this->upBuffer = new byte[DATA_STREAM_BUFFER_SIZE];
    3230  this->downBuffer = new byte[DATA_STREAM_BUFFER_SIZE];
     
    3836DataStream::DataStream(DataStream& inStream, DataStream& outStream)
    3937{
    40     this->setClassID(CL_DATA_STREAM, "DataStream");
     38  this->registerObject(this, DataStream::_objectList);
    4139    this->downStream = &outStream;
    4240    this->upStream = &inStream;
  • trunk/src/lib/network/data_stream.h

    r6981 r9869  
    1717class DataStream : public BaseObject
    1818{
    19       public:
     19  ObjectListDeclaration(DataStream);
     20  public:
    2021      DataStream();
    2122      DataStream(DataStream& inStream, DataStream& outStream);
  • trunk/src/lib/network/handshake.cc

    r9656 r9869  
    2323
    2424
    25 
     25ObjectListDefinition(Handshake);
    2626
    2727
     
    3030{
    3131  /* set the class id for the base object */
    32   this->setClassID(CL_HANDSHAKE, "Handshake");
     32  this->registerObject(this, Handshake::_objectList);
    3333
    3434
  • trunk/src/lib/network/handshake.h

    r9494 r9869  
    4242class Handshake : public Synchronizeable
    4343{
    44 
     44  ObjectListDeclaration(Handshake);
    4545  public:
    4646    Handshake( int nodeType, int clientId = 0, int networkGameManagerId = 0, int messageManagerId = 0 );
  • trunk/src/lib/network/message_manager.cc

    r9656 r9869  
    2828
    2929
    30 
     30ObjectListDefinition(MessageManager);
    3131MessageManager* MessageManager::singletonRef = NULL;
    3232
     
    3737MessageManager::MessageManager ()
    3838{
    39   this->setClassID( CL_MESSAGE_MANAGER, "MessageManager" );
     39  this->registerObject(this, MessageManager::_objectList);
    4040  newNumber = 1;
    4141  setSynchronized( true );
  • trunk/src/lib/network/message_manager.h

    r9656 r9869  
    9696class MessageManager : public Synchronizeable {
    9797
    98 
     98  ObjectListDeclaration(MessageManager);
    9999 public:
    100100   inline static MessageManager * getInstance(){ if (!singletonRef) singletonRef = new MessageManager();  return singletonRef; }
  • trunk/src/lib/network/monitor/connection_monitor.cc

    r9494 r9869  
    2323/* using namespace std is default, this needs to be here */
    2424
    25 
     25ObjectListDefinition(ConnectionMonitor);
    2626/**
    2727 * constructor
     
    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;
  • trunk/src/lib/network/monitor/connection_monitor.h

    r9494 r9869  
    1919class ConnectionMonitor : virtual public BaseObject
    2020{
     21  ObjectListDeclaration(ConnectionMonitor);
    2122  public:
    2223    ConnectionMonitor( int userId );
  • trunk/src/lib/network/monitor/network_monitor.cc

    r9656 r9869  
    3737SHELL_COMMAND(debug, NetworkMonitor, debug);
    3838
     39ObjectListDefinition(NetworkMonitor);
    3940
    4041
     
    4546  : Synchronizeable()
    4647{
    47   this->setClassID(CL_NETWORK_MONITOR, "NetworkMonitor");
     48  this->registerObject(this, NetworkMonitor::_objectList);
    4849
    4950  this->networkStream = networkStream;
  • trunk/src/lib/network/monitor/network_monitor.h

    r9656 r9869  
    2727class NetworkMonitor : public Synchronizeable
    2828{
    29 
     29  ObjectListDeclaration(NetworkMonitor);
    3030  public:
    3131    NetworkMonitor(NetworkStream* networkStream);
  • trunk/src/lib/network/monitor/network_stats_widget.cc

    r9656 r9869  
    2020#include "peer_info.h"
    2121
     22#include "loading/resource_manager.h"
     23
    2224#include "multi_type.h"
    2325
    2426#include "shell_command.h"
    25 
    26 #include "loading/resource_manager.h"
    2727
    2828// this fcuk does not work!
     
    3030// ->setAlias("ProxyGui");
    3131
    32 
    3332HostWidget::HostWidget(const std::string& name, const IP& ip)
    3433    : GLGuiBox(OrxGui::Horizontal)
     
    5756{
    5857  if(_font == NULL)
    59     _font = new Font(ResourceManager::getInstance()->getDataDir() + "/fonts/arial.ttf", 20);
     58    _font = new Font(Resources::ResourceManager::getInstance()->mainGlobalPath().name() + "/fonts/arial.ttf", 20);
    6059
    6160  //this->_name.setFont(*_font);
     
    211210//======================================================//
    212211
     212
     213ObjectListDefinition(NetworkStatsWidget);
    213214/**
    214215 * @brief standard constructor
     
    273274NetworkStatsWidget* NetworkStatsWidget::_statsWidget = NULL;
    274275
    275 #include "class_list.h"
    276 
    277276void NetworkStatsWidget::toggleGUI()
    278277{
    279   BaseObject* bo = NULL;
    280   const std::list<BaseObject*>* ls = ClassList::getList(CL_NETWORK_MONITOR);
    281   if (ls != NULL && !ls->empty())
    282     bo = ls->front();
    283 
    284   if (bo != NULL && NetworkStatsWidget::_statsWidget == NULL)
    285   {
    286     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);
    287285    NetworkStatsWidget::_statsWidget->showAll();
    288286  }
  • trunk/src/lib/network/monitor/network_stats_widget.h

    r9656 r9869  
    8181class NetworkStatsWidget : public OrxGui::GLGuiFixedpositionBox
    8282{
     83  ObjectListDeclaration(NetworkStatsWidget);
    8384  public:
    8485    static void toggleGUI();
  • trunk/src/lib/network/network_game_manager.cc

    r9656 r9869  
    2323#include "util/loading/factory.h"
    2424#include "state.h"
    25 #include "class_list.h"
    2625#include "debug.h"
    2726
     
    4342#include "multiplayer_team_deathmatch.h"
    4443
    45 #include "preferences.h"
    46 
    47 
    48 
    49 
     44#include "parser/preferences/preferences.h"
     45
     46
     47
     48ObjectListDefinition(NetworkGameManager);
    5049NetworkGameManager* NetworkGameManager::singletonRef = NULL;
    5150
     
    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::staticClassID()) );
    9695
    9796  NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules()));
    9897
    9998  int          team = rules.getTeamForNewUser();
    100   ClassID      playableClassId = rules.getPlayableClassId( userId, team );
     99  ClassID   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::staticClassID()) );
    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::staticClassID()) )
    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 (ObjectList<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::staticClassID()) )
    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::staticClassID()) );
    327324
    328325  NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules()));
  • trunk/src/lib/network/network_game_manager.h

    r9656 r9869  
    3333class NetworkGameManager: public Synchronizeable
    3434{
    35 
     35  ObjectListDeclaration(NetworkGameManager);
    3636  public:
    3737    virtual ~NetworkGameManager();
    3838
    39     static NetworkGameManager* NetworkGameManager::getInstance()
     39    static NetworkGameManager* getInstance()
    4040    { if (!NetworkGameManager::singletonRef) NetworkGameManager::singletonRef = new NetworkGameManager(); return NetworkGameManager::singletonRef; }
    4141
  • trunk/src/lib/network/network_log.cc

    r7954 r9869  
    1515
    1616#include "network_log.h"
     17#include <cassert>
    1718
    1819/**
     
    5354    return false;
    5455  }
    55  
     56
    5657  listensock = SDLNet_TCP_Open( &ip );
    57  
     58
    5859  if( !listensock ) {
    5960    PRINT(1)( "SDLNet_TCP_Open: %s\n", SDLNet_GetError() );
    6061    return false;
    61   } 
     62  }
    6263
    6364  return true;
     
    7172  va_list ap;
    7273  va_start( ap, format );
    73  
    74   assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
    75  
    76   va_end( ap );
    77  
     74
     75  assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
     76
     77  va_end( ap );
     78
    7879  printfnet();
    7980}
     
    8586{
    8687  TCPsocket newSock = SDLNet_TCP_Accept( listensock );
    87  
     88
    8889  if ( newSock )
    8990    sockets.push_back( newSock );
     
    9798  va_list ap;
    9899  va_start( ap, format );
    99  
    100   assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
    101  
    102   va_end( ap );
    103  
     100
     101  assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
     102
     103  va_end( ap );
     104
    104105  PRINT(0)( buf );
    105106  printfnet();
     
    114115  va_list ap;
    115116  va_start( ap, format );
    116  
    117   assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
    118  
    119   va_end( ap );
    120  
     117
     118  assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
     119
     120  va_end( ap );
     121
    121122  PRINT(1)( buf );
    122123  printfnet();
     
    131132  va_list ap;
    132133  va_start( ap, format );
    133  
    134   assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
    135  
    136   va_end( ap );
    137  
     134
     135  assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
     136
     137  va_end( ap );
     138
    138139  PRINT(2)( buf );
    139140  printfnet();
     
    148149  va_list ap;
    149150  va_start( ap, format );
    150  
    151   assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
    152  
    153   va_end( ap );
    154  
     151
     152  assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
     153
     154  va_end( ap );
     155
    155156  PRINT(3)( buf );
    156157  printfnet();
     
    165166  va_list ap;
    166167  va_start( ap, format );
    167  
    168   assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
    169  
    170   va_end( ap );
    171  
     168
     169  assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
     170
     171  va_end( ap );
     172
    172173  PRINT(4)( buf );
    173174  printfnet();
     
    182183  va_list ap;
    183184  va_start( ap, format );
    184  
    185   assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
    186  
    187   va_end( ap );
    188  
     185
     186  assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
     187
     188  va_end( ap );
     189
    189190  PRINT(5)( buf );
    190191  printfnet();
     
    200201  if ( !listensock )
    201202    return;
    202  
     203
    203204  acceptNewConnections();
    204205
     
    213214      continue;
    214215    }
    215    
     216
    216217    it++;
    217218  }
  • trunk/src/lib/network/network_log.h

    r7954 r9869  
    3838class NetworkLog
    3939{
    40 
    4140  public:
    4241    virtual ~NetworkLog(void);
  • trunk/src/lib/network/network_manager.cc

    r9656 r9869  
    2020#define DEBUG_MODULE_NETWORK
    2121
    22 #include "class_list.h"
    2322#include "debug.h"
    2423#include "shell_command.h"
     
    2827#include "shared_network_data.h"
    2928#include "network_stream.h"
    30 #include "preferences.h"
     29#include "parser/preferences/preferences.h"
    3130#include "network_log.h"
    3231#include "network_game_manager.h"
     
    4140
    4241
    43 
     42ObjectListDefinition(NetworkManager);
    4443NetworkManager* NetworkManager::singletonRef = NULL;
    4544
     
    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
  • trunk/src/lib/network/network_manager.h

    r9656 r9869  
    2525class NetworkManager : public BaseObject
    2626{
    27 
     27  ObjectListDeclaration(NetworkManager);
    2828  public:
    2929
  • trunk/src/lib/network/network_protocol.cc

    r9406 r9869  
    3535
    3636
    37 
     37ObjectListDefinition(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}
  • trunk/src/lib/network/network_protocol.h

    r6981 r9869  
    2525class NetworkProtocol : virtual public BaseObject
    2626{
     27  ObjectListDeclaration(NetworkProtocol);
    2728  public:
    2829    NetworkProtocol();
  • trunk/src/lib/network/network_socket.cc

    r9406 r9869  
    2424#include "network_socket.h"
    2525
    26 /* header for debug output */
    27 #include "debug.h"
    28 
     26ObjectListDefinition(NetworkSocket);
    2927/**
    3028 * Default constructor
  • trunk/src/lib/network/network_socket.h

    r9406 r9869  
    1717class NetworkSocket : public BaseObject
    1818{
     19  ObjectListDeclaration(NetworkSocket);
    1920  public:
    2021    NetworkSocket();
  • trunk/src/lib/network/network_stream.cc

    r9656 r9869  
    3333#include "shared_network_data.h"
    3434#include "message_manager.h"
    35 #include "preferences.h"
     35#include "parser/preferences/preferences.h"
    3636#include "zip.h"
    3737
    38 #include "src/lib/util/loading/resource_manager.h"
    39 
    4038#include "network_log.h"
    4139
    4240#include "player_stats.h"
    4341
    44 #include "lib/util/loading/factory.h"
     42#include "loading/factory.h"
     43#include "loading/resource_manager.h"
    4544
    4645#include "debug.h"
    47 #include "class_list.h"
    48 #include <algorithm>
    49 
    5046
    5147#include "network_stream.h"
     
    5753#define PACKAGE_SIZE  256
    5854
    59 
     55ObjectListDefinition(NetworkStream);
    6056/**
    6157 * empty constructor
     
    118114{
    119115  /* set the class id for the base object */
    120   this->setClassID(CL_NETWORK_STREAM, "NetworkStream");
     116  this->registerObject(this, NetworkStream::_objectList);
    121117  this->clientSocket = NULL;
    122118  this->clientSoftSocket = NULL;
     
    970966
    971967      // if handshake not finished only sync handshake
    972       if ( peer->second.handshake && sync.getLeafClassID() != CL_HANDSHAKE )
     968      if ( peer->second.handshake && Handshake::staticClassID() != sync.getLeafClassID())
    973969        continue;
    974970
     
    976972      if ( ( SharedNetworkData::getInstance()->isMasterServer() ||
    977973             SharedNetworkData::getInstance()->isProxyServerActive() &&  peer->second.isClient())
    978              && sync.getLeafClassID() == CL_HANDSHAKE && sync.getUniqueID() != peer->second.userId )
     974             && Handshake::staticClassID() == sync.getLeafClassID() && sync.getUniqueID() != peer->second.userId )
    979975        continue;
    980976
    981977      /* list of synchronizeables that will never be synchronized over the network: */
    982978      // do not sync null parent
    983       if ( sync.getLeafClassID() == CL_NULL_PARENT )
     979      if ( NullParent::staticClassID() == sync.getLeafClassID())
    984980        continue;
    985981
     
    11901186          /* These are some small exeptions in creation: Not all objects can/should be created via Factory */
    11911187          /* Exception 1: NullParent */
    1192           if( leafClassId == CL_NULL_PARENT || leafClassId == CL_SYNCHRONIZEABLE || leafClassId == CL_NETWORK_GAME_MANAGER )
     1188          if( NullParent::staticClassID() == leafClassId || Synchronizeable::staticClassID() == leafClassId || NetworkGameManager::staticClassID() == leafClassId)
    11931189          {
    11941190            PRINTF(1)("Don't create Object with ID %x, ignored!\n", (int)leafClassId);
     
    11971193          }
    11981194          else
    1199             b = Factory::fabricate( (ClassID)leafClassId );
     1195            ; /// FIXME CLASS_ID :: b = Factory::fabricate( leafClassId );
    12001196
    12011197          if ( !b )
     
    12061202          }
    12071203
    1208           if ( b->isA(CL_SYNCHRONIZEABLE) )
     1204          if ( b->isA(Synchronizeable::staticClassID()) )
    12091205          {
    12101206            sync = dynamic_cast<Synchronizeable*>(b);
     
    13031299    length = remainingBytesToWriteToDict;
    13041300
    1305   std::string fileName = ResourceManager::getInstance()->getDataDir();
     1301  std::string fileName = Resources::ResourceManager::getInstance()->mainGlobalPath().name();
    13061302  fileName += "/dicts/newdict";
    13071303
  • trunk/src/lib/network/network_stream.h

    r9656 r9869  
    3333class NetworkStream : public DataStream
    3434{
    35 
     35  ObjectListDeclaration(NetworkStream);
    3636  public:
    3737    NetworkStream();
  • trunk/src/lib/network/player_stats.cc

    r9656 r9869  
    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"
     
    2525#include "converter.h"
    2626
    27 #include "preferences.h"
     27#include "parser/preferences/preferences.h"
    2828
    2929#include "debug.h"
    3030#include "shell_command.h"
    3131
    32 
    33 CREATE_FACTORY(PlayerStats, CL_PLAYER_STATS);
    34 
     32#include "class_id_DEPRECATED.h"
     33
     34ObjectListDefinitionID(PlayerStats, CL_PLAYER_STATS);
     35CREATE_FACTORY(PlayerStats);
    3536
    3637/**
     
    5455void PlayerStats::init( )
    5556{
    56   this->setClassID( CL_PLAYER_STATS, "PlayerStats" );
     57  this->registerObject(this, PlayerStats::_objectList);
    5758
    5859  this->assignedUserId = 0;
     
    122123PlayerStats * PlayerStats::getStats( int userId )
    123124{
    124   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    125 
    126   if ( !list )
    127   {
    128     return NULL;
    129   }
    130 
    131   for ( std::list<BaseObject*>::const_iterator it = list->
    132         begin();
    133         it != list->end();
    134         it++ )
    135   {
    136 
    137 
    138     if ( dynamic_cast<PlayerStats*>(*it)->getAssignedUserId() == userId )
     125  for (ObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin();
     126       it != PlayerStats::objectList().end();
     127       ++it)
     128  {
     129    if ( (*it)->getAssignedUserId() == userId )
    139130    {
    140       return dynamic_cast<PlayerStats*>(*it);
     131      return (*it);
    141132    }
    142133  }
     
    150141void PlayerStats::setPlayableUniqueId( int uniqueId )
    151142{
    152   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
    153 
    154   if ( !list )
    155   {
    156     this->playableUniqueId = uniqueId;
    157     return;
    158   }
    159 
    160143  this->playable = NULL;
    161   for ( std::list<BaseObject*>::const_iterator it = list->
    162         begin();
    163         it != list->end();
    164         it++ )
    165   {
    166     if ( dynamic_cast<Playable*>(*it)->
    167          getUniqueID() == uniqueId )
     144  for (ObjectList<Playable>::const_iterator it = Playable::objectList().begin();
     145       it != Playable::objectList().end();
     146       ++it)
     147  {
     148    if ( (*it)->getUniqueID() == uniqueId )
    168149    {
    169       this->playable = dynamic_cast<Playable*>(*it);
     150      this->playable = (*it);
    170151      //TODO when OM_PLAYERS is ticked add line:
    171152      //this->playable->toList( OM_PLAYERS );
     
    174155  }
    175156
    176   if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance()
    177        ->getHostID() )
     157  if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance()->getHostID() )
    178158  {
    179159    State::getPlayer()->setPlayable( this->playable );
     
    272252void PlayerStats::deleteAllPlayerStats( )
    273253{
    274   const std::list<BaseObject*> * list;
    275 
    276   while ( (list  = ClassList::getList( CL_PLAYER_STATS )) != NULL && list->begin() != list->end() )
    277     delete *list->begin();
     254
     255  while(!PlayerStats::objectList().empty())
     256    delete PlayerStats::objectList().front();
    278257}
    279258
     
    287266  ScoreList result;
    288267
    289   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    290 
    291   if ( !list )
    292   {
    293     return result;
    294   }
    295 
    296   for ( std::list<BaseObject*>::const_iterator it = list->
    297         begin();
    298         it != list->end();
    299         it++ )
    300   {
    301     PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
     268  for (ObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin();
     269       it != PlayerStats::objectList().end();
     270       ++it)
     271  {
     272    PlayerStats& stats = *(*it);
    302273
    303274    TeamScoreList::iterator it = result[stats.getTeamId()].begin();
  • trunk/src/lib/network/player_stats.h

    r9656 r9869  
    3636class PlayerStats : public Synchronizeable
    3737{
    38 
     38  ObjectListDeclaration(PlayerStats);
    3939  public:
    4040    PlayerStats( const TiXmlElement* root = NULL );
     
    5858
    5959    inline int getPlayableClassId(){ return playableClassId; }
    60     void setPlayableClassId( int classId ){ this->playableClassId = classId; };
     60    void setPlayableClassId( const ClassID& classId ){ this->playableClassId = classId.id(); };
    6161
    6262    inline int getPlayableUniqueId(){ return playableUniqueId; }
  • trunk/src/lib/network/proxy/network_settings.cc

    r9656 r9869  
    2121#include "shared_network_data.h"
    2222
     23#include "loading/load_param.h"
    2324#include "loading/resource_manager.h"
    24 #include "loading/load_param.h"
    25 
    2625#include "debug.h"
    2726
    2827
     28ObjectListDefinition(NetworkSettings);
    2929
    3030NetworkSettings* NetworkSettings::singletonRef = NULL;
     
    3636{
    3737  /* set the class id for the base object */
    38   this->setClassID(CL_NETWORK_SETTINGS, "NetworkSettings");
     38  this->registerObject(this, NetworkSettings::_objectList);
    3939
    4040  // suggest a good standard max players value
     
    6464void NetworkSettings::loadData()
    6565{
    66   std::string fileName = ResourceManager::getInstance()->getDataDir();
     66  std::string fileName = Resources::ResourceManager::getInstance()->mainGlobalPath().name();
    6767  fileName += "configs/network_settings.conf";
    6868
  • trunk/src/lib/network/proxy/network_settings.h

    r9494 r9869  
    2424class NetworkSettings : public BaseObject
    2525{
    26 
     26  ObjectListDeclaration(NetworkSettings);
    2727  public:
    2828    inline static NetworkSettings* getInstance() { if (!NetworkSettings::singletonRef) NetworkSettings::singletonRef = new NetworkSettings();
  • trunk/src/lib/network/proxy/proxy_control.cc

    r9656 r9869  
    1515#include "proxy_control.h"
    1616
    17 #include "class_list.h"
    1817#include "shell_command.h"
    1918
     
    2827#include "converter.h"
    2928
    30 #include "preferences.h"
     29#include "parser/preferences/preferences.h"
    3130
    3231#include "debug.h"
     
    4140
    4241SHELL_COMMAND(forceReconnect, ProxyControl, forceReconnectionShell);
     42ObjectListDefinition(ProxyControl);
    4343
    4444/**
     
    4747ProxyControl::ProxyControl()
    4848{
    49   this->setClassID( CL_PROXY_CONTROL, "ProxyControl" );
     49  this->registerObject(this, ProxyControl::_objectList);
    5050
    5151  this->setSynchronized(false);
  • trunk/src/lib/network/proxy/proxy_control.h

    r9656 r9869  
    3030class ProxyControl : public Synchronizeable
    3131{
    32 
     32  ObjectListDeclaration(ProxyControl);
    3333  public:
    3434    inline static ProxyControl* getInstance() { if (!ProxyControl::singletonRef) ProxyControl::singletonRef = new ProxyControl();
  • trunk/src/lib/network/server_socket.cc

    r7954 r9869  
    2323#include "server_socket.h"
    2424
    25 /* header for debug output */
    26 #include "debug.h"
    27 
    28 
     25ObjectListDefinition(ServerSocket);
    2926/**
    3027 * constructor
  • trunk/src/lib/network/server_socket.h

    r9656 r9869  
    1919class ServerSocket : public BaseObject
    2020{
     21  ObjectListDeclaration(ServerSocket);
    2122  public:
    2223    ServerSocket( int port);
  • trunk/src/lib/network/shared_network_data.cc

    r9494 r9869  
    2525
    2626
    27 
     27ObjectListDefinition(SharedNetworkData);
    2828SharedNetworkData* SharedNetworkData::singletonRef = NULL;
    2929
     
    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;
  • trunk/src/lib/network/shared_network_data.h

    r9656 r9869  
    2222class SharedNetworkData : public BaseObject
    2323{
    24 
     24  ObjectListDeclaration(SharedNetworkData);
    2525  public:
    2626    inline static SharedNetworkData* getInstance() { if (!SharedNetworkData::singletonRef) SharedNetworkData::singletonRef = new SharedNetworkData();
  • trunk/src/lib/network/synchronizeable.cc

    r9656 r9869  
    3232
    3333
     34ObjectListDefinition(Synchronizeable);
    3435
    3536/**
     
    3839Synchronizeable::Synchronizeable()
    3940{
    40   this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable");
     41  this->registerObject(this, Synchronizeable::_objectList);
    4142  this->owner = 0;
    4243//   this->setIsServer(SharedNetworkData::getInstance()->getHostID() == 0);
     
    7475    // remove the message manager only by the server
    7576    if ( (SharedNetworkData::getInstance()->isMasterServer() )
    76            && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) )
     77          && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( MessageManager::staticClassID() ) )
    7778      NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() );
    7879  }
  • trunk/src/lib/network/synchronizeable.h

    r9406 r9869  
    4141class Synchronizeable : virtual public BaseObject
    4242{
     43  ObjectListDeclaration(Synchronizeable);
    4344
    4445  public:
  • trunk/src/lib/network/tcp_server_socket.cc

    r9494 r9869  
    2626#include "debug.h"
    2727
     28ObjectListDefinition(TcpServerSocket);
    2829TcpServerSocket::TcpServerSocket( int port ) : ServerSocket( port )
    2930{
     
    4849{
    4950  /* set the class id for the base object */
    50   this->setClassID(CL_SERVER_SOCKET, "TcpServerSocket");
     51  this->registerObject(this, TcpServerSocket::_objectList);
    5152
    5253  terminateThread = false;
  • trunk/src/lib/network/tcp_server_socket.h

    r9406 r9869  
    1919class TcpServerSocket : public ServerSocket
    2020{
     21  ObjectListDeclaration(TcpServerSocket);
    2122  public:
    2223    TcpServerSocket( int port );
  • trunk/src/lib/network/tcp_socket.cc

    r7954 r9869  
    3030#include "debug.h"
    3131
     32ObjectListDefinition(TcpSocket);
    3233/**
    3334 * Default constructor
     
    6061{
    6162  /* set the class id for the base object */
    62   this->setClassID(CL_NETWORK_SOCKET, "TcpSocket");
     63  this->registerObject(this, TcpSocket::_objectList);
    6364
    6465  tcpSocket = NULL;
     
    122123{
    123124  IPaddress ip;
    124  
    125   bOk = true; 
    126  
     125
     126  bOk = true;
     127
    127128  if ( SDLNet_ResolveHost( &ip, host.c_str(), port ) != 0 )
    128129  {
     
    131132    return;
    132133  }
    133  
     134
    134135  //check if not already connected or listening
    135136  if (tcpSocket)
     
    345346}
    346347#endif
    347  
     348
    348349  PRINTF(0)("QUIT READ THREAD\n");
    349  
     350
    350351  return 0;
    351352}
     
    425426
    426427  return 0;
    427  
     428
    428429}
    429430
  • trunk/src/lib/network/tcp_socket.h

    r9406 r9869  
    4040class TcpSocket : public NetworkSocket
    4141{
     42  ObjectListDeclaration(TcpSocket);
    4243  public:
    4344    TcpSocket();
  • trunk/src/lib/network/udp_broadcast.cc

    r8623 r9869  
    2626  this->port = 0;
    2727  packet = SDLNet_AllocPacket( BROADCAST_PACKET_SIZE );
    28  
    29   if ( !packet ) 
     28
     29  if ( !packet )
    3030  {
    3131    printf( "SDLNet_AllocPacket: %s\n", SDLNet_GetError() );
    3232    assert( packet );
    3333  }
    34  
     34
    3535  this->socket = NULL;
    3636}
     
    4747    this->packet = NULL;
    4848  }
    49  
     49
    5050  if ( this->socket )
    5151  {
     
    5353    this->socket = NULL;
    5454  }
    55  
     55
    5656}
    5757
    5858/**
    5959 * listen for incoming broadcast packets
    60  * @param port port to listen on 
     60 * @param port port to listen on
    6161 * @return true on success
    6262 */
     
    7474{
    7575  this->port = port;
    76  
     76
    7777  return true;
    7878}
     
    8080/**
    8181 * send packet
    82  * @param data data to send 
     82 * @param data data to send
    8383 * @param length length of data
    8484 * @param ip if ip == NULL broadcast is used
  • trunk/src/lib/network/udp_broadcast.h

    r8623 r9869  
    1515class UdpBroadcast
    1616{
    17 
    1817  public:
    1918    UdpBroadcast();
    2019    virtual ~UdpBroadcast();
    21    
     20
    2221    bool listen( int port );
    2322    bool open( int port );
  • trunk/src/lib/network/udp_server_socket.cc

    r9494 r9869  
    1818
    1919
    20 
     20ObjectListDefinition(UdpServerSocket);
    2121/**
    2222 * constructor
  • trunk/src/lib/network/udp_server_socket.h

    r9494 r9869  
    5050class UdpServerSocket : public ServerSocket
    5151{
     52  ObjectListDeclaration(UdpServerSocket);
    5253  public:
    5354    UdpServerSocket( int port);
  • trunk/src/lib/network/udp_socket.cc

    r9406 r9869  
    1818#include "debug.h"
    1919
     20ObjectListDefinition(UdpSocket);
    2021
    2122void UdpSocket::init( )
  • trunk/src/lib/network/udp_socket.h

    r9656 r9869  
    2424class UdpSocket : public NetworkSocket
    2525{
     26  ObjectListDeclaration(UdpSocket);
    2627  public:
    2728    UdpSocket();
  • trunk/src/lib/network/zip.cc

    r8623 r9869  
    1515
    1616#include "zip.h"
    17 
    18 #include "src/lib/util/loading/resource_manager.h"
     17#include "loading/resource_manager.h"
    1918#include "debug.h"
    2019
     
    5150int Zip::loadDictionary( std::string name )
    5251{
    53   std::string fileName = ResourceManager::getInstance()->getDataDir();
     52  std::string fileName = Resources::ResourceManager::getInstance()->mainGlobalPath().name();
    5453  //PRINTF(0)("datadir: %s\n", fileName.c_str());
    5554  fileName = fileName + "/dicts/" + name;
Note: See TracChangeset for help on using the changeset viewer.