Allow pre-set IP type in config.xml

This commit is contained in:
Benau 2020-01-31 13:20:11 +08:00
parent ab315fab4e
commit 1e9dab821c
3 changed files with 11 additions and 1 deletions

View File

@ -825,6 +825,10 @@ namespace UserConfigParams
PARAM_PREFIX IntUserConfigParam m_timer_sync_difference_tolerance
PARAM_DEFAULT(IntUserConfigParam(5, "timer-sync-difference-tolerance",
&m_network_group, "Max time difference tolerance (in ms) to synchronize timer with server."));
PARAM_PREFIX IntUserConfigParam m_default_ip_type
PARAM_DEFAULT(IntUserConfigParam(0, "default-ip-type",
&m_network_group, "Default IP type of this machine, "
"0 detect every time, 1 IPv4, 2 IPv6, 3 IPv6 NAT64, 4 Dual stack."));
// ---- Gamemode setup
PARAM_PREFIX UIntToUIntUserConfigParam m_num_karts_per_gamemode

View File

@ -200,6 +200,12 @@ bool NetworkConfig::roundValuesNow() const
void NetworkConfig::detectIPType()
{
m_nat64_prefix_data.fill(-1);
if (UserConfigParams::m_default_ip_type != IP_NONE)
{
int ip_type = UserConfigParams::m_default_ip_type;
m_ip_type.store((IPType)ip_type);
return;
}
#ifdef ENABLE_IPV6
ENetAddress eaddr;
eaddr.host = STKHost::HOST_ANY;

View File

@ -49,7 +49,7 @@ class PlayerProfile;
class NetworkConfig : public NoCopy
{
public:
enum IPType : uint8_t
enum IPType : int
{
IP_NONE, IP_V4, IP_V6, IP_V6_NAT64, IP_DUAL_STACK
};