Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7556 in orxonox.OLD for branches/network/src/lib


Ignore:
Timestamp:
May 8, 2006, 11:55:55 AM (19 years ago)
Author:
rennerc
Message:

fixed some bugs in udpSockets. subprojects/network should work now

Location:
branches/network/src/lib/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/udp_server_socket.cc

    r7553 r7556  
    4444  for ( int i = 0; i < packetBuffer.size(); i++ )
    4545    removeUserPackets( i );
     46 
     47  if ( packet )
     48    SDLNet_FreePacket( packet );
     49 
     50  if ( socket )
     51    SDLNet_UDP_Close( socket );
    4652}
    4753
     
    106112    NetworkPacket networkPacket;
    107113    networkPacket.length = packet->len;
    108     networkPacket.data = (byte*)malloc( packet->len );
    109     assert( networkPacket.data );
     114    if ( packet->len != 0 )
     115    {
     116      networkPacket.data = (byte*)malloc( packet->len );
     117      assert( networkPacket.data );
     118    }
     119    else
     120      networkPacket.data = NULL;
    110121    memcpy( networkPacket.data, packet->data, packet->len );
    111122    packetBuffer[userId].push_back( networkPacket );
     
    155166    if ( it->data )
    156167    {
    157       delete it->data;
     168      free( it->data );
    158169      it->data = NULL;
    159170    }
     
    253264  memcpy( packet->data, networkPacket.data, networkPacket.length );
    254265  packet->len = networkPacket.length;
     266  packet->channel = -1;
    255267 
    256268  if ( SDLNet_UDP_Send( socket, userId, packet ) == 0 )
  • branches/network/src/lib/network/udp_socket.cc

    r7553 r7556  
    6868  this->init();
    6969  this->serverSocket = serverSocket;
     70  this->userId = userId;
    7071}
    7172
     
    7374 * destructor
    7475 */
    75 UdpSocket::~ UdpSocket( )
     76UdpSocket::~UdpSocket( )
    7677{
    7778  if ( serverSocket )
     
    7980 
    8081  disconnectServer();
     82 
     83  if ( this->packet )
     84    SDLNet_FreePacket( this->packet );
     85 
     86  if ( socket )
     87    SDLNet_UDP_Close( socket );
    8188}
    8289
     
    186193    if ( networkPacket.data )
    187194    {
    188       delete networkPacket.data;
     195      free( networkPacket.data );
    189196      networkPacket.data = NULL;
    190197    }
Note: See TracChangeset for help on using the changeset viewer.