SuperTuxKart
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
NetworkConfig Class Reference

This class is the interface between STK and the online code, particularly STKHost. More...

Inheritance diagram for NetworkConfig:
Inheritance graph
[legend]

Public Types

enum  IPType : int {
  IP_NONE , IP_V4 , IP_V6 , IP_V6_NAT64 ,
  IP_DUAL_STACK
}
 

Public Member Functions

void setIsServer (bool b)
 Sets if this instance is a server or client.
 
void setClientPort (uint16_t port)
 Sets the port on which a client listens for server connection.
 
uint16_t getClientPort () const
 Returns the port on which a client listens for server connections.
 
void setIsPublicServer ()
 Sets that this server can be contacted directly.
 
bool isPublicServer () const
 Returns if connections directly to the server are to be accepted.
 
bool isNetworking () const
 Return if a network setting is happening.
 
bool isLAN () const
 Return true if it's a networked game with a LAN server.
 
bool isWAN () const
 Return true if it's a networked game but with a WAN server.
 
void setIsLAN ()
 Set that this is a LAN networked game.
 
void setIsWAN ()
 Set that this is a WAN networked game.
 
void unsetNetworking ()
 Set that this is not a networked game.
 
std::vector< std::tuple< InputDevice *, PlayerProfile *, HandicapLevel > > & getNetworkPlayers ()
 
bool isAddingNetworkPlayers () const
 
void doneAddingNetworkPlayers ()
 
bool addNetworkPlayer (InputDevice *device, PlayerProfile *profile, HandicapLevel h)
 
bool playerExists (PlayerProfile *profile) const
 
void cleanNetworkPlayers ()
 
bool isServer () const
 Returns if this instance is a server.
 
bool isClient () const
 Returns if this instance is a client.
 
void setAutoConnect (bool b)
 Sets if a client should immediately connect to the first server.
 
bool isAutoConnect () const
 Returns if an immediate connection to the first server was requested.
 
void setNetworkAIInstance (bool b)
 
bool isNetworkAIInstance () const
 
void setCurrentUserId (uint32_t id)
 
void setCurrentUserToken (const std::string &t)
 
uint32_t getCurrentUserId () const
 
const std::string & getCurrentUserToken () const
 
void setUserDetails (std::shared_ptr< Online::XMLRequest > r, const std::string &name)
 
void setServerDetails (std::shared_ptr< Online::XMLRequest > r, const std::string &name)
 
void setServerIdFile (const std::string &id)
 
const std::string & getServerIdFile () const
 
std::vector< GUIEngine::Screen * > getResetScreens (bool lobby=false) const
 
void setJoinedServerVersion (uint32_t v)
 
uint32_t getJoinedServerVersion () const
 
void clearActivePlayersForClient () const
 Called before (re)starting network race, must be used before adding split screen players.
 
void setStateFrequency (int frequency)
 
int getStateFrequency () const
 
bool roundValuesNow () const
 True when client needs to round the bodies phyiscal info for current ticks, server doesn't as it will be done implictly in save state.
 
void setServerCapabilities (std::set< std::string > &caps)
 
void clearServerCapabilities ()
 
const std::set< std::string > & getServerCapabilities () const
 
void getIPDetectionResult (uint64_t timeout)
 Use stun servers to detect current ip type.
 
IPType getIPType () const
 
void setIPType (IPType ip_type)
 
const std::string & getNAT64Prefix () const
 
const std::array< uint32_t, 8 > & getNAT64PrefixData () const
 
void initClientPort ()
 Separated from constructor because this needs to be run after user config is load.
 
void setNumFixedAI (unsigned num)
 
unsigned getNumFixedAI () const
 
void setTuxHitboxAddon (bool val)
 
bool useTuxHitboxAddon () const
 

Static Public Member Functions

static void initSystemIP ()
 Initialize detection of system IPv4 or IPv6 support.
 
