Changeset 2944 for code/branches/netp2/src/network/packet
- Timestamp:
- May 1, 2009, 9:47:34 AM (16 years ago)
- Location:
- code/branches/netp2/src/network/packet
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp2/src/network/packet/FunctionCalls.cc
r2938 r2944 72 72 { 73 73 uint32_t functionID = *(uint32_t*)temp; 74 bool isStatic = NetworkFunctionBase::isStatic( functionID);74 bool isStatic = *(uint8_t*)(temp+sizeof(uint32_t)); 75 75 if( isStatic ) 76 76 { 77 77 MultiType mt1, mt2, mt3, mt4, mt5; 78 78 NetworkFunctionStatic *fct = NetworkFunctionStatic::getFunction( functionID ); 79 uint32_t nrOfArguments = *(uint32_t*)(temp+sizeof(uint32_t) );80 temp+=2*sizeof(uint32_t) ;79 uint32_t nrOfArguments = *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t)); 80 temp+=2*sizeof(uint32_t)+sizeof(uint8_t); 81 81 switch(nrOfArguments) 82 82 { … … 122 122 MultiType mt1, mt2, mt3, mt4, mt5; 123 123 NetworkMemberFunctionBase *fct = NetworkMemberFunctionBase::getFunction( functionID ); 124 uint32_t nrOfArguments = *(uint32_t*)(temp+sizeof(uint32_t) );125 uint32_t objectID = *(uint32_t*)(temp+2*sizeof(uint32_t) );126 temp+=3*sizeof(uint32_t) ;124 uint32_t nrOfArguments = *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t)); 125 uint32_t objectID = *(uint32_t*)(temp+2*sizeof(uint32_t)+sizeof(uint8_t)); 126 temp+=3*sizeof(uint32_t)+sizeof(uint8_t); 127 127 switch(nrOfArguments) 128 128 { … … 166 166 } 167 167 } 168 delete this; 168 169 return true; 169 170 } … … 173 174 174 175 // first determine the size that has to be reserved for this call 175 uint32_t callsize = 2*sizeof(uint32_t) ; //size for network-function-id and nrOfArguments176 uint32_t callsize = 2*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and for bool isStatic 176 177 uint32_t nrOfArguments = 0; 177 178 if(mt1) … … 211 212 } 212 213 213 // now serialise the mt values and copy the function id 214 // now serialise the mt values and copy the function id and isStatic 214 215 uint8_t* temp = data_+currentSize_; 215 216 *(uint32_t*)(data_+sizeof(uint32_t)) = *(uint32_t*)(data_+sizeof(uint32_t))+1; // increase number of calls 216 217 *(uint32_t*)temp = networkID; 217 *(uint32_t*)(temp+sizeof(uint32_t)) = nrOfArguments; 218 temp += 2*sizeof(uint32_t); 218 *(uint8_t*)(temp+sizeof(uint32_t)) = true; 219 *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t)) = nrOfArguments; 220 temp += 2*sizeof(uint32_t)+sizeof(uint8_t); 219 221 if(mt1) 220 222 { … … 237 239 } 238 240 } 239 currentSize_ += callsize; 241 //currentSize_ += callsize; 242 currentSize_ = temp-data_; 240 243 241 244 } … … 245 248 246 249 // first determine the size that has to be reserved for this call 247 uint32_t callsize = 3*sizeof(uint32_t) ; //size for network-function-id and nrOfArguments and the objectID250 uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID 248 251 uint32_t nrOfArguments = 0; 249 252 if(mt1) … … 287 290 *(uint32_t*)(data_+sizeof(uint32_t)) = *(uint32_t*)(data_+sizeof(uint32_t))+1; // increase number of calls 288 291 *(uint32_t*)temp = networkID; 289 *(uint32_t*)(temp+sizeof(uint32_t)) = nrOfArguments; 290 *(uint32_t*)(temp+2*sizeof(uint32_t)) = objectID; 291 temp += 3*sizeof(uint32_t); 292 *(uint8_t*)(temp+sizeof(uint32_t)) = false; 293 *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t)) = nrOfArguments; 294 *(uint32_t*)(temp+2*sizeof(uint32_t)+sizeof(uint8_t)) = objectID; 295 temp += 3*sizeof(uint32_t)+sizeof(uint8_t); 292 296 if(mt1) 293 297 { -
code/branches/netp2/src/network/packet/Packet.cc
r2937 r2944 39 39 40 40 #include "Acknowledgement.h" 41 #include "DeleteObjects.h" 41 42 #include "Chat.h" 42 43 #include "ClassID.h" 44 #include "FunctionCalls.h" 45 #include "FunctionIDs.h" 43 46 #include "Gamestate.h" 44 47 #include "Welcome.h" 45 #include "DeleteObjects.h"46 48 #include "network/Host.h" 47 49 #include "core/CoreIncludes.h" … … 172 174 unsigned int clientID = ClientInformation::findClient(&peer->address)->getID(); 173 175 Packet *p = 0; 174 COUT( 5) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;176 COUT(6) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl; 175 177 switch( *(ENUM::Type *)(data + _PACKETID) ) 176 178 { 177 179 case ENUM::Acknowledgement: 178 COUT( 4) << "ack" << std::endl;180 COUT(5) << "ack" << std::endl; 179 181 p = new Acknowledgement( data, clientID ); 180 182 break; 181 183 case ENUM::Chat: 182 COUT( 4) << "chat" << std::endl;184 COUT(5) << "chat" << std::endl; 183 185 p = new Chat( data, clientID ); 184 186 break; 185 187 case ENUM::ClassID: 186 COUT( 4) << "classid" << std::endl;188 COUT(5) << "classid" << std::endl; 187 189 p = new ClassID( data, clientID ); 188 190 break; 189 191 case ENUM::Gamestate: 190 COUT( 4) << "gamestate" << std::endl;192 COUT(5) << "gamestate" << std::endl; 191 193 // TODO: remove brackets 192 194 p = new Gamestate( data, clientID ); 193 195 break; 194 196 case ENUM::Welcome: 195 COUT( 4) << "welcome" << std::endl;197 COUT(5) << "welcome" << std::endl; 196 198 p = new Welcome( data, clientID ); 197 199 break; 198 200 case ENUM::DeleteObjects: 199 COUT( 4) << "deleteobjects" << std::endl;201 COUT(5) << "deleteobjects" << std::endl; 200 202 p = new DeleteObjects( data, clientID ); 203 break; 204 case ENUM::FunctionCalls: 205 COUT(5) << "functionCalls" << std::endl; 206 p = new FunctionCalls( data, clientID ); 207 break; 208 case ENUM::FunctionIDs: 209 COUT(5) << "functionIDs" << std::endl; 210 p = new FunctionIDs( data, clientID ); 201 211 break; 202 212 default:
Note: See TracChangeset
for help on using the changeset viewer.