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

OpenTTD Source 14.0-beta1

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 <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef NETWORK_TYPE_H
11 #define NETWORK_TYPE_H
12
13 #include "../core/enum_type.hpp"
14
16 static const uint MAX_CLIENTS = 255;
17
23 static const uint MAX_CLIENT_SLOTS = 256;
24
28 enum NetworkVehicleType {
29 NETWORK_VEH_TRAIN = 0,
30 NETWORK_VEH_LORRY,
31 NETWORK_VEH_BUS,
32 NETWORK_VEH_PLANE,
33 NETWORK_VEH_SHIP,
34
35 NETWORK_VEH_END
36 };
37
42 enum ServerGameType : uint8_t {
43 SERVER_GAME_TYPE_LOCAL = 0,
44 SERVER_GAME_TYPE_PUBLIC,
45 SERVER_GAME_TYPE_INVITE_ONLY,
46 };
47
49 enum ClientID : uint32_t {
50 INVALID_CLIENT_ID = 0,
51 CLIENT_ID_SERVER = 1,
52 CLIENT_ID_FIRST = 2,
53 };
54
56 typedef uint8_t ClientIndex;
57
59 typedef uint8_t AdminIndex;
60
62 static const AdminIndex MAX_ADMINS = 16;
64 static const AdminIndex INVALID_ADMIN_ID = UINT8_MAX;
65
67 struct NetworkCompanyStats {
68 uint16_t num_vehicle[NETWORK_VEH_END];
69 uint16_t num_station[NETWORK_VEH_END];
70 bool ai;
71 };
72
74 struct NetworkCompanyState {
75 std::string password;
76 uint16_t months_empty;
77 };
78
79 struct NetworkClientInfo;
80
82 enum NetworkPasswordType {
83 NETWORK_GAME_PASSWORD,
84 NETWORK_COMPANY_PASSWORD,
85 };
86
91 enum DestType : byte {
92 DESTTYPE_BROADCAST,
93 DESTTYPE_TEAM,
94 DESTTYPE_CLIENT,
95 };
96 DECLARE_ENUM_AS_ADDABLE(DestType)
97
98
102 enum NetworkAction {
103 NETWORK_ACTION_JOIN,
104 NETWORK_ACTION_LEAVE,
105 NETWORK_ACTION_SERVER_MESSAGE,
106 NETWORK_ACTION_CHAT,
107 NETWORK_ACTION_CHAT_COMPANY,
108 NETWORK_ACTION_CHAT_CLIENT,
109 NETWORK_ACTION_GIVE_MONEY,
110 NETWORK_ACTION_NAME_CHANGE,
111 NETWORK_ACTION_COMPANY_SPECTATOR,
112 NETWORK_ACTION_COMPANY_JOIN,
113 NETWORK_ACTION_COMPANY_NEW,
114 NETWORK_ACTION_KICKED,
115 NETWORK_ACTION_EXTERNAL_CHAT,
116 };
117
122 enum NetworkErrorCode {
123 NETWORK_ERROR_GENERAL, // Try to use this one like never
124
125 /* Signals from clients */
126 NETWORK_ERROR_DESYNC,
127 NETWORK_ERROR_SAVEGAME_FAILED,
128 NETWORK_ERROR_CONNECTION_LOST,
129 NETWORK_ERROR_ILLEGAL_PACKET,
130 NETWORK_ERROR_NEWGRF_MISMATCH,
131
132 /* Signals from servers */
133 NETWORK_ERROR_NOT_AUTHORIZED,
134 NETWORK_ERROR_NOT_EXPECTED,
135 NETWORK_ERROR_WRONG_REVISION,
136 NETWORK_ERROR_NAME_IN_USE,
137 NETWORK_ERROR_WRONG_PASSWORD,
138 NETWORK_ERROR_COMPANY_MISMATCH, // Happens in CLIENT_COMMAND
139 NETWORK_ERROR_KICKED,
140 NETWORK_ERROR_CHEATER,
141 NETWORK_ERROR_FULL,
142 NETWORK_ERROR_TOO_MANY_COMMANDS,
143 NETWORK_ERROR_TIMEOUT_PASSWORD,
144 NETWORK_ERROR_TIMEOUT_COMPUTER,
145 NETWORK_ERROR_TIMEOUT_MAP,
146 NETWORK_ERROR_TIMEOUT_JOIN,
147 NETWORK_ERROR_INVALID_CLIENT_NAME,
148
149 NETWORK_ERROR_END,
150 };
151
152 #endif /* NETWORK_TYPE_H */
NetworkCompanyStats::num_station
uint16_t num_station[NETWORK_VEH_END]
How many stations are there of this type?
Definition: network_type.h:69
NetworkCompanyStats
Simple calculated statistics of a company.
Definition: network_type.h:67
NetworkCompanyState::months_empty
uint16_t months_empty
How many months the company is empty.
Definition: network_type.h:76
NetworkCompanyState
Some state information of a company, especially for servers.
Definition: network_type.h:74
NetworkAction
NetworkAction
Actions that can be used for NetworkTextMessage.
Definition: network_type.h:102
MAX_CLIENTS
static const uint MAX_CLIENTS
How many clients can we have.
Definition: network_type.h:16
INVALID_ADMIN_ID
static const AdminIndex INVALID_ADMIN_ID
An invalid admin marker.
Definition: network_type.h:64
ClientIndex
uint8_t ClientIndex
Indices into the client tables.
Definition: network_type.h:56
ServerGameType
ServerGameType
Game type the server can be using.
Definition: network_type.h:42
CLIENT_ID_FIRST
@ CLIENT_ID_FIRST
The first client ID.
Definition: network_type.h:52
MAX_ADMINS
static const AdminIndex MAX_ADMINS
Maximum number of allowed admins.
Definition: network_type.h:62
NetworkCompanyStats::num_vehicle
uint16_t num_vehicle[NETWORK_VEH_END]
How many vehicles are there of this type?
Definition: network_type.h:68
NETWORK_COMPANY_PASSWORD
@ NETWORK_COMPANY_PASSWORD
The password of the company.
Definition: network_type.h:84
NetworkCompanyState::password
std::string password
The password for the company.
Definition: network_type.h:75
NetworkVehicleType
NetworkVehicleType
Vehicletypes in the order they are send in info packets.
Definition: network_type.h:28
DECLARE_ENUM_AS_ADDABLE
#define DECLARE_ENUM_AS_ADDABLE(EnumType)
Operator that allows this enumeration to be added to any other enumeration.
Definition: enum_type.hpp:41
DESTTYPE_TEAM
@ DESTTYPE_TEAM
Send message/notice to everyone playing the same company (Team)
Definition: network_type.h:93
ClientID
ClientID
'Unique' identifier to be given to clients
Definition: network_type.h:49
DestType
DestType
Destination of our chat messages.
Definition: network_type.h:91
NetworkPasswordType
NetworkPasswordType
The type of password we're asking for.
Definition: network_type.h:82
DESTTYPE_CLIENT
@ DESTTYPE_CLIENT
Send message/notice to only a certain client (Private)
Definition: network_type.h:94
NetworkCompanyStats::ai
bool ai
Is this company an AI.
Definition: network_type.h:70
INVALID_CLIENT_ID
@ INVALID_CLIENT_ID
Client is not part of anything.
Definition: network_type.h:50
DESTTYPE_BROADCAST
@ DESTTYPE_BROADCAST
Send message/notice to all clients (All)
Definition: network_type.h:92
MAX_CLIENT_SLOTS
static const uint MAX_CLIENT_SLOTS
The number of slots; must be at least 1 more than MAX_CLIENTS.
Definition: network_type.h:23
CLIENT_ID_SERVER
@ CLIENT_ID_SERVER
Servers always have this ID.
Definition: network_type.h:51
AdminIndex
uint8_t AdminIndex
Indices into the admin tables.
Definition: network_type.h:59
NetworkErrorCode
NetworkErrorCode
The error codes we send around in the protocols.
Definition: network_type.h:122
NetworkClientInfo
Container for all information known about a client.
Definition: network_base.h:24
NETWORK_GAME_PASSWORD
@ NETWORK_GAME_PASSWORD
The password of the game.
Definition: network_type.h:83