- Timestamp:
- Jun 22, 2006, 3:17:53 PM (18 years ago)
- Location:
- branches/network/src/lib/network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/udp_server_socket.cc
r8723 r8727 170 170 * @param ip users host / port 171 171 */ 172 void UdpServerSocket::initUser( int userId, IPaddress ip )172 void UdpServerSocket::initUser( int userId, IPaddress ip, byte randomByte ) 173 173 { 174 174 int channel = SDLNet_UDP_Bind( socket, userId, &ip ); … … 189 189 userList.resize( userId + 1 ); 190 190 191 userList[ userId ] = ip; 191 userList[ userId ].addr = ip; 192 userList[ userId ].randomByte = randomByte; 192 193 } 193 194 … … 203 204 return; 204 205 205 userList[userId]. host = 0;206 userList[userId]. port = 0;206 userList[userId].addr.host = 0; 207 userList[userId].addr.port = 0; 207 208 208 209 SDLNet_UDP_Unbind( socket, userId ); … … 248 249 bool isNewConnection = false; 249 250 251 if ( packet->len <= 0 ) 252 continue; 253 250 254 for ( userId =0; userId < (int)userList.size(); userId++ ) 251 if ( userList[userId]. host == packet->address.host && userList[userId].port == packet->address.port)255 if ( userList[userId].addr.host == packet->address.host && userList[userId].addr.port == packet->address.port && userList[userId].randomByte == ( packet->data[0] & 0xFC ) ) 252 256 break; 253 257 254 258 if ( userId >= (int)userList.size() ) 255 259 { 256 if ( packet->len <= 0 )257 continue;258 259 260 newConn++; 260 261 isNewConnection = true; … … 267 268 268 269 for ( userId =0; userId < (int)userList.size(); userId++ ) 269 if ( userList[userId]. host == 0 && userList[userId].port == 0 )270 if ( userList[userId].addr.host == 0 && userList[userId].addr.port == 0 ) 270 271 break; 271 272 272 initUser( userId, packet->address );273 initUser( userId, packet->address, packet->data[0] & 0xFC ); 273 274 UdpSocket * sock = new UdpSocket( this, packet->address, userId, packet->data[0] & 0xFC ); 274 275 newSocketList.push_back( sock ); -
branches/network/src/lib/network/udp_server_socket.h
r7954 r8727 33 33 typedef std::vector<NetworkPacketList> PacketBuffer; 34 34 35 typedef std::vector<IPaddress> UserList; 35 struct UserInfo 36 { 37 IPaddress addr; 38 byte randomByte; 39 }; 40 41 typedef std::vector<UserInfo> UserList; 36 42 37 43 typedef std::list<UdpSocket*> UdpSocketList; … … 57 63 bool sendPacket( NetworkPacket networkPacket, int userId ); 58 64 int getPacketCount( int childId ); 59 void initUser( int childId, IPaddress ip );65 void initUser( int childId, IPaddress ip, byte randomByte ); 60 66 61 67 private:
Note: See TracChangeset
for help on using the changeset viewer.