OpenTTD Source 20260711-master-g3fb3006dff
network_type.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
9
10#ifndef NETWORK_TYPE_H
11#define NETWORK_TYPE_H
12
13#include "../core/enum_type.hpp"
14#include "../core/pool_type.hpp"
15
17static const uint MAX_CLIENTS = 255;
18
22enum class NetworkVehicleType : uint8_t {
23 Train = 0,
28
30};
31
36enum class ServerGameType : uint8_t {
37 Local = 0,
40};
41
43enum class ClientID : uint32_t {
44 Invalid = 0,
45 Server = 1,
46 First = 2,
47};
48
50using ClientPoolID = PoolID<uint16_t, struct ClientPoolIDTag, MAX_CLIENTS + 1 /* dedicated server. */, 0xFFFF>;
51
54
62
64
74
94
128
135class NetworkAuthorizedKeys : public std::vector<std::string> {
136public:
137 bool Contains(std::string_view key) const;
138 bool Add(std::string_view key);
139 bool Remove(std::string_view key);
140};
141
142#endif /* NETWORK_TYPE_H */
Simple helper to (more easily) manage authorized keys.
bool Contains(std::string_view key) const
Check whether the given key is contains in these authorized keys.
Definition network.cpp:180
bool Add(std::string_view key)
Add the given key to the authorized keys, when it is not already contained.
Definition network.cpp:190
bool Remove(std::string_view key)
Remove the given key from the authorized keys, when it is exists.
Definition network.cpp:206
Type (helpers) for enums.
EnumClassIndexContainer< std::array< T, to_underlying(N)>, Index > EnumIndexArray
A typedef for EnumClassIndexContainer using std::array as the backing container type.
NetworkVehicleType
Vehicletypes in the order they are send in info packets.
@ Bus
A road vehicle that stops at bus stops.
@ Truck
A road vehicle that stops at truck stops.
@ End
End marker for array sizes.
PoolID< uint8_t, struct AdminIDTag, 16, 0xFF > AdminID
Indices into the admin tables.
NetworkErrorCode
The error codes we send around in the protocols.
@ WrongRevision
The client is using the wrong revision.
@ General
Fallback error code in case nothing matches.
@ Desync
Client tells that they desynced.
@ SavegameFailed
Client tells they could not load the savegame.
@ Cheater
The client is trying control companies in a way they are not supposed to.
@ TimeoutPassword
The client has timed out providing a password.
@ TooManyCommands
The client has sent too many commands in a short time.
@ TimeoutComputer
The client has timed out because the computer could not keep up with the server.
@ TimeoutMap
The client has timed out because it took too long to download the map.
@ NotAuthorized
The client tried to do something there are not authorized to.
@ ServerFull
The server is full.
@ InvalidClientName
The client tried to set an invalid name.
@ TimeoutJoin
The client has timed out because getting up to speed with the server failed.
@ NotOnAllowList
The client is not on the allow list.
@ WrongPassword
The client entered a wrong password.
@ NotExpected
The request/packet was not expected in the current state.
@ Kicked
The client got kicked.
@ ConnectionLost
Connection to the client was lost.
@ IllegalPacket
A packet was received that has invalid content.
@ NameInUse
The client has a duplicate name (and we couldn't make it unique).
@ NoAuthenticationMethodAvailable
The client and server could not find a common authentication method.
@ CompanyMismatch
The client was impersonating another company.
@ NewGRFMismatch
Client does not have the right NewGRFs.
NetworkAction
Actions that can be used for NetworkTextMessage.
@ ChatExternal
An external application sent a message over the admin port.
@ ServerMessage
The server sent a message.
@ ClientKicked
A client got kicked.
@ ChatTeam
A chat sent to all clients of a team/company.
@ ClientNameChange
A client changed their name.
@ ClientJoin
A client joined the server.
@ CompanySpectator
A client joined the spectators.
@ ChatClient
A chat sent to a specific client.
@ ChatBroadcast
A chat broadcast to all clients.
@ ClientLeave
A client left the server.
@ CompanyNew
A client created an joined a new company.
@ CompanyJoin
A client joined an existing company.
@ GiveMoney
A company was given money.
static const uint MAX_CLIENTS
How many clients can we have.
NetworkChatDestinationType
Destination of our chat messages.
@ Client
Send message/notice to only a certain client (Private).
@ Team
Send message/notice to everyone playing the same company (Team).
@ Broadcast
Send message/notice to all clients (All).
ClientID
'Unique' identifier to be given to clients
@ First
The first client ID.
@ Server
Servers always have this ID.
ServerGameType
Game type the server can be using.
@ Public
The game is publicly accessible.
@ Local
Do not communicate with the game coordinator.
@ InviteOnly
The game can be accessed if you know the invite code.
PoolID< uint16_t, struct ClientPoolIDTag, MAX_CLIENTS+1, 0xFFFF > ClientPoolID
Indices into the client related pools.
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
@ Invalid
broken savegame (used internally)
Definition saveload.h:449
Aircraft, helicopters, rotors and their shadows belong to this class.
Definition aircraft.h:75
Container for all information known about a client.
Simple calculated statistics of a company.
NetworkVehicleTypeArray num_station
How many stations are there of this type?
EnumIndexArray< uint16_t, NetworkVehicleType, NetworkVehicleType::End > NetworkVehicleTypeArray
Array indexed by NetworkVehicleType.
NetworkVehicleTypeArray num_vehicle
How many vehicles are there of this type?
Templated helper to make a PoolID a single POD value.
Definition pool_type.hpp:50
All ships have this type.
Definition ship.h:32
'Train' is either a loco or a wagon.
Definition train.h:97