summaryrefslogtreecommitdiff
path: root/src/openttd.cpp
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-05-04 19:32:37 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-05-06 20:33:26 +0200
commit3d91eee919de2ecec11102b4ba1f4caafa4d7a83 (patch)
tree99e8163ee701b5a641648f8c03a7ddfc2829212d /src/openttd.cpp
parent6c4a65eeb80431ce35e91affee865419e7d7af34 (diff)
downloadopenttd-3d91eee919de2ecec11102b4ba1f4caafa4d7a83.tar.xz
Codechange: [Network] Move connection string parsing away from C-strings
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r--src/openttd.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index d4c7da6e4..d9e0b835e 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -405,7 +405,7 @@ void OpenBrowser(const char *url)
struct AfterNewGRFScan : NewGRFScanCallback {
Year startyear; ///< The start year.
uint32 generation_seed; ///< Seed for the new game.
- char *dedicated_host; ///< Hostname for the dedicated server.
+ std::string dedicated_host; ///< Hostname for the dedicated server.
uint16 dedicated_port; ///< Port for the dedicated server.
char *network_conn; ///< Information about the server to connect to, or nullptr.
const char *join_server_password; ///< The password to join the server with.
@@ -417,7 +417,7 @@ struct AfterNewGRFScan : NewGRFScanCallback {
*/
AfterNewGRFScan() :
startyear(INVALID_YEAR), generation_seed(GENERATE_NEW_SEED),
- dedicated_host(nullptr), dedicated_port(0), network_conn(nullptr),
+ dedicated_port(0), network_conn(nullptr),
join_server_password(nullptr), join_company_password(nullptr),
save_config(true)
{
@@ -458,7 +458,7 @@ struct AfterNewGRFScan : NewGRFScanCallback {
if (startyear != INVALID_YEAR) IConsoleSetSetting("game_creation.starting_year", startyear);
if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
- if (dedicated_host != nullptr) {
+ if (!dedicated_host.empty()) {
_network_bind_list.clear();
_network_bind_list.emplace_back(dedicated_host);
}
@@ -565,10 +565,7 @@ int openttd_main(int argc, char *argv[])
dedicated = true;
SetDebugString("net=6");
if (mgo.opt != nullptr) {
- const char *port = nullptr;
- ParseFullConnectionString(nullptr, &port, mgo.opt);
- if (!StrEmpty(mgo.opt)) scanner->dedicated_host = mgo.opt;
- if (port != nullptr) scanner->dedicated_port = atoi(port);
+ scanner->dedicated_host = ParseFullConnectionString(mgo.opt, scanner->dedicated_port);
}
break;
case 'f': _dedicated_forks = true; break;