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

Function MultiSendJoinObjects

Descent3/multi_server.cpp:1361–1452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1359// Server only
1360#define MAX_OBJECTS_PER_PACKET 50
1361void MultiSendJoinObjects(int slot) {
1362 ASSERT(Netgame.local_role == LR_SERVER);
1363
1364 uint8_t data[MAX_GAME_DATA_SIZE];
1365 uint16_t outgoing_objects[MAX_OBJECTS];
1366 int count = 0;
1367 int size_offset;
1368 int i;
1369
1370 mprintf(0, "Sending MP_JOIN_OBJECTS packet to player %d!\n", slot);
1371
1372 uint16_t total_objects = 0;
1373 last_sent_bytes[slot] = timer_GetTime();
1374
1375 Num_moved_robots[slot] = 0;
1376 Num_changed_anim[slot] = 0;
1377 Num_changed_turret[slot] = 0;
1378 Num_changed_wb_anim[slot] = 0;
1379
1380 // Count how many powerups/robots we have to send and make a list
1381 for (i = 0; i < MAX_OBJECTS; i++) {
1382 if (Objects[i].type == OBJ_ROBOT || Objects[i].type == OBJ_POWERUP || Objects[i].type == OBJ_MARKER ||
1383 Objects[i].type == OBJ_CAMERA || Objects[i].type == OBJ_CLUTTER || Objects[i].type == OBJ_BUILDING ||
1384 Objects[i].type == OBJ_DUMMY || Objects[i].type == OBJ_DOOR) {
1385 outgoing_objects[total_objects] = i;
1386 total_objects++;
1387
1388 if (MultiIsValidMovedObject(&Objects[i])) {
1389 if (Num_changed_anim[slot] < MAX_CHANGED_OBJECTS) {
1390 Changed_anim[Num_changed_anim[slot]][slot] = Objects[i].handle;
1391 Num_changed_anim[slot]++;
1392 }
1393
1394 object *obj = &Objects[i];
1395 polyobj_info *p_info = &obj->rtype.pobj_info;
1396 if (p_info->multi_turret_info.num_turrets) {
1397 if (Num_changed_turret[slot] < MAX_CHANGED_OBJECTS) {
1398 Changed_turret[Num_changed_turret[slot]][slot] = Objects[i].handle;
1399 Num_changed_turret[slot]++;
1400 }
1401 }
1402 }
1403 }
1404 }
1405
1406 // Only send up to n objects in a packet lest we overflow outgoing packet size
1407
1408 int cur_object = 0;
1409 int objects_to_go = total_objects;
1410
1411 while (objects_to_go > 0) {
1412 int num_objects_this_packet = std::min(MAX_OBJECTS_PER_PACKET, objects_to_go);
1413 int overflow = 0;
1414
1415 count = 0;
1416 size_offset = START_DATA(MP_JOIN_OBJECTS, data, &count);
1417 int num_objs_offset = count;
1418 MultiAddByte(0, data, &count);

Callers 1

MultiDoServerFrameFunction · 0.85

Calls 7

MultiIsValidMovedObjectFunction · 0.85
START_DATAFunction · 0.85
MultiAddByteFunction · 0.85
StuffObjectIntoPacketFunction · 0.85
END_DATAFunction · 0.85
nw_SendReliableFunction · 0.85
MultiSendJoinDemoObjectsFunction · 0.85

Tested by

no test coverage detected