Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 22, 2010, 7:24:24 PM (13 years ago)
Author:
dafrick
Message:

Merging presentation2 branch back to trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/GamestateManager.h

    r7163 r7801  
    4646#include "GamestateHandler.h"
    4747#include "core/CorePrereqs.h"
     48#include "packet/Gamestate.h"
     49#include <boost/concept_check.hpp>
    4850
    4951namespace orxonox
     
    6668  * @author Oliver Scheuss
    6769  */
    68   class _NetworkExport GamestateManager: public GamestateHandler{
     70  class _NetworkExport GamestateManager: public GamestateHandler
     71  {
     72    struct peerInfo
     73    {
     74      uint32_t  peerID;
     75      uint32_t  lastProcessedGamestateID;
     76      uint32_t  lastAckedGamestateID;
     77      bool      isSynched;
     78      std::map< uint32_t, packet::Gamestate* > gamestates;
     79    };
     80   
    6981  public:
     82   
    7083    GamestateManager();
    7184    ~GamestateManager();
    7285
    73     bool add(packet::Gamestate *gs, unsigned int clientID);
     86    virtual bool      addGamestate(packet::Gamestate *gs, unsigned int peerID);
     87    virtual bool      ackGamestate(unsigned int gamestateID, unsigned int peerID);
     88    virtual uint32_t  getLastProcessedGamestateID( unsigned int peerID );
     89    virtual uint32_t  getCurrentGamestateID(){ return currentGamestate_->getID(); }
     90   
    7491    bool processGamestates();
     92    bool sendAck(unsigned int gamestateID, uint32_t peerID);
    7593    bool update();
    76     void sendGamestates();
    77 //     packet::Gamestate *popGameState(unsigned int clientID);
    78     void finishGamestate( unsigned int clientID, packet::Gamestate*& destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate );
     94    std::vector<packet::Gamestate*> getGamestates();
     95    void finishGamestate( unsigned int peerID, packet::Gamestate*& destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate );
    7996
    8097    bool getSnapshot();
    8198
    82     bool ack(unsigned int gamestateID, unsigned int clientID);
    83     void removeClient(ClientInformation *client);
     99    void addPeer( uint32_t peerID );
     100    void setSynched( uint32_t peerID )
     101      { assert(peerMap_.find(peerID)!=peerMap_.end()); peerMap_[peerID].isSynched = true; }
     102    void removePeer( uint32_t peerID );
     103//     void removeClient(ClientInformation *client);
     104  protected:
     105    virtual bool sendPacket( packet::Packet* packet ) = 0;
    84106  private:
    85107    bool processGamestate(packet::Gamestate *gs);
    86108
    87     std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> > gamestateMap_;
     109//     std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> > gamestateMap_;
    88110    std::map<unsigned int, packet::Gamestate*> gamestateQueue;
    89     packet::Gamestate *reference;
    90     TrafficControl *trafficControl_;
     111//     std::map<unsigned int, uint32_t> lastProcessedGamestateID_;
     112    std::map<uint32_t, peerInfo> peerMap_;
     113    packet::Gamestate* currentGamestate_;
     114//     TrafficControl *trafficControl_;
    91115    unsigned int id_;
    92116//     boost::mutex* threadMutex_;
Note: See TracChangeset for help on using the changeset viewer.