Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 11, 2008, 5:06:24 PM (16 years ago)
Author:
scheusso
Message:

sync frequencies do work now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/network/GamestateClient.cc

    r1767 r1769  
    3535#include "core/Iterator.h"
    3636#include "Synchronisable.h"
     37#include "packet/Acknowledgement.h"
    3738
    3839
     
    7071  }
    7172
    72   int GamestateClient::processGamestates(){
     73  bool GamestateClient::processGamestates(){
    7374    if(tempGamestate_==NULL)
    74       return 0;
     75      return false;
    7576    int id = GAMESTATEID_INITIAL;
    7677    bool b = saveShipCache();
    7778    packet::Gamestate *processed = processGamestate(tempGamestate_);
    78     if(!processed)
    79       return GAMESTATEID_INITIAL;
     79    if(!processed){
     80      if(b)
     81        loadShipCache();
     82      return false;
     83    }
    8084//    assert(processed);
    8185    //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs
    82     tempGamestate_=0;
     86    tempGamestate_=NULL;
    8387    gamestateMap_[processed->getID()]=processed;
    8488    last_diff_ = processed->getID();
     
    8690      loadShipCache();
    8791    id = processed->getID();
    88     cleanup();
    89     return id;
     92    sendAck(id);
     93    return true;
    9094  }
    9195
     
    129133    COUT(4) << std::endl;
    130134
     135  }
     136 
     137  bool GamestateClient::sendAck(unsigned int gamestateID){
     138    packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, 0);
     139    if(!ack->send()){
     140      COUT(3) << "could not ack gamestate: " << gamestateID << std::endl;
     141      return false;
     142    }
     143    else{
     144      COUT(3) << "acked a gamestate: " << gamestateID << std::endl;
     145      return true;
     146    }
    131147  }
    132148
     
    169185    if(gs->isDiffed()){
    170186      packet::Gamestate *base = gamestateMap_[gs->getBaseID()];
    171       if(!base)
     187      if(!base){
     188        delete gs;
    172189        return 0;
     190      }
    173191//      assert(base); //TODO: fix this
    174192      packet::Gamestate *undiffed = gs->undiff(base);
Note: See TracChangeset for help on using the changeset viewer.