Move port configuration to user and stk config
This commit is contained in:
parent
88e9d6a34c
commit
1dc7f3aa4e
@ -487,4 +487,11 @@
|
||||
-->
|
||||
<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.
|
||||
-->
|
||||
<network server-discovery-port="2757" client-port="2758" server-port="2759"/>
|
||||
|
||||
</config>
|
||||
|
@ -126,6 +126,12 @@ void STKConfig::load(const std::string &filename)
|
||||
Log::fatal("StkConfig", "No rotationalsmoothing defined in stk_config.");
|
||||
}
|
||||
|
||||
if (m_client_port == 0 || m_server_port == 0 || m_server_discovery_port == 0 ||
|
||||
m_client_port == m_server_port || m_client_port == m_server_discovery_port ||
|
||||
m_server_port == m_server_discovery_port)
|
||||
{
|
||||
Log::fatal("StkConfig", "Invalid default port values.");
|
||||
}
|
||||
CHECK_NEG(m_max_karts, "<karts max=..." );
|
||||
CHECK_NEG(m_item_switch_time, "item-switch-time" );
|
||||
CHECK_NEG(m_bubblegum_counter, "bubblegum disappear counter");
|
||||
@ -195,6 +201,9 @@ void STKConfig::init_defaults()
|
||||
m_cutscene_fov = 0.61f;
|
||||
m_max_skinning_bones = 1024;
|
||||
m_tc_quality = 16;
|
||||
m_server_discovery_port = 2757;
|
||||
m_client_port = 2758;
|
||||
m_server_port = 2759;
|
||||
|
||||
m_score_increase.clear();
|
||||
m_leader_intervals.clear();
|
||||
@ -398,6 +407,19 @@ void STKConfig::getAllData(const XMLNode * root)
|
||||
tc->get("quality", &m_tc_quality);
|
||||
}
|
||||
|
||||
if (const XMLNode *tc = root->getNode("network"))
|
||||
{
|
||||
unsigned server_discovery_port = 0;
|
||||
unsigned client_port = 0;
|
||||
unsigned server_port = 0;
|
||||
tc->get("server-discovery-port", &server_discovery_port);
|
||||
tc->get("client-port", &client_port);
|
||||
tc->get("server-port", &server_port);
|
||||
m_server_discovery_port = (uint16_t)server_discovery_port;
|
||||
m_client_port = (uint16_t)client_port;
|
||||
m_server_port = (uint16_t)server_port;
|
||||
}
|
||||
|
||||
// Get the default KartProperties
|
||||
// ------------------------------
|
||||
const XMLNode *node = root -> getNode("general-kart-defaults");
|
||||
|
@ -171,6 +171,11 @@ public:
|
||||
|
||||
unsigned m_tc_quality;
|
||||
|
||||
/** Client and server port use random ports if enabled in user config. */
|
||||
uint16_t m_server_discovery_port;
|
||||
uint16_t m_client_port;
|
||||
uint16_t m_server_port;
|
||||
|
||||
/** Lists of TTF files used in STK. */
|
||||
std::vector<std::string> m_normal_ttf;
|
||||
std::vector<std::string> m_digit_ttf;
|
||||
|
@ -739,9 +739,15 @@ namespace UserConfigParams
|
||||
std::make_pair(1100, 4)
|
||||
));
|
||||
|
||||
// ---- Network
|
||||
PARAM_PREFIX GroupUserConfigParam m_network_group
|
||||
PARAM_DEFAULT(GroupUserConfigParam("Network", "Network Settings"));
|
||||
PARAM_PREFIX BoolUserConfigParam m_log_packets
|
||||
PARAM_DEFAULT( BoolUserConfigParam(false, "log-network-packets",
|
||||
"If all network packets should be logged") );
|
||||
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, "randrom-ports",
|
||||
&m_network_group, "Use random ports for client and server connection"));
|
||||
|
||||
// ---- Graphic Quality
|
||||
PARAM_PREFIX GroupUserConfigParam m_graphics_quality
|
||||
|
@ -17,6 +17,8 @@
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "network/network_config.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "online/xml_request.hpp"
|
||||
|
||||
NetworkConfig *NetworkConfig::m_network_config = NULL;
|
||||
@ -46,9 +48,17 @@ NetworkConfig::NetworkConfig()
|
||||
m_cur_user_token = "";
|
||||
m_server_name = "";
|
||||
m_password = "";
|
||||
m_server_discovery_port = 2757;
|
||||
m_server_port = 2758;
|
||||
m_client_port = 2759;
|
||||
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;
|
||||
}
|
||||
} // NetworkConfig
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user