From: Gregory B. <gb...@us...> - 2003-02-25 22:19:27
|
Update of /cvsroot/planeshift/planeshift/src/common/engine In directory sc8-pr-cvs1:/tmp/cvs-serv935/src/common/engine Modified Files: netpersist.cpp Log Message: Let's try this again. Checking in endian fix. Index: netpersist.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/engine/netpersist.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** netpersist.cpp 25 Feb 2003 01:35:02 -0000 1.44 --- netpersist.cpp 25 Feb 2003 22:19:22 -0000 1.45 *************** *** 39,45 **** extra_str = ""; ! size_t size = sizeof(uint16_t) + sizeof(uint32_t) + sizeof(uint32_t) + strlen(extra_str) + ! (memfile ? memfile->GetSize() : 0); ! me = new MsgEntry(size); me->data->type = MSGTYPECELPERSIST; --- 39,46 ---- extra_str = ""; ! size_t size = sizeof(cmd) + sizeof(id) + (extra_str!=NULL ? strlen(extra_str)+1 : 1) ! + sizeof(uint32_t) + (memfile ? memfile->GetSize() : 0); ! ! me = new MsgEntry(size); me->data->type = MSGTYPECELPERSIST; *************** *** 47,64 **** me->priority = prty; ! uint16_t* cmdptr = (uint16_t*) me->data->data; ! *(cmdptr++) = cmd; ! uint32_t* idptr = (uint32_t*) cmdptr; ! *(idptr++) = id; ! *(idptr++) = strlen(extra_str); ! ! char* dataptr = (char*) idptr; ! if (strlen(extra_str)) ! { ! memcpy (dataptr, extra_str, strlen(extra_str) ); ! dataptr += strlen(extra_str); ! } ! if (memfile != NULL) ! memcpy (dataptr, memfile->GetData(), memfile->GetSize()); } --- 48,60 ---- me->priority = prty; ! me->Add(cmd); ! me->Add(id); ! me->Add(extra_str); ! if (memfile==NULL) { ! // Must always add the null data block; this makes the other side behave uniformly. ! me->Add(NULL, 0); ! } else { ! me->Add(memfile->GetData(), memfile->GetSize()); ! } } *************** *** 68,89 **** me->IncRef(); ! size_t argsize = sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint16_t); ! uint16_t* cmdptr = (uint16_t*) me->data->data; ! cmd = *(cmdptr++); ! uint32_t* idptr = (uint32_t*) cmdptr; ! id = *(idptr++); ! int str_len = *(idptr++); ! argsize += str_len; ! const char* dataptr = (const char*) idptr; ! if (str_len) ! { ! char buff[1000]; ! memcpy (buff, dataptr, str_len); ! buff[str_len] = 0; ! extra_str = buff; ! dataptr += str_len; ! } ! memfile = new csMemFile(dataptr, me->data->size - argsize ); } --- 64,74 ---- me->IncRef(); ! cmd = me->GetInt16(); ! id = me->GetInt32(); ! extra_str = me->GetStr(); ! uint32_t datalength; ! void *dataptr = me->GetData(&datalength); ! memfile = new csMemFile((const char *)dataptr, datalength); } |