diff options
author | Patric Stout <truebrain@openttd.org> | 2021-05-05 23:21:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-05 23:21:14 +0200 |
commit | f94fb9377910c63fc8e1ea0ede1d96603e4d8862 (patch) | |
tree | 9b8041b53749744b4df075520181294806332e07 /src/network/core/tcp_connect.cpp | |
parent | ead30dc725c60cac8bc13c86d18b179dac684bec (diff) | |
download | openttd-f94fb9377910c63fc8e1ea0ede1d96603e4d8862.tar.xz |
Codechange: use connection_string in favour of NetworkAddress (#9197)
We now resolve the connection_string to a NetworkAddress in a much
later state. This means there are fewer places constructing a NetworkAddress.
The main benefit of this is in later PRs that introduce different types
of NetworkAddresses. Storing this in things like NetworkGameList is
rather complex, especially as NetworkAddress has to be mutable at all
times.
Additionally, the NetworkAddress is a complex object to store simple
information: how to connect to this server.
Diffstat (limited to 'src/network/core/tcp_connect.cpp')
-rw-r--r-- | src/network/core/tcp_connect.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/network/core/tcp_connect.cpp b/src/network/core/tcp_connect.cpp index b4485cfe9..81c4d8c26 100644 --- a/src/network/core/tcp_connect.cpp +++ b/src/network/core/tcp_connect.cpp @@ -13,6 +13,7 @@ #include "../../thread.h" #include "tcp.h" +#include "../network_internal.h" #include "../../safeguards.h" @@ -21,15 +22,16 @@ static std::vector<TCPConnecter *> _tcp_connecters; /** * Create a new connecter for the given address - * @param address the (un)resolved address to connect to + * @param connection_string the address to connect to */ -TCPConnecter::TCPConnecter(const NetworkAddress &address) : +TCPConnecter::TCPConnecter(const std::string &connection_string, uint16 default_port) : connected(false), aborted(false), killed(false), - sock(INVALID_SOCKET), - address(address) + sock(INVALID_SOCKET) { + this->address = ParseConnectionString(connection_string, default_port); + _tcp_connecters.push_back(this); if (!StartNewThread(nullptr, "ottd:tcp", &TCPConnecter::ThreadEntry, this)) { this->Connect(); |