Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 22, 2010, 7:24:24 PM (13 years ago)
Author:
dafrick
Message:

Merging presentation2 branch back to trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/packet/FunctionCalls.cc

    r7495 r7801  
    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}
     
    5758
    5859
    59 bool FunctionCalls::process(){
     60bool FunctionCalls::process(orxonox::Host* host)
     61{
    6062  assert(isDataENetAllocated());
    6163 
    6264  uint8_t* temp = data_+sizeof(uint32_t); //skip packetid
    6365  uint32_t nrOfCalls = *(uint32_t*)temp;
     66  temp += sizeof(uint32_t);
     67  this->minGamestateID_ = *(uint32_t*)temp;
    6468  temp += sizeof(uint32_t);
    6569  for( unsigned int i = 0; i<nrOfCalls; i++ )
     
    6872    fctCall.loadData(temp);
    6973    if( !fctCall.execute() )
    70       FunctionCallManager::bufferIncomingFunctionCall( fctCall );
     74    {
     75      FunctionCallManager::bufferIncomingFunctionCall( fctCall, minGamestateID_, this->getPeerID() );
     76    }
    7177  }
    7278 
     
    7581}
    7682
    77 void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
     83void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
     84{
    7885  assert(!isDataENetAllocated());
    7986 
     
    8390}
    8491
    85 void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
     92void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
     93{
    8694  assert(!isDataENetAllocated());
    8795 
     
    9199}
    92100
    93 bool FunctionCalls::send()
     101bool FunctionCalls::send(orxonox::Host* host)
    94102{
     103  this->minGamestateID_ = host->getCurrentGamestateID();
    95104  assert(this->functionCalls_.size());
    96105  data_=new uint8_t[ currentSize_ ];
    97106  *(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);
     107  *(uint32_t*)(data_+sizeof(uint32_t)) = this->functionCalls_.size(); // set nrOfCalls
     108  *(uint32_t*)(data_+2*sizeof(uint32_t)) = this->minGamestateID_; // set minGamestateID_
     109  uint8_t* temp = data_+3*sizeof(uint32_t);
    100110 
    101111  while( this->functionCalls_.size() )
     
    107117  assert( temp==data_+currentSize_ );
    108118 
    109   Packet::send();
     119  Packet::send(host);
    110120  return true;
    111121}
Note: See TracChangeset for help on using the changeset viewer.