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)
| 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) |
| 207 | void 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 | // |
no outgoing calls
no test coverage detected