Split random ports (default off for server) configuration

This commit is contained in:
Benau 2018-07-31 10:46:41 +08:00
parent 8acd13542e
commit 2bb52df3c8
3 changed files with 14 additions and 17 deletions

View File

@ -538,10 +538,8 @@
-->
<texture-compression quality="64"/>
<!-- List of default ports used, by default STK use random ports
for client and server, disable it in user config to allow
port forward. The server discovery port has to be the same
across all clients and servers.
<!-- List of default ports used, by default STK use random ports for client.
The server discovery port has to be the same across all clients and servers.
-->
<network server-discovery-port="2757" client-port="2758" server-port="2759"/>

View File

@ -708,9 +708,14 @@ namespace UserConfigParams
PARAM_PREFIX BoolUserConfigParam m_log_packets
PARAM_DEFAULT(BoolUserConfigParam(false, "log-network-packets",
&m_network_group, "If all network packets should be logged"));
PARAM_PREFIX BoolUserConfigParam m_random_ports
PARAM_DEFAULT(BoolUserConfigParam(true, "random-ports",
&m_network_group, "Use random ports for client and server connection"));
PARAM_PREFIX BoolUserConfigParam m_random_client_port
PARAM_DEFAULT(BoolUserConfigParam(true, "random-client-port",
&m_network_group, "Use random port for client connection "
"(check stk_config.xml for default value)"));
PARAM_PREFIX BoolUserConfigParam m_random_server_port
PARAM_DEFAULT(BoolUserConfigParam(false, "random-server-port",
&m_network_group, "Use random port for server connection "
"(check stk_config.xml for default value)"));
PARAM_PREFIX BoolUserConfigParam m_lobby_chat
PARAM_DEFAULT(BoolUserConfigParam(false, "lobby-chat",
&m_network_group, "Enable chatting in networking lobby, if off than "

View File

@ -60,16 +60,10 @@ NetworkConfig::NetworkConfig()
m_server_name = "";
m_password = "";
m_server_discovery_port = stk_config->m_server_discovery_port;
if (UserConfigParams::m_random_ports)
{
m_client_port = 0;
m_server_port = 0;
}
else
{
m_client_port = stk_config->m_client_port;
m_server_port = stk_config->m_server_port;
}
m_client_port = UserConfigParams::m_random_client_port ?
0 : stk_config->m_client_port;
m_server_port = UserConfigParams::m_random_server_port ?
0 : stk_config->m_server_port;
m_team_choosing = false;
} // NetworkConfig