Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1261


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
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network3/cmake/FindBoost.cmake

    r790 r1261  
    101101# Add in some path suffixes. These will have to be updated whenever a new Boost version comes out.
    102102SET(SUFFIX_FOR_PATH
     103 boost
    103104 boost-1_34_1
    104105 boost-1_34_0
  • 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);
  • code/branches/network3/src/orxonox/Main.cc

    r1250 r1261  
    7575{
    7676  try {
    77     //SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
     77    SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
    7878    Orxonox* orx = Orxonox::getSingleton();
    7979
  • code/branches/network3/src/orxonox/Orxonox.cc

    r1232 r1261  
    494494      ogreRoot._fireFrameEnded(evt);
    495495          }
     496    if(mode_==CLIENT)
     497      network::Client::getSingleton()->closeConnection();
     498    else if(mode_==SERVER)
     499      server_g->close();
    496500  }
    497501
  • code/branches/network3/src/orxonox/objects/SpaceShip.cc

    r1250 r1261  
    113113    SpaceShip::~SpaceShip()
    114114    {
    115         if (this->tt_)
     115        if (this->tt_){
    116116            delete this->tt_;
     117        }
    117118    }
    118119
  • code/branches/network3/src/orxonox/objects/WorldEntity.cc

    r1245 r1261  
    7575    WorldEntity::~WorldEntity()
    7676    {
     77      // just to make sure we clean out all scene nodes
     78      this->getNode()->removeAndDestroyAllChildren();
    7779    }
    7880
     
    207209      registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA, 0x3);
    208210      // register velocity_
    209       registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA, 0x3);
    210       registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA, 0x3);
    211       registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA, 0x3);
    212       // register rotationAxis/rate
    213       registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA, 0x3);
    214       registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA, 0x3);
    215       registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA, 0x3);
    216       registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3);
     211//       registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA, 0x3);
     212//       registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA, 0x3);
     213//       registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA, 0x3);
     214//       // register rotationAxis/rate
     215//       registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA, 0x3);
     216//       registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA, 0x3);
     217//       registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA, 0x3);
     218//       registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3);
    217219      // register scale of node
    218220      registerVar( (void*) &(this->getScale().x), sizeof(this->getScale().x), network::DATA, 0x3);
  • code/branches/network3/src/orxonox/particle/ParticleInterface.cc

    r1039 r1261  
    6363  ParticleInterface::~ParticleInterface(void)
    6464  {
     65    while(particleSystem_->getNumEmitters()>0)
     66      particleSystem_->removeEmitter(particleSystem_->getNumEmitters()-1);
    6567    sceneManager_->destroyParticleSystem(particleSystem_);
    6668  }
Note: See TracChangeset for help on using the changeset viewer.