SuperTuxKart
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
ServerLobby Class Reference
Inheritance diagram for ServerLobby:
Inheritance graph
[legend]

Classes

struct  KeyData
 

Public Types

enum  ServerState : unsigned int {
  SET_PUBLIC_ADDRESS , REGISTER_SELF_ADDRESS , WAITING_FOR_START_GAME , SELECTING ,
  LOAD_WORLD , WAIT_FOR_WORLD_LOADED , WAIT_FOR_RACE_STARTED , RACING ,
  WAIT_FOR_RACE_STOPPED , RESULT_DISPLAY , ERROR_LEAVE , EXITING
}
 
- Public Types inherited from LobbyProtocol
enum  : uint8_t {
  LE_CONNECTION_REQUESTED = 1 , LE_CONNECTION_REFUSED , LE_CONNECTION_ACCEPTED , LE_SERVER_INFO ,
  LE_REQUEST_BEGIN , LE_UPDATE_PLAYER_LIST , LE_KART_SELECTION , LE_PLAYER_DISCONNECTED ,
  LE_CLIENT_LOADED_WORLD , LE_LOAD_WORLD , LE_START_RACE , LE_START_SELECTION ,
  LE_RACE_FINISHED , LE_RACE_FINISHED_ACK , LE_BACK_LOBBY , LE_VOTE ,
  LE_CHAT , LE_SERVER_OWNERSHIP , LE_KICK_HOST , LE_CHANGE_TEAM ,
  LE_BAD_TEAM , LE_BAD_CONNECTION , LE_CONFIG_SERVER , LE_CHANGE_HANDICAP ,
  LE_LIVE_JOIN , LE_LIVE_JOIN_ACK , LE_KART_INFO , LE_CLIENT_BACK_LOBBY ,
  LE_REPORT_PLAYER , LE_ASSETS_UPDATE , LE_COMMAND
}
 Lists all lobby events (LE).
 
enum  RejectReason : uint8_t {
  RR_BUSY = 0 , RR_BANNED = 1 , RR_INCORRECT_PASSWORD = 2 , RR_INCOMPATIBLE_DATA = 3 ,
  RR_TOO_MANY_PLAYERS = 4 , RR_INVALID_PLAYER = 5
}
 
enum  BackLobbyReason : uint8_t {
  BLR_NONE = 0 , BLR_NO_GAME_FOR_LIVE_JOIN = 1 , BLR_NO_PLACE_FOR_LIVE_JOIN = 2 , BLR_ONE_PLAYER_IN_RANKED_MATCH = 3 ,
  BLR_SERVER_ONWER_QUITED_THE_GAME = 4 , BLR_SPECTATING_NEXT_GAME = 5
}
 

Public Member Functions

 ServerLobby ()
 This is the central game setup protocol running in the server.
 
virtual ~ServerLobby ()
 Destructor.
 
virtual bool notifyEventAsynchronous (Event *event) OVERRIDE
 Notify a protocol matching the Event type of that event.
 
virtual bool notifyEvent (Event *event) OVERRIDE
 Notify a protocol matching the Event type of that event.
 
virtual void setup () OVERRIDE
 A previous GameSetup is deleted and a new one is created.
 
virtual void update (int ticks) OVERRIDE
 Simple finite state machine.
 
virtual void asynchronousUpdate () OVERRIDE
 Find out the public IP server or poll STK server asynchronously.
 
void startSelection (const Event *event=NULL)
 Instructs all clients to start the kart selection.
 
void checkIncomingConnectionRequests ()
 Query the STK server for connection requests.
 
void finishedLoadingWorld () OVERRIDE
 Called from the RaceManager of the server when the world is loaded.
 
ServerState getCurrentState () const
 
void updateBanList ()
 
bool waitingForPlayers () const
 
virtual bool allPlayersReady () const OVERRIDE
 
virtual bool isRacing () const OVERRIDE
 
bool allowJoinedPlayersWaiting () const
 
void setSaveServerConfig (bool val)
 
float getStartupBoostOrPenaltyForKart (uint32_t ping, unsigned kart_id)
 
int getDifficulty () const
 
int getGameMode () const
 
int getLobbyPlayers () const
 
