summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-04-27 10:56:26 +0200
committerCharles Pigott <charlespigott@googlemail.com>2021-04-27 18:17:34 +0100
commitcbad518bf3c7e6d05b62d8c1d063b89d974e5f33 (patch)
tree4c48ee1f10f23ec4a27e82d3db110de54db31480 /src
parentcf8c1aa860e05e696f9829e3b031a22ca82781ef (diff)
downloadopenttd-cbad518bf3c7e6d05b62d8c1d063b89d974e5f33.tar.xz
Codechange: [Network] Do not leak os_abstraction.h via network_func
Diffstat (limited to 'src')
-rw-r--r--src/console_cmds.cpp4
-rw-r--r--src/network/network.cpp15
-rw-r--r--src/network/network_func.h5
-rw-r--r--src/network/network_gui.cpp6
-rw-r--r--src/openttd.cpp6
5 files changed, 18 insertions, 18 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index f8d9eb1b0..048b8b3e9 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -900,7 +900,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:%d...", _settings_client.network.last_host, _settings_client.network.last_port);
- NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), playas);
+ NetworkClientConnectGame(_settings_client.network.last_host, _settings_client.network.last_port, playas);
return true;
}
@@ -942,7 +942,7 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
IConsolePrintF(CC_DEFAULT, " port: %s", port);
}
- NetworkClientConnectGame(NetworkAddress(ip, rport), join_as);
+ NetworkClientConnectGame(ip, rport, join_as);
return true;
}
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 1e0838684..812456b4e 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -688,16 +688,16 @@ public:
/* Used by clients, to connect to a server */
-void NetworkClientConnectGame(NetworkAddress address, CompanyID join_as, const char *join_server_password, const char *join_company_password)
+void NetworkClientConnectGame(const char *hostname, uint16 port, CompanyID join_as, const char *join_server_password, const char *join_company_password)
{
if (!_network_available) return;
- if (address.GetPort() == 0) return;
+ if (port == 0) return;
if (!NetworkValidateClientName()) return;
- strecpy(_settings_client.network.last_host, address.GetHostname(), lastof(_settings_client.network.last_host));
- _settings_client.network.last_port = address.GetPort();
+ strecpy(_settings_client.network.last_host, hostname, lastof(_settings_client.network.last_host));
+ _settings_client.network.last_port = port;
_network_join_as = join_as;
_network_join_server_password = join_server_password;
_network_join_company_password = join_company_password;
@@ -708,7 +708,7 @@ void NetworkClientConnectGame(NetworkAddress address, CompanyID join_as, const c
_network_join_status = NETWORK_JOIN_STATUS_CONNECTING;
ShowJoinStatusWindow();
- new TCPClientConnecter(address);
+ new TCPClientConnecter(NetworkAddress(hostname, port));
}
static void NetworkInitGameInfo()
@@ -1059,12 +1059,13 @@ static void NetworkGenerateServerId()
seprintf(_settings_client.network.network_id, lastof(_settings_client.network.network_id), "%s", hex_output);
}
-void NetworkStartDebugLog(NetworkAddress address)
+void NetworkStartDebugLog(const char *hostname, uint16 port)
{
extern SOCKET _debug_socket; // Comes from debug.c
- DEBUG(net, 0, "Redirecting DEBUG() to %s:%d", address.GetHostname(), address.GetPort());
+ DEBUG(net, 0, "Redirecting DEBUG() to %s:%d", hostname, port);
+ NetworkAddress address(hostname, port);
SOCKET s = address.Connect();
if (s == INVALID_SOCKET) {
DEBUG(net, 0, "Failed to open socket for redirection DEBUG()");
diff --git a/src/network/network_func.h b/src/network/network_func.h
index c1271f69c..66719b216 100644
--- a/src/network/network_func.h
+++ b/src/network/network_func.h
@@ -17,7 +17,6 @@
// #define DEBUG_DUMP_COMMANDS
// #define DEBUG_FAILED_DUMP_COMMANDS
-#include "core/address.h"
#include "network_type.h"
#include "../console_type.h"
#include "../gfx_type.h"
@@ -48,12 +47,12 @@ void NetworkGameLoop();
void NetworkBackgroundLoop();
void ParseConnectionString(const char **port, char *connection_string);
void ParseGameConnectionString(const char **company, const char **port, char *connection_string);
-void NetworkStartDebugLog(NetworkAddress address);
+void NetworkStartDebugLog(const char *hostname, uint16 port);
void NetworkPopulateCompanyStats(NetworkCompanyStats *stats);
void NetworkUpdateClientInfo(ClientID client_id);
void NetworkClientsToSpectators(CompanyID cid);
-void NetworkClientConnectGame(NetworkAddress address, CompanyID join_as, const char *join_server_password = nullptr, const char *join_company_password = nullptr);
+void NetworkClientConnectGame(const char *hostname, uint16 port, CompanyID join_as, const char *join_server_password = nullptr, const char *join_company_password = nullptr);
void NetworkClientRequestMove(CompanyID company, const char *pass = "");
void NetworkClientSendRcon(const char *password, const char *command);
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg, int64 data = 0);
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 68208ee3f..ebba47d85 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -1470,15 +1470,15 @@ struct NetworkLobbyWindow : public Window {
case WID_NL_JOIN: // Join company
/* Button can be clicked only when it is enabled. */
- NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), this->company);
+ NetworkClientConnectGame(_settings_client.network.last_host, _settings_client.network.last_port, this->company);
break;
case WID_NL_NEW: // New company
- NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), COMPANY_NEW_COMPANY);
+ NetworkClientConnectGame(_settings_client.network.last_host, _settings_client.network.last_port, COMPANY_NEW_COMPANY);
break;
case WID_NL_SPECTATE: // Spectate game
- NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), COMPANY_SPECTATOR);
+ NetworkClientConnectGame(_settings_client.network.last_host, _settings_client.network.last_port, COMPANY_SPECTATOR);
break;
case WID_NL_REFRESH: // Refresh
diff --git a/src/openttd.cpp b/src/openttd.cpp
index b204ca5a2..016d48287 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -495,7 +495,7 @@ struct AfterNewGRFScan : NewGRFScanCallback {
LoadIntroGame();
_switch_mode = SM_NONE;
- NetworkClientConnectGame(NetworkAddress(network_conn, rport), join_as, join_server_password, join_company_password);
+ NetworkClientConnectGame(network_conn, rport, join_as, join_server_password, join_company_password);
}
/* After the scan we're not used anymore. */
@@ -779,7 +779,7 @@ int openttd_main(int argc, char *argv[])
ParseConnectionString(&port, debuglog_conn);
if (port != nullptr) rport = atoi(port);
- NetworkStartDebugLog(NetworkAddress(debuglog_conn, rport));
+ NetworkStartDebugLog(debuglog_conn, rport);
}
if (!HandleBootstrap()) {
@@ -1491,7 +1491,7 @@ void GameLoop()
if (_network_reconnect > 0 && --_network_reconnect == 0) {
/* This means that we want to reconnect to the last host
* We do this here, because it means that the network is really closed */
- NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), COMPANY_SPECTATOR);
+ NetworkClientConnectGame(_settings_client.network.last_host, _settings_client.network.last_port, COMPANY_SPECTATOR);
}
/* Singleplayer */
StateGameLoop();