Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7780 for code/branches


Ignore:
Timestamp:
Dec 19, 2010, 9:41:57 PM (14 years ago)
Author:
scheusso
Message:

some fixes
reactivating acking and gamestate diffing

Location:
code/branches/network5/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network5/src/libraries/network/Client.h

    r7777 r7780  
    8080    bool closeConnection();
    8181    void queuePacket(ENetPacket* packet, int clientID, uint8_t channelID);
     82    virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); }
    8283    bool processChat(const std::string& message, unsigned int playerID);
    8384    virtual bool chat(const std::string& message);
  • code/branches/network5/src/libraries/network/Connection.cc

    r7777 r7780  
    8282  void Connection::disconnectPeer(ENetPeer *peer)
    8383  {
     84    assert(peer);
    8485    outgoingEvent outEvent = { peer, outgoingEventType::disconnectPeer, (ENetPacket*)10, 15 };
    8586   
     
    9192  void Connection::addPacket(ENetPacket *packet, ENetPeer *peer, uint8_t channelID)
    9293  {
     94    assert(peer);
    9395    outgoingEvent outEvent = { peer, outgoingEventType::sendPacket, packet, channelID };
    9496   
     
    100102  void Connection::broadcastPacket(ENetPacket* packet, uint8_t channelID)
    101103  {
    102     outgoingEvent outEvent = { 0, outgoingEventType::broadcastPacket, packet, channelID };
     104    outgoingEvent outEvent = { (ENetPeer*)15, outgoingEventType::broadcastPacket, packet, channelID };
    103105   
    104106    this->outgoingEventsMutex_->lock();
  • code/branches/network5/src/libraries/network/GamestateManager.cc

    r7777 r7780  
    110110      bool b = processGamestate(it->second);
    111111      assert(b);
     112      sendAck( it->second->getID(), it->second->getPeerID() );
    112113      delete it->second;
    113114    }
     
    117118    NetworkCallbackManager::callCallbacks();
    118119    return true;
     120  }
     121 
     122  bool GamestateManager::sendAck(unsigned int gamestateID, uint32_t peerID)
     123  {
     124    packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, peerID);
     125    if( !this->sendPacket(ack))
     126    {
     127      COUT(3) << "could not ack gamestate: " << gamestateID << std::endl;
     128      return false;
     129    }
     130    else
     131    {
     132      COUT(5) << "acked a gamestate: " << gamestateID << std::endl;
     133      return true;
     134    }
    119135  }
    120136
     
    173189      peerGamestates.push_back(0);  // insert an empty gamestate* to change
    174190      finishGamestate( peerID, peerGamestates.back(), baseGamestate, currentGamestate_ );
     191      if( peerGamestates.back()==0 )
     192        // nothing to send to remove pointer from vector
     193        peerGamestates.pop_back();
    175194      //FunctorMember<GamestateManager>* functor =
    176195//       ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate, this) );
     
    236255
    237256
    238   bool GamestateManager::ackGamestate(unsigned int gamestateID, unsigned int peerID) {
     257  bool GamestateManager::ackGamestate(unsigned int gamestateID, unsigned int peerID)
     258  {
    239259//     ClientInformation *temp = ClientInformation::findClient(peerID);
    240260//     assert(temp);
     
    255275    }
    256276
    257     assert(curid==GAMESTATEID_INITIAL || curid<gamestateID);
     277    assert(curid==GAMESTATEID_INITIAL || curid<=gamestateID);
    258278    COUT(5) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << std::endl;
    259279    std::map<uint32_t, packet::Gamestate*>::iterator it2;
  • code/branches/network5/src/libraries/network/GamestateManager.h

    r7777 r7780  
    9090   
    9191    bool processGamestates();
     92    bool sendAck(unsigned int gamestateID, uint32_t peerID);
    9293    bool update();
    9394    std::vector<packet::Gamestate*> getGamestates();
     
    101102    void removePeer( uint32_t peerID );
    102103//     void removeClient(ClientInformation *client);
     104  protected:
     105    virtual bool sendPacket( packet::Packet* packet ) = 0;
    103106  private:
    104107    bool processGamestate(packet::Gamestate *gs);
  • code/branches/network5/src/libraries/network/Server.cc

    r7777 r7780  
    360360    else
    361361    {
     362      GamestateManager::removePeer(client->getID());
    362363      //ServerConnection::disconnectClient( client );
    363364      //ClientConnectionListener::broadcastClientDisconnected( client->getID() ); //this is done in ClientInformation now
  • code/branches/network5/src/libraries/network/Server.h

    r7777 r7780  
    6767    bool processChat(const std::string& message, unsigned int playerID);
    6868    void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID);
     69    virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); }
    6970    void update(const Clock& time);
    7071    unsigned int getRTT(unsigned int clientID);
  • code/branches/network5/src/libraries/network/packet/FunctionCalls.cc

    r7777 r7780  
    7171    FunctionCall fctCall;
    7272    fctCall.loadData(temp);
    73     if( this->minGamestateID_ > host->getLastProcessedGamestateID(this->getPeerID()) || !fctCall.execute() )
     73    if( !fctCall.execute() )
    7474    {
    7575      FunctionCallManager::bufferIncomingFunctionCall( fctCall, minGamestateID_, this->getPeerID() );
  • code/branches/network5/src/libraries/network/packet/Packet.cc

    r7777 r7780  
    179179  assert(ClientInformation::findClient(&peer->address)->getID() != static_cast<unsigned int>(-2) || !Host::isServer());
    180180  unsigned int peerID = ClientInformation::findClient(&peer->address)->getID();
     181  // HACK
     182  if( peerID==static_cast<unsigned int>(-2))
     183    peerID = NETWORK_PEER_ID_SERVER;
    181184  Packet *p = 0;
    182185//   COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl;
  • code/branches/network5/src/orxonox/gametypes/Gametype.cc

    r7777 r7780  
    171171    void Gametype::playerEntered(PlayerInfo* player)
    172172    {
    173       COUT(0) << "Gametype: playerentered" << endl;
    174173        this->players_[player].state_ = PlayerState::Joined;
    175174    }
     
    412411    void Gametype::spawnPlayer(PlayerInfo* player)
    413412    {
    414       COUT(0) << "Gametype: spawnPlayer" << endl;
    415413        SpawnPoint* spawnpoint = this->getBestSpawnPoint(player);
    416414        if (spawnpoint)
Note: See TracChangeset for help on using the changeset viewer.