Changeset 7801 for code/trunk/src/libraries/network/packet/FunctionCalls.cc
- Timestamp:
- Dec 22, 2010, 7:24:24 PM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/network/packet/FunctionCalls.cc
r7495 r7801 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 } … … 57 58 58 59 59 bool FunctionCalls::process(){ 60 bool FunctionCalls::process(orxonox::Host* host) 61 { 60 62 assert(isDataENetAllocated()); 61 63 62 64 uint8_t* temp = data_+sizeof(uint32_t); //skip packetid 63 65 uint32_t nrOfCalls = *(uint32_t*)temp; 66 temp += sizeof(uint32_t); 67 this->minGamestateID_ = *(uint32_t*)temp; 64 68 temp += sizeof(uint32_t); 65 69 for( unsigned int i = 0; i<nrOfCalls; i++ ) … … 68 72 fctCall.loadData(temp); 69 73 if( !fctCall.execute() ) 70 FunctionCallManager::bufferIncomingFunctionCall( fctCall ); 74 { 75 FunctionCallManager::bufferIncomingFunctionCall( fctCall, minGamestateID_, this->getPeerID() ); 76 } 71 77 } 72 78 … … 75 81 } 76 82 77 void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){ 83 void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5) 84 { 78 85 assert(!isDataENetAllocated()); 79 86 … … 83 90 } 84 91 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){ 92 void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5) 93 { 86 94 assert(!isDataENetAllocated()); 87 95 … … 91 99 } 92 100 93 bool FunctionCalls::send( )101 bool FunctionCalls::send(orxonox::Host* host) 94 102 { 103 this->minGamestateID_ = host->getCurrentGamestateID(); 95 104 assert(this->functionCalls_.size()); 96 105 data_=new uint8_t[ currentSize_ ]; 97 106 *(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); 100 110 101 111 while( this->functionCalls_.size() ) … … 107 117 assert( temp==data_+currentSize_ ); 108 118 109 Packet::send( );119 Packet::send(host); 110 120 return true; 111 121 }
Note: See TracChangeset
for help on using the changeset viewer.