Changeset 1713
- Timestamp:
- Sep 6, 2008, 2:50:12 PM (16 years ago)
- Location:
- code/branches/network/src/network
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/ConnectionManager.cc
r1711 r1713 334 334 } 335 335 336 void ConnectionManager::syncClassid(int clientID) { 336 /** 337 * 338 * @param clientID 339 */ 340 void ConnectionManager::syncClassid(unsigned int clientID) { 337 341 unsigned int network_id=0, failures=0; 338 342 std::string classname; … … 349 353 COUT(4) << "Con.Man:syncClassid:\tnetwork_id: " << network_id << ", classname: " << classname << std::endl; 350 354 351 packet::ClassID classid( network_id, classname );352 classid .setClientID(clientID);353 while(!classid .send() && failures < 10){355 packet::ClassID *classid = new packet::ClassID( network_id, classname ); 356 classid->setClientID(clientID); 357 while(!classid->send() && failures < 10){ 354 358 failures++; 355 359 } -
code/branches/network/src/network/ConnectionManager.h
r1705 r1713 94 94 //bool createClient(int clientID); 95 95 void disconnectClient(ClientInformation *client); 96 void syncClassid( int clientID);96 void syncClassid(unsigned int clientID); 97 97 98 98 private: -
code/branches/network/src/network/packet/Acknowledgement.cc
r1711 r1713 44 44 flags_ = flags_ | PACKET_FLAGS_ACK; 45 45 data_=new unsigned char[ getSize() ]; 46 *(ENUM::Type *) &data_[ _PACKETID ]= ENUM::Acknowledgement;46 *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::Acknowledgement; 47 47 *(unsigned int *)&data_[ _ACKID ] = id; 48 48 clientID_=clientID; -
code/branches/network/src/network/packet/ClassID.cc
r1712 r1713 51 51 data_=new unsigned char[ getSize() ]; 52 52 assert(data_); 53 *(ENUM::Type *) &data_[ _PACKETID ]= ENUM::ClassID;54 *(unsigned int *) &data_[ _CLASSID ]= classID;55 *(unsigned int *) &data_[ _CLASSNAMELENGTH ]= classNameLength_;56 memcpy( &data_[ _CLASSNAME ], (void *)className.c_str(), classNameLength_ );53 *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::ClassID; 54 *(unsigned int *)(data_ + _CLASSID ) = classID; 55 *(unsigned int *)(data_ + _CLASSNAMELENGTH ) = classNameLength_; 56 memcpy( data_+_CLASSNAME, (void *)className.c_str(), classNameLength_ ); 57 57 } 58 58 … … 72 72 73 73 bool ClassID::process(){ 74 COUT(3) << "processing classid: " << getClassID() << " name: " << &data_[ sizeof(network::packet::ENUM::Type) ] << std::endl; 74 75 orxonox::Identifier *id=ID( std::string((const char*)&data_[ sizeof(network::packet::ENUM::Type) ]) ); 75 76 if(id==NULL) -
code/branches/network/src/network/packet/Gamestate.cc
r1712 r1713 106 106 //start write gamestate header 107 107 HEADER->packetType = ENUM::Gamestate; 108 assert( *(ENUM::Type *)&data_[ 0 ] == ENUM::Gamestate); 108 assert( *(ENUM::Type *)&data_[ 0 ] == ENUM::Gamestate); 109 109 HEADER->normsize = currentsize; 110 110 HEADER->id = id; -
code/branches/network/src/network/packet/Packet.cc
r1712 r1713 61 61 62 62 void blub(ENetPacket *packet){ 63 COUT( 0) << "blubb" << std::endl;63 COUT(4) << "blubb" << std::endl; 64 64 } 65 65 66 66 Packet::Packet(unsigned char *data, int clientID){ 67 67 flags_ = PACKET_FLAG_DEFAULT; 68 packetDirection_ = ENUM:: Outgoing;68 packetDirection_ = ENUM::Incoming; 69 69 clientID_=clientID; 70 70 data_=data; … … 72 72 } 73 73 74 Packet::Packet(ENetPacket *packet, ENetPeer *peer){74 /*Packet::Packet(ENetPacket *packet, ENetPeer *peer){ 75 75 packetDirection_ = ENUM::Incoming; 76 76 enetPacket_ = packet; 77 77 clientID_ = ClientInformation::findClient(&peer->address)->getID(); 78 78 data_ = packet->data; 79 } 79 }*/ 80 80 81 81 Packet::Packet(const Packet &p){ … … 107 107 } 108 108 enetPacket_ = enet_packet_create(getData(), getSize(), getFlags()); 109 //enetPacket_->freeCallback = &Packet::deletePacket; 109 110 enetPacket_->freeCallback = &blub; 110 111 packetMap_[enetPacket_] = this; … … 119 120 unsigned int clientID = ClientInformation::findClient(&peer->address)->getID(); 120 121 Packet *p; 122 COUT(3) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl; 121 123 switch( *(ENUM::Type *)&data[_PACKETID] ) 122 124 { 123 125 case ENUM::Acknowledgement: 126 COUT(3) << "ack" << std::endl; 124 127 p = new Acknowledgement( data, clientID ); 125 128 break; 126 129 case ENUM::Chat: 130 COUT(3) << "chat" << std::endl; 127 131 p = new Chat( data, clientID ); 128 132 break; 129 133 case ENUM::ClassID: 134 COUT(3) << "classid" << std::endl; 130 135 p = new ClassID( data, clientID ); 131 136 break; 132 137 case ENUM::Gamestate: 138 COUT(3) << "gamestate" << std::endl; 133 139 // TODO: remove brackets 134 140 p = new Gamestate( data, true, clientID ); 135 141 break; 136 142 case ENUM::Welcome: 143 COUT(3) << "welcome" << std::endl; 137 144 p = new Welcome( data, clientID ); 138 145 default: -
code/branches/network/src/network/packet/Packet.h
r1711 r1713 75 75 Packet(); 76 76 Packet(unsigned char *data, int clientID); 77 Packet(ENetPacket *packet, ENetPeer *peer);77 // Packet(ENetPacket *packet, ENetPeer *peer); 78 78 enet_uint32 flags_; 79 79 int clientID_; -
code/branches/network/src/network/packet/Welcome.cc
r1711 r1713 49 49 data_=new unsigned char[ getSize() ]; 50 50 assert(data_); 51 *(packet::ENUM::Type *) &data_[ _PACKETID ]= packet::ENUM::Welcome;51 *(packet::ENUM::Type *)(data_ + _PACKETID ) = packet::ENUM::Welcome; 52 52 *(unsigned int *)&data_[ _CLIENTID ] = clientID; 53 53 *(unsigned int *)&data_[ _SHIPID ] = shipID;
Note: See TracChangeset
for help on using the changeset viewer.