SuperTuxKart
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. More...
 
void setClientPort (uint16_t port)
 Sets the port on which a client listens for server connection. More...
 
uint16_t getClientPort () const
 Returns the port on which a client listens for server connections. More...
 
void setIsPublicServer ()
 Sets that this server can be contacted directly. More...
 
bool isPublicServer () const
 Returns if connections directly to the server are to be accepted. More...
 
bool isNetworking () const
 Return if a network setting is happening. More...
 
bool isLAN () const
 Return true if it's a networked game with a LAN server. More...
 
bool isWAN () const
 Return true if it's a networked game but with a WAN server. More...
 
void setIsLAN ()
 Set that this is a LAN networked game. More...
 
void setIsWAN ()
 Set that this is a WAN networked game. More...
 
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. More...
 
bool isClient () const
 Returns if this instance is a client. More...
 
void setAutoConnect (bool b)
 Sets if a client should immediately connect to the first server. More...
 
bool isAutoConnect () const
 Returns if an immediate connection to the first server was requested. More...
 
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. More...
 
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. More...
 
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. More...
 
static NetworkConfigget ()
 Singleton get, which creates this object if necessary. More...
 
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. More...
 
bool m_is_public_server
 If set it allows clients to connect directly to this server without using the stk server in between. More...
 
std::atomic_bool m_is_server
 True if this host is a server, false otherwise. More...
 
bool m_auto_connect
 True if a client should connect to the first server it finds and immediately start a race. More...
 
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. More...
 
bool m_tux_hitbox_addon
 When live join is disabled addon kart will use their real hitbox.
 
unsigned m_num_fixed_ai
 No. More...
 
uint16_t m_client_port
 The LAN port on which a client is waiting for a server connection. More...
 
uint32_t m_cur_user_id
 Used by wan server. More...
 
std::string m_cur_user_token
 
std::string m_server_id_file
 Used by client server to determine if the child server is created. More...
 
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. More...
 
std::set< std::string > m_server_capabilities
 List of server capabilities set when joining it, to determine features available in same version. More...
 
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. More...
 
std::array< uint32_t, 8 > m_nat64_prefix_data
 

Static Private Attributes

static NetworkConfigm_network_config [PT_COUNT]
 The singleton instance. More...
 
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

◆ clearActivePlayersForClient()

void NetworkConfig::clearActivePlayersForClient ( ) const

Called before (re)starting network race, must be used before adding split screen players.

◆ get()

static NetworkConfig* NetworkConfig::get ( )
inlinestatic

Singleton get, which creates this object if necessary.

◆ getClientPort()

uint16_t NetworkConfig::getClientPort ( ) const
inline

Returns the port on which a client listens for server connections.

◆ initSystemIP()

void NetworkConfig::initSystemIP ( )
static

Initialize detection of system IPv4 or IPv6 support.

◆ isAutoConnect()

bool NetworkConfig::isAutoConnect ( ) const
inline

Returns if an immediate connection to the first server was requested.

◆ isClient()

bool NetworkConfig::isClient ( ) const
inline

Returns if this instance is a client.

◆ isLAN()

bool NetworkConfig::isLAN ( ) const
inline

Return true if it's a networked game with a LAN server.

◆ 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.

◆ isPublicServer()

bool NetworkConfig::isPublicServer ( ) const
inline

Returns if connections directly to the server are to be accepted.

◆ isServer()

bool NetworkConfig::isServer ( ) const
inline

Returns if this instance is a server.

◆ isWAN()

bool NetworkConfig::isWAN ( ) const
inline

Return true if it's a networked game but with a WAN server.

◆ roundValuesNow()

bool NetworkConfig::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.

◆ setAutoConnect()

void NetworkConfig::setAutoConnect ( bool  b)
inline

Sets if a client should immediately connect to the first server.

◆ setClientPort()

void NetworkConfig::setClientPort ( uint16_t  port)
inline

Sets the port on which a client listens for server connection.

◆ setIsLAN()

void NetworkConfig::setIsLAN ( )
inline

Set that this is a LAN networked game.

◆ setIsPublicServer()

void NetworkConfig::setIsPublicServer ( )
inline

Sets that this server can be contacted directly.

◆ setIsServer()

void NetworkConfig::setIsServer ( bool  b)
inline

Sets if this instance is a server or client.

◆ setIsWAN()

void NetworkConfig::setIsWAN ( )
inline

Set that this is a WAN networked game.

Member Data Documentation

◆ m_auto_connect

bool NetworkConfig::m_auto_connect
private

True if a client should connect to the first server it finds and immediately start a race.

◆ m_client_port

uint16_t NetworkConfig::m_client_port
private

The LAN port on which a client is waiting for a server connection.

◆ m_cur_user_id

uint32_t NetworkConfig::m_cur_user_id
private

Used by wan server.

◆ 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_is_server

std::atomic_bool NetworkConfig::m_is_server
private

True if this host is a server, false otherwise.

◆ 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_network_config

NetworkConfig * NetworkConfig::m_network_config
staticprivate

The singleton instance.

◆ m_network_type

std::atomic<NetworkType> NetworkConfig::m_network_type
private

Keeps the type of network connection: none (yet), LAN or WAN.

◆ 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.

◆ m_server_capabilities

std::set<std::string> NetworkConfig::m_server_capabilities
private

List of server capabilities set when joining it, to determine features available in same version.

◆ m_server_id_file

std::string NetworkConfig::m_server_id_file
private

Used by client server to determine if the child server is created.

◆ m_state_frequency

int NetworkConfig::m_state_frequency
private

Set by client or server which is required to be the same.


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