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

Function MultiSendMissileRelease

Descent3/multi.cpp:5589–5632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5587}
5588
5589void MultiSendMissileRelease(int slot, bool is_guided) {
5590 ASSERT(slot >= 0 && slot < MAX_PLAYERS);
5591
5592 if (!(NetPlayers[slot].flags & NPF_CONNECTED) || NetPlayers[slot].sequence != NETSEQ_PLAYING)
5593 return; // hey this player isn't in the game
5594
5595 if (is_guided && Players[slot].guided_obj == NULL)
5596 return; // no guided missile for this player
5597 if (!is_guided && Players[slot].user_timeout_obj == NULL)
5598 return; // no user timeout object
5599
5600 // everything looks ok, fire off this packet
5601 int count = 0;
5602 uint8_t data[MAX_GAME_DATA_SIZE];
5603 int size_offset;
5604
5605 uint8_t byte_to_send;
5606 byte_to_send = slot;
5607 if (is_guided)
5608 byte_to_send |= 0x80;
5609
5610 size_offset = START_DATA(MP_MISSILE_RELEASE, data, &count, 1);
5611 MultiAddUbyte(byte_to_send, data, &count);
5612 END_DATA(count, data, size_offset);
5613
5614 if (Netgame.local_role == LR_SERVER) {
5615 int i;
5616
5617 // tell all the clients (except the player who is releasing)
5618 for (i = 0; i < MAX_NET_PLAYERS; i++) {
5619 if (i == Player_num)
5620 continue;
5621 if (i == slot)
5622 continue;
5623
5624 if ((NetPlayers[i].flags & NPF_CONNECTED) && (NetPlayers[i].sequence == NETSEQ_PLAYING)) {
5625 nw_SendReliable(NetPlayers[i].reliable_socket, data, count, true);
5626 }
5627 }
5628 } else {
5629 // tell the server
5630 nw_SendReliable(NetPlayers[Player_num].reliable_socket, data, count, true);
5631 }
5632}
5633
5634// Calls the scripts packet extractor code
5635void MultiDoSpecialPacket(uint8_t *data) {

Callers 3

MultiDoMissileReleaseFunction · 0.85
ReleaseGuidedMissileFunction · 0.85

Calls 4

START_DATAFunction · 0.85
MultiAddUbyteFunction · 0.85
END_DATAFunction · 0.85
nw_SendReliableFunction · 0.85

Tested by

no test coverage detected