Codechange: split ParseConnectionString into two functions

One also looks for a company, the other doesn't. There were more
uses of the latter than the first, leaving very weird code all
over the place.
This commit is contained in:
Patric Stout
2021-04-20 16:26:07 +02:00
committed by Patric Stout
parent 05612d60ae
commit 31897eaa7d
5 changed files with 40 additions and 17 deletions

View File

@@ -478,7 +478,7 @@ struct AfterNewGRFScan : NewGRFScanCallback {
uint16 rport = NETWORK_DEFAULT_PORT;
CompanyID join_as = COMPANY_NEW_COMPANY;
ParseConnectionString(&company, &port, network_conn);
ParseGameConnectionString(&company, &port, network_conn);
if (company != nullptr) {
join_as = (CompanyID)atoi(company);
@@ -584,11 +584,8 @@ int openttd_main(int argc, char *argv[])
dedicated = true;
SetDebugString("net=6");
if (mgo.opt != nullptr) {
/* Use the existing method for parsing (openttd -n).
* However, we do ignore the #company part. */
const char *temp = nullptr;
const char *port = nullptr;
ParseConnectionString(&temp, &port, mgo.opt);
ParseConnectionString(&port, mgo.opt);
if (!StrEmpty(mgo.opt)) scanner->dedicated_host = mgo.opt;
if (port != nullptr) scanner->dedicated_port = atoi(port);
}
@@ -774,13 +771,12 @@ int openttd_main(int argc, char *argv[])
NetworkStartUp(); // initialize network-core
if (debuglog_conn != nullptr && _network_available) {
const char *not_used = nullptr;
const char *port = nullptr;
uint16 rport;
rport = NETWORK_DEFAULT_DEBUGLOG_PORT;
ParseConnectionString(&not_used, &port, debuglog_conn);
ParseConnectionString(&port, debuglog_conn);
if (port != nullptr) rport = atoi(port);
NetworkStartDebugLog(NetworkAddress(debuglog_conn, rport));