| 1288 | } |
| 1289 | |
| 1290 | int StuffObjectIntoPacket(object *obj, uint8_t *data) { |
| 1291 | uint32_t index; |
| 1292 | int count = 0; |
| 1293 | bool obj_is_dummy = false; |
| 1294 | |
| 1295 | MultiAddUshort(obj - Objects, data, &count); |
| 1296 | MultiAddByte(obj->type, data, &count); |
| 1297 | |
| 1298 | // Send old object type if it's a dummy |
| 1299 | if (obj->type == OBJ_DUMMY) { |
| 1300 | obj_is_dummy = true; |
| 1301 | MultiAddByte(obj->dummy_type, data, &count); |
| 1302 | ObjUnGhostObject(obj - Objects); |
| 1303 | } |
| 1304 | |
| 1305 | if (obj->type != OBJ_CAMERA && obj->type != OBJ_DOOR) { |
| 1306 | // Stuff the checksum |
| 1307 | index = MultiGetMatchChecksum(obj->type, obj->id); |
| 1308 | MultiAddUint(index, data, &count); |
| 1309 | } |
| 1310 | |
| 1311 | if (obj->type != OBJ_POWERUP && obj->type != OBJ_DOOR) { |
| 1312 | multi_orientation mat; |
| 1313 | MultiMakeMatrix(&mat, &obj->orient); |
| 1314 | MultiMatrixMakeEndianFriendly(&mat); |
| 1315 | memcpy(&data[count], &mat, sizeof(multi_orientation)); |
| 1316 | count += sizeof(multi_orientation); |
| 1317 | } |
| 1318 | |
| 1319 | // Send position |
| 1320 | if (obj->type != OBJ_DOOR) { |
| 1321 | // memcpy (&data[count],&obj->pos,sizeof(vector)); |
| 1322 | // count+=sizeof(vector); |
| 1323 | MultiAddVector(obj->pos, data, &count); |
| 1324 | |
| 1325 | // Send room number and terrain flag |
| 1326 | MultiAddUshort(CELLNUM(obj->roomnum), data, &count); |
| 1327 | |
| 1328 | if (OBJECT_OUTSIDE(obj)) |
| 1329 | MultiAddByte(1, data, &count); |
| 1330 | else |
| 1331 | MultiAddByte(0, data, &count); |
| 1332 | |
| 1333 | if (obj->flags & OF_USES_LIFELEFT) { |
| 1334 | ASSERT(obj->lifeleft < 255); |
| 1335 | MultiAddUbyte(obj->lifeleft, data, &count); |
| 1336 | } else |
| 1337 | MultiAddUbyte(255, data, &count); |
| 1338 | } |
| 1339 | |
| 1340 | if (obj->type == OBJ_MARKER) { |
| 1341 | // Add marker message to the end of this |
| 1342 | uint8_t len = strlen(MarkerMessages[obj->id]) + 1; |
| 1343 | MultiAddByte(len, data, &count); |
| 1344 | memcpy(data + count, MarkerMessages[obj->id], len); |
| 1345 | count += len; |
| 1346 | } |
| 1347 |
no test coverage detected