summaryrefslogtreecommitdiff
path: root/src/console_cmds.cpp
diff options
context:
space:
mode:
authorrubidium42 <rubidium42@users.noreply.github.com>2021-04-29 16:43:13 +0200
committerPatric Stout <github@truebrain.nl>2021-04-29 20:12:11 +0200
commita61696d6c565ff92c6604b12eefe36198d094056 (patch)
tree00b97ce4ada979ebf61e6c6c273a187bb0da67ee /src/console_cmds.cpp
parentbe37a2cab831cb645ef0f51dbcc944bd750f6926 (diff)
downloadopenttd-a61696d6c565ff92c6604b12eefe36198d094056.tar.xz
Change: [Network] Encapsulate logic about the connection string to the network code (#23)
Diffstat (limited to 'src/console_cmds.cpp')
-rw-r--r--src/console_cmds.cpp21
1 files changed, 2 insertions, 19 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 7ab6d3179..9dce39909 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -901,8 +901,7 @@ DEF_CONSOLE_CMD(ConNetworkReconnect)
/* Don't resolve the address first, just print it directly as it comes from the config file. */
IConsolePrintF(CC_DEFAULT, "Reconnecting to %s ...", _settings_client.network.last_joined);
- NetworkAddress address = ParseConnectionString(_settings_client.network.last_joined, NETWORK_DEFAULT_PORT);
- NetworkClientConnectGame(address, playas);
+ NetworkClientConnectGame(_settings_client.network.last_joined, playas);
return true;
}
@@ -918,23 +917,7 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
if (argc < 2) return false;
if (_networking) NetworkDisconnect(); // we are in network-mode, first close it!
- CompanyID join_as = COMPANY_NEW_COMPANY;
- NetworkAddress address = ParseGameConnectionString(&join_as, argv[1], NETWORK_DEFAULT_PORT);
-
- IConsolePrintF(CC_DEFAULT, "Connecting to %s...", address.GetAddressAsString().c_str());
- if (join_as != COMPANY_NEW_COMPANY) {
- IConsolePrintF(CC_DEFAULT, " company-no: %d", join_as);
-
- /* From a user pov 0 is a new company, internally it's different and all
- * companies are offset by one to ease up on users (eg companies 1-8 not 0-7) */
- if (join_as != COMPANY_SPECTATOR) {
- if (join_as > MAX_COMPANIES) return false;
- join_as--;
- }
- }
-
- NetworkClientConnectGame(address, join_as);
-
+ NetworkClientConnectGame(argv[1], COMPANY_NEW_COMPANY);
return true;
}