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

Function ConBan

src/console_cmds.cpp:746–768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

744}
745
746static bool ConBan(std::span<std::string_view> argv)
747{
748 if (argv.empty()) {
749 IConsolePrint(CC_HELP, "Ban a client from a network game. Usage: 'ban <ip | client-id> [<ban-reason>]'.");
750 IConsolePrint(CC_HELP, "For client-id's, see the command 'clients'.");
751 IConsolePrint(CC_HELP, "If the client is no longer online, you can still ban their IP.");
752 return true;
753 }
754
755 if (argv.size() != 2 && argv.size() != 3) return false;
756
757 /* No reason supplied for kicking */
758 if (argv.size() == 2) return ConKickOrBan(argv[1], true, {});
759
760 /* Reason for kicking supplied */
761 size_t kick_message_length = argv[2].size();
762 if (kick_message_length >= 255) {
763 IConsolePrint(CC_ERROR, "Maximum kick message length is 254 characters. You entered {} characters.", kick_message_length);
764 return false;
765 } else {
766 return ConKickOrBan(argv[1], true, argv[2]);
767 }
768}
769
770static bool ConUnBan(std::span<std::string_view> argv)
771{

Callers

nothing calls this directly

Calls 4

ConKickOrBanFunction · 0.85
IConsolePrintFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected