summaryrefslogtreecommitdiff
path: root/src/openttd.cpp
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-05-02 09:18:56 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-05-14 23:22:04 +0200
commit297d6e20bf0467d2a42e49bee291829ce3bb7c58 (patch)
treed428b9f170c31b1552b0365b21b916ff6ead6278 /src/openttd.cpp
parentebe32ad9129bb5846433366509728fb594f3be62 (diff)
downloadopenttd-297d6e20bf0467d2a42e49bee291829ce3bb7c58.tar.xz
Codechange: [Network] Pass passwords as std::string to the network code
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r--src/openttd.cpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 5674a4671..fec8bf9ca 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -400,23 +400,19 @@ void OpenBrowser(const char *url)
/** Callback structure of statements to be executed after the NewGRF scan. */
struct AfterNewGRFScan : NewGRFScanCallback {
- Year startyear; ///< The start year.
- uint32 generation_seed; ///< Seed for the new game.
- 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.
- const char *join_company_password; ///< The password to join the company with.
- bool save_config; ///< The save config setting.
+ Year startyear = INVALID_YEAR; ///< The start year.
+ uint32 generation_seed = GENERATE_NEW_SEED; ///< Seed for the new game.
+ std::string dedicated_host; ///< Hostname for the dedicated server.
+ uint16 dedicated_port = 0; ///< Port for the dedicated server.
+ std::string connection_string; ///< Information about the server to connect to
+ std::string join_server_password; ///< The password to join the server with.
+ std::string join_company_password; ///< The password to join the company with.
+ bool save_config = true; ///< The save config setting.
/**
* Create a new callback.
*/
- AfterNewGRFScan() :
- startyear(INVALID_YEAR), generation_seed(GENERATE_NEW_SEED),
- dedicated_port(0), network_conn(nullptr),
- join_server_password(nullptr), join_company_password(nullptr),
- save_config(true)
+ AfterNewGRFScan()
{
/* Visual C++ 2015 fails compiling this line (AfterNewGRFScan::generation_seed undefined symbol)
* if it's placed outside a member function, directly in the struct body. */
@@ -469,11 +465,11 @@ struct AfterNewGRFScan : NewGRFScanCallback {
/* Make sure _settings is filled with _settings_newgame if we switch to a game directly */
if (_switch_mode != SM_NONE) MakeNewgameSettingsLive();
- if (_network_available && network_conn != nullptr) {
+ if (_network_available && !connection_string.empty()) {
LoadIntroGame();
_switch_mode = SM_NONE;
- NetworkClientConnectGame(network_conn, COMPANY_NEW_COMPANY, join_server_password, join_company_password);
+ NetworkClientConnectGame(connection_string, COMPANY_NEW_COMPANY, join_server_password, join_company_password);
}
/* After the scan we're not used anymore. */
@@ -567,7 +563,7 @@ int openttd_main(int argc, char *argv[])
break;
case 'f': _dedicated_forks = true; break;
case 'n':
- scanner->network_conn = mgo.opt; // optional IP parameter, nullptr if unset
+ scanner->connection_string = mgo.opt; // optional IP:port#company parameter
break;
case 'l':
debuglog_conn = mgo.opt;
@@ -875,7 +871,7 @@ static void MakeNewGameDone()
/* We are the server, we start a new company (not dedicated),
* so set the default password *if* needed. */
if (_network_server && !_settings_client.network.default_company_pass.empty()) {
- NetworkChangeCompanyPassword(_local_company, _settings_client.network.default_company_pass.c_str());
+ NetworkChangeCompanyPassword(_local_company, _settings_client.network.default_company_pass);
}
if (_settings_client.gui.pause_on_newgame) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);