Changeset 1261 for code/branches/network3/src
- Timestamp:
- May 12, 2008, 11:44:01 PM (17 years ago)
- Location:
- code/branches/network3/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network3/src/network/ClientConnection.cc
r1253 r1261 112 112 if(server==NULL) 113 113 return false; 114 if( !packet){115 COUT( 4) << "Cl.con: addpacket: invalid packet" << std::endl;114 if(packet==NULL){ 115 COUT(3) << "Cl.con: addpacket: invalid packet" << std::endl; 116 116 return false; 117 117 } -
code/branches/network3/src/network/ClientConnection.h
r1245 r1261 53 53 #define NETWORK_PORT 55556 54 54 #define NETWORK_CLIENT_MAX_CONNECTIONS 5 55 #define NETWORK_CLIENT_TIMEOUT 10 55 #define NETWORK_CLIENT_TIMEOUT 100 56 56 #define NETWORK_SEND_WAIT 5 57 57 #define NETWORK_CLIENT_CHANNELS 2 -
code/branches/network3/src/network/ClientInformation.h
r1232 r1261 92 92 93 93 bool head; 94 unsigned short failures_; 94 95 95 96 private: -
code/branches/network3/src/network/ConnectionManager.cc
r1250 r1261 191 191 //std::cout << "received data" << std::endl; 192 192 COUT(5) << "Con.Man: receive event has occured" << std::endl; 193 processData(event); 193 // only add, if client has connected yet and not been disconnected 194 if(head_->findClient(&event->peer->address)) 195 processData(event); 194 196 break; 195 197 case ENET_EVENT_TYPE_DISCONNECT: … … 354 356 } 355 357 358 bool ConnectionManager::removeShip(ClientInformation *client){ 359 int id=client->getShipID(); 360 orxonox::Iterator<orxonox::SpaceShip> it; 361 for(it = orxonox::ObjectList<orxonox::SpaceShip>::start(); it; ++it){ 362 if(it->objectID!=id) 363 continue; 364 delete *it; 365 } 366 return true; 367 } 368 356 369 bool ConnectionManager::sendWelcome(int clientID, int shipID, bool allowed){ 357 370 addPacket(packet_gen.generateWelcome(clientID, shipID, allowed),clientID); 358 371 sendPackets(); 359 372 return true; 373 } 374 375 void ConnectionManager::disconnectClient(ClientInformation *client){ 376 enet_peer_disconnect(client->getPeer(), 0); 377 removeShip(client); 360 378 } 361 379 -
code/branches/network3/src/network/ConnectionManager.h
r1245 r1261 86 86 bool sendPackets(); 87 87 bool createClient(int clientID); 88 void disconnectClient(ClientInformation *client); 88 89 89 90 private: … … 99 100 ENetPeer *getClientPeer(int clientID); 100 101 bool createShip(ClientInformation *client); 102 bool removeShip(ClientInformation *client); 101 103 bool sendWelcome(int clientID, int shipID, bool allowed); 102 104 bool addFakeConnectRequest(ENetEvent *ev); -
code/branches/network3/src/network/GameStateManager.cc
r1253 r1261 449 449 return true; // TODO: change this 450 450 } 451 452 void GameStateManager::removeClient(ClientInformation* client){ 453 gameStateUsed[client->getGamestateID()]--; 454 head_->removeClient(client->getID()); 455 } 451 456 452 457 } -
code/branches/network3/src/network/GameStateManager.h
r1232 r1261 76 76 bool pushGameState(GameStateCompressed *gs, int clientID); 77 77 void ackGameState(int clientID, int gamestateID); 78 void removeClient(ClientInformation *client); 78 79 private: 79 80 void cleanup(); // "garbage handler" -
code/branches/network3/src/network/Server.cc
r1253 r1261 53 53 namespace network 54 54 { 55 56 57 #define MAX_FAILURES 20; 58 59 55 60 /** 56 61 * Constructor for default values (bindaddress is set to ENET_HOST_ANY … … 205 210 } 206 211 //std::cout << "adding gamestate" << std::endl; 207 if ( !(connection->addPacket(packet_gen.gstate(gs), cid)) ) 208 COUT(4) << "Server: packet with client id (cid): " << cid << " not sended" << std::endl; 212 if ( !(connection->addPacket(packet_gen.gstate(gs), cid)) ){ 213 COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->failures_ << std::endl; 214 temp->failures_++; 215 if(temp->failures_ > 20 ) 216 disconnectClient(temp); 209 217 //std::cout << "added gamestate" << std::endl; 218 } 210 219 added=true; 211 220 temp=temp->next(); … … 240 249 if(!gamestates->pushGameState(data, clientID)) 241 250 COUT(3) << "Could not push gamestate\t\t\t\t=====" << std::endl; 242 } 243 251 else 252 clients->findClient(clientID)->failures_=0; 253 } 254 255 void Server::disconnectClient(int clientID){ 256 ClientInformation *client = clients->findClient(clientID); 257 disconnectClient(client); 258 } 259 void Server::disconnectClient( ClientInformation *client){ 260 connection->disconnectClient(client); 261 gamestates->removeClient(client); 262 } 263 244 264 } -
code/branches/network3/src/network/Server.h
r1245 r1261 71 71 void updateGamestate(); 72 72 private: 73 void disconnectClient(int clientID); 74 void disconnectClient( ClientInformation *client); 73 75 bool sendGameState(); 74 76 void processAck( ack *data, int clientID); -
code/branches/network3/src/orxonox/Main.cc
r1250 r1261 75 75 { 76 76 try { 77 //SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");77 SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log"); 78 78 Orxonox* orx = Orxonox::getSingleton(); 79 79 -
code/branches/network3/src/orxonox/Orxonox.cc
r1232 r1261 494 494 ogreRoot._fireFrameEnded(evt); 495 495 } 496 if(mode_==CLIENT) 497 network::Client::getSingleton()->closeConnection(); 498 else if(mode_==SERVER) 499 server_g->close(); 496 500 } 497 501 -
code/branches/network3/src/orxonox/objects/SpaceShip.cc
r1250 r1261 113 113 SpaceShip::~SpaceShip() 114 114 { 115 if (this->tt_) 115 if (this->tt_){ 116 116 delete this->tt_; 117 } 117 118 } 118 119 -
code/branches/network3/src/orxonox/objects/WorldEntity.cc
r1245 r1261 75 75 WorldEntity::~WorldEntity() 76 76 { 77 // just to make sure we clean out all scene nodes 78 this->getNode()->removeAndDestroyAllChildren(); 77 79 } 78 80 … … 207 209 registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA, 0x3); 208 210 // register velocity_ 209 registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA, 0x3);210 registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA, 0x3);211 registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA, 0x3);212 // register rotationAxis/rate213 registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA, 0x3);214 registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA, 0x3);215 registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA, 0x3);216 registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3);211 // registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA, 0x3); 212 // registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA, 0x3); 213 // registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA, 0x3); 214 // // register rotationAxis/rate 215 // registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA, 0x3); 216 // registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA, 0x3); 217 // registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA, 0x3); 218 // registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3); 217 219 // register scale of node 218 220 registerVar( (void*) &(this->getScale().x), sizeof(this->getScale().x), network::DATA, 0x3); -
code/branches/network3/src/orxonox/particle/ParticleInterface.cc
r1039 r1261 63 63 ParticleInterface::~ParticleInterface(void) 64 64 { 65 while(particleSystem_->getNumEmitters()>0) 66 particleSystem_->removeEmitter(particleSystem_->getNumEmitters()-1); 65 67 sceneManager_->destroyParticleSystem(particleSystem_); 66 68 }
Note: See TracChangeset
for help on using the changeset viewer.