Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1769 for code/trunk


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

sync frequencies do work now

Location:
code/trunk/src
Files:
6 edited

Legend:

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

    r1767 r1769  
    4545#include "core/ConsoleCommand.h"
    4646#include "packet/Packet.h"
    47 #include "packet/Acknowledgement.h"
     47// #include "packet/Acknowledgement.h"
    4848
    4949namespace network
     
    166166      assert(packet->process());
    167167    }
    168     int gameStateID = gamestate.processGamestates();
    169     if(gameStateID==GAMESTATEID_INITIAL)
    170       if(gameStateFailure_){
    171         packet::Acknowledgement *ack = new packet::Acknowledgement((unsigned int)GAMESTATEID_INITIAL, 0);
    172         if(!ack->send())
    173           COUT(3) << "could not (negatively) ack gamestate" << std::endl;
    174         else
    175           COUT(4) << "negatively acked a gamestate" << std::endl;
    176         }
    177       else
    178         gameStateFailure_=true;
    179     else if(gameStateID!=0){
    180       // ack gamestate and set synched
     168    if(gamestate.processGamestates())
     169    {
    181170      if(!isSynched_)
    182171        isSynched_=true;
    183       gameStateFailure_=false;
    184       packet::Acknowledgement *ack = new packet::Acknowledgement(gameStateID, 0);
    185       if(!ack->send())
    186         COUT(3) << "could not ack gamestate" << std::endl;
    187     }// otherwise we had no gamestate to load
     172    }else
     173      COUT(3) << "gamestate has not been processed sucessfully" << std::endl;
    188174    gamestate.cleanup();
    189175    return;
  • 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);
  • code/trunk/src/network/GamestateClient.h

    r1763 r1769  
    6262    bool ack(int gamestateID, int clientID);
    6363
    64     int processGamestates();
     64    bool processGamestates();
    6565    packet::Gamestate *getGamestate();
    6666    void cleanup();
     
    6969    void removeObject(orxonox::ObjectListIterator<Synchronisable> &it);
    7070    void printGamestateMap();
     71    bool sendAck(unsigned int gamestateID);
    7172    bool saveShipCache();
    7273    bool loadShipCache();
  • code/trunk/src/network/GamestateManager.cc

    r1763 r1769  
    157157    int curid = temp->getGamestateID();
    158158   
    159     if(gamestateID == GAMESTATEID_INITIAL){
     159    if(gamestateID == 0){
    160160      temp->setGamestateID(GAMESTATEID_INITIAL);
    161161      if(curid!=GAMESTATEID_INITIAL){
     
    163163        --(gamestateUsed.find(curid)->second);
    164164      }
    165       return false;
    166     }
    167     if(curid > gamestateID)
     165      return true;
     166    }
     167    //if(curid > gamestateID)
     168    assert(curid<gamestateID);
    168169      // the network packets got messed up
    169       return true;
     170      //return true;
    170171    COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
    171172    // decrease usage of gamestate and save it
  • code/trunk/src/network/packet/Acknowledgement.cc

    r1763 r1769  
    3131#include "network/Host.h"
    3232#include "network/GamestateHandler.h"
     33#include "core/CoreIncludes.h"
    3334
    3435namespace network {
     
    6364
    6465bool Acknowledgement::process(){
    65   bool b = GamestateHandler::ackGamestate(data_[_ACKID], clientID_);
     66  bool b = GamestateHandler::ackGamestate(getAckID(), clientID_);
    6667  delete this;
    6768  return b;
     
    6970
    7071unsigned int Acknowledgement::getAckID(){
    71   return *(unsigned int *)&data_[ _ACKID ];
     72  return *(unsigned int *)(data_ + _ACKID);
    7273}
    7374
  • code/trunk/src/orxonox/objects/Model.cc

    r1751 r1769  
    5252        RegisterObject(Model);
    5353        registerAllVariables();
    54         if(this->isExactlyA(Class(Model)))
    55            setObjectFrequency(1);
    5654    }
    5755
     
    8785        COUT(4) << "Loader (Model.cc): Created model" << std::endl;
    8886      }
     87      if(this->isExactlyA(Class(Model)))
     88        setObjectFrequency(300); //sync all 10 seconds (this only applies to asteroids and other isExactlyA(Model)
    8989      return true;
    9090    }
Note: See TracChangeset for help on using the changeset viewer.