mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Add command line option for listen address
This commit is contained in:
@@ -345,6 +345,11 @@ namespace OpenRCT2
|
|||||||
gNetworkStartPort = gConfigNetwork.default_port;
|
gNetworkStartPort = gConfigNetwork.default_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (String::IsNullOrEmpty(gNetworkStartAddress))
|
||||||
|
{
|
||||||
|
gNetworkStartAddress = gConfigNetwork.listen_address;
|
||||||
|
}
|
||||||
|
|
||||||
if (String::IsNullOrEmpty(gCustomPassword))
|
if (String::IsNullOrEmpty(gCustomPassword))
|
||||||
{
|
{
|
||||||
network_set_password(gConfigNetwork.default_password);
|
network_set_password(gConfigNetwork.default_password);
|
||||||
@@ -353,7 +358,7 @@ namespace OpenRCT2
|
|||||||
{
|
{
|
||||||
network_set_password(gCustomPassword);
|
network_set_password(gCustomPassword);
|
||||||
}
|
}
|
||||||
network_begin_server(gNetworkStartPort);
|
network_begin_server(gNetworkStartPort, gNetworkStartAddress);
|
||||||
}
|
}
|
||||||
#endif // DISABLE_NETWORK
|
#endif // DISABLE_NETWORK
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ extern "C"
|
|||||||
extern sint32 gNetworkStart;
|
extern sint32 gNetworkStart;
|
||||||
extern char gNetworkStartHost[128];
|
extern char gNetworkStartHost[128];
|
||||||
extern sint32 gNetworkStartPort;
|
extern sint32 gNetworkStartPort;
|
||||||
|
extern char* gNetworkStartAddress;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void openrct2_write_full_version_info(utf8 * buffer, size_t bufferSize);
|
void openrct2_write_full_version_info(utf8 * buffer, size_t bufferSize);
|
||||||
|
|||||||
@@ -44,8 +44,10 @@ extern "C"
|
|||||||
sint32 gNetworkStart = NETWORK_MODE_NONE;
|
sint32 gNetworkStart = NETWORK_MODE_NONE;
|
||||||
char gNetworkStartHost[128];
|
char gNetworkStartHost[128];
|
||||||
sint32 gNetworkStartPort = NETWORK_DEFAULT_PORT;
|
sint32 gNetworkStartPort = NETWORK_DEFAULT_PORT;
|
||||||
|
char* gNetworkStartAddress = nullptr;
|
||||||
|
|
||||||
static uint32 _port = 0;
|
static uint32 _port = 0;
|
||||||
|
static char* _address = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool _help = false;
|
static bool _help = false;
|
||||||
@@ -72,6 +74,7 @@ static const CommandLineOptionDefinition StandardOptions[]
|
|||||||
{ CMDLINE_TYPE_SWITCH, &_headless, NAC, "headless", "run " OPENRCT2_NAME " headless" IMPLIES_SILENT_BREAKPAD },
|
{ CMDLINE_TYPE_SWITCH, &_headless, NAC, "headless", "run " OPENRCT2_NAME " headless" IMPLIES_SILENT_BREAKPAD },
|
||||||
#ifndef DISABLE_NETWORK
|
#ifndef DISABLE_NETWORK
|
||||||
{ CMDLINE_TYPE_INTEGER, &_port, NAC, "port", "port to use for hosting or joining a server" },
|
{ CMDLINE_TYPE_INTEGER, &_port, NAC, "port", "port to use for hosting or joining a server" },
|
||||||
|
{ CMDLINE_TYPE_STRING, &_address, NAC, "address", "address to listen on when hosting a server" },
|
||||||
#endif
|
#endif
|
||||||
{ CMDLINE_TYPE_STRING, &_password, NAC, "password", "password needed to join the server" },
|
{ CMDLINE_TYPE_STRING, &_password, NAC, "password", "password needed to join the server" },
|
||||||
{ CMDLINE_TYPE_STRING, &_userDataPath, NAC, "user-data-path", "path to the user data directory (containing config.ini)" },
|
{ CMDLINE_TYPE_STRING, &_userDataPath, NAC, "user-data-path", "path to the user data directory (containing config.ini)" },
|
||||||
@@ -287,6 +290,8 @@ exitcode_t HandleCommandHost(CommandLineArgEnumerator * enumerator)
|
|||||||
|
|
||||||
gNetworkStart = NETWORK_MODE_SERVER;
|
gNetworkStart = NETWORK_MODE_SERVER;
|
||||||
gNetworkStartPort = _port;
|
gNetworkStartPort = _port;
|
||||||
|
gNetworkStartAddress = _address;
|
||||||
|
|
||||||
return EXITCODE_CONTINUE;
|
return EXITCODE_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user