OpenTTD Source  1.11.0-beta2
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/game.h"
14 
16 static const uint MAX_CLIENTS = 255;
17 
23 static const uint MAX_CLIENT_SLOTS = 256;
24 
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 
39 enum ClientID : uint32 {
43 };
44 
46 typedef uint8 ClientIndex;
47 
49 typedef uint8 AdminIndex;
50 
52 static const AdminIndex MAX_ADMINS = 16;
54 static const AdminIndex INVALID_ADMIN_ID = UINT8_MAX;
55 
58  uint16 num_vehicle[NETWORK_VEH_END];
59  uint16 num_station[NETWORK_VEH_END];
60  bool ai;
61 };
62 
66  uint16 months_empty;
67 };
68 
69 struct NetworkClientInfo;
70 
75 };
76 
81 enum DestType {
85 };
86 
92  NETWORK_ACTION_JOIN,
93  NETWORK_ACTION_LEAVE,
94  NETWORK_ACTION_SERVER_MESSAGE,
95  NETWORK_ACTION_CHAT,
96  NETWORK_ACTION_CHAT_COMPANY,
97  NETWORK_ACTION_CHAT_CLIENT,
98  NETWORK_ACTION_GIVE_MONEY,
99  NETWORK_ACTION_NAME_CHANGE,
100  NETWORK_ACTION_COMPANY_SPECTATOR,
101  NETWORK_ACTION_COMPANY_JOIN,
102  NETWORK_ACTION_COMPANY_NEW,
103  NETWORK_ACTION_KICKED,
104 };
105 
111  NETWORK_ERROR_GENERAL, // Try to use this one like never
112 
113  /* Signals from clients */
114  NETWORK_ERROR_DESYNC,
115  NETWORK_ERROR_SAVEGAME_FAILED,
116  NETWORK_ERROR_CONNECTION_LOST,
117  NETWORK_ERROR_ILLEGAL_PACKET,
118  NETWORK_ERROR_NEWGRF_MISMATCH,
119 
120  /* Signals from servers */
121  NETWORK_ERROR_NOT_AUTHORIZED,
122  NETWORK_ERROR_NOT_EXPECTED,
123  NETWORK_ERROR_WRONG_REVISION,
124  NETWORK_ERROR_NAME_IN_USE,
125  NETWORK_ERROR_WRONG_PASSWORD,
126  NETWORK_ERROR_COMPANY_MISMATCH, // Happens in CLIENT_COMMAND
127  NETWORK_ERROR_KICKED,
128  NETWORK_ERROR_CHEATER,
129  NETWORK_ERROR_FULL,
130  NETWORK_ERROR_TOO_MANY_COMMANDS,
131  NETWORK_ERROR_TIMEOUT_PASSWORD,
132  NETWORK_ERROR_TIMEOUT_COMPUTER,
133  NETWORK_ERROR_TIMEOUT_MAP,
134  NETWORK_ERROR_TIMEOUT_JOIN,
135 
136  NETWORK_ERROR_END,
137 };
138 
139 #endif /* NETWORK_TYPE_H */
ClientIndex
uint8 ClientIndex
Indices into the client tables.
Definition: network_type.h:46
NetworkCompanyStats::num_station
uint16 num_station[NETWORK_VEH_END]
How many stations are there of this type?
Definition: network_type.h:59
NetworkCompanyStats
Simple calculated statistics of a company.
Definition: network_type.h:57
DestType
DestType
Destination of our chat messages.
Definition: network_type.h:81
INVALID_CLIENT_ID
@ INVALID_CLIENT_ID
Client is not part of anything.
Definition: network_type.h:40
NetworkCompanyState
Some state information of a company, especially for servers.
Definition: network_type.h:64
NetworkAction
NetworkAction
Actions that can be used for NetworkTextMessage.
Definition: network_type.h:91
NetworkCompanyState::password
char password[NETWORK_PASSWORD_LENGTH]
The password for the company.
Definition: network_type.h:65
MAX_CLIENTS
static const uint MAX_CLIENTS
How many clients can we have.
Definition: network_type.h:16
DESTTYPE_TEAM
@ DESTTYPE_TEAM
Send message/notice to everyone playing the same company (Team)
Definition: network_type.h:83
NetworkCompanyState::months_empty
uint16 months_empty
How many months the company is empty.
Definition: network_type.h:66
INVALID_ADMIN_ID
static const AdminIndex INVALID_ADMIN_ID
An invalid admin marker.
Definition: network_type.h:54
NetworkCompanyStats::num_vehicle
uint16 num_vehicle[NETWORK_VEH_END]
How many vehicles are there of this type?
Definition: network_type.h:58
MAX_ADMINS
static const AdminIndex MAX_ADMINS
Maximum number of allowed admins.
Definition: network_type.h:52
ClientID
ClientID
'Unique' identifier to be given to clients
Definition: network_type.h:39
NETWORK_COMPANY_PASSWORD
@ NETWORK_COMPANY_PASSWORD
The password of the company.
Definition: network_type.h:74
CLIENT_ID_SERVER
@ CLIENT_ID_SERVER
Servers always have this ID.
Definition: network_type.h:41
NetworkVehicleType
NetworkVehicleType
Vehicletypes in the order they are send in info packets.
Definition: network_type.h:28
NETWORK_PASSWORD_LENGTH
static const uint NETWORK_PASSWORD_LENGTH
The maximum length of the password, in bytes including '\0' (must be >= NETWORK_SERVER_ID_LENGTH)
Definition: config.h:45
NetworkPasswordType
NetworkPasswordType
The type of password we're asking for.
Definition: network_type.h:72
NetworkCompanyStats::ai
bool ai
Is this company an AI.
Definition: network_type.h:60
AdminIndex
uint8 AdminIndex
Indices into the admin tables.
Definition: network_type.h:49
DESTTYPE_BROADCAST
@ DESTTYPE_BROADCAST
Send message/notice to all clients (All)
Definition: network_type.h:82
game.h
DESTTYPE_CLIENT
@ DESTTYPE_CLIENT
Send message/notice to only a certain client (Private)
Definition: network_type.h:84
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
NetworkErrorCode
NetworkErrorCode
The error codes we send around in the protocols.
Definition: network_type.h:110
NetworkClientInfo
Container for all information known about a client.
Definition: network_base.h:23
NETWORK_GAME_PASSWORD
@ NETWORK_GAME_PASSWORD
The password of the game.
Definition: network_type.h:73
CLIENT_ID_FIRST
@ CLIENT_ID_FIRST
The first client ID.
Definition: network_type.h:42