- Timestamp:
- Dec 19, 2010, 2:27:06 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network5/src/libraries/network/packet/Packet.cc
r7773 r7777 68 68 flags_ = PACKET_FLAG_DEFAULT; 69 69 packetDirection_ = Direction::Outgoing; 70 clientID_=0;70 peerID_=0; 71 71 data_=0; 72 72 enetPacket_=0; … … 74 74 } 75 75 76 Packet::Packet(uint8_t *data, unsigned int clientID)76 Packet::Packet(uint8_t *data, unsigned int peerID) 77 77 { 78 78 flags_ = PACKET_FLAG_DEFAULT; 79 79 packetDirection_ = Direction::Incoming; 80 clientID_=clientID;80 peerID_=peerID; 81 81 data_=data; 82 82 enetPacket_=0; … … 89 89 flags_=p.flags_; 90 90 packetDirection_ = p.packetDirection_; 91 clientID_ = p.clientID_;91 peerID_ = p.peerID_; 92 92 if(p.data_){ 93 93 data_ = new uint8_t[p.getSize()]; … … 125 125 } 126 126 127 bool Packet::send( ){127 bool Packet::send(orxonox::Host* host){ 128 128 if(packetDirection_ != Direction::Outgoing && packetDirection_ != Direction::Bidirectional ){ 129 129 assert(0); … … 169 169 // enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet 170 170 if( this->flags_ & PacketFlag::Reliable ) 171 Host::addPacket( enetPacket_, clientID_, NETWORK_CHANNEL_DEFAULT);171 host->addPacket( enetPacket_, peerID_, NETWORK_CHANNEL_DEFAULT); 172 172 else 173 Host::addPacket( enetPacket_, clientID_, NETWORK_CHANNEL_UNRELIABLE);173 host->addPacket( enetPacket_, peerID_, NETWORK_CHANNEL_UNRELIABLE); 174 174 return true; 175 175 } … … 178 178 uint8_t *data = packet->data; 179 179 assert(ClientInformation::findClient(&peer->address)->getID() != static_cast<unsigned int>(-2) || !Host::isServer()); 180 unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();180 unsigned int peerID = ClientInformation::findClient(&peer->address)->getID(); 181 181 Packet *p = 0; 182 182 // COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl; … … 185 185 case Type::Acknowledgement: 186 186 // COUT(5) << "ack" << std::endl; 187 p = new Acknowledgement( data, clientID );187 p = new Acknowledgement( data, peerID ); 188 188 break; 189 189 case Type::Chat: 190 190 // COUT(5) << "chat" << std::endl; 191 p = new Chat( data, clientID );191 p = new Chat( data, peerID ); 192 192 break; 193 193 case Type::ClassID: 194 194 // COUT(5) << "classid" << std::endl; 195 p = new ClassID( data, clientID );195 p = new ClassID( data, peerID ); 196 196 break; 197 197 case Type::Gamestate: 198 198 // COUT(5) << "gamestate" << std::endl; 199 p = new Gamestate( data, clientID );199 p = new Gamestate( data, peerID ); 200 200 break; 201 201 case Type::Welcome: 202 202 // COUT(5) << "welcome" << std::endl; 203 p = new Welcome( data, clientID );203 p = new Welcome( data, peerID ); 204 204 break; 205 205 case Type::DeleteObjects: 206 206 // COUT(5) << "deleteobjects" << std::endl; 207 p = new DeleteObjects( data, clientID );207 p = new DeleteObjects( data, peerID ); 208 208 break; 209 209 case Type::FunctionCalls: 210 210 // COUT(5) << "functionCalls" << std::endl; 211 p = new FunctionCalls( data, clientID );211 p = new FunctionCalls( data, peerID ); 212 212 break; 213 213 case Type::FunctionIDs: 214 214 // COUT(5) << "functionIDs" << std::endl; 215 p = new FunctionIDs( data, clientID );215 p = new FunctionIDs( data, peerID ); 216 216 break; 217 217 default:
Note: See TracChangeset
for help on using the changeset viewer.