void saveInitialItems (std::shared_ptr< NetworkItemManager > nim)
 
void saveIPBanTable (const SocketAddress &addr)
 
void listBanTable ()
 
void initServerStatsTable ()
 
bool isAIProfile (const std::shared_ptr< NetworkPlayerProfile > &npp) const
 
uint32_t getServerIdOnline () const
 
void setClientServerHostId (uint32_t id)
 
- Public Member Functions inherited from LobbyProtocol
virtual void setup ()=0
 A previous GameSetup is deleted and a new one is created.
 
virtual void update (int ticks)=0
 Called by the protocol listener, synchronously with the main loop.
 
virtual void finishedLoadingWorld ()=0
 
virtual void loadWorld ()
 Starts the sychronization protocol and the RaceEventManager.
 
virtual bool allPlayersReady () const =0
 
virtual bool isRacing () const =0
 
void startVotingPeriod (float max_time)
 Starts the voting period time with the specified maximum time.
 
float getRemainingVotingTime ()
 Returns the remaining voting time in seconds.
 
bool isVotingOver ()
 Returns if the voting period is over.
 
float getMaxVotingTime ()
 Returns the maximum floating time in seconds.
 
GameSetupgetGameSetup () const
 Returns the game setup data structure.
 
int getNumberOfVotes () const
 Returns the number of votes received so far.
 
void addVote (uint32_t host_id, const PeerVote &vote)
 Adds a vote.
 
const PeerVotegetVote (uint32_t host_id) const
 Returns the voting data for one host.
 
void resetVotingTime ()
 
const std::map< uint32_t, PeerVote > & getAllVotes () const
 Returns all voting data.
 
std::pair< uint32_t, uint32_t > getGameStartedProgress () const
 
void setGameStartedProgress (const std::pair< uint32_t, uint32_t > &p)
 
void resetGameStartedProgress ()
 
bool hasLiveJoiningRecently () const
 
void storePlayingTrack (const std::string &track_ident)
 
std::string getPlayingTrackIdent () const
 
TrackgetPlayingTrack () const
 
- Public Member Functions inherited from Protocol
 Protocol (ProtocolType type)
 Constructor Sets the basic protocol parameters, as the callback object and the protocol type.
 
virtual ~Protocol ()
 Destructor.
 
virtual void setup ()=0
 Called when the protocol is going to start.
 
virtual void update (int ticks)=0
 Called by the protocol listener, synchronously with the main loop.
 
virtual void asynchronousUpdate ()=0
 Called by the protocol listener as often as possible.
 
NetworkStringgetNetworkString (size_t capacity=16) const
 functions to check incoming data easily
 
bool checkDataSize (Event *event, unsigned int minimum_size)
 Checks if the message has at least the specified size, and if not prints a warning message including the message content.
 
void sendMessageToPeers (NetworkString *message, bool reliable=true)
 Sends a message to all validated peers in game, encrypt the message if needed.
 
void sendMessageToPeersInServer (NetworkString *message, bool reliable=true)
 Sends a message to all validated peers in server, encrypt the message if needed.
 
void sendToServer (NetworkString *message, bool reliable=true)
 Sends a message from a client to the server.
 
virtual void requestStart ()
 Starts a request in the protocol manager to start this protocol.
 
virtual void requestTerminate ()
 Submits a request to the ProtocolManager to terminate this protocol.
 
virtual bool notifyEvent (Event *event)
 Notify a protocol matching the Event type of that event.
 
virtual bool notifyEventAsynchronous (Event *event)
 Notify a protocol matching the Event type of that event.
 
ProtocolType getProtocolType () const
 Method to get a protocol's type.
 
void setHandleConnections (bool b)
 Sets if this protocol should receive connection events.
 
void setHandleDisconnections (bool b)
 Sets if this protocol should receive disconnection events.
 
virtual bool handleConnects () const
 Return true if this protocol should be informed about connects.
 
virtual bool handleDisconnects () const
 Return true if this protocol should be informed about disconnects.
 

Static Public Attributes

static int m_fixed_laps = -1
 

Private Types

enum  ResetState : unsigned int { RS_NONE , RS_WAITING , RS_ASYNC_RESET }
 

Private Member Functions

void initDatabase ()
 
