1
/* $Id: network_type.h 15242 2009-01-23 22:18:06Z rubidium $ */
3
/** @file network_type.h Types used for networking. */
10
#include "../company_type.h"
11
#include "../economy_type.h"
12
#include "core/config.h"
13
#include "core/game.h"
16
/** How many clients can we have */
19
/** The number of bits per pool client block */
20
NCI_BITS_PER_POOL_BLOCK = 3, // => 8 items per block
22
* The number of slots; must be a multiple of (1 << NCI_BITS_PER_POOL_BLOCK)
23
* and be at least 1 more than MAX_CLIENTS. It must furthermore be less than
24
* or equal to 256 as client indices (sent over the network) are 8 bits.
25
* It needs 1 more for the dedicated server.
27
MAX_CLIENT_SLOTS = 256,
29
/** Maximum number of internet interfaces supported. */
32
/** How many vehicle/station types we put over the network */
33
NETWORK_VEHICLE_TYPES = 5,
34
NETWORK_STATION_TYPES = 5,
37
/** 'Unique' identifier to be given to clients */
39
INVALID_CLIENT_ID = 0, ///< Client is not part of anything
40
CLIENT_ID_SERVER = 1, ///< Servers always have this ID
41
CLIENT_ID_FIRST = 2, ///< The first client ID
44
/** Indices into the client tables */
45
typedef uint8 ClientIndex;
47
/** Simple calculated statistics of a company */
48
struct NetworkCompanyStats {
49
uint16 num_vehicle[NETWORK_VEHICLE_TYPES]; ///< How many vehicles are there of this type?
50
uint16 num_station[NETWORK_STATION_TYPES]; ///< How many stations are there of this type?
51
bool ai; ///< Is this company an AI
54
/** Some state information of a company, especially for servers */
55
struct NetworkCompanyState {
56
char password[NETWORK_PASSWORD_LENGTH]; ///< The password for the company
57
uint16 months_empty; ///< How many months the company is empty
60
struct NetworkClientInfo;
62
enum NetworkPasswordType {
63
NETWORK_GAME_PASSWORD,
64
NETWORK_COMPANY_PASSWORD,
68
DESTTYPE_BROADCAST, ///< Send message/notice to all clients (All)
69
DESTTYPE_TEAM, ///< Send message/notice to everyone playing the same company (Team)
70
DESTTYPE_CLIENT, ///< Send message/notice to only a certain client (Private)
73
/** Actions that can be used for NetworkTextMessage */
77
NETWORK_ACTION_SERVER_MESSAGE,
79
NETWORK_ACTION_CHAT_COMPANY,
80
NETWORK_ACTION_CHAT_CLIENT,
81
NETWORK_ACTION_GIVE_MONEY,
82
NETWORK_ACTION_NAME_CHANGE,
83
NETWORK_ACTION_COMPANY_SPECTATOR,
84
NETWORK_ACTION_COMPANY_JOIN,
85
NETWORK_ACTION_COMPANY_NEW,
88
/** Messages the server can give */
89
enum NetworkServerMessage {
90
NETWORK_SERVER_MESSAGE_GAME_PAUSED_PLAYERS, ///< Game paused (not enough players)
91
NETWORK_SERVER_MESSAGE_GAME_UNPAUSED_PLAYERS, ///< Game unpaused (enough players)
92
NETWORK_SERVER_MESSAGE_GAME_PAUSED_CONNECT, ///< Game paused (connecting client)
93
NETWORK_SERVER_MESSAGE_GAME_UNPAUSED_CONNECT, ///< Game unpaused (client connected)
94
NETWORK_SERVER_MESSAGE_GAME_UNPAUSED_CONNECT_FAIL, ///< Game unpaused (client failed to connect)
95
NETWORK_SERVER_MESSAGE_END
98
enum NetworkErrorCode {
99
NETWORK_ERROR_GENERAL, // Try to use this one like never
101
/* Signals from clients */
102
NETWORK_ERROR_DESYNC,
103
NETWORK_ERROR_SAVEGAME_FAILED,
104
NETWORK_ERROR_CONNECTION_LOST,
105
NETWORK_ERROR_ILLEGAL_PACKET,
106
NETWORK_ERROR_NEWGRF_MISMATCH,
108
/* Signals from servers */
109
NETWORK_ERROR_NOT_AUTHORIZED,
110
NETWORK_ERROR_NOT_EXPECTED,
111
NETWORK_ERROR_WRONG_REVISION,
112
NETWORK_ERROR_NAME_IN_USE,
113
NETWORK_ERROR_WRONG_PASSWORD,
114
NETWORK_ERROR_COMPANY_MISMATCH, // Happens in CLIENT_COMMAND
115
NETWORK_ERROR_KICKED,
116
NETWORK_ERROR_CHEATER,
120
#endif /* ENABLE_NETWORK */
121
#endif /* NETWORK_TYPE_H */