Changeset 9869 in orxonox.OLD for trunk/src/lib/network
- Timestamp:
- Oct 3, 2006, 12:19:30 AM (18 years ago)
- Location:
- trunk/src/lib/network
- Files:
-
- 49 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/network/converter.cc
r9406 r9869 28 28 SHELL_COMMAND_STATIC(debug, Converter, Converter::debug); 29 29 30 30 ObjectListDefinition(Converter); 31 31 /* using namespace std is default, this needs to be here */ 32 32 -
trunk/src/lib/network/converter.h
r7230 r9869 24 24 class Converter : public BaseObject 25 25 { 26 ObjectListDeclaration(Converter); 26 27 public: 27 28 static byte* intToByteArray(int x); -
trunk/src/lib/network/data_stream.cc
r9406 r9869 20 20 /* using namespace std is default, this needs to be here */ 21 21 22 23 22 ObjectListDefinition(DataStream); 24 23 25 24 /** … … 28 27 DataStream::DataStream() 29 28 { 30 this->setClassID(CL_DATA_STREAM, "DataStream");31 29 this->upBuffer = new byte[DATA_STREAM_BUFFER_SIZE]; 32 30 this->downBuffer = new byte[DATA_STREAM_BUFFER_SIZE]; … … 38 36 DataStream::DataStream(DataStream& inStream, DataStream& outStream) 39 37 { 40 this->setClassID(CL_DATA_STREAM, "DataStream");38 this->registerObject(this, DataStream::_objectList); 41 39 this->downStream = &outStream; 42 40 this->upStream = &inStream; -
trunk/src/lib/network/data_stream.h
r6981 r9869 17 17 class DataStream : public BaseObject 18 18 { 19 public: 19 ObjectListDeclaration(DataStream); 20 public: 20 21 DataStream(); 21 22 DataStream(DataStream& inStream, DataStream& outStream); -
trunk/src/lib/network/handshake.cc
r9656 r9869 23 23 24 24 25 25 ObjectListDefinition(Handshake); 26 26 27 27 … … 30 30 { 31 31 /* set the class id for the base object */ 32 this-> setClassID(CL_HANDSHAKE, "Handshake");32 this->registerObject(this, Handshake::_objectList); 33 33 34 34 -
trunk/src/lib/network/handshake.h
r9494 r9869 42 42 class Handshake : public Synchronizeable 43 43 { 44 44 ObjectListDeclaration(Handshake); 45 45 public: 46 46 Handshake( int nodeType, int clientId = 0, int networkGameManagerId = 0, int messageManagerId = 0 ); -
trunk/src/lib/network/message_manager.cc
r9656 r9869 28 28 29 29 30 30 ObjectListDefinition(MessageManager); 31 31 MessageManager* MessageManager::singletonRef = NULL; 32 32 … … 37 37 MessageManager::MessageManager () 38 38 { 39 this-> setClassID( CL_MESSAGE_MANAGER, "MessageManager");39 this->registerObject(this, MessageManager::_objectList); 40 40 newNumber = 1; 41 41 setSynchronized( true ); -
trunk/src/lib/network/message_manager.h
r9656 r9869 96 96 class MessageManager : public Synchronizeable { 97 97 98 98 ObjectListDeclaration(MessageManager); 99 99 public: 100 100 inline static MessageManager * getInstance(){ if (!singletonRef) singletonRef = new MessageManager(); return singletonRef; } -
trunk/src/lib/network/monitor/connection_monitor.cc
r9494 r9869 23 23 /* using namespace std is default, this needs to be here */ 24 24 25 25 ObjectListDefinition(ConnectionMonitor); 26 26 /** 27 27 * constructor … … 31 31 { 32 32 /* 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); 34 34 35 35 this->userId = userId; -
trunk/src/lib/network/monitor/connection_monitor.h
r9494 r9869 19 19 class ConnectionMonitor : virtual public BaseObject 20 20 { 21 ObjectListDeclaration(ConnectionMonitor); 21 22 public: 22 23 ConnectionMonitor( int userId ); -
trunk/src/lib/network/monitor/network_monitor.cc
r9656 r9869 37 37 SHELL_COMMAND(debug, NetworkMonitor, debug); 38 38 39 ObjectListDefinition(NetworkMonitor); 39 40 40 41 … … 45 46 : Synchronizeable() 46 47 { 47 this-> setClassID(CL_NETWORK_MONITOR, "NetworkMonitor");48 this->registerObject(this, NetworkMonitor::_objectList); 48 49 49 50 this->networkStream = networkStream; -
trunk/src/lib/network/monitor/network_monitor.h
r9656 r9869 27 27 class NetworkMonitor : public Synchronizeable 28 28 { 29 29 ObjectListDeclaration(NetworkMonitor); 30 30 public: 31 31 NetworkMonitor(NetworkStream* networkStream); -
trunk/src/lib/network/monitor/network_stats_widget.cc
r9656 r9869 20 20 #include "peer_info.h" 21 21 22 #include "loading/resource_manager.h" 23 22 24 #include "multi_type.h" 23 25 24 26 #include "shell_command.h" 25 26 #include "loading/resource_manager.h"27 27 28 28 // this fcuk does not work! … … 30 30 // ->setAlias("ProxyGui"); 31 31 32 33 32 HostWidget::HostWidget(const std::string& name, const IP& ip) 34 33 : GLGuiBox(OrxGui::Horizontal) … … 57 56 { 58 57 if(_font == NULL) 59 _font = new Font(Resource Manager::getInstance()->getDataDir() + "/fonts/arial.ttf", 20);58 _font = new Font(Resources::ResourceManager::getInstance()->mainGlobalPath().name() + "/fonts/arial.ttf", 20); 60 59 61 60 //this->_name.setFont(*_font); … … 211 210 //======================================================// 212 211 212 213 ObjectListDefinition(NetworkStatsWidget); 213 214 /** 214 215 * @brief standard constructor … … 273 274 NetworkStatsWidget* NetworkStatsWidget::_statsWidget = NULL; 274 275 275 #include "class_list.h"276 277 276 void NetworkStatsWidget::toggleGUI() 278 277 { 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); 287 285 NetworkStatsWidget::_statsWidget->showAll(); 288 286 } -
trunk/src/lib/network/monitor/network_stats_widget.h
r9656 r9869 81 81 class NetworkStatsWidget : public OrxGui::GLGuiFixedpositionBox 82 82 { 83 ObjectListDeclaration(NetworkStatsWidget); 83 84 public: 84 85 static void toggleGUI(); -
trunk/src/lib/network/network_game_manager.cc
r9656 r9869 23 23 #include "util/loading/factory.h" 24 24 #include "state.h" 25 #include "class_list.h"26 25 #include "debug.h" 27 26 … … 43 42 #include "multiplayer_team_deathmatch.h" 44 43 45 #include "p references.h"46 47 48 49 44 #include "parser/preferences/preferences.h" 45 46 47 48 ObjectListDefinition(NetworkGameManager); 50 49 NetworkGameManager* NetworkGameManager::singletonRef = NULL; 51 50 … … 59 58 60 59 /* set the class id for the base object */ 61 this-> setClassID(CL_NETWORK_GAME_MANAGER, "NetworkGameManager");60 this->registerObject(this, NetworkGameManager::_objectList); 62 61 63 62 this->setSynchronized(true); … … 93 92 assert( SharedNetworkData::getInstance()->isMasterServer()); 94 93 assert( State::getGameRules() ); 95 assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES) );94 assert( State::getGameRules()->isA( NetworkGameRules::staticClassID()) ); 96 95 97 96 NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules())); 98 97 99 98 int team = rules.getTeamForNewUser(); 100 ClassID 99 ClassID playableClassId = rules.getPlayableClassId( userId, team ); 101 100 std::string playableModel = rules.getPlayableModelFileName( userId, team, playableClassId ); 102 101 std::string playableTexture = rules.getPlayableModelFileName( userId, team, playableClassId ); … … 106 105 107 106 assert( bo != NULL ); 108 assert( bo->isA( CL_PLAYABLE) );107 assert( bo->isA( Playable::staticClassID()) ); 109 108 110 109 Playable & playable = *(dynamic_cast<Playable*>(bo)); … … 131 130 stats->setNickName( Preferences::getInstance()->getString( "multiplayer", "nickname", "Server" ) ); 132 131 133 if ( rules.isA( CL_MULTIPLAYER_TEAM_DEATHMATCH) )132 if ( rules.isA( MultiplayerTeamDeathmatch::staticClassID()) ) 134 133 dynamic_cast<MultiplayerTeamDeathmatch*>(&rules)->respawnPlayable( &playable, team, 0.0f ); 135 134 … … 187 186 } 188 187 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 ) 194 193 { 195 if ( (*it)->isA( CL_PLAYABLE) )194 if ( (*it)->isA(Playable::staticClassID()) ) 196 195 { 197 196 getInstance()->playablesToDelete.push_back( dynamic_cast<Playable*>(*it) ); … … 199 198 } 200 199 201 delete dynamic_cast<Synchronizeable*>(*it);200 delete (*it); 202 201 return true; 203 202 } … … 297 296 if ( State::getPlayer()->getPlayable() != *it ) 298 297 { 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() ) 302 299 { 303 300 PRINTF(0)("Delete unused playable: %s owner: %d\n", (*it)->getClassCName(), (*it)->getOwner() ); … … 324 321 325 322 assert( State::getGameRules() ); 326 assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES) );323 assert( State::getGameRules()->isA( NetworkGameRules::staticClassID()) ); 327 324 328 325 NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules())); -
trunk/src/lib/network/network_game_manager.h
r9656 r9869 33 33 class NetworkGameManager: public Synchronizeable 34 34 { 35 35 ObjectListDeclaration(NetworkGameManager); 36 36 public: 37 37 virtual ~NetworkGameManager(); 38 38 39 static NetworkGameManager* NetworkGameManager::getInstance()39 static NetworkGameManager* getInstance() 40 40 { if (!NetworkGameManager::singletonRef) NetworkGameManager::singletonRef = new NetworkGameManager(); return NetworkGameManager::singletonRef; } 41 41 -
trunk/src/lib/network/network_log.cc
r7954 r9869 15 15 16 16 #include "network_log.h" 17 #include <cassert> 17 18 18 19 /** … … 53 54 return false; 54 55 } 55 56 56 57 listensock = SDLNet_TCP_Open( &ip ); 57 58 58 59 if( !listensock ) { 59 60 PRINT(1)( "SDLNet_TCP_Open: %s\n", SDLNet_GetError() ); 60 61 return false; 61 } 62 } 62 63 63 64 return true; … … 71 72 va_list ap; 72 73 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 78 79 printfnet(); 79 80 } … … 85 86 { 86 87 TCPsocket newSock = SDLNet_TCP_Accept( listensock ); 87 88 88 89 if ( newSock ) 89 90 sockets.push_back( newSock ); … … 97 98 va_list ap; 98 99 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 104 105 PRINT(0)( buf ); 105 106 printfnet(); … … 114 115 va_list ap; 115 116 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 121 122 PRINT(1)( buf ); 122 123 printfnet(); … … 131 132 va_list ap; 132 133 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 138 139 PRINT(2)( buf ); 139 140 printfnet(); … … 148 149 va_list ap; 149 150 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 155 156 PRINT(3)( buf ); 156 157 printfnet(); … … 165 166 va_list ap; 166 167 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 172 173 PRINT(4)( buf ); 173 174 printfnet(); … … 182 183 va_list ap; 183 184 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 189 190 PRINT(5)( buf ); 190 191 printfnet(); … … 200 201 if ( !listensock ) 201 202 return; 202 203 203 204 acceptNewConnections(); 204 205 … … 213 214 continue; 214 215 } 215 216 216 217 it++; 217 218 } -
trunk/src/lib/network/network_log.h
r7954 r9869 38 38 class NetworkLog 39 39 { 40 41 40 public: 42 41 virtual ~NetworkLog(void); -
trunk/src/lib/network/network_manager.cc
r9656 r9869 20 20 #define DEBUG_MODULE_NETWORK 21 21 22 #include "class_list.h"23 22 #include "debug.h" 24 23 #include "shell_command.h" … … 28 27 #include "shared_network_data.h" 29 28 #include "network_stream.h" 30 #include "p references.h"29 #include "parser/preferences/preferences.h" 31 30 #include "network_log.h" 32 31 #include "network_game_manager.h" … … 41 40 42 41 43 42 ObjectListDefinition(NetworkManager); 44 43 NetworkManager* NetworkManager::singletonRef = NULL; 45 44 … … 50 49 { 51 50 /* set the class id for the base object */ 52 this-> setClassID(CL_NETWORK_MANAGER, "NetworkManager");51 this->registerObject(this, NetworkManager::_objectList); 53 52 PRINTF(0)("START\n"); 54 53 -
trunk/src/lib/network/network_manager.h
r9656 r9869 25 25 class NetworkManager : public BaseObject 26 26 { 27 27 ObjectListDeclaration(NetworkManager); 28 28 public: 29 29 -
trunk/src/lib/network/network_protocol.cc
r9406 r9869 35 35 36 36 37 37 ObjectListDefinition(NetworkProtocol); 38 38 /** 39 39 standard constructor … … 42 42 { 43 43 /* set the class id for the base object */ 44 this-> setClassID(CL_NETWORK_PROTOCOL, "NetworkProtocol");44 this->registerObject(this, NetworkProtocol::_objectList); 45 45 this->headerLength = INTSIZE+FLOATSIZE; 46 46 } -
trunk/src/lib/network/network_protocol.h
r6981 r9869 25 25 class NetworkProtocol : virtual public BaseObject 26 26 { 27 ObjectListDeclaration(NetworkProtocol); 27 28 public: 28 29 NetworkProtocol(); -
trunk/src/lib/network/network_socket.cc
r9406 r9869 24 24 #include "network_socket.h" 25 25 26 /* header for debug output */ 27 #include "debug.h" 28 26 ObjectListDefinition(NetworkSocket); 29 27 /** 30 28 * Default constructor -
trunk/src/lib/network/network_socket.h
r9406 r9869 17 17 class NetworkSocket : public BaseObject 18 18 { 19 ObjectListDeclaration(NetworkSocket); 19 20 public: 20 21 NetworkSocket(); -
trunk/src/lib/network/network_stream.cc
r9656 r9869 33 33 #include "shared_network_data.h" 34 34 #include "message_manager.h" 35 #include "p references.h"35 #include "parser/preferences/preferences.h" 36 36 #include "zip.h" 37 37 38 #include "src/lib/util/loading/resource_manager.h"39 40 38 #include "network_log.h" 41 39 42 40 #include "player_stats.h" 43 41 44 #include "lib/util/loading/factory.h" 42 #include "loading/factory.h" 43 #include "loading/resource_manager.h" 45 44 46 45 #include "debug.h" 47 #include "class_list.h"48 #include <algorithm>49 50 46 51 47 #include "network_stream.h" … … 57 53 #define PACKAGE_SIZE 256 58 54 59 55 ObjectListDefinition(NetworkStream); 60 56 /** 61 57 * empty constructor … … 118 114 { 119 115 /* set the class id for the base object */ 120 this-> setClassID(CL_NETWORK_STREAM, "NetworkStream");116 this->registerObject(this, NetworkStream::_objectList); 121 117 this->clientSocket = NULL; 122 118 this->clientSoftSocket = NULL; … … 970 966 971 967 // 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()) 973 969 continue; 974 970 … … 976 972 if ( ( SharedNetworkData::getInstance()->isMasterServer() || 977 973 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 ) 979 975 continue; 980 976 981 977 /* list of synchronizeables that will never be synchronized over the network: */ 982 978 // do not sync null parent 983 if ( sync.getLeafClassID() == CL_NULL_PARENT)979 if ( NullParent::staticClassID() == sync.getLeafClassID()) 984 980 continue; 985 981 … … 1190 1186 /* These are some small exeptions in creation: Not all objects can/should be created via Factory */ 1191 1187 /* 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) 1193 1189 { 1194 1190 PRINTF(1)("Don't create Object with ID %x, ignored!\n", (int)leafClassId); … … 1197 1193 } 1198 1194 else 1199 b = Factory::fabricate( (ClassID)leafClassId );1195 ; /// FIXME CLASS_ID :: b = Factory::fabricate( leafClassId ); 1200 1196 1201 1197 if ( !b ) … … 1206 1202 } 1207 1203 1208 if ( b->isA(CL_SYNCHRONIZEABLE) )1204 if ( b->isA(Synchronizeable::staticClassID()) ) 1209 1205 { 1210 1206 sync = dynamic_cast<Synchronizeable*>(b); … … 1303 1299 length = remainingBytesToWriteToDict; 1304 1300 1305 std::string fileName = Resource Manager::getInstance()->getDataDir();1301 std::string fileName = Resources::ResourceManager::getInstance()->mainGlobalPath().name(); 1306 1302 fileName += "/dicts/newdict"; 1307 1303 -
trunk/src/lib/network/network_stream.h
r9656 r9869 33 33 class NetworkStream : public DataStream 34 34 { 35 35 ObjectListDeclaration(NetworkStream); 36 36 public: 37 37 NetworkStream(); -
trunk/src/lib/network/player_stats.cc
r9656 r9869 16 16 #include "player_stats.h" 17 17 18 #include "class_list.h"19 18 #include "src/lib/util/loading/factory.h" 20 19 21 20 #include "player.h" 21 #include "playable.h" 22 22 #include "state.h" 23 23 #include "shared_network_data.h" … … 25 25 #include "converter.h" 26 26 27 #include "p references.h"27 #include "parser/preferences/preferences.h" 28 28 29 29 #include "debug.h" 30 30 #include "shell_command.h" 31 31 32 33 CREATE_FACTORY(PlayerStats, CL_PLAYER_STATS); 34 32 #include "class_id_DEPRECATED.h" 33 34 ObjectListDefinitionID(PlayerStats, CL_PLAYER_STATS); 35 CREATE_FACTORY(PlayerStats); 35 36 36 37 /** … … 54 55 void PlayerStats::init( ) 55 56 { 56 this-> setClassID( CL_PLAYER_STATS, "PlayerStats");57 this->registerObject(this, PlayerStats::_objectList); 57 58 58 59 this->assignedUserId = 0; … … 122 123 PlayerStats * PlayerStats::getStats( int userId ) 123 124 { 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 ) 139 130 { 140 return dynamic_cast<PlayerStats*>(*it);131 return (*it); 141 132 } 142 133 } … … 150 141 void PlayerStats::setPlayableUniqueId( int uniqueId ) 151 142 { 152 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );153 154 if ( !list )155 {156 this->playableUniqueId = uniqueId;157 return;158 }159 160 143 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 ) 168 149 { 169 this->playable = dynamic_cast<Playable*>(*it);150 this->playable = (*it); 170 151 //TODO when OM_PLAYERS is ticked add line: 171 152 //this->playable->toList( OM_PLAYERS ); … … 174 155 } 175 156 176 if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance() 177 ->getHostID() ) 157 if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance()->getHostID() ) 178 158 { 179 159 State::getPlayer()->setPlayable( this->playable ); … … 272 252 void PlayerStats::deleteAllPlayerStats( ) 273 253 { 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(); 278 257 } 279 258 … … 287 266 ScoreList result; 288 267 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); 302 273 303 274 TeamScoreList::iterator it = result[stats.getTeamId()].begin(); -
trunk/src/lib/network/player_stats.h
r9656 r9869 36 36 class PlayerStats : public Synchronizeable 37 37 { 38 38 ObjectListDeclaration(PlayerStats); 39 39 public: 40 40 PlayerStats( const TiXmlElement* root = NULL ); … … 58 58 59 59 inline int getPlayableClassId(){ return playableClassId; } 60 void setPlayableClassId( int classId ){ this->playableClassId = classId; };60 void setPlayableClassId( const ClassID& classId ){ this->playableClassId = classId.id(); }; 61 61 62 62 inline int getPlayableUniqueId(){ return playableUniqueId; } -
trunk/src/lib/network/proxy/network_settings.cc
r9656 r9869 21 21 #include "shared_network_data.h" 22 22 23 #include "loading/load_param.h" 23 24 #include "loading/resource_manager.h" 24 #include "loading/load_param.h"25 26 25 #include "debug.h" 27 26 28 27 28 ObjectListDefinition(NetworkSettings); 29 29 30 30 NetworkSettings* NetworkSettings::singletonRef = NULL; … … 36 36 { 37 37 /* set the class id for the base object */ 38 this-> setClassID(CL_NETWORK_SETTINGS, "NetworkSettings");38 this->registerObject(this, NetworkSettings::_objectList); 39 39 40 40 // suggest a good standard max players value … … 64 64 void NetworkSettings::loadData() 65 65 { 66 std::string fileName = Resource Manager::getInstance()->getDataDir();66 std::string fileName = Resources::ResourceManager::getInstance()->mainGlobalPath().name(); 67 67 fileName += "configs/network_settings.conf"; 68 68 -
trunk/src/lib/network/proxy/network_settings.h
r9494 r9869 24 24 class NetworkSettings : public BaseObject 25 25 { 26 26 ObjectListDeclaration(NetworkSettings); 27 27 public: 28 28 inline static NetworkSettings* getInstance() { if (!NetworkSettings::singletonRef) NetworkSettings::singletonRef = new NetworkSettings(); -
trunk/src/lib/network/proxy/proxy_control.cc
r9656 r9869 15 15 #include "proxy_control.h" 16 16 17 #include "class_list.h"18 17 #include "shell_command.h" 19 18 … … 28 27 #include "converter.h" 29 28 30 #include "p references.h"29 #include "parser/preferences/preferences.h" 31 30 32 31 #include "debug.h" … … 41 40 42 41 SHELL_COMMAND(forceReconnect, ProxyControl, forceReconnectionShell); 42 ObjectListDefinition(ProxyControl); 43 43 44 44 /** … … 47 47 ProxyControl::ProxyControl() 48 48 { 49 this-> setClassID( CL_PROXY_CONTROL, "ProxyControl");49 this->registerObject(this, ProxyControl::_objectList); 50 50 51 51 this->setSynchronized(false); -
trunk/src/lib/network/proxy/proxy_control.h
r9656 r9869 30 30 class ProxyControl : public Synchronizeable 31 31 { 32 32 ObjectListDeclaration(ProxyControl); 33 33 public: 34 34 inline static ProxyControl* getInstance() { if (!ProxyControl::singletonRef) ProxyControl::singletonRef = new ProxyControl(); -
trunk/src/lib/network/server_socket.cc
r7954 r9869 23 23 #include "server_socket.h" 24 24 25 /* header for debug output */ 26 #include "debug.h" 27 28 25 ObjectListDefinition(ServerSocket); 29 26 /** 30 27 * constructor -
trunk/src/lib/network/server_socket.h
r9656 r9869 19 19 class ServerSocket : public BaseObject 20 20 { 21 ObjectListDeclaration(ServerSocket); 21 22 public: 22 23 ServerSocket( int port); -
trunk/src/lib/network/shared_network_data.cc
r9494 r9869 25 25 26 26 27 27 ObjectListDefinition(SharedNetworkData); 28 28 SharedNetworkData* SharedNetworkData::singletonRef = NULL; 29 29 … … 34 34 { 35 35 /* set the class id for the base object */ 36 this-> setClassID(CL_SHARED_NETWORK_DATA, "SharedNetworkData");36 this->registerObject(this, SharedNetworkData::_objectList); 37 37 38 38 this->nodeType = NET_MASTER_SERVER; -
trunk/src/lib/network/shared_network_data.h
r9656 r9869 22 22 class SharedNetworkData : public BaseObject 23 23 { 24 24 ObjectListDeclaration(SharedNetworkData); 25 25 public: 26 26 inline static SharedNetworkData* getInstance() { if (!SharedNetworkData::singletonRef) SharedNetworkData::singletonRef = new SharedNetworkData(); -
trunk/src/lib/network/synchronizeable.cc
r9656 r9869 32 32 33 33 34 ObjectListDefinition(Synchronizeable); 34 35 35 36 /** … … 38 39 Synchronizeable::Synchronizeable() 39 40 { 40 this-> setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable");41 this->registerObject(this, Synchronizeable::_objectList); 41 42 this->owner = 0; 42 43 // this->setIsServer(SharedNetworkData::getInstance()->getHostID() == 0); … … 74 75 // remove the message manager only by the server 75 76 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() ) ) 77 78 NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() ); 78 79 } -
trunk/src/lib/network/synchronizeable.h
r9406 r9869 41 41 class Synchronizeable : virtual public BaseObject 42 42 { 43 ObjectListDeclaration(Synchronizeable); 43 44 44 45 public: -
trunk/src/lib/network/tcp_server_socket.cc
r9494 r9869 26 26 #include "debug.h" 27 27 28 ObjectListDefinition(TcpServerSocket); 28 29 TcpServerSocket::TcpServerSocket( int port ) : ServerSocket( port ) 29 30 { … … 48 49 { 49 50 /* set the class id for the base object */ 50 this-> setClassID(CL_SERVER_SOCKET, "TcpServerSocket");51 this->registerObject(this, TcpServerSocket::_objectList); 51 52 52 53 terminateThread = false; -
trunk/src/lib/network/tcp_server_socket.h
r9406 r9869 19 19 class TcpServerSocket : public ServerSocket 20 20 { 21 ObjectListDeclaration(TcpServerSocket); 21 22 public: 22 23 TcpServerSocket( int port ); -
trunk/src/lib/network/tcp_socket.cc
r7954 r9869 30 30 #include "debug.h" 31 31 32 ObjectListDefinition(TcpSocket); 32 33 /** 33 34 * Default constructor … … 60 61 { 61 62 /* set the class id for the base object */ 62 this-> setClassID(CL_NETWORK_SOCKET, "TcpSocket");63 this->registerObject(this, TcpSocket::_objectList); 63 64 64 65 tcpSocket = NULL; … … 122 123 { 123 124 IPaddress ip; 124 125 bOk = true; 126 125 126 bOk = true; 127 127 128 if ( SDLNet_ResolveHost( &ip, host.c_str(), port ) != 0 ) 128 129 { … … 131 132 return; 132 133 } 133 134 134 135 //check if not already connected or listening 135 136 if (tcpSocket) … … 345 346 } 346 347 #endif 347 348 348 349 PRINTF(0)("QUIT READ THREAD\n"); 349 350 350 351 return 0; 351 352 } … … 425 426 426 427 return 0; 427 428 428 429 } 429 430 -
trunk/src/lib/network/tcp_socket.h
r9406 r9869 40 40 class TcpSocket : public NetworkSocket 41 41 { 42 ObjectListDeclaration(TcpSocket); 42 43 public: 43 44 TcpSocket(); -
trunk/src/lib/network/udp_broadcast.cc
r8623 r9869 26 26 this->port = 0; 27 27 packet = SDLNet_AllocPacket( BROADCAST_PACKET_SIZE ); 28 29 if ( !packet ) 28 29 if ( !packet ) 30 30 { 31 31 printf( "SDLNet_AllocPacket: %s\n", SDLNet_GetError() ); 32 32 assert( packet ); 33 33 } 34 34 35 35 this->socket = NULL; 36 36 } … … 47 47 this->packet = NULL; 48 48 } 49 49 50 50 if ( this->socket ) 51 51 { … … 53 53 this->socket = NULL; 54 54 } 55 55 56 56 } 57 57 58 58 /** 59 59 * listen for incoming broadcast packets 60 * @param port port to listen on 60 * @param port port to listen on 61 61 * @return true on success 62 62 */ … … 74 74 { 75 75 this->port = port; 76 76 77 77 return true; 78 78 } … … 80 80 /** 81 81 * send packet 82 * @param data data to send 82 * @param data data to send 83 83 * @param length length of data 84 84 * @param ip if ip == NULL broadcast is used -
trunk/src/lib/network/udp_broadcast.h
r8623 r9869 15 15 class UdpBroadcast 16 16 { 17 18 17 public: 19 18 UdpBroadcast(); 20 19 virtual ~UdpBroadcast(); 21 20 22 21 bool listen( int port ); 23 22 bool open( int port ); -
trunk/src/lib/network/udp_server_socket.cc
r9494 r9869 18 18 19 19 20 20 ObjectListDefinition(UdpServerSocket); 21 21 /** 22 22 * constructor -
trunk/src/lib/network/udp_server_socket.h
r9494 r9869 50 50 class UdpServerSocket : public ServerSocket 51 51 { 52 ObjectListDeclaration(UdpServerSocket); 52 53 public: 53 54 UdpServerSocket( int port); -
trunk/src/lib/network/udp_socket.cc
r9406 r9869 18 18 #include "debug.h" 19 19 20 ObjectListDefinition(UdpSocket); 20 21 21 22 void UdpSocket::init( ) -
trunk/src/lib/network/udp_socket.h
r9656 r9869 24 24 class UdpSocket : public NetworkSocket 25 25 { 26 ObjectListDeclaration(UdpSocket); 26 27 public: 27 28 UdpSocket(); -
trunk/src/lib/network/zip.cc
r8623 r9869 15 15 16 16 #include "zip.h" 17 18 #include "src/lib/util/loading/resource_manager.h" 17 #include "loading/resource_manager.h" 19 18 #include "debug.h" 20 19 … … 51 50 int Zip::loadDictionary( std::string name ) 52 51 { 53 std::string fileName = Resource Manager::getInstance()->getDataDir();52 std::string fileName = Resources::ResourceManager::getInstance()->mainGlobalPath().name(); 54 53 //PRINTF(0)("datadir: %s\n", fileName.c_str()); 55 54 fileName = fileName + "/dicts/" + name;
Note: See TracChangeset
for help on using the changeset viewer.