Changeset 6250 in orxonox.OLD for branches/network/src/lib
- Timestamp:
- Dec 21, 2005, 4:29:15 PM (19 years ago)
- Location:
- branches/network/src/lib/network
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/network_game_manager.cc
r6238 r6250 38 38 NetworkGameManager::NetworkGameManager() 39 39 { 40 PRINTF(0)("START\n"); 41 40 42 /* set the class id for the base object */ 41 43 this->setClassID(CL_ENTITY_MANAGER, "EntityManager"); … … 204 206 } 205 207 208 209 /*! 210 * Checks whether this is connected to a server or a client 211 * and afterwards creates the needed entity 212 * @param classID: The ID of the class of which an entity should be created 213 */ 214 BaseObject* NetworkGameManager::createEntity( TiXmlElement* element) 215 { 216 if ( this->isServer() ) 217 { 218 if ( newUniqueID < 0 ) 219 { 220 PRINTF(1)("Cannot create entity! There are no more uniqueIDs left!\n"); 221 return NULL; 222 } 223 newUniqueID++; 224 225 BaseObject * b = Factory::fabricate( element ); 226 227 if ( !b ) 228 { 229 PRINTF(1)("Could not fabricate Object with classID %x\n", element->Value() ); 230 return NULL; 231 } 232 233 if ( b->isA(CL_SYNCHRONIZEABLE) ) 234 { 235 Synchronizeable * s = dynamic_cast<Synchronizeable*>(b); 236 s->setUniqueID( newUniqueID ); 237 s->setOwner( 0 ); 238 this->networkStream->connectSynchronizeable( *s ); 239 return b; 240 } 241 else 242 { 243 PRINTF(1)("Class %s is not a synchronizeable!\n", b->getClassName() ); 244 delete b; 245 } 246 } 247 else 248 { 249 PRINTF(1)("This node is not a server and cannot create id %x\n", element->Value()); 250 } 251 return NULL; 252 } 253 254 206 255 /*! 207 256 * Checks whether this is connected to a server or a client -
branches/network/src/lib/network/network_game_manager.h
r6238 r6250 14 14 15 15 16 class TiXmlElement; 16 17 17 18 /** … … 72 73 73 74 void createEntity( ClassID classID, int owner = 0 ); 75 BaseObject* createEntity( TiXmlElement* element); 74 76 void removeEntity( int uniqueID ); 75 77 void sendYouAre( int uniqueID, int userID ); -
branches/network/src/lib/network/network_manager.cc
r6239 r6250 44 44 /* set the class id for the base object */ 45 45 this->setClassID(CL_NETWORK_MANAGER, "NetworkManager"); 46 PRINTF(0)("START\n"); 46 47 47 48 /* initialize the references */ … … 49 50 this->syncList = NULL; 50 51 this->tmpStream = NULL; 52 51 53 this->hostID = -1; 52 54 this->bGameServer = false; … … 107 109 int NetworkManager::createServer(unsigned int port) 108 110 { 111 this->hostID = 0; 112 this->bGameServer = true; 109 113 this->tmpStream = new NetworkStream(port); 110 114 this->bGameServer = true; … … 124 128 this->tmpStream = new NetworkStream(address); 125 129 this->tmpStream->connectSynchronizeable(sync); 126 }127 128 129 /**130 * creates a new NetworkStream of server type131 * @param sync: the listener132 */133 NetworkStream& NetworkManager::createServer(Synchronizeable& sync, unsigned int port)134 {135 PRINTF(0)("Create a new server socket\n");136 /* creating a new network stream, it will register itself automaticaly to the class list */137 this->tmpStream = new NetworkStream(port);138 this->tmpStream->connectSynchronizeable(sync);139 this->bGameServer = true;140 130 } 141 131 … … 178 168 void NetworkManager::setHostID(int id) 179 169 { 180 this->hostID = id;170 this->hostID = id; 181 171 } -
branches/network/src/lib/network/network_manager.h
r6139 r6250 39 39 40 40 NetworkStream& establishConnection(IPaddress& address, Synchronizeable& sync); 41 NetworkStream& createServer(Synchronizeable& sync, unsigned int port);42 41 void shutdownConnection(); 43 42 -
branches/network/src/lib/network/synchronizeable.cc
r6190 r6250 28 28 Synchronizeable::Synchronizeable() 29 29 { 30 30 this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable"); 31 31 owner = 0; 32 32 hostID = NetworkManager::getInstance()->getHostID(); 33 this->setIsServer(this->hostID == 0); 34 PRINTF(0)("sync created,id %i\n", this->hostID); 33 35 uniqueID = -1; 34 36 this->networkStream = NULL; … … 37 39 } 38 40 39 /**40 * default constructor41 */42 Synchronizeable::Synchronizeable(const char* name)43 {44 this->setName(name);45 this->networkStream = NULL;46 }47 41 48 42 -
branches/network/src/lib/network/synchronizeable.h
r6190 r6250 25 25 { 26 26 public: 27 28 Synchronizeable(const char* name);29 27 Synchronizeable(); 30 28 ~Synchronizeable();
Note: See TracChangeset
for help on using the changeset viewer.