MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SendCommand

Method SendCommand

src/network/network_command.cpp:395–408  ·  view source on GitHub ↗

* Sends a command over the network. * @param p the packet to send it in. * @param cp the packet to actually send. */

Source from the content-addressed store, hash-verified

393 * @param cp the packet to actually send.
394 */
395void 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. */
411template <class T>

Callers

nothing calls this directly

Calls 4

FindCallbackIndexFunction · 0.85
Send_uint16Method · 0.80
Send_bufferMethod · 0.80
Send_uint8Method · 0.45

Tested by

no test coverage detected