Changeset 1180 for code/branches/network3/src/network
- Timestamp:
- Apr 24, 2008, 6:01:12 PM (17 years ago)
- Location:
- code/branches/network3/src/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network3/src/network/PacketGenerator.cc
r1168 r1180 108 108 //std::cout << "states->compsize " << states->compsize << std::endl; 109 109 int gid = GAMESTATE; //first assign the correct enet id 110 int totalLen = 4*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory110 int totalLen = 5*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory 111 111 //std::cout << "totalLen " << totalLen << std::endl; 112 112 unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream … … 120 120 memcpy( (void*)(data+5*sizeof( int ) + sizeof(bool)), (const void*)states->data, states->compsize ); 121 121 //create an enet packet with the generated bytestream 122 COUT(4) << "PacketGenerator generating totalLen " << totalLen << std::endl; 122 123 ENetPacket *packet = enet_packet_create( data , totalLen, reliable ); 123 124 //delete data; -
code/branches/network3/src/network/Synchronisable.cc
r1177 r1180 70 70 * @param size size of the datatype the variable consists of 71 71 */ 72 void Synchronisable::registerVar( constvoid *var, int size, variableType t){72 void Synchronisable::registerVar(void *var, int size, variableType t){ 73 73 // create temporary synch.Var struct 74 74 synchronisableVariable *temp = new synchronisableVariable; … … 155 155 switch((*i)->type){ 156 156 case DATA: 157 std::memcpy( (void *)(retVal.data+n), ( constvoid*)((*i)->var), (*i)->size);157 std::memcpy( (void *)(retVal.data+n), (void*)((*i)->var), (*i)->size); 158 158 n+=(*i)->size; 159 159 break; 160 160 case STRING: 161 memcpy( (void *)(retVal.data+n), ( constvoid *)&((*i)->size), sizeof(int) );161 memcpy( (void *)(retVal.data+n), (void *)&((*i)->size), sizeof(int) ); 162 162 n+=sizeof(int); 163 std::memcpy( retVal.data+n, (const void*)( ( (std::string *) (*i)->var)->c_str()), (*i)->size); 163 const char *data = ( ( *(std::string *) (*i)->var).c_str()); 164 std::memcpy( retVal.data+n, (void*)data, (*i)->size); 165 COUT(4) << "synchronisable: char: " << (const char *)(retVal.data+n) << " data: " << data << " string: " << *(std::string *)((*i)->var) << std::endl; 164 166 n+=(*i)->size; 165 167 break; … … 191 193 case STRING: 192 194 (*i)->size = *(int *)data; 195 COUT(4) << "string size: " << (*i)->size << std::endl; 193 196 data+=sizeof(int); 194 197 *((std::string *)((*i)->var)) = std::string((const char*)data); 198 COUT(4) << "synchronisable: char: " << (const char*)data << " string: " << std::string((const char*)data) << std::endl; 195 199 data += (*i)->size; 196 200 break; … … 215 219 tsize+=sizeof(int); 216 220 (*i)->size=((std::string *)(*i)->var)->length()+1; 221 COUT(4) << "String size: " << (*i)->size << std::endl; 217 222 tsize+=(*i)->size; 218 223 break; -
code/branches/network3/src/network/Synchronisable.h
r1168 r1180 62 62 typedef struct synchronisableVariable{ 63 63 int size; 64 constvoid *var;64 void *var; 65 65 variableType type; 66 66 }SYNCVAR; … … 79 79 int classID; 80 80 81 void registerVar( constvoid *var, int size, variableType t);81 void registerVar(void *var, int size, variableType t); 82 82 // syncData getData(); 83 83 syncData getData(unsigned char *mem);
Note: See TracChangeset
for help on using the changeset viewer.