Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 28, 2010, 7:11:32 PM (14 years ago)
Author:
scheusso
Message:

this should prevent disconnecting clients from crashing our servers ;)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network6/src/libraries/network/Connection.cc

    r7823 r7824  
    183183    {
    184184      case outgoingEventType::sendPacket:
    185         assert(this->peerMap_.find(event.peerID) != this->peerMap_.end());
    186         peer = this->peerMap_[event.peerID];
    187         enet_peer_send( peer, event.channelID, event.packet );
     185        // check whether the peer is still/already in the peer list
     186        if( this->peerMap_.find(event.peerID) != this->peerMap_.end() )
     187        {
     188          peer = this->peerMap_[event.peerID];
     189          enet_peer_send( peer, event.channelID, event.packet );
     190        }
     191        else
     192        {
     193          // peer probably already disconnected so just discard packet
     194          assert(event.peerID<this->nextPeerID_);
     195          delete event.packet;
     196        }
    188197        break;
    189198      case outgoingEventType::disconnectPeer:
    190         assert(this->peerMap_.find(event.peerID) != this->peerMap_.end());
    191         peer = this->peerMap_[event.peerID];
    192         enet_peer_disconnect(peer, 0);
     199        if( this->peerMap_.find(event.peerID) != this->peerMap_.end() )
     200        {
     201          peer = this->peerMap_[event.peerID];
     202          enet_peer_disconnect(peer, 0);
     203        }
     204        else
     205        {
     206          // peer probably already disconnected so just discard disconnect event
     207          assert(event.peerID<this->nextPeerID_);
     208        }
    193209        break;
    194210      case outgoingEventType::disconnectPeers:
Note: See TracChangeset for help on using the changeset viewer.