SuperTuxKart
|
This class is the interface between STK and the online code, particularly STKHost. More...
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 NetworkConfig * | get () |
Singleton get, which creates this object if necessary. More... | |
static NetworkConfig * | getByType (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 NetworkConfig * | m_network_config [PT_COUNT] |
The singleton instance. More... | |
static bool | m_system_ipv4 = false |
static bool | m_system_ipv6 = false |
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.
void NetworkConfig::clearActivePlayersForClient | ( | ) | const |
Called before (re)starting network race, must be used before adding split screen players.
|
inlinestatic |
Singleton get, which creates this object if necessary.
|
inline |
Returns the port on which a client listens for server connections.
|
static |
Initialize detection of system IPv4 or IPv6 support.
|
inline |
Returns if an immediate connection to the first server was requested.
|
inline |
Returns if this instance is a client.
|
inline |
Return true if it's a networked game with a LAN server.
|
inline |
Return if a network setting is happening.
A network setting is active if a host (server or client) exists.
|
inline |
Returns if connections directly to the server are to be accepted.
|
inline |
Returns if this instance is a server.
|
inline |
Return true if it's a networked game but with a WAN server.
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.
|
inline |
Sets if a client should immediately connect to the first server.
|
inline |
Sets the port on which a client listens for server connection.
|
inline |
Set that this is a LAN networked game.
|
inline |
Sets that this server can be contacted directly.
|
inline |
Sets if this instance is a server or client.
|
inline |
Set that this is a WAN networked game.
|
private |
True if a client should connect to the first server it finds and immediately start a race.
|
private |
The LAN port on which a client is waiting for a server connection.
|
private |
Used by wan 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.
|
private |
True if this host is a server, false otherwise.
|
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.
|
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)
|
staticprivate |
The singleton instance.
|
private |
Keeps the type of network connection: none (yet), LAN or WAN.
|
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.
|
private |
List of server capabilities set when joining it, to determine features available in same version.
|
private |
Used by client server to determine if the child server is created.
|
private |
Set by client or server which is required to be the same.