Changeset 1747 for code/trunk/src/network
- Timestamp:
- Sep 9, 2008, 4:25:52 AM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core3 (added) merged: 1573-1574,1583-1586,1591-1594,1596-1597,1603,1606-1607,1610-1611,1655,1658,1676-1679,1681-1685,1687,1716-1723,1725-1729,1736
- Property svn:mergeinfo changed
-
code/trunk/src/network/ClientConnection.cc
r1534 r1747 45 45 46 46 #include "util/Sleep.h" 47 #include " core/Debug.h"47 #include "util/Debug.h" 48 48 49 49 namespace network … … 91 91 return getPacket(address); 92 92 }*/ 93 93 94 94 ENetEvent *ClientConnection::getEvent(){ 95 95 if(!buffer.isEmpty()) -
code/trunk/src/network/ConnectionManager.cc
r1735 r1747 45 45 #include "core/CoreIncludes.h" 46 46 #include "core/BaseObject.h" 47 #include "core/Iterator.h" 47 48 #include "objects/SpaceShip.h" 48 49 #include "util/Math.h" … … 66 67 { 67 68 //boost::thread_group network_threads; 68 69 69 70 ConnectionManager *ConnectionManager::instance_=0; 70 71 71 72 ConnectionManager::ConnectionManager():receiverThread_(0){ 72 73 assert(instance_==0); … … 77 78 } 78 79 boost::recursive_mutex ConnectionManager::enet_mutex; 79 80 80 81 // ConnectionManager::ConnectionManager(ClientInformation *head) : receiverThread_(0) { 81 82 // assert(instance_==0); … … 85 86 // bindAddress.port = NETWORK_PORT; 86 87 // } 87 88 88 89 ConnectionManager::ConnectionManager(int port){ 89 90 assert(instance_==0); … … 109 110 bindAddress.port = NETWORK_PORT; 110 111 } 111 112 112 113 ConnectionManager::~ConnectionManager(){ 113 114 instance_=0; … … 135 136 return packet; 136 137 }*/ 137 138 138 139 ENetEvent *ConnectionManager::getEvent(){ 139 140 if(!buffer.isEmpty()) … … 160 161 return true; 161 162 } 162 163 163 164 // bool ConnectionManager::addPacket(Packet::Packet *packet){ 164 165 // ClientInformation *temp = instance_->head_->findClient(packet->getClientID()); … … 170 171 // // TODO: finish implementation 171 172 // } 172 // 173 173 // 174 174 175 bool ConnectionManager::addPacket(ENetPacket *packet, ENetPeer *peer) { 175 176 boost::recursive_mutex::scoped_lock lock(instance_->enet_mutex); … … 276 277 } 277 278 } 278 279 279 280 //### added some bugfixes here, but we cannot test them because 280 281 //### the server crashes everytime because of some gamestates … … 335 336 336 337 /** 337 * 338 * @param clientID 338 * 339 * @param clientID 339 340 */ 340 341 void ConnectionManager::syncClassid(unsigned int clientID) { … … 364 365 } 365 366 366 367 367 368 368 369 bool ConnectionManager::removeShip(ClientInformation *client){ 369 370 unsigned int id=client->getShipID(); 370 orxonox:: Iterator<orxonox::SpaceShip>it;371 for(it = orxonox::ObjectList<orxonox::SpaceShip>:: start(); it; ++it){371 orxonox::ObjectList<orxonox::SpaceShip>::iterator it; 372 for(it = orxonox::ObjectList<orxonox::SpaceShip>::begin(); it; ++it){ 372 373 if(it->objectID!=id) 373 374 continue; … … 376 377 return true; 377 378 } 378 379 379 380 380 381 void ConnectionManager::disconnectClient(ClientInformation *client){ 381 382 { … … 386 387 removeShip(client); 387 388 } 388 389 389 390 390 391 } -
code/trunk/src/network/GamestateClient.cc
r1735 r1747 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/BaseObject.h" 35 #include "core/Iterator.h" 35 36 #include "Synchronisable.h" 36 37 … … 68 69 return true; 69 70 } 70 71 71 72 int GamestateClient::processGamestates(){ 72 73 if(tempGamestate_==NULL) … … 89 90 * @return iterator pointing to the next object in the list 90 91 */ 91 void GamestateClient::removeObject(orxonox:: Iterator<Synchronisable>&it) {92 orxonox:: Iterator<Synchronisable>temp=it;92 void GamestateClient::removeObject(orxonox::ObjectList<Synchronisable>::iterator &it) { 93 orxonox::ObjectList<Synchronisable>::iterator temp=it; 93 94 ++it; 94 95 delete *temp; -
code/trunk/src/network/GamestateClient.h
r1735 r1747 42 42 43 43 #include <map> 44 // 44 // 45 45 #include "NetworkPrereqs.h" 46 46 #include "core/CorePrereqs.h" … … 58 58 GamestateClient(); 59 59 ~GamestateClient(); 60 60 61 61 bool add(packet::Gamestate *gs, int clientID); 62 62 bool ack(int gamestateID, int clientID); 63 63 64 64 int processGamestates(); 65 65 packet::Gamestate *getGamestate(); … … 67 67 private: 68 68 bool processGamestate(packet::Gamestate *gs); 69 void removeObject(orxonox:: Iterator<Synchronisable> &it);69 void removeObject(orxonox::ObjectListIterator<Synchronisable> &it); 70 70 void printGamestateMap(); 71 71 bool saveShipCache(); … … 78 78 orxonox::SpaceShip *myShip_; 79 79 unsigned char *shipCache_; 80 80 81 81 }; 82 82 -
code/trunk/src/network/Server.cc
r1735 r1747 50 50 #include "objects/SpaceShip.h" 51 51 #include "core/ConsoleCommand.h" 52 #include "core/Iterator.h" 52 53 #include "packet/Chat.h" 53 54 #include "packet/Packet.h" … … 58 59 #define MAX_FAILURES 20; 59 60 #define NETWORK_FREQUENCY 30 60 61 61 62 /** 62 63 * Constructor for default values (bindaddress is set to ENET_HOST_ANY … … 68 69 gamestates_ = new GamestateManager(); 69 70 } 70 71 71 72 Server::Server(int port){ 72 73 timeSinceLastUpdate_=0; … … 123 124 return message->process(); 124 125 } 125 126 126 127 /** 127 128 * This function sends out a message to all clients … … 175 176 return; 176 177 } 177 178 178 179 bool Server::queuePacket(ENetPacket *packet, int clientID){ 179 180 return connection->addPacket(packet, clientID); … … 230 231 return p->process(); 231 232 } 232 233 233 234 /** 234 235 * sends the gamestate … … 261 262 assert(gs->compressData()); 262 263 if ( !gs->send() ){ 263 COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl; 264 COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl; 264 265 temp->addFailure(); 265 266 }else … … 276 277 return true; 277 278 } 278 279 279 280 // void Server::processChat( chat *data, int clientId){ 280 281 // char *message = new char [strlen(data->message)+10+1]; … … 286 287 // delete data; 287 288 // } 288 289 289 290 bool Server::addClient(ENetEvent *event){ 290 291 ClientInformation *temp = ClientInformation::insertBack(new ClientInformation); … … 303 304 return createClient(temp->getID()); 304 305 } 305 306 306 307 bool Server::createClient(int clientID){ 307 308 ClientInformation *temp = ClientInformation::findClient(clientID); … … 325 326 return true; 326 327 } 327 328 328 329 bool Server::createShip(ClientInformation *client){ 329 330 if(!client) … … 351 352 no->create(); 352 353 no->setBacksync(true); 353 354 354 355 return true; 355 356 } 356 357 357 358 bool Server::disconnectClient(ENetEvent *event){ 358 359 COUT(4) << "removing client from list" << std::endl; 359 360 //return removeClient(head_->findClient(&(peer->address))->getID()); 360 361 361 362 //boost::recursive_mutex::scoped_lock lock(head_->mutex_); 362 orxonox:: Iterator<orxonox::SpaceShip> it = orxonox::ObjectList<orxonox::SpaceShip>::start();363 orxonox::ObjectList<orxonox::SpaceShip>::iterator it = orxonox::ObjectList<orxonox::SpaceShip>::begin(); 363 364 ClientInformation *client = ClientInformation::findClient(&event->peer->address); 364 365 if(!client) … … 369 370 continue; 370 371 } 371 orxonox:: Iterator<orxonox::SpaceShip>temp=it;372 orxonox::ObjectList<orxonox::SpaceShip>::iterator temp=it; 372 373 ++it; 373 374 delete *temp; … … 386 387 gamestates_->removeClient(client); 387 388 } 388 389 389 390 } -
code/trunk/src/network/Synchronisable.h
r1735 r1747 92 92 Synchronisable(); 93 93 private: 94 /* bool removeObject( Iterator<Synchronisable>it);*/94 /* bool removeObject(ObjectList<Synchronisable>::iterator it);*/ 95 95 96 96 std::list<synchronisableVariable *> *syncList; -
code/trunk/src/network/packet/Gamestate.cc
r1740 r1747 30 30 #include "network/ClientInformation.h" 31 31 #include "network/GamestateHandler.h" 32 #include "core/Iterator.h" 32 33 33 34 #include <zlib.h> … … 79 80 unsigned char *mem=data_; 80 81 mem+=sizeof(GamestateHeader); 81 orxonox:: Iterator<Synchronisable>it;82 for(it = orxonox::ObjectList<Synchronisable>:: start(); it; ++it){82 orxonox::ObjectList<Synchronisable>::iterator it; 83 for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){ 83 84 tempsize=it->getSize2(mode); 84 85 … … 86 87 // start allocate additional memory 87 88 COUT(3) << "G.St.Man: need additional memory" << std::endl; 88 orxonox:: Iterator<Synchronisable>temp = it;89 orxonox::ObjectList<Synchronisable>::iterator temp = it; 89 90 int addsize=tempsize; 90 91 while(++temp) … … 124 125 unsigned char *mem=data_+sizeof(GamestateHeader); 125 126 // get the start of the Synchronisable list 126 orxonox:: Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::start();127 orxonox::ObjectList<Synchronisable>::iterator it=orxonox::ObjectList<Synchronisable>::begin(); 127 128 128 129 while(mem < data_+sizeof(GamestateHeader)+HEADER->normsize){ … … 318 319 int size=0; 319 320 // get the start of the Synchronisable list 320 orxonox:: Iterator<Synchronisable>it;321 orxonox::ObjectList<Synchronisable>::iterator it; 321 322 // get total size of gamestate 322 for(it = orxonox::ObjectList<Synchronisable>:: start(); it; ++it)323 for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it) 323 324 size+=it->getSize2(mode); // size of the actual data of the synchronisable 324 325 // size+=sizeof(GamestateHeader); … … 331 332 * @return iterator pointing to the next object in the list 332 333 */ 333 void Gamestate::removeObject(orxonox:: Iterator<Synchronisable>&it) {334 orxonox:: Iterator<Synchronisable>temp=it;334 void Gamestate::removeObject(orxonox::ObjectList<Synchronisable>::iterator &it) { 335 orxonox::ObjectList<Synchronisable>::iterator temp=it; 335 336 ++it; 336 337 delete *temp; -
code/trunk/src/network/packet/Gamestate.h
r1735 r1747 38 38 39 39 namespace packet { 40 40 41 41 struct GamestateHeader{ 42 42 ENUM::Type packetType; … … 51 51 52 52 /** 53 @author 53 @author 54 54 */ 55 55 class Gamestate: public Packet{ … … 57 57 Gamestate(); 58 58 Gamestate(unsigned char *data, int clientID); 59 59 60 60 ~Gamestate(); 61 61 62 62 bool collectData(int id, int mode=0x0); 63 63 bool spreadData(int mode=0x0); … … 69 69 bool compressData(); 70 70 bool decompressData(); 71 71 72 72 // Packet functions 73 73 virtual unsigned int getSize() const; 74 74 virtual bool process(); 75 75 76 76 77 77 private: 78 78 unsigned int calcGamestateSize(int mode=0x0); 79 void removeObject(orxonox:: Iterator<Synchronisable> &it);79 void removeObject(orxonox::ObjectListIterator<Synchronisable> &it); 80 80 81 81 82 82 //Bytestream *bs_; 83 83 //GamestateHeader *header_;
Note: See TracChangeset
for help on using the changeset viewer.