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

Function ConNetworkReconnect

src/console_cmds.cpp:1119–1148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1117}
1118
1119static bool ConNetworkReconnect(std::span<std::string_view> argv)
1120{
1121 if (argv.empty()) {
1122 IConsolePrint(CC_HELP, "Reconnect to server to which you were connected last time. Usage: 'reconnect [<company-id>]'.");
1123 IConsolePrint(CC_HELP, "Company 255 is spectator (default, if not specified), 254 means creating new company.");
1124 IConsolePrint(CC_HELP, "All others are a certain company with Company 1 being #1.");
1125 return true;
1126 }
1127
1128 CompanyID playas = COMPANY_SPECTATOR;
1129 if (argv.size() >= 2) {
1130 auto company_id = ParseCompanyID(argv[1]);
1131 if (!company_id.has_value()) {
1132 IConsolePrint(CC_ERROR, "The given company-id is not a valid number.");
1133 return true;
1134 }
1135 if (*company_id >= MAX_COMPANIES && *company_id != COMPANY_NEW_COMPANY && *company_id != COMPANY_SPECTATOR) return false;
1136 playas = *company_id;
1137 }
1138
1139 if (_settings_client.network.last_joined.empty()) {
1140 IConsolePrint(CC_DEFAULT, "No server for reconnecting.");
1141 return true;
1142 }
1143
1144 /* Don't resolve the address first, just print it directly as it comes from the config file. */
1145 IConsolePrint(CC_DEFAULT, "Reconnecting to {} ...", _settings_client.network.last_joined);
1146
1147 return NetworkClientConnectGame(_settings_client.network.last_joined, playas);
1148}
1149
1150static bool ConNetworkConnect(std::span<std::string_view> argv)
1151{

Callers

nothing calls this directly

Calls 5

ParseCompanyIDFunction · 0.85
NetworkClientConnectGameFunction · 0.85
IConsolePrintFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected