Changeset 9691 in orxonox.OLD for branches/new_class_id/src/lib/network
- Timestamp:
- Aug 22, 2006, 11:45:21 PM (18 years ago)
- 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 27 27 DataStream::DataStream() 28 28 { 29 this->setClassID(CL_DATA_STREAM, "DataStream");30 29 this->upBuffer = new byte[DATA_STREAM_BUFFER_SIZE]; 31 30 this->downBuffer = new byte[DATA_STREAM_BUFFER_SIZE]; … … 37 36 DataStream::DataStream(DataStream& inStream, DataStream& outStream) 38 37 { 39 this->setClassID(CL_DATA_STREAM, "DataStream");38 this->registerObject(this, DataStream::_objectList); 40 39 this->downStream = &outStream; 41 40 this->upStream = &inStream; -
branches/new_class_id/src/lib/network/handshake.cc
r9690 r9691 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 -
branches/new_class_id/src/lib/network/message_manager.cc
r9690 r9691 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 ); -
branches/new_class_id/src/lib/network/monitor/connection_monitor.cc
r9690 r9691 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; -
branches/new_class_id/src/lib/network/monitor/network_monitor.cc
r9690 r9691 46 46 : Synchronizeable() 47 47 { 48 this-> setClassID(CL_NETWORK_MONITOR, "NetworkMonitor");48 this->registerObject(this, NetworkMonitor::_objectList); 49 49 50 50 this->networkStream = networkStream; -
branches/new_class_id/src/lib/network/monitor/network_stats_widget.cc
r9690 r9691 274 274 NetworkStatsWidget* NetworkStatsWidget::_statsWidget = NULL; 275 275 276 #include "class_list.h"277 278 276 void NetworkStatsWidget::toggleGUI() 279 277 { 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); 288 285 NetworkStatsWidget::_statsWidget->showAll(); 289 286 } -
branches/new_class_id/src/lib/network/monitor/network_stats_widget.h
r9690 r9691 20 20 class HostWidget : public OrxGui::GLGuiBox 21 21 { 22 NewObjectListDeclaration(HostWidget);23 22 public: 24 23 HostWidget(const std::string& name, const IP& ip); … … 82 81 class NetworkStatsWidget : public OrxGui::GLGuiFixedpositionBox 83 82 { 83 NewObjectListDeclaration(NetworkStatsWidget); 84 84 public: 85 85 static void toggleGUI(); -
branches/new_class_id/src/lib/network/network_game_manager.cc
r9690 r9691 23 23 #include "util/loading/factory.h" 24 24 #include "state.h" 25 #include "class_list.h"26 25 #include "debug.h" 27 26 … … 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::classID()) ); 96 95 97 96 NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules())); 98 97 99 98 int team = rules.getTeamForNewUser(); 100 ClassIDplayableClassId = rules.getPlayableClassId( userId, team );99 NewClassID 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::classID()) ); 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::classID()) ) 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 (NewObjectList<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::classID()) ) 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::classID()) ); 327 324 328 325 NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules())); -
branches/new_class_id/src/lib/network/network_manager.cc
r9690 r9691 20 20 #define DEBUG_MODULE_NETWORK 21 21 22 #include "class_list.h"23 22 #include "debug.h" 24 23 #include "shell_command.h" … … 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 -
branches/new_class_id/src/lib/network/network_protocol.cc
r9690 r9691 35 35 36 36 37 NewObjectListDefinition(Network Manager);37 NewObjectListDefinition(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 } -
branches/new_class_id/src/lib/network/network_stream.cc
r9690 r9691 45 45 46 46 #include "debug.h" 47 #include "class_list.h"48 #include <algorithm>49 50 47 51 48 #include "network_stream.h" … … 118 115 { 119 116 /* set the class id for the base object */ 120 this-> setClassID(CL_NETWORK_STREAM, "NetworkStream");117 this->registerObject(this, NetworkStream::_objectList); 121 118 this->clientSocket = NULL; 122 119 this->clientSoftSocket = NULL; … … 970 967 971 968 // 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()) 973 970 continue; 974 971 … … 976 973 if ( ( SharedNetworkData::getInstance()->isMasterServer() || 977 974 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 ) 979 976 continue; 980 977 981 978 /* list of synchronizeables that will never be synchronized over the network: */ 982 979 // do not sync null parent 983 if ( sync.getLeafClassID() == CL_NULL_PARENT)980 if ( NullParent::classID() == sync.getLeafClassID()) 984 981 continue; 985 982 … … 1190 1187 /* These are some small exeptions in creation: Not all objects can/should be created via Factory */ 1191 1188 /* 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) 1193 1190 { 1194 1191 PRINTF(1)("Don't create Object with ID %x, ignored!\n", (int)leafClassId); … … 1197 1194 } 1198 1195 else 1199 b = Factory::fabricate( (ClassID)leafClassId );1196 b = Factory::fabricate( leafClassId ); 1200 1197 1201 1198 if ( !b ) … … 1206 1203 } 1207 1204 1208 if ( b->isA(CL_SYNCHRONIZEABLE) )1205 if ( b->isA(Synchronizeable::classID()) ) 1209 1206 { 1210 1207 sync = dynamic_cast<Synchronizeable*>(b); -
branches/new_class_id/src/lib/network/player_stats.cc
r9690 r9691 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" … … 55 55 void PlayerStats::init( ) 56 56 { 57 this-> setClassID( CL_PLAYER_STATS, "PlayerStats");57 this->registerObject(this, PlayerStats::_objectList); 58 58 59 59 this->assignedUserId = 0; … … 123 123 PlayerStats * PlayerStats::getStats( int userId ) 124 124 { 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 ) 140 130 { 141 return dynamic_cast<PlayerStats*>(*it);131 return (*it); 142 132 } 143 133 } … … 151 141 void PlayerStats::setPlayableUniqueId( int uniqueId ) 152 142 { 153 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );154 155 if ( !list )156 {157 this->playableUniqueId = uniqueId;158 return;159 }160 161 143 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 ) 169 149 { 170 this->playable = dynamic_cast<Playable*>(*it);150 this->playable = (*it); 171 151 //TODO when OM_PLAYERS is ticked add line: 172 152 //this->playable->toList( OM_PLAYERS ); … … 175 155 } 176 156 177 if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance() 178 ->getHostID() ) 157 if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance()->getHostID() ) 179 158 { 180 159 State::getPlayer()->setPlayable( this->playable ); … … 273 252 void PlayerStats::deleteAllPlayerStats( ) 274 253 { 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(); 279 257 } 280 258 … … 288 266 ScoreList result; 289 267 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); 303 273 304 274 TeamScoreList::iterator it = result[stats.getTeamId()].begin(); -
branches/new_class_id/src/lib/network/player_stats.h
r9690 r9691 58 58 59 59 inline int getPlayableClassId(){ return playableClassId; } 60 void setPlayableClassId( int classId ){ this->playableClassId = classId; };60 void setPlayableClassId( const NewClassID& classId ){ this->playableClassId = classId.id(); }; 61 61 62 62 inline int getPlayableUniqueId(){ return playableUniqueId; } -
branches/new_class_id/src/lib/network/proxy/network_settings.cc
r9690 r9691 37 37 { 38 38 /* set the class id for the base object */ 39 this-> setClassID(CL_NETWORK_SETTINGS, "NetworkSettings");39 this->registerObject(this, NetworkSettings::_objectList); 40 40 41 41 // suggest a good standard max players value -
branches/new_class_id/src/lib/network/proxy/proxy_control.cc
r9690 r9691 15 15 #include "proxy_control.h" 16 16 17 #include "class_list.h"18 17 #include "shell_command.h" 19 18 … … 48 47 ProxyControl::ProxyControl() 49 48 { 50 this-> setClassID( CL_PROXY_CONTROL, "ProxyControl");49 this->registerObject(this, ProxyControl::_objectList); 51 50 52 51 this->setSynchronized(false); -
branches/new_class_id/src/lib/network/shared_network_data.cc
r9690 r9691 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; -
branches/new_class_id/src/lib/network/synchronizeable.cc
r9690 r9691 75 75 // remove the message manager only by the server 76 76 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() ) ) 78 78 NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() ); 79 79 } -
branches/new_class_id/src/lib/network/tcp_server_socket.cc
r9690 r9691 49 49 { 50 50 /* set the class id for the base object */ 51 this-> setClassID(CL_SERVER_SOCKET, "TcpServerSocket");51 this->registerObject(this, TcpServerSocket::_objectList); 52 52 53 53 terminateThread = false; -
branches/new_class_id/src/lib/network/tcp_socket.cc
r9690 r9691 61 61 { 62 62 /* set the class id for the base object */ 63 this-> setClassID(CL_NETWORK_SOCKET, "TcpSocket");63 this->registerObject(this, TcpSocket::_objectList); 64 64 65 65 tcpSocket = NULL; -
branches/new_class_id/src/lib/network/udp_broadcast.cc
r9690 r9691 18 18 #include "udp_broadcast.h" 19 19 20 NewObjectListDefinition(UdpBroadcast);21 20 /** 22 21 * standard constructor -
branches/new_class_id/src/lib/network/udp_broadcast.h
r9690 r9691 15 15 class UdpBroadcast 16 16 { 17 NewObjectListDeclaration(UdpBroadcast);18 17 public: 19 18 UdpBroadcast();
Note: See TracChangeset
for help on using the changeset viewer.