- Timestamp:
- Dec 14, 2010, 8:54:00 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network5/src/libraries/network/packet/FunctionCalls.cc
r7495 r7759 32 32 #include "network/FunctionCall.h" 33 33 #include "network/FunctionCallManager.h" 34 #include "network/GamestateHandler.h" 34 35 35 36 namespace orxonox { … … 40 41 const unsigned int FUNCTIONCALLS_MEM_ALLOCATION = 1000; 41 42 42 FunctionCalls::FunctionCalls() 43 : Packet()43 FunctionCalls::FunctionCalls(): 44 Packet(), minGamestateID_(GAMESTATEID_INITIAL) 44 45 { 45 46 flags_ = flags_ | PACKET_FLAGS_FUNCTIONCALLS; 46 currentSize_ = 2*sizeof(uint32_t); // for packetid and nrOfCalls47 currentSize_ = 3*sizeof(uint32_t); // for packetid, nrOfCalls and minGamestateID_ 47 48 } 48 49 49 FunctionCalls::FunctionCalls( uint8_t* data, unsigned int clientID ) 50 : Packet(data, clientID)50 FunctionCalls::FunctionCalls( uint8_t* data, unsigned int clientID ): 51 Packet(data, clientID), minGamestateID_(GAMESTATEID_INITIAL) 51 52 { 52 53 } … … 63 64 uint32_t nrOfCalls = *(uint32_t*)temp; 64 65 temp += sizeof(uint32_t); 66 this->minGamestateID_ = *(uint32_t*)temp; 67 temp += sizeof(uint32_t); 65 68 for( unsigned int i = 0; i<nrOfCalls; i++ ) 66 69 { 67 70 FunctionCall fctCall; 68 71 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 } 71 76 } 72 77 … … 93 98 bool FunctionCalls::send() 94 99 { 100 this->minGamestateID_ = GamestateHandler::getInstance()->getCurrentGamestateID(); 95 101 assert(this->functionCalls_.size()); 96 102 data_=new uint8_t[ currentSize_ ]; 97 103 *(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); 100 107 101 108 while( this->functionCalls_.size() )
Note: See TracChangeset
for help on using the changeset viewer.