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

Method SendCmdNames

src/network/network_admin.cpp:572–599  ·  view source on GitHub ↗

Send the names of the commands. */

Source from the content-addressed store, hash-verified

570
571/** Send the names of the commands. */
572NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdNames()
573{
574 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CMD_NAMES);
575
576 for (uint16_t i = 0; i < CMD_END; i++) {
577 std::string_view cmdname = GetCommandName(static_cast<Commands>(i));
578
579 /* Should COMPAT_MTU be exceeded, start a new packet
580 * (magic 5: 1 bool "more data" and one uint16_t "command id", one
581 * byte for string '\0' termination and 1 bool "no more data" */
582 if (!p->CanWriteToPacket(cmdname.size() + 5)) {
583 p->Send_bool(false);
584 this->SendPacket(std::move(p));
585
586 p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CMD_NAMES);
587 }
588
589 p->Send_bool(true);
590 p->Send_uint16(i);
591 p->Send_string(cmdname);
592 }
593
594 /* Marker to notify the end of the packet has been reached. */
595 p->Send_bool(false);
596 this->SendPacket(std::move(p));
597
598 return NETWORK_RECV_STATUS_OKAY;
599}
600
601/**
602 * Send a command for logging purposes.

Callers 1

Receive_ADMIN_POLLMethod · 0.95

Calls 7

GetCommandNameFunction · 0.85
CanWriteToPacketMethod · 0.80
Send_boolMethod · 0.80
Send_uint16Method · 0.80
Send_stringMethod · 0.80
sizeMethod · 0.45
SendPacketMethod · 0.45

Tested by

no test coverage detected