MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / MultiSendObject

Function MultiSendObject

Descent3/multi.cpp:5348–5445  ·  view source on GitHub ↗

Sends an object from the server to the client

Source from the content-addressed store, hash-verified

5346
5347// Sends an object from the server to the client
5348void MultiSendObject(object *obj, uint8_t announce, uint8_t demo_record) {
5349 MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_SERVER);
5350
5351 int count = 0;
5352 uint8_t data[MAX_GAME_DATA_SIZE];
5353 int size_offset;
5354
5355 if (obj->type != OBJ_WEAPON)
5356 obj->flags |= OF_CLIENT_KNOWS;
5357
5358 if (demo_record)
5359 obj->flags |= OF_CLIENTDEMOOBJECT;
5360
5361 // mprintf(0,"Telling clients to CREATE object %d type=%d\n",obj-Objects,obj->type);
5362
5363 object *parent_obj = ObjGetUltimateParent(obj);
5364
5365 size_offset = START_DATA(MP_OBJECT, data, &count, 1);
5366
5367 uint32_t index = MultiGetMatchChecksum(obj->type, obj->id);
5368
5369 // Send server object number
5370 MultiAddByte(announce, data, &count);
5371 MultiAddUshort(obj - Objects, data, &count);
5372
5373 // Add parent
5374 if (obj->parent_handle == OBJECT_HANDLE_NONE)
5375 MultiAddUshort(65535, data, &count);
5376 else
5377 MultiAddUshort((obj->parent_handle & HANDLE_OBJNUM_MASK), data, &count); // Add parent
5378
5379 MultiAddByte(obj->type, data, &count);
5380 MultiAddUint(index, data, &count);
5381 // If it's a ghost object (type==OBJ_DUMMY) send it's old type
5382 if (obj->type == OBJ_DUMMY)
5383 MultiAddByte(obj->dummy_type, data, &count);
5384
5385 // Send position
5386 // memcpy (&data[count],&obj->pos,sizeof(vector));
5387 // count+=sizeof(vector);
5388 MultiAddVector(obj->pos, data, &count);
5389
5390 // Send velocity
5391 // memcpy (&data[count],&obj->mtype.phys_info.velocity,sizeof(vector));
5392 // count+=sizeof(vector);
5393 MultiAddVector(obj->mtype.phys_info.velocity, data, &count);
5394
5395 if (obj->type != OBJ_POWERUP && obj->type != OBJ_DUMMY) {
5396 // Send over orientation
5397 angvec angs;
5398 vm_ExtractAnglesFromMatrix(&angs, &obj->orient);
5399
5400 MultiAddShort(angs.p, data, &count);
5401 MultiAddShort(angs.h, data, &count);
5402 MultiAddShort(angs.b, data, &count);
5403 }
5404
5405 // Send movement type

Callers 10

ProcessTestKeysFunction · 0.85
osipf_ObjCreateFunction · 0.85
MultiDoRequestMarkerFunction · 0.85
MultiClearGuidebotFunction · 0.85
DoDeathSpewFunction · 0.85
PlayerSpewObjectFunction · 0.85
UseMethod · 0.85
DoObjProdMethod · 0.85

Calls 15

ObjGetUltimateParentFunction · 0.85
START_DATAFunction · 0.85
MultiGetMatchChecksumFunction · 0.85
MultiAddByteFunction · 0.85
MultiAddUshortFunction · 0.85
MultiAddUintFunction · 0.85
MultiAddVectorFunction · 0.85
MultiAddShortFunction · 0.85
MultiAddUbyteFunction · 0.85
END_DATAFunction · 0.85
CreateRandomSparksFunction · 0.85
MultiAnnounceEffectFunction · 0.85

Tested by

no test coverage detected