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

Method SendPacket

netgames/dmfc/dmfcpackets.cpp:207–247  ·  view source on GitHub ↗

DMFCBase::SendPacket Ships a Special Packet away to the destination. This call must be preceeded by a StartPacket call data = buffer of data to be sent out (same buffer that was passed to StartPacket size = size (in bytes) of the packet destination = either a player number, SP_ALL for all the players or SP_SERVER to send to the server (if you are a client)

Source from the content-addressed store, hash-verified

205// destination = either a player number, SP_ALL for all the players or SP_SERVER to send to the server (if you are a
206// client)
207void DMFCBase::SendPacket(uint8_t *data, int size, int destination) {
208 ASSERT(size < MAX_GAME_DATA_SIZE - 2); // allow for a header by the d3
209 if (size >= MAX_GAME_DATA_SIZE - 2)
210 return;
211
212 // if we are the server and are trying to send to the server then exit out
213 if ((GetLocalRole() == LR_SERVER) && (destination == SP_SERVER)) {
214 return;
215 }
216
217 // we can safely send this packet out to it's appropriate destination
218
219 // see if we are trying to send to the server, it's specially handled
220 if (destination == SP_SERVER) {
221 DLLMultiClientSendSpecialPacket(data, size);
222 return;
223 }
224
225 // server trying to send to clients
226 if (GetLocalRole() == LR_CLIENT) {
227 // we can't send client to client
228 return;
229 }
230
231 // if server is trying to send to all the clients then we need to send to each individual
232 if (destination == SP_ALL) {
233 int pnum;
234 for (pnum = 0; pnum < DLLMAX_PLAYERS; pnum++) {
235
236 if ((pnum != GetPlayerNum()) && (PacketCheckPlayerNum(pnum))) {
237 // ship it!
238 DLLMultiSendSpecialPacket(pnum, data, size);
239 }
240 }
241 return;
242 }
243
244 // we are only sending to one client
245 if (destination != GetPlayerNum())
246 DLLMultiSendSpecialPacket(destination, data, size);
247}
248
249// DMFCBase::GetGameStateRequest
250//

Callers 15

SendGameStartPacketFunction · 0.80
SendCollideInfoFunction · 0.80
SendLastHitInfoFunction · 0.80
SendGameStartPacketFunction · 0.80
SendHoardInvFunction · 0.80
SendGameConfigFunction · 0.80
PRec_SendPRecToPlayerFunction · 0.80
Remote_SendMessageFunction · 0.80
OnServerCollideFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected