Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 12, 2008, 11:44:01 PM (17 years ago)
Author:
scheusso
Message:

fixed a 'bug' in WE-Model-Spaceship

Location:
code/branches/network3/src/network
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network3/src/network/ClientConnection.cc

    r1253 r1261  
    112112    if(server==NULL)
    113113      return false;
    114     if(!packet){
    115       COUT(4) << "Cl.con: addpacket: invalid packet" << std::endl;
     114    if(packet==NULL){
     115      COUT(3) << "Cl.con: addpacket: invalid packet" << std::endl;
    116116      return false;
    117117    }
  • code/branches/network3/src/network/ClientConnection.h

    r1245 r1261  
    5353#define NETWORK_PORT 55556
    5454#define NETWORK_CLIENT_MAX_CONNECTIONS 5
    55 #define NETWORK_CLIENT_TIMEOUT 10
     55#define NETWORK_CLIENT_TIMEOUT 100
    5656#define NETWORK_SEND_WAIT 5
    5757#define NETWORK_CLIENT_CHANNELS 2
  • code/branches/network3/src/network/ClientInformation.h

    r1232 r1261  
    9292
    9393    bool head;
     94    unsigned short failures_;
    9495
    9596  private:
  • code/branches/network3/src/network/ConnectionManager.cc

    r1250 r1261  
    191191          //std::cout << "received data" << std::endl;
    192192          COUT(5) << "Con.Man: receive event has occured" << std::endl;
    193           processData(event);
     193          // only add, if client has connected yet and not been disconnected
     194          if(head_->findClient(&event->peer->address))
     195            processData(event);
    194196          break;
    195197        case ENET_EVENT_TYPE_DISCONNECT:
     
    354356  }
    355357 
     358  bool ConnectionManager::removeShip(ClientInformation *client){
     359    int id=client->getShipID();
     360    orxonox::Iterator<orxonox::SpaceShip> it;
     361    for(it = orxonox::ObjectList<orxonox::SpaceShip>::start(); it; ++it){
     362      if(it->objectID!=id)
     363        continue;
     364      delete *it;
     365    }
     366    return true;
     367  }
     368 
    356369  bool ConnectionManager::sendWelcome(int clientID, int shipID, bool allowed){
    357370    addPacket(packet_gen.generateWelcome(clientID, shipID, allowed),clientID);
    358371    sendPackets();
    359372    return true;
     373  }
     374 
     375  void ConnectionManager::disconnectClient(ClientInformation *client){
     376    enet_peer_disconnect(client->getPeer(), 0);
     377    removeShip(client);
    360378  }
    361379 
  • code/branches/network3/src/network/ConnectionManager.h

    r1245 r1261  
    8686    bool sendPackets();
    8787    bool createClient(int clientID);
     88    void disconnectClient(ClientInformation *client);
    8889
    8990  private:
     
    99100    ENetPeer *getClientPeer(int clientID);
    100101    bool createShip(ClientInformation *client);
     102    bool removeShip(ClientInformation *client);
    101103    bool sendWelcome(int clientID, int shipID, bool allowed);
    102104    bool addFakeConnectRequest(ENetEvent *ev);
  • code/branches/network3/src/network/GameStateManager.cc

    r1253 r1261  
    449449    return true; // TODO: change this
    450450  }
     451 
     452  void GameStateManager::removeClient(ClientInformation* client){
     453    gameStateUsed[client->getGamestateID()]--;
     454    head_->removeClient(client->getID());
     455  }
    451456
    452457}
  • code/branches/network3/src/network/GameStateManager.h

    r1232 r1261  
    7676    bool pushGameState(GameStateCompressed *gs, int clientID);
    7777    void ackGameState(int clientID, int gamestateID);
     78    void removeClient(ClientInformation *client);
    7879  private:
    7980    void cleanup(); // "garbage handler"
  • code/branches/network3/src/network/Server.cc

    r1253 r1261  
    5353namespace network
    5454{
     55 
     56 
     57#define MAX_FAILURES 20;
     58 
     59 
    5560  /**
    5661  * Constructor for default values (bindaddress is set to ENET_HOST_ANY
     
    205210      }
    206211      //std::cout << "adding gamestate" << std::endl;
    207       if ( !(connection->addPacket(packet_gen.gstate(gs), cid)) )
    208         COUT(4) << "Server: packet with client id (cid): " << cid << " not sended" << std::endl;
     212      if ( !(connection->addPacket(packet_gen.gstate(gs), cid)) ){
     213        COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->failures_ << std::endl;
     214        temp->failures_++;
     215        if(temp->failures_ > 20 )
     216          disconnectClient(temp);
    209217      //std::cout << "added gamestate" << std::endl;
     218      }
    210219      added=true;
    211220      temp=temp->next();
     
    240249    if(!gamestates->pushGameState(data, clientID))
    241250        COUT(3) << "Could not push gamestate\t\t\t\t=====" << std::endl;
    242   }
    243 
     251    else
     252        clients->findClient(clientID)->failures_=0;
     253  }
     254
     255  void Server::disconnectClient(int clientID){
     256    ClientInformation *client = clients->findClient(clientID);
     257    disconnectClient(client);
     258  }
     259  void Server::disconnectClient( ClientInformation *client){
     260    connection->disconnectClient(client);
     261    gamestates->removeClient(client);
     262  }
     263 
    244264}
  • code/branches/network3/src/network/Server.h

    r1245 r1261  
    7171    void updateGamestate();
    7272  private:
     73    void disconnectClient(int clientID);
     74    void disconnectClient( ClientInformation *client);
    7375    bool sendGameState();
    7476    void processAck( ack *data, int clientID);
Note: See TracChangeset for help on using the changeset viewer.