void destroyDatabase ()
 
void clientDisconnected (Event *event)
 Called when a client disconnects.
 
void connectionRequested (Event *event)
 
void kartSelectionRequested (Event *event)
 Called when a player asks to select karts.
 
void handlePlayerVote (Event *event)
 Called when a player votes for track(s), it will auto correct client data if it sends some invalid data.
 
void playerFinishedResult (Event *event)
 Called when a client clicks on 'ok' on the race result screen.
 
void registerServer (bool first_time)
 Register this server (i.e.
 
void finishedLoadingWorldClient (Event *event)
 Called when a client notifies the server that it has loaded the world.
 
void finishedLoadingLiveJoinClient (Event *event)
 Finally put the kart in the world and inform client the current world status, (including current confirmed item state, kart scores...)
 
void kickHost (Event *event)
 
void changeTeam (Event *event)
 
void handleChat (Event *event)
 
void unregisterServer (bool now, std::weak_ptr< ServerLobby > sl=std::weak_ptr< ServerLobby >())
 Unregister this server (i.e.
 
void updatePlayerList (bool update_when_reset_server=false)
 Called when any players change their setting (team for example), or connection / disconnection, it will use the game_started parameter to determine if this should be send to all peers in server or just in game.
 
void updateServerOwner ()
 
void handleServerConfiguration (Event *event)
 Called when the server owner request to change game mode or difficulty.
 
void updateTracksForMode ()
 Called whenever server is reset or game mode is changed.
 
bool checkPeersReady (bool ignore_ai_peer) const
 
void resetPeersReady ()
 
void addPeerConnection (const std::string &addr_str)
 
void removeExpiredPeerConnection ()
 
void replaceKeys (std::map< uint32_t, KeyData > &new_keys)
 
void handlePendingConnection ()
 
void handleUnencryptedConnection (std::shared_ptr< STKPeer > peer, BareNetworkString &data, uint32_t online_id, const irr::core::stringw &online_name, bool is_pending_connection, std::string country_code="")
 
bool decryptConnectionRequest (std::shared_ptr< STKPeer > peer, BareNetworkString &data, const std::string &key, const std::string &iv, uint32_t online_id, const irr::core::stringw &online_name, const std::string &country_code)
 
bool handleAllVotes (PeerVote *winner, uint32_t *winner_peer_id)
 Select the track to be used based on all votes being received.
 
void getRankingForPlayer (std::shared_ptr< NetworkPlayerProfile > p)
 
void submitRankingsToAddons ()
 
void computeNewRankings ()
 Compute the new player's rankings used in ranked servers.
 
void clearDisconnectedRankedPlayer ()
 
double getModeFactor ()
 Returns the mode race importance factor, used to make ranking move slower in more random modes.
 
double getModeSpread ()
 Returns the mode spread factor, used so that a similar difference in skill will result in a similar ranking difference in more random modes.
 
double getTimeSpread (double time)
 Returns the time spread factor.
 
double getUncertaintySpread (uint32_t online_id)
 
double scalingValueForTime (double time)
 Compute the scaling value of a given time This is linear to race duration, getTimeSpread takes care of expecting a more random result in shorter races.
 
double computeH2HResult (double player1_time, double player2_time)
 Computes the score of a head-to-head minimatch.
 
double computeDataAccuracy (double player1_rd, double player2_rd, double player1_scores, double player2_scores, int player_count, bool handicap_used)
 Computes a relative factor indicating how much informative value the new race result gives us.
 
void checkRaceFinished ()
 Checks if the race is finished, and if so informs the clients and switches to state RESULT_DISPLAY, during which the race result gui is shown and all clients can click on 'continue'.
 
void getHitCaptureLimit ()
 
void configPeersStartTime ()
 This function is called when all clients have loaded the world and are therefore ready to start the race.
 
void resetServer ()
 
void addWaitingPlayersToGame ()
 
void changeHandicap (Event *event)
 Called when a player want to change his handicap.
 
void handlePlayerDisconnection () const
 Update and see if any player disconnects, if so eliminate the kart in world, so this function must be called in main thread.
 
void addLiveJoinPlaceholder (std::vector< std::shared_ptr< NetworkPlayerProfile > > &players) const
 Add reserved players for live join later if required.
 
NetworkStringgetLoadWorldMessage (std::vector< std::shared_ptr< NetworkPlayerProfile > > &players, bool live_join) const
 
void encodePlayers (BareNetworkString *bns, std::vector< std::shared_ptr< NetworkPlayerProfile > > &players) const
 
std::vector< std::shared_ptr< NetworkPlayerProfile > > getLivePlayers () const
 Get a list of current ingame players for live join or spectate.
 
void setPlayerKarts (const NetworkString &ns, STKPeer *peer) const
 
bool handleAssets (const NetworkString &ns, STKPeer *peer)
 
void handleServerCommand (Event *event, std::shared_ptr< STKPeer > peer)
 
void liveJoinRequest (Event *event)
 This message is like kartSelectionRequested, but it will send the peer load world message if he can join the current started game.
 
void rejectLiveJoin (STKPeer *peer, BackLobbyReason blr)
 STKPeer peer will be reset back to the lobby with reason BackLobbyReason blr
 
bool canLiveJoinNow () const
 Returns true if server can be live joined or spectating.
 
bool worldIsActive () const
 Returns true if world is active for clients to live join, spectate or going back to lobby live.
 
int getReservedId (std::shared_ptr< NetworkPlayerProfile > &p, unsigned local_id) const
 Decide where to put the live join player depends on his team and game mode.
 
void handleKartInfo (Event *event)
 Tell the client RemoteKartInfo of a player when some player joining live.
 
void clientInGameWantsToBackLobby (Event *event)
 Client if currently in-game (including spectator) wants to go back to lobby.
 
void clientSelectingAssetsWantsToBackLobby (Event *event)
 Client if currently select assets wants to go back to lobby.
 
std::set< std::shared_ptr< STKPeer > > getSpectatorsByLimit ()
 
void kickPlayerWithReason (STKPeer *peer, const char *reason) const
 
void testBannedForIP (STKPeer *peer) const
 
void testBannedForIPv6 (STKPeer *peer) const
 
void testBannedForOnlineId (STKPeer *peer, uint32_t online_id) const
 
void writeDisconnectInfoTable (STKPeer *peer)
 
void writePlayerReport (Event *event)
 
bool supportsAI ()
 
void updateAddons ()
 

Private Attributes

bool m_player_reports_table_exists
 
std::atomic< ServerState > m_state
 
std::atomic< ResetState > m_rs_state
 
std::weak_ptr< STKPeerm_server_owner
 Hold the next connected peer for server owner if current one expired (disconnected).
 
std::weak_ptr< STKPeerm_ai_peer
 AI peer which holds the list of reserved AI for dedicated server.
 
std::vector< std::shared_ptr< NetworkPlayerProfile > > m_ai_profiles
 AI profiles for all-in-one graphical client server, this will be a fixed count thorough the live time of server, which its value is configured in NetworkConfig.
 
std::atomic< uint32_t > m_server_owner_id
 
std::pair< std::set< std::string >, std::set< std::string > > m_official_kts
 Official karts and tracks available in server.
 
std::pair< std::set< std::string >, std::set< std::string > > m_addon_kts
 Addon karts and tracks available in server.
 
std::set< std::string > m_addon_arenas
 Addon arenas available in server.
 
std::set< std::string > m_addon_soccers
 Addon soccers available in server.
 
std::pair< std::set< std::string >, std::set< std::string > > m_available_kts
 Available karts and tracks for all clients, this will be initialized with data in server first.
 
std::atomic_bool m_server_has_loaded_world
 Keeps track of the server state.
 
bool m_registered_for_once_only
 
bool m_save_server_config
 
std::map< std::weak_ptr< STKPeer >, bool, std::owner_less< std::weak_ptr< STKPeer > > > m_peers_ready
 Counts how many peers have finished loading the world.
 
std::map< std::weak_ptr< STKPeer >, std::set< irr::core::stringw >, std::owner_less< std::weak_ptr< STKPeer > > > m_peers_muted_players
 
std::weak_ptr< Online::Requestm_server_registering
 
std::atomic< int64_t > m_timeout
 Timeout counter for various state.
 
std::mutex m_keys_mutex
 
std::map< uint32_t, KeyDatam_keys
 
std::map< std::weak_ptr< STKPeer >, std::pair< uint32_t, BareNetworkString >, std::owner_less< std::weak_ptr< STKPeer > > > m_pending_connection
 
std::map< std::string, uint64_t > m_pending_peer_connection
 
const double BASE_RANKING_POINTS = 4000.0
 
const double BASE_RATING_DEVIATION = 1000.0
 
const double MIN_RATING_DEVIATION = 100.0
 
const double BASE_RD_PER_DISCONNECT = 15.0
 
const double VAR_RD_PER_DISCONNECT = 3.0
 
const double MAX_SCALING_TIME = 360.0
 
const double BASE_POINTS_PER_SECOND = 0.18
 
const double HANDICAP_OFFSET = 2000.0
 
std::map< uint32_t, std::weak_ptr< NetworkPlayerProfile > > m_ranked_players
 Online id to profile map, handling disconnection in ranked server.
 
std::map< uint32_t, double > m_raw_scores
 Multi-session rating for each current player.
 
std::map< uint32_t, double > m_rating_deviations
 The rating uncertainty for each current player.
 
std::map< uint32_t, double > m_scores
 A single number compounding "raw score" and RD, for rating display to players and rankings.
 
std::map< uint32_t, double > m_max_scores
 The maximum rating obtained for each current player.
 
std::map< uint32_t, uint64_t > m_num_ranked_disconnects
 Number of disconnects in the previous 64 ranked races for each current players.
 
std::map< uint32_t, unsigned > m_num_ranked_races
 Number of ranked races done for each current players.
 
NetworkStringm_result_ns
 
BareNetworkStringm_items_complete_state
 
std::atomic< uint32_t > m_server_id_online
 
std::atomic< uint32_t > m_client_server_host_id
 
std::atomic< int > m_difficulty
 
std::atomic< int > m_game_mode
 
std::atomic< int > m_lobby_players
 
std::atomic< int > m_current_ai_count
 
std::atomic< uint64_t > m_last_success_poll_time
 
uint64_t m_last_unsuccess_poll_time
 
uint64_t m_server_started_at
 
uint64_t m_server_delay
 
PeerVotem_default_vote
 
int m_battle_hit_capture_limit
 
float m_battle_time_limit
 
unsigned m_item_seed
 
uint32_t m_winner_peer_id
 
uint64_t m_client_starting_time
 
unsigned m_ai_count
 

Additional Inherited Members

- Static Public Member Functions inherited from LobbyProtocol
template<typename Singleton , typename... Types>
static std::shared_ptr< Singletoncreate (Types ...args)
 Creates either a client or server lobby protocol as a singleton.
 
template<class T >
static std::shared_ptr< T > get ()
 Returns the singleton client or server lobby protocol.
 
template<class T >
static std::shared_ptr< T > getByType (ProcessType pt)
 Returns specific singleton client or server lobby protocol.
 
- Protected Member Functions inherited from LobbyProtocol
void configRemoteKart (const std::vector< std::shared_ptr< NetworkPlayerProfile > > &players, int local_player_size) const
 
void joinStartGameThread ()
 
void addLiveJoiningKart (int kart_id, const RemoteKartInfo &rki, int live_join_util_ticks) const
 
void exitGameState ()
 
- Protected Attributes inherited from LobbyProtocol
const ProcessType m_process_type
 
std::map< uint32_t, PeerVotem_peers_votes
 Vote from each peer.
 
std::atomic< uint64_t > m_end_voting_period
 Timer user for voting periods in both lobbies.
 
uint64_t m_max_voting_time
 The maximum voting time.
 
std::thread m_start_game_thread
 
std::atomic< uint32_t > m_estimated_remaining_time
 Estimated current started game remaining time, uint32_t max if not available.
 
std::atomic< uint32_t > m_estimated_progress
 Estimated current started game progress in 0-100%, uint32_t max if not available.
 
int m_last_live_join_util_ticks
 Save the last live join ticks, for physical objects to update current transformation in server, and reset smooth network body in client.
 
std::mutex m_current_track_mutex
 Mutex to protect m_current_track.
 
std::string m_current_track
 Store current playing track in name.
 
GameSetupm_game_setup
 Stores data about the online game to play.
 
- Protected Attributes inherited from Protocol
ProtocolType m_type
 The type of the protocol.
 
bool m_handle_connections
 True if this protocol should receive connection events.
 
bool m_handle_disconnections
 TRue if this protocol should recceiver disconnection events.
 
- Static Protected Attributes inherited from LobbyProtocol
static std::weak_ptr< LobbyProtocolm_lobby [PT_COUNT]
 

Constructor & Destructor Documentation

◆ ServerLobby()

ServerLobby::ServerLobby ( )

This is the central game setup protocol running in the server.

It is mostly a finite state machine. Note that all nodes in ellipses and light grey background are actual states; nodes in boxes and white background are functions triggered from a state or triggering potentially a state change.

dot_inline_dotgraph_2.png

It starts with detecting the public ip address and port of this host (GetPublicAddress).

Member Function Documentation

◆ allPlayersReady()

virtual bool ServerLobby::allPlayersReady ( ) const
inlinevirtual

Implements LobbyProtocol.

◆ asynchronousUpdate()

void ServerLobby::asynchronousUpdate ( )
virtual

Find out the public IP server or poll STK server asynchronously.

Implements Protocol.

◆ changeHandicap()

void ServerLobby::changeHandicap ( Event event)
private

Called when a player want to change his handicap.

Parameters
event: Event providing the information.

Format of the data :

Byte 0 1

Size | 1 | 1 |

Data | local player id | new handicap |

◆ checkIncomingConnectionRequests()

void ServerLobby::checkIncomingConnectionRequests ( )

Query the STK server for connection requests.

For each connection request start a ConnectToPeer protocol.

◆ clientDisconnected()

void ServerLobby::clientDisconnected ( Event event)
private

Called when a client disconnects.

Parameters
eventThe disconnect event.

◆ computeDataAccuracy()

double ServerLobby::computeDataAccuracy ( double  player1_rd,
double  player2_rd,
double  player1_scores,
double  player2_scores,
int  player_count,
bool  handicap_used 
)
private

Computes a relative factor indicating how much informative value the new race result gives us.

For a player with a high own rating deviation, the current rating is unreliable so any new data holds more importance. This is crucial to allow reasonably fast rating convergence of new players, provided they play accurately rated opponents.

When the opponent has a high rating deviation, the expected scores are likely off. Therefore, the information from such a result is much less valuable.

We also reduce rating changes when the player ratings are very different, even after considering the uncertainties from rating deviation. This is multi-purpose :

  • With a very high rating difference, random race events (very poor luck, disconnects) are very likely to be the cause of any upset, so the rate of legitimate upsets is unreliable. No rating method is safe.
  • Attempting to "farm" much lower rated players against which a practical 100% winrate may be reached (outside of random events) becomes very ineffective. Instead, to gain rating points, the player has incentive to play well-rated opponents.
  • The primary goal is to ensure that two players of equal rating would be about evenly matched in head-to-head. If two strong players each beat a much weaker third player, very little information is gained on how a direct head-to-head between the strong players would go. For the purposes of this rating computation, we assume that the informational value of a race is roughly proportional to the likelihood of the weaker player winning. We cap the effect so that losing to a much weaker player still costs rating points.

In a race with many players, a single event can have a significant impact on the results of all the H2H. To avoid races with high players count having too strong rating swings, we apply a modifier scaling down accuracy.

Finally, while handicap is allowed in ranked races and a rating offset is applied to keep expected results realistic (without incentivizing playing handicap-only), the results of such races are much less reliable.

◆ computeH2HResult()

double ServerLobby::computeH2HResult ( double  player1_time,
double  player2_time 
)
private

Computes the score of a head-to-head minimatch.

If time difference > 2,5% ; the result is 1 (complete win of player 1) or 0 (complete loss of player 1) Otherwise, it is averaged between 0 and 1.

◆ configPeersStartTime()

void ServerLobby::configPeersStartTime ( )
private

This function is called when all clients have loaded the world and are therefore ready to start the race.

It determine the start time in network timer for client and server based on pings and then switches state to WAIT_FOR_RACE_STARTED.

◆ finishedLoadingWorld()

void ServerLobby::finishedLoadingWorld ( )
virtual

Called from the RaceManager of the server when the world is loaded.

Marks the server to be ready to start the race.

Implements LobbyProtocol.

◆ finishedLoadingWorldClient()

void ServerLobby::finishedLoadingWorldClient ( Event event)
private

Called when a client notifies the server that it has loaded the world.

When all clients and the server are ready, the race can be started.

◆ getTimeSpread()

double ServerLobby::getTimeSpread ( double  time)
private

Returns the time spread factor.

Short races are more random, so the expected result changes depending on race duration.

◆ handleAllVotes()

bool ServerLobby::handleAllVotes ( PeerVote winner_vote,
uint32_t *  winner_peer_id 
)
private

Select the track to be used based on all votes being received.

Parameters
winner_voteThe PeerVote that was picked.
winner_peer_idThe host id of winner (unchanged if no vote).
Returns
True if race can go on, otherwise wait.

◆ handlePlayerVote()

void ServerLobby::handlePlayerVote ( Event event)
private

Called when a player votes for track(s), it will auto correct client data if it sends some invalid data.

Parameters
event: Event providing the information.

◆ handleServerConfiguration()

void ServerLobby::handleServerConfiguration ( Event event)
private

Called when the server owner request to change game mode or difficulty.

Parameters
event: Event providing the information.

Format of the data :

Byte 0 1 2

Size | 1 | 1 | 1 |

Data | difficulty | game mode | soccer goal target |

◆ isRacing()

virtual bool ServerLobby::isRacing ( ) const
inlinevirtual

Implements LobbyProtocol.

◆ kartSelectionRequested()

void ServerLobby::kartSelectionRequested ( Event event)
private

Called when a player asks to select karts.

Parameters
event: Event providing the information.

◆ notifyEvent()

bool ServerLobby::notifyEvent ( Event event)
virtual

Notify a protocol matching the Event type of that event.

Parameters
event: Pointer to the event.
Returns
True if the event has been treated, false otherwise.

Reimplemented from Protocol.

◆ notifyEventAsynchronous()

bool ServerLobby::notifyEventAsynchronous ( Event event)
virtual

Notify a protocol matching the Event type of that event.

This update is done asynchronously :

Parameters
event: Pointer to the event.
Returns
True if the event has been treated, false otherwise

Reimplemented from Protocol.

◆ playerFinishedResult()

void ServerLobby::playerFinishedResult ( Event event)
private

Called when a client clicks on 'ok' on the race result screen.

If all players have clicked on 'ok', go back to the lobby.

◆ registerServer()

void ServerLobby::registerServer ( bool  first_time)
private

Register this server (i.e.

its public address) with the STK server so that clients can find it. It blocks till a response from the stk server is received (this function is executed from the ProtocolManager thread). The information about this client is added to the table 'server'.

◆ setup()

void ServerLobby::setup ( )
virtual

A previous GameSetup is deleted and a new one is created.

Returns
Newly create GameSetup object.

Implements LobbyProtocol.

◆ startSelection()

void ServerLobby::startSelection ( const Event event = NULL)

Instructs all clients to start the kart selection.

If event is NULL, the command comes from the owner less server.

◆ unregisterServer()

void ServerLobby::unregisterServer ( bool  now,
std::weak_ptr< ServerLobby sl = std::weak_ptr<ServerLobby>() 
)
private

Unregister this server (i.e.

its public address) with the STK server, currently when karts enter kart selection screen it will be done or quit stk.

◆ update()

void ServerLobby::update ( int  ticks)
virtual

Simple finite state machine.

Once this is known, register the server and its address with the stk server so that client can find it.

Implements LobbyProtocol.

◆ updatePlayerList()

void ServerLobby::updatePlayerList ( bool  update_when_reset_server = false)
private

Called when any players change their setting (team for example), or connection / disconnection, it will use the game_started parameter to determine if this should be send to all peers in server or just in game.

Parameters
update_when_reset_serverIf true, this message will be sent to all peers.

Member Data Documentation

◆ m_max_scores

std::map<uint32_t, double> ServerLobby::m_max_scores
private

The maximum rating obtained for each current player.

This is based on m_scores, not m_raw_scores


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