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

Method SendConsole

src/network/network_admin.cpp:529–544  ·  view source on GitHub ↗

* Send console output of other clients. * @param origin The origin of the string. * @param string The string that's put on the console. */

Source from the content-addressed store, hash-verified

527 * @param string The string that's put on the console.
528 */
529NetworkRecvStatus ServerNetworkAdminSocketHandler::SendConsole(std::string_view origin, std::string_view string)
530{
531 /* If the length of both strings, plus the 2 '\0' terminations and 3 bytes of the packet
532 * are bigger than the MTU, just ignore the message. Better safe than sorry. It should
533 * never occur though as the longest strings are chat messages, which are still 30%
534 * smaller than COMPAT_MTU. */
535 if (origin.size() + string.size() + 2 + 3 >= COMPAT_MTU) return NETWORK_RECV_STATUS_OKAY;
536
537 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CONSOLE);
538
539 p->Send_string(origin);
540 p->Send_string(string);
541 this->SendPacket(std::move(p));
542
543 return NETWORK_RECV_STATUS_OKAY;
544}
545
546/**
547 * Send GameScript JSON output.

Callers 1

NetworkAdminConsoleFunction · 0.80

Calls 3

Send_stringMethod · 0.80
sizeMethod · 0.45
SendPacketMethod · 0.45

Tested by

no test coverage detected