mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
Add config option for socket listen address
This commit is contained in:
@@ -343,6 +343,11 @@ namespace Config
|
||||
auto model = &gConfigNetwork;
|
||||
model->player_name = reader->GetCString("player_name", "Player");
|
||||
model->default_port = reader->GetSint32("default_port", NETWORK_DEFAULT_PORT);
|
||||
|
||||
model->listen_address = reader->GetCString("listen_address", "");
|
||||
if (strlen(model->listen_address) == 0)
|
||||
model->listen_address = nullptr;
|
||||
|
||||
model->default_password = reader->GetCString("default_password", nullptr);
|
||||
model->stay_connected = reader->GetBoolean("stay_connected", true);
|
||||
model->advertise = reader->GetBoolean("advertise", true);
|
||||
@@ -365,6 +370,7 @@ namespace Config
|
||||
writer->WriteSection("network");
|
||||
writer->WriteString("player_name", model->player_name);
|
||||
writer->WriteSint32("default_port", model->default_port);
|
||||
writer->WriteString("listen_address", model->listen_address);
|
||||
writer->WriteString("default_password", model->default_password);
|
||||
writer->WriteBoolean("stay_connected", model->stay_connected);
|
||||
writer->WriteBoolean("advertise", model->advertise);
|
||||
|
||||
@@ -137,6 +137,7 @@ typedef struct NetworkConfiguration
|
||||
{
|
||||
utf8 * player_name;
|
||||
sint32 default_port;
|
||||
char * listen_address;
|
||||
utf8 * default_password;
|
||||
bool stay_connected;
|
||||
bool advertise;
|
||||
|
||||
@@ -264,7 +264,7 @@ bool Network::BeginClient(const char* host, uint16 port)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Network::BeginServer(uint16 port, const char* address)
|
||||
bool Network::BeginServer(uint16 port)
|
||||
{
|
||||
Close();
|
||||
if (!Init())
|
||||
@@ -280,7 +280,7 @@ bool Network::BeginServer(uint16 port, const char* address)
|
||||
listening_socket = CreateTcpSocket();
|
||||
try
|
||||
{
|
||||
listening_socket->Listen(address, port);
|
||||
listening_socket->Listen(gConfigNetwork.listen_address, port);
|
||||
}
|
||||
catch (const Exception &ex)
|
||||
{
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
bool Init();
|
||||
void Close();
|
||||
bool BeginClient(const char* host, uint16 port);
|
||||
bool BeginServer(uint16 port, const char* address = NULL);
|
||||
bool BeginServer(uint16 port);
|
||||
sint32 GetMode();
|
||||
sint32 GetStatus();
|
||||
sint32 GetAuthStatus();
|
||||
|
||||
Reference in New Issue
Block a user