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

@ -825,6 +825,10 @@ namespace UserConfigParams
PARAM_PREFIX IntUserConfigParam m_timer_sync_difference_tolerance PARAM_PREFIX IntUserConfigParam m_timer_sync_difference_tolerance
PARAM_DEFAULT(IntUserConfigParam(5, "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.")); &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 // ---- Gamemode setup
PARAM_PREFIX UIntToUIntUserConfigParam m_num_karts_per_gamemode PARAM_PREFIX UIntToUIntUserConfigParam m_num_karts_per_gamemode

@ -200,6 +200,12 @@ bool NetworkConfig::roundValuesNow() const
void NetworkConfig::detectIPType() void NetworkConfig::detectIPType()
{ {
m_nat64_prefix_data.fill(-1); 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 #ifdef ENABLE_IPV6
ENetAddress eaddr; ENetAddress eaddr;
eaddr.host = STKHost::HOST_ANY; eaddr.host = STKHost::HOST_ANY;

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