Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 14, 2010, 8:54:00 PM (14 years ago)
Author:
scheusso
Message:

a lot of changes:

  • some fixes (mostly gamestate:diff)
  • FunctionCall buffering (if Gamestate is not recent enough)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network5/src/libraries/network/packet/FunctionCalls.cc

    r7495 r7759  
    3232#include "network/FunctionCall.h"
    3333#include "network/FunctionCallManager.h"
     34#include "network/GamestateHandler.h"
    3435
    3536namespace orxonox {
     
    4041const unsigned int FUNCTIONCALLS_MEM_ALLOCATION = 1000;
    4142
    42 FunctionCalls::FunctionCalls()
    43  : Packet()
     43FunctionCalls::FunctionCalls():
     44  Packet(), minGamestateID_(GAMESTATEID_INITIAL)
    4445{
    4546  flags_ = flags_ | PACKET_FLAGS_FUNCTIONCALLS;
    46   currentSize_ = 2*sizeof(uint32_t); // for packetid and nrOfCalls
     47  currentSize_ = 3*sizeof(uint32_t); // for packetid, nrOfCalls and minGamestateID_
    4748}
    4849
    49 FunctionCalls::FunctionCalls( uint8_t* data, unsigned int clientID )
    50   : Packet(data, clientID)
     50FunctionCalls::FunctionCalls( uint8_t* data, unsigned int clientID ):
     51  Packet(data, clientID), minGamestateID_(GAMESTATEID_INITIAL)
    5152{
    5253}
     
    6364  uint32_t nrOfCalls = *(uint32_t*)temp;
    6465  temp += sizeof(uint32_t);
     66  this->minGamestateID_ = *(uint32_t*)temp;
     67  temp += sizeof(uint32_t);
    6568  for( unsigned int i = 0; i<nrOfCalls; i++ )
    6669  {
    6770    FunctionCall fctCall;
    6871    fctCall.loadData(temp);
    69     if( !fctCall.execute() )
    70       FunctionCallManager::bufferIncomingFunctionCall( fctCall );
     72    if( this->minGamestateID_ > GamestateHandler::getInstance()->getLastProcessedGamestateID(this->getClientID()) || !fctCall.execute() )
     73    {
     74      FunctionCallManager::bufferIncomingFunctionCall( fctCall, minGamestateID_, this->getClientID() );
     75    }
    7176  }
    7277 
     
    9398bool FunctionCalls::send()
    9499{
     100  this->minGamestateID_ = GamestateHandler::getInstance()->getCurrentGamestateID();
    95101  assert(this->functionCalls_.size());
    96102  data_=new uint8_t[ currentSize_ ];
    97103  *(Type::Value *)(data_ + _PACKETID ) = Type::FunctionCalls; // Set the Packet ID
    98   *(uint32_t*)(data_+sizeof(uint32_t)) = this->functionCalls_.size(); // set nrOfCalls to 0
    99   uint8_t* temp = data_+2*sizeof(uint32_t);
     104  *(uint32_t*)(data_+sizeof(uint32_t)) = this->functionCalls_.size(); // set nrOfCalls
     105  *(uint32_t*)(data_+2*sizeof(uint32_t)) = this->minGamestateID_; // set minGamestateID_
     106  uint8_t* temp = data_+3*sizeof(uint32_t);
    100107 
    101108  while( this->functionCalls_.size() )
Note: See TracChangeset for help on using the changeset viewer.