Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1431 for code


Ignore:
Timestamp:
May 26, 2008, 9:21:53 PM (16 years ago)
Author:
scheusso
Message:

another one bites the dust: solved that problem with zeros in the gamestate

Location:
code/branches/network/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/Client.cc

    r1425 r1431  
    8585    isConnected=false;
    8686    isSynched_=false;
     87    gameStateFailure_=false;
    8788  }
    8889
     
    9596    isConnected=false;
    9697    isSynched_=false;
     98    gameStateFailure_=false;
    9799  }
    98100
     
    105107    isConnected=false;
    106108    isSynched_=false;
     109    gameStateFailure_=false;
    107110  }
    108111
     
    247250    }
    248251    int gameStateID = gamestate.processGameState();
    249     if(gameStateID!=GAMESTATEID_INITIAL){
     252    if(gameStateID==GAMESTATEID_INITIAL)
     253      if(gameStateFailure_){
     254        if(!client_connection.addPacket(pck_gen.acknowledgement(GAMESTATEID_INITIAL)))
     255          COUT(3) << "could not (negatively) ack gamestate" << std::endl;
     256        else
     257          COUT(4) << "negatively acked a gamestate" << std::endl;
     258        }
     259      else
     260        gameStateFailure_=true;
     261    else if(gameStateID!=0){
    250262      // ack gamestate and set synched
    251263      if(!isSynched_)
    252264        isSynched_=true;
     265      gameStateFailure_=false;
    253266      if(!client_connection.addPacket(pck_gen.acknowledgement(gameStateID)))
    254267        COUT(3) << "could not ack gamestate" << std::endl;
    255     }
     268    }// otherwise we had no gamestate to load
    256269    gamestate.cleanup();
    257270    if(!client_connection.sendPackets())
  • code/branches/network/src/network/Client.h

    r1293 r1431  
    110110    int clientID_;     // this is the id the server gave to us
    111111    int shipID_;
     112    bool gameStateFailure_;
    112113  };
    113114
  • code/branches/network/src/network/ClientInformation.cc

    r1389 r1431  
    156156  }
    157157
    158   bool ClientInformation::setGamestateID(int id){
     158  bool ClientInformation::setGameStateID(int id){
    159159    boost::recursive_mutex::scoped_lock lock(mutex_);
    160160    if(!this)
  • code/branches/network/src/network/ClientInformation.h

    r1389 r1431  
    6969    void setID(int clientID);
    7070    bool setPeer(ENetPeer *peer);
    71     bool setGamestateID(int id);
     71    bool setGameStateID(int id);
    7272    bool setPartialGamestateID(int id);
    7373    inline void setShipID(int id){ShipID_=id;}
  • code/branches/network/src/network/GameStateClient.cc

    r1425 r1431  
    117117  int GameStateClient::processGameState(){
    118118    if(tempGameState_==NULL)
    119       return GAMESTATEID_INITIAL;
     119      return 0;
    120120    int id=tempGameState_->id;
    121121    bool b = saveShipCache();
     
    176176          orxonox::Identifier* id = ID((unsigned int)sync.classID);
    177177          if(!id){
    178             COUT(4) << "We could not identify a new object; classid: " << sync.classID << std::endl;
    179             return false;
     178            COUT(3) << "We could not identify a new object; classid: " << sync.classID << " objectID: " << sync.objectID << " size: " << sync.length << std::endl;
     179            return false; // most probably the gamestate is corrupted
    180180          }
    181181          Synchronisable *no = dynamic_cast<Synchronisable *>(id->fabricate());
     
    278278    int of=0; // pointers offset
    279279    int dest_length=0;
    280     if(old->size>=diff->size)
     280    /*if(old->size>=diff->size)
    281281      dest_length=old->size;
    282     else
     282    else*/
    283283      dest_length=diff->size;
    284284//     unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
     
    295295          of++;
    296296        }
    297       } else{
     297      } /*else{
    298298        while(of<dest_length){
    299299          *(dp+of)=*(ap+of)^n;
    300300          of++;
    301301        }
    302       }
     302      }*/
    303303    }
    304304    // should be finished now
  • code/branches/network/src/network/GameStateManager.cc

    r1425 r1431  
    140140        client = it->second;
    141141      GameState *server = reference;
    142       COUT(3) << "client: " << client << " server: " << server << " gamestatemap: " << &gameStateMap << std::endl;
     142      COUT(3) << "client: " << client << " server: " << server << " gamestatemap: " << &gameStateMap << " size: " << server->size << std::endl;
    143143      if(client)
    144144        return encode(client, server);
     
    260260      data+=sizeof(int);
    261261      sync.classID = *(int*)data;
     262      if(sync.classID == 0) // TODO: remove this
     263        COUT(3) << "received a classid 0" << std::endl;
    262264      data+=sizeof(int);
    263265      sync.data = data;
     
    269271
    270272      if(!it){
    271         // the object does not exist yet
     273        // the objectaber ich glaub die does not exist yet
    272274        COUT(4) << "loadsnapshot: creating new object " << std::endl;
    273275        //COUT(4) << "loadSnapshot:\tclassid: " << sync.classID << ", name: " << ID((unsigned int) sync.classID)->getName() << std::endl;
     
    337339  }
    338340
    339   GameState *GameStateManager::diff(GameState *a, GameState *b) {
    340     unsigned char *ap = a->data, *bp = b->data;
     341  GameState *GameStateManager::diff(GameState *alt, GameState *neu) {
     342    unsigned char *ap = alt->data, *bp = neu->data;
    341343    int of=0; // pointers offset
    342344    int dest_length=0;
    343     if(a->size>=b->size)
    344       dest_length=a->size;
    345     else
    346       dest_length=b->size;
     345    /*if(alt->size>neu->size)
     346      dest_length=alt->size;
     347    else*/
     348      dest_length=neu->size;
    347349    //unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
    348350    unsigned char *dp = new unsigned char[dest_length*sizeof(unsigned char)];
    349     while(of<a->size && of<b->size){
     351    while(of<alt->size && of<neu->size){
    350352      *(dp+of)=*(ap+of)^*(bp+of); // do the xor
    351353      ++of;
    352354    }
    353     if(a->size!=b->size){ // do we have to fill up ?
     355    if(alt->size!=neu->size){ // do we have to fill up ?
    354356      unsigned char n=0;
    355       if(a->size<b->size){
     357      if(alt->size<neu->size){
    356358        while(of<dest_length){
    357359          *(dp+of)=n^*(bp+of);
    358360          of++;
    359361        }
    360       } else{
     362      } /*else{
    361363        while(of<dest_length){
    362364          *(dp+of)=*(ap+of)^n;
    363365          of++;
    364366        }
    365       }
     367      }*/
    366368    }
    367369
    368370    GameState *r = new GameState;
    369     r->id = b->id;
     371    r->id = neu->id;
    370372    r->size = dest_length;
    371373    r->diffed = true;
    372     r->base_id = a->id;
     374    r->base_id = alt->id;
    373375    r->data = dp;
    374376    r->complete = true;
     
    459461      return;
    460462    int curid = temp->getGamestateID();
     463   
     464    if(gamestateID == GAMESTATEID_INITIAL){
     465      temp->setGameStateID(GAMESTATEID_INITIAL);
     466      --(gameStateUsed.find(curid)->second);
     467      return;
     468    }
    461469    if(curid > gamestateID)
    462470      // the network packets got messed up
     
    469477      --(gameStateUsed.find(curid)->second);
    470478    ++(gameStateUsed.find(gamestateID)->second);
    471     temp->setGamestateID(gamestateID);
     479    temp->setGameStateID(gamestateID);
    472480    /*
    473481    GameState *old = clientGameState[clientID];
  • code/branches/network/src/network/GameStateManager.h

    r1425 r1431  
    8686    GameStateCompressed *encode(GameState *a, GameState *b);
    8787    GameStateCompressed *encode(GameState *a);
    88     GameState *diff(GameState *a, GameState *b);
     88    GameState *diff(GameState *alt, GameState *neu);
    8989    GameStateCompressed *compress_(GameState *a);
    9090    GameState *decompress(GameStateCompressed *a);
  • code/branches/network/src/network/Server.cc

    r1425 r1431  
    263263
    264264  void Server::processAck( ack *data, int clientID) {
    265     COUT(4) << "\b\b\b\n\n\n\n\nServer: processing ack from client: " << clientID << "; ack-id: " << data->a << std::endl;
     265    COUT(4) << "Server: processing ack from client: " << clientID << "; ack-id: " << data->a << std::endl;
    266266    gamestates->ackGameState(clientID, data->a);
    267267    delete data;
  • code/branches/network/src/network/Synchronisable.cc

    r1425 r1431  
    7070  bool Synchronisable::create(){
    7171    this->classID = this->getIdentifier()->getNetworkID();
    72     COUT(4) << "setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl;
     72    COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl;
    7373    return true;
    7474  }
  • code/branches/network/src/network/diffTest.cc

    r1360 r1431  
    549549
    550550  std::cout << "test setGamestateID" << std::endl;
    551   temp->setGamestateID( 8 );
     551  temp->setGameStateID( 8 );
    552552  printClientInformationBox( temp );
    553553
     
    559559  newInfo->setSynched( true );
    560560  newInfo->setPeer( NULL );
    561   toool->setGamestateID( 199 );
     561  toool->setGameStateID( 199 );
    562562  toool->setID( numberOfClients+1);
    563563  toool->setSynched( true );
  • code/branches/network/src/orxonox/objects/SpaceShip.cc

    r1425 r1431  
    359359            Projectile *p = new Projectile(this);
    360360            p->create();
     361            if(p->classID==0)
     362              COUT(3) << "generated projectile with classid 0" <<  std::endl; // TODO: remove this output
    361363
    362364            p->setBacksync(true);
Note: See TracChangeset for help on using the changeset viewer.