OpenTTD Source: src/network/network_gamelist.h File Reference

OpenTTD Source 15.3

Data Structures | Enumerations | Functions | Variables
network_gamelist.h File Reference

Handling of the list of games. More...

`#include "core/address.h"`
`#include "core/network_game_info.h"`
`#include "network_type.h"`

Go to the source code of this file.

## Data Structures
struct | NetworkGame
| Structure with information shown in the game list (GUI) More...

## Enumerations
enum | NetworkGameStatus : uint8_t { NGLS_OFFLINE , NGLS_ONLINE , NGLS_FULL , NGLS_BANNED , NGLS_TOO_OLD }
| The status a server can be in. More...

## Functions
NetworkGame * | NetworkGameListAddItem (std::string_view connection_string)
| Add a new item to the linked gamelist.
void | NetworkGameListRemoveItem (NetworkGame *remove)
| Remove an item from the gamelist linked list.
void | NetworkGameListRemoveExpired ()
| Remove all servers that have not recently been updated.

## Variables
std::vector< std::unique_ptr< NetworkGame > > | _network_game_list
| Game list of this client.
int | _network_game_list_version
| Current version of all items in the list.

## Detailed Description

Handling of the list of games.

Definition in file network_gamelist.h.

## Enumeration Type Documentation

## ◆ NetworkGameStatus

enum NetworkGameStatus : uint8_t

The status a server can be in.

Enumerator
NGLS_OFFLINE | Server is offline (or cannot be queried).
NGLS_ONLINE | Server is online.
NGLS_FULL | Server is full and cannot be queried.
NGLS_BANNED | You are banned from this server.
NGLS_TOO_OLD | Server is too old to query.

Definition at line 18 of file network_gamelist.h.

## Function Documentation

## ◆ NetworkGameListAddItem()

NetworkGame * NetworkGameListAddItem | ( | std::string_view | connection_string | ) |

Add a new item to the linked gamelist.

If the IP and Port match return the existing item instead of adding it again

Parameters

  connection_string | the address of the to-be added item

Returns
  a point to the newly added or already existing item

Definition at line 30 of file network_gamelist.cpp.

References _network_game_list, _network_game_list_version, ServerAddress::connection_string, NetworkGame::connection_string, NETWORK_DEFAULT_PORT, ServerAddress::Parse(), and UpdateNetworkGameWindow().

Referenced by QueryNetworkGameSocketHandler::CloseConnection(), NetworkAddServer(), NetworkQueryServer(), TCPQueryConnecter::OnFailure(), ClientNetworkCoordinatorSocketHandler::Receive_GC_ERROR(), ClientNetworkCoordinatorSocketHandler::Receive_GC_LISTING(), QueryNetworkGameSocketHandler::Receive_SERVER_BANNED(), QueryNetworkGameSocketHandler::Receive_SERVER_ERROR(), QueryNetworkGameSocketHandler::Receive_SERVER_FULL(), and QueryNetworkGameSocketHandler::Receive_SERVER_GAME_INFO().

## ◆ NetworkGameListRemoveExpired()

void NetworkGameListRemoveExpired | ( |  | ) |

Remove all servers that have not recently been updated.

Call this after you received all the servers from the Game Coordinator, so the ones that are no longer listed are removed.

Definition at line 68 of file network_gamelist.cpp.

References _network_game_list, _network_game_list_version, and UpdateNetworkGameWindow().

Referenced by ClientNetworkCoordinatorSocketHandler::Receive_GC_LISTING().

## ◆ NetworkGameListRemoveItem()

void NetworkGameListRemoveItem | ( | NetworkGame * | remove | ) |

Remove an item from the gamelist linked list.

Parameters

  remove | pointer to the item to be removed

Definition at line 52 of file network_gamelist.cpp.

References _network_game_list, and UpdateNetworkGameWindow().

Referenced by NetworkGameWindow::OnKeyPress().

## Variable Documentation

## ◆ _network_game_list

std::vector<std::unique_ptr<NetworkGame> > _network_game_list
| extern

Game list of this client.

Definition at line 21 of file network_gamelist.cpp.

Referenced by NetworkGameWindow::BuildGUINetworkGameList(), NetworkAfterNewGRFScan(), NetworkGameListAddItem(), NetworkGameListRemoveExpired(), and NetworkGameListRemoveItem().

## ◆ _network_game_list_version

int _network_game_list_version
| extern

Current version of all items in the list.

Definition at line 22 of file network_gamelist.cpp.

Referenced by ClientNetworkCoordinatorSocketHandler::GetListing(), NetworkGameListAddItem(), NetworkGameListRemoveExpired(), and ClientNetworkCoordinatorSocketHandler::Receive_GC_LISTING().