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

OpenTTD Source 15.0-RC2

network_gamelist.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef NETWORK_GAMELIST_H
11#define NETWORK_GAMELIST_H
12
13#include "core/address.h"
14#include "core/network_game_info.h"
15#include "network_type.h"
16
18 enum NetworkGameStatus : uint8_t {
19 NGLS_OFFLINE,
20 NGLS_ONLINE,
21 NGLS_FULL,
22 NGLS_BANNED,
23 NGLS_TOO_OLD,
24};
25
27 struct NetworkGame {
28 NetworkGame(std::string_view connection_string) : connection_string(connection_string) {}
29
30 NetworkGameInfo info{};
31 std::string connection_string;
32 NetworkGameStatus status = NGLS_OFFLINE;
33 bool manually = false;
34 bool refreshing = false;
35 int version = 0;
36};
37
38extern std::vector<std::unique_ptr<NetworkGame>> _network_game_list;
39extern int _network_game_list_version;
40
41 NetworkGame *NetworkGameListAddItem(std::string_view connection_string);
42void NetworkGameListRemoveItem(NetworkGame *remove);
43void NetworkGameListRemoveExpired();
44
45#endif /* NETWORK_GAMELIST_H */
address.h
Wrapper for network addresses.
NetworkGameListAddItem
NetworkGame * NetworkGameListAddItem(std::string_view connection_string)
Add a new item to the linked gamelist.
Definition network_gamelist.cpp:30
NetworkGameListRemoveItem
void NetworkGameListRemoveItem(NetworkGame *remove)
Remove an item from the gamelist linked list.
Definition network_gamelist.cpp:52
NetworkGameListRemoveExpired
void NetworkGameListRemoveExpired()
Remove all servers that have not recently been updated.
Definition network_gamelist.cpp:68
NetworkGameStatus
NetworkGameStatus
The status a server can be in.
Definition network_gamelist.h:18
NGLS_ONLINE
@ NGLS_ONLINE
Server is online.
Definition network_gamelist.h:20
NGLS_FULL
@ NGLS_FULL
Server is full and cannot be queried.
Definition network_gamelist.h:21
NGLS_TOO_OLD
@ NGLS_TOO_OLD
Server is too old to query.
Definition network_gamelist.h:23
NGLS_OFFLINE
@ NGLS_OFFLINE
Server is offline (or cannot be queried).
Definition network_gamelist.h:19
NGLS_BANNED
@ NGLS_BANNED
You are banned from this server.
Definition network_gamelist.h:22
_network_game_list
std::vector< std::unique_ptr< NetworkGame > > _network_game_list
Game list of this client.
Definition network_gamelist.cpp:21
_network_game_list_version
int _network_game_list_version
Current version of all items in the list.
Definition network_gamelist.cpp:22
network_type.h
Types used for networking.
NetworkGameInfo
The game information that is sent from the server to the clients with extra information only required...
Definition network_game_info.h:122
NetworkGame
Structure with information shown in the game list (GUI)
Definition network_gamelist.h:27
NetworkGame::refreshing
bool refreshing
Whether this server is being queried.
Definition network_gamelist.h:34
NetworkGame::connection_string
std::string connection_string
Address of the server.
Definition network_gamelist.h:31
NetworkGame::version
int version
Used to see which servers are no longer available on the Game Coordinator and can be removed.
Definition network_gamelist.h:35
NetworkGame::info
NetworkGameInfo info
The game information of this server.
Definition network_gamelist.h:30
NetworkGame::manually
bool manually
True if the server was added manually.
Definition network_gamelist.h:33
NetworkGame::status
NetworkGameStatus status
Stats of the server.
Definition network_gamelist.h:32