summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-04-27 21:10:11 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-05-13 23:13:17 +0200
commitcc6c078dec3792173b5d2057667bec9597c71d90 (patch)
tree3634a76f302f1dbae914679fe7097da7df6b9e5c
parentc73d64adf984036a99d6974b130eda65dfc18c6c (diff)
downloadopenttd-cc6c078dec3792173b5d2057667bec9597c71d90.tar.xz
Codechange: move hostnames in settings to std::string
-rw-r--r--src/console_cmds.cpp4
-rw-r--r--src/network/network.cpp2
-rw-r--r--src/network/network_gui.cpp4
-rw-r--r--src/settings_type.h4
-rw-r--r--src/table/settings.ini10
5 files changed, 13 insertions, 11 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 3929b44c1..90f635d60 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -893,13 +893,13 @@ DEF_CONSOLE_CMD(ConNetworkReconnect)
break;
}
- if (StrEmpty(_settings_client.network.last_joined)) {
+ if (_settings_client.network.last_joined.empty()) {
IConsolePrint(CC_DEFAULT, "No server for reconnecting.");
return true;
}
/* 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);
+ IConsolePrintF(CC_DEFAULT, "Reconnecting to %s ...", _settings_client.network.last_joined.c_str());
return NetworkClientConnectGame(_settings_client.network.last_joined, playas);
}
diff --git a/src/network/network.cpp b/src/network/network.cpp
index b9160e208..94566d232 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -824,7 +824,7 @@ void NetworkClientJoinGame()
NetworkDisconnect();
NetworkInitialize();
- strecpy(_settings_client.network.last_joined, _network_join.connection_string.c_str(), lastof(_settings_client.network.last_joined));
+ _settings_client.network.last_joined = _network_join.connection_string;
_network_join_status = NETWORK_JOIN_STATUS_CONNECTING;
ShowJoinStatusWindow();
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 67992cac7..ca0e67d0a 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -828,7 +828,7 @@ public:
void OnQueryTextFinished(char *str) override
{
if (!StrEmpty(str)) {
- strecpy(_settings_client.network.connect_to_ip, str, lastof(_settings_client.network.connect_to_ip));
+ _settings_client.network.connect_to_ip = str;
NetworkAddServer(str);
NetworkRebuildHostList();
}
@@ -1556,7 +1556,7 @@ static void ShowNetworkLobbyWindow(NetworkGameList *ngl)
DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_START);
DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
- strecpy(_settings_client.network.last_joined, ngl->connection_string.c_str(), lastof(_settings_client.network.last_joined));
+ _settings_client.network.last_joined = ngl->connection_string;
NetworkQueryLobbyServer(ngl->connection_string);
diff --git a/src/settings_type.h b/src/settings_type.h
index 248761fe6..0828baa58 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -269,7 +269,7 @@ struct NetworkSettings {
bool server_advertise; ///< advertise the server to the masterserver
char client_name[NETWORK_CLIENT_NAME_LENGTH]; ///< name of the player (as client)
std::string default_company_pass; ///< default password for new companies in encrypted form
- char connect_to_ip[NETWORK_HOSTNAME_PORT_LENGTH]; ///< default for the "Add server" query
+ std::string connect_to_ip; ///< default for the "Add server" query
char network_id[NETWORK_SERVER_ID_LENGTH]; ///< network ID for servers
bool autoclean_companies; ///< automatically remove companies that are not in use
uint8 autoclean_unprotected; ///< remove passwordless companies after this many months
@@ -281,7 +281,7 @@ struct NetworkSettings {
Year restart_game_year; ///< year the server restarts
uint8 min_active_clients; ///< minimum amount of active clients to unpause the game
bool reload_cfg; ///< reload the config file before restarting
- char last_joined[NETWORK_HOSTNAME_PORT_LENGTH]; ///< Last joined server
+ std::string last_joined; ///< Last joined server
bool no_http_content_downloads; ///< do not do content downloads over HTTP
};
diff --git a/src/table/settings.ini b/src/table/settings.ini
index e8fa4560b..6dbff01db 100644
--- a/src/table/settings.ini
+++ b/src/table/settings.ini
@@ -3970,9 +3970,10 @@ def = nullptr
proc = UpdateClientConfigValues
cat = SC_BASIC
-[SDTC_STR]
+[SDTC_SSTR]
var = network.connect_to_ip
-type = SLE_STRB
+type = SLE_STR
+length = 0
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
def = nullptr
@@ -4075,9 +4076,10 @@ guiflags = SGF_NETWORK_ONLY
def = false
cat = SC_EXPERT
-[SDTC_STR]
+[SDTC_SSTR]
var = network.last_joined
-type = SLE_STRB
+type = SLE_STR
+length = 0
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
def = """"
cat = SC_EXPERT