static NetworkConfigget ()
 Singleton get, which creates this object if necessary.
 
static NetworkConfiggetByType (ProcessType type)
 
static void clearDetectIPThread (bool quit_stk)
 
static void queueIPDetection ()
 Use stun servers to detect current ip type.
 
static void destroy ()
 
static void clear ()
 
static const std::vector< std::pair< std::string, int > > & getStunList (bool ipv4)
 

Private Types

enum  NetworkType : int { NETWORK_NONE , NETWORK_WAN , NETWORK_LAN }
 

Private Member Functions

 NetworkConfig ()
 Constructor.
 

Static Private Member Functions

static void fillStunList (std::vector< std::pair< std::string, int > > *l, const std::string &dns)
 

Private Attributes

std::atomic< IPType > m_ip_type
 
std::atomic< NetworkType > m_network_type
 Keeps the type of network connection: none (yet), LAN or WAN.
 
bool m_is_public_server
 If set it allows clients to connect directly to this server without using the stk server in between.
 
std::atomic_bool m_is_server
 True if this host is a server, false otherwise.
 
bool m_auto_connect
 True if a client should connect to the first server it finds and immediately start a race.
 
bool m_done_adding_network_players
 
bool m_network_ai_instance
 True if this STK instance is an AI instance which is used for server AI.
 
bool m_tux_hitbox_addon
 When live join is disabled addon kart will use their real hitbox.
 
unsigned m_num_fixed_ai
 No.
 
uint16_t m_client_port
 The LAN port on which a client is waiting for a server connection.
 
uint32_t m_cur_user_id
 Used by wan server.
 
std::string m_cur_user_token
 
std::string m_server_id_file
 Used by client server to determine if the child server is created.
 
std::vector< std::tuple< InputDevice *, PlayerProfile *, HandicapLevel > > m_network_players
 
uint32_t m_joined_server_version
 
int m_state_frequency
 Set by client or server which is required to be the same.
 
std::set< std::string > m_server_capabilities
 List of server capabilities set when joining it, to determine features available in same version.
 
std::string m_nat64_prefix
 For IPv6 only network we try to detect the NAT64 prefix so we can use it to connect to ipv4 only servers.
 
std::array< uint32_t, 8 > m_nat64_prefix_data
 

Static Private Attributes

static NetworkConfigm_network_config [PT_COUNT]
 The singleton instance.
 
static bool m_system_ipv4 = false
 
static bool m_system_ipv6 = false
 

Detailed Description

This class is the interface between STK and the online code, particularly STKHost.

It stores all online related properties (e.g. if this is a server or a host, name of the server, maximum number of players, ip address, ...). They can either be set from the GUI code, or via the command line (for a stand-alone server). When STKHost is created, it takes all necessary information from this instance.

Member Function Documentation

◆ isNetworking()

bool NetworkConfig::isNetworking ( ) const
inline

Return if a network setting is happening.

A network setting is active if a host (server or client) exists.

Member Data Documentation

◆ m_is_public_server

bool NetworkConfig::m_is_public_server
private

If set it allows clients to connect directly to this server without using the stk server in between.

It requires obviously that this server is accessible (through the firewall) from the outside.

◆ m_nat64_prefix

std::string NetworkConfig::m_nat64_prefix
private

For IPv6 only network we try to detect the NAT64 prefix so we can use it to connect to ipv4 only servers.

STK assumes that for all ipv4 addresses they use the same prefix for each initIPTest.

◆ m_network_ai_instance

bool NetworkConfig::m_network_ai_instance
private

True if this STK instance is an AI instance which is used for server AI.

(usually used together with ai-handling in server config)

◆ m_num_fixed_ai

unsigned NetworkConfig::m_num_fixed_ai
private

No.

of fixed AI in all-in-one graphical client server, the player connecting with 127.* or ::1/128 will be in charged of controlling the AI.


The documentation for this class was generated from the following files: