* Sends a command over the network. * @param p the packet to send it in. * @param cp the packet to actually send. */
| 393 | * @param cp the packet to actually send. |
| 394 | */ |
| 395 | void NetworkGameSocketHandler::SendCommand(Packet &p, const CommandPacket &cp) |
| 396 | { |
| 397 | p.Send_uint8(cp.company); |
| 398 | p.Send_uint16(cp.cmd); |
| 399 | p.Send_uint16(cp.err_msg); |
| 400 | p.Send_buffer(cp.data); |
| 401 | |
| 402 | size_t callback = FindCallbackIndex(cp.callback); |
| 403 | if (callback > UINT8_MAX || _cmd_dispatch[cp.cmd].Unpack[callback] == nullptr) { |
| 404 | Debug(net, 0, "Unknown callback for command; no callback sent (command: {})", cp.cmd); |
| 405 | callback = 0; // _callback_table[0] == nullptr |
| 406 | } |
| 407 | p.Send_uint8 ((uint8_t)callback); |
| 408 | } |
| 409 | |
| 410 | /** Helper to process a single ClientID argument. */ |
| 411 | template <class T> |
nothing calls this directly
no test coverage detected