Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1990 for code


Ignore:
Timestamp:
Oct 21, 2008, 5:53:09 PM (16 years ago)
Author:
scheusso
Message:
  • some adjustments in client handling (we use unsigned int as id now everywhere)
  • fixed a problem with clientinformation
Location:
code/branches/objecthierarchy/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/network/ClientInformation.cc

    r1960 r1990  
    5959
    6060  ClientInformation::~ClientInformation() {
    61     if(this==head_)
    62       head_=next();
    6361    if(prev()!=0)
    6462      prev()->setNext(this->next());
    6563    if(next()!=0)
    6664      next()->setPrev(this->prev());
     65    if(this==head_)
     66      head_=next();
    6767  }
    6868
  • code/branches/objecthierarchy/src/network/GamestateClient.cc

    r1944 r1990  
    4343  struct _NetworkExport GameStateItem{
    4444    packet::Gamestate *state;
    45     int id;
     45    unsigned int id;
    4646  };
    4747
     
    5656  }
    5757
    58   bool GamestateClient::ack(int gamestateID, int clientID){
     58  bool GamestateClient::ack(unsigned int gamestateID, unsigned int clientID){
    5959    return true;
    6060  }
    6161
    62   bool GamestateClient::add(packet::Gamestate *gs, int clientID){
     62  bool GamestateClient::add(packet::Gamestate *gs, unsigned int clientID){
    6363    if(tempGamestate_!=NULL){
    6464      //delete the obsolete gamestate
     
    110110
    111111  void GamestateClient::cleanup(){
    112     std::map<int, packet::Gamestate*>::iterator temp, it = gamestateMap_.begin();
     112    std::map<unsigned int, packet::Gamestate*>::iterator temp, it = gamestateMap_.begin();
    113113    while(it!=gamestateMap_.end()){
    114114      if(it->first>=last_diff_)
     
    123123
    124124  void GamestateClient::printGamestateMap(){
    125     std::map<int, packet::Gamestate*>::iterator it;
     125    std::map<unsigned int, packet::Gamestate*>::iterator it;
    126126    COUT(4) << "gamestates: ";
    127127    for(it=gamestateMap_.begin(); it!=gamestateMap_.end(); it++){
  • code/branches/objecthierarchy/src/network/GamestateClient.h

    r1916 r1990  
    4848#include "GamestateHandler.h"
    4949
    50 #define GAMESTATEID_INITIAL -1
     50const unsigned int GAMESTATEID_INITIAL=-1;
    5151
    5252namespace network
     
    5858    ~GamestateClient();
    5959
    60     bool add(packet::Gamestate *gs, int clientID);
    61     bool ack(int gamestateID, int clientID);
     60    bool add(packet::Gamestate *gs, unsigned int clientID);
     61    bool ack(unsigned int gamestateID, unsigned int clientID);
    6262
    6363    bool processGamestates();
     
    7070    bool sendAck(unsigned int gamestateID);
    7171
    72     int           last_diff_;
    73     int           last_gamestate_;
    74     std::map<int, packet::Gamestate *> gamestateMap_;
     72    unsigned int           last_diff_;
     73    unsigned int           last_gamestate_;
     74    std::map<unsigned int, packet::Gamestate *> gamestateMap_;
    7575    packet::Gamestate *tempGamestate_; // we save the received gamestates here during processQueue
    7676    unsigned char *shipCache_;
  • code/branches/objecthierarchy/src/network/GamestateHandler.h

    r1916 r1990  
    4141class _NetworkExport GamestateHandler{
    4242  private:
    43     virtual bool add(packet::Gamestate *gs, int clientID)=0;
    44     virtual bool ack(int gamestateID, int clientID)=0;
     43    virtual bool add(packet::Gamestate *gs, unsigned int clientID)=0;
     44    virtual bool ack(unsigned int gamestateID, unsigned int clientID)=0;
    4545
    4646    static GamestateHandler *instance_;
     
    5252
    5353  public:
    54     static bool addGamestate(packet::Gamestate *gs, int clientID){ return instance_->add(gs, clientID); }
    55     static bool ackGamestate(int gamestateID, int clientID){ return instance_->ack(gamestateID, clientID); }
     54    static bool addGamestate(packet::Gamestate *gs, unsigned int clientID){ return instance_->add(gs, clientID); }
     55    static bool ackGamestate(unsigned int gamestateID, unsigned int clientID){ return instance_->ack(gamestateID, clientID); }
    5656};
    5757
  • code/branches/objecthierarchy/src/network/GamestateManager.cc

    r1962 r1990  
    6565  }
    6666
    67   bool GamestateManager::add(packet::Gamestate *gs, int clientID){
     67  bool GamestateManager::add(packet::Gamestate *gs, unsigned int clientID){
    6868    assert(gs);
    69     std::map<int, packet::Gamestate*>::iterator it = gamestateQueue.find(clientID);
     69    std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateQueue.find(clientID);
    7070    if(it!=gamestateQueue.end()){
    7171      // delete obsolete gamestate
     
    7777
    7878  bool GamestateManager::processGamestates(){
    79     std::map<int, packet::Gamestate*>::iterator it;
     79    std::map<unsigned int, packet::Gamestate*>::iterator it;
    8080    // now push only the most recent gamestates we received (ignore obsolete ones)
    8181    for(it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++){
     
    126126  }*/
    127127
    128   packet::Gamestate *GamestateManager::popGameState(int clientID) {
     128  packet::Gamestate *GamestateManager::popGameState(unsigned int clientID) {
    129129    //why are we searching the same client's gamestate id as we searched in
    130130    //Server::sendGameState?
     
    141141    packet::Gamestate *client=NULL;
    142142    if(gID != GAMESTATEID_INITIAL){
    143       std::map<unsigned int, std::map<int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(clientID);
     143      std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(clientID);
    144144      if(clientMap!=gamestateMap_.end()){
    145         std::map<int, packet::Gamestate*>::iterator it = clientMap->second.find(gID);
     145        std::map<unsigned int, packet::Gamestate*>::iterator it = clientMap->second.find(gID);
    146146        if(it!=clientMap->second.end())
    147147          client = it->second;
     
    162162
    163163
    164   bool GamestateManager::ack(int gamestateID, int clientID) {
     164  bool GamestateManager::ack(unsigned int gamestateID, unsigned int clientID) {
    165165    ClientInformation *temp = ClientInformation::findClient(clientID);
    166166    assert(temp);
     
    172172    }
    173173
    174     assert(curid<gamestateID);
     174    assert(curid==(unsigned int)GAMESTATEID_INITIAL || curid<gamestateID);
    175175    COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
    176     std::map<int, packet::Gamestate*>::iterator it, tempit;
     176    std::map<unsigned int, packet::Gamestate*>::iterator it, tempit;
    177177    for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end() && it->first<gamestateID; it++){
    178178      delete it->second;
     
    186186  void GamestateManager::removeClient(ClientInformation* client){
    187187    assert(client);
    188     std::map<unsigned int, std::map<int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(client->getID());
     188    std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(client->getID());
    189189    // first delete all remained gamestates
    190     std::map<int, packet::Gamestate*>::iterator it;
     190    std::map<unsigned int, packet::Gamestate*>::iterator it;
    191191    for(it=clientMap->second.begin(); it!=clientMap->second.end(); it++)
    192192      delete it->second;
  • code/branches/objecthierarchy/src/network/GamestateManager.h

    r1916 r1990  
    7171    ~GamestateManager();
    7272
    73     bool add(packet::Gamestate *gs, int clientID);
     73    bool add(packet::Gamestate *gs, unsigned int clientID);
    7474    bool processGamestates();
    7575    bool update();
    76     packet::Gamestate *popGameState(int clientID);
     76    packet::Gamestate *popGameState(unsigned int clientID);
    7777
    7878    bool getSnapshot();
    7979
    80     bool ack(int gamestateID, int clientID);
     80    bool ack(unsigned int gamestateID, unsigned int clientID);
    8181    void removeClient(ClientInformation *client);
    8282    private:
     
    8484    bool processGamestate(packet::Gamestate *gs);
    8585
    86     std::map<unsigned int, std::map<int, packet::Gamestate*> > gamestateMap_;
     86    std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> > gamestateMap_;
    8787    //std::map<int, packet::Gamestate*> gamestateMap; //map gsID to gamestate*
    8888    //std::map<int, int> gamestateUsed; // save the number of clients, that use the specific gamestate
    89     std::map<int, packet::Gamestate*> gamestateQueue;
     89    std::map<unsigned int, packet::Gamestate*> gamestateQueue;
    9090    packet::Gamestate *reference;
    91     int id_;
     91    unsigned int id_;
    9292  };
    9393
  • code/branches/objecthierarchy/src/network/Synchronisable.cc

    r1989 r1990  
    230230   *             0x2: client->server (not recommended)
    231231   *             0x3: bidirectional
    232    * @return true: if !isMyTick or if everything was successfully saved
     232   * @return true: if !doSync or if everything was successfully saved
    233233   */
    234234  bool Synchronisable::getData(uint8_t*& mem, unsigned int id, int mode){
    235235    //if this tick is we dont synchronise, then abort now
    236     if(!isMyTick(id))
     236    if(!doSync(id))
    237237      return true;
    238238    //std::cout << "inside getData" << std::endl;
     
    363363  */
    364364  uint32_t Synchronisable::getSize(unsigned int id, int mode){
    365     if(!isMyTick(id))
     365    if(!doSync(id))
    366366      return 0;
    367367    int tsize=sizeof(synchronisableHeader);
     
    392392   * @return true/false
    393393   */
    394   bool Synchronisable::isMyTick(unsigned int id){
     394  bool Synchronisable::doSync(unsigned int id){
    395395    return ( (objectMode_&state_)!=0 );
    396396  }
  • code/branches/objecthierarchy/src/network/Synchronisable.h

    r1989 r1990  
    122122    bool isMyData(uint8_t* mem);
    123123    bool doSelection(unsigned int id);
    124     bool isMyTick(unsigned int id);
     124    bool doSync(unsigned int id);
    125125
    126126    unsigned int objectID;
  • code/branches/objecthierarchy/src/network/packet/Gamestate.cc

    r1907 r1990  
    268268  unsigned int compsize = HEADER->compsize;
    269269  unsigned int bufsize;
    270   assert(compsize<=datasize);
     270//  assert(compsize<=datasize);
    271271  bufsize = datasize;
    272272  assert(bufsize!=0);
  • code/branches/objecthierarchy/src/orxonox/objects/Test.cc

    r1960 r1990  
    6565
    6666        void Test::checkV1(){
    67           COUT(1) << "V1 changed: " << v1 << std::endl;
     67                COUT(1) << "V1 changed: " << v1 << std::endl;
    6868        }
    6969
    7070        void Test::checkV2(){
    71           COUT(1) << "V2 changed: " << v2 << std::endl;
     71                COUT(1) << "V2 changed: " << v2 << std::endl;
    7272        }
    7373
    7474        void Test::checkV3(){
    75           COUT(1) << "V3 changed: " << v3 << std::endl;
     75                COUT(1) << "V3 changed: " << v3 << std::endl;
    7676        }
    7777
  • code/branches/objecthierarchy/src/orxonox/objects/Test.h

    r1958 r1990  
    3636namespace orxonox
    3737{
    38   class _OrxonoxExport Test: public BaseObject, virtual public network::Synchronisable
     38  class _OrxonoxExport Test: public BaseObject, public network::Synchronisable
    3939  {
    4040    public:
     
    6060}
    6161
    62 #endif /* _PlayerInfo_H__ */
     62#endif /* _Test_H__ */
Note: See TracChangeset for help on using the changeset viewer.