OpenTTD Source  1.11.2
game_info.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 
12 #ifndef NETWORK_CORE_GAME_INFO_H
13 #define NETWORK_CORE_GAME_INFO_H
14 
15 #include "config.h"
16 #include "core.h"
17 #include "../../newgrf_config.h"
18 #include "../../date_type.h"
19 
20 /*
21  * NetworkGameInfo has several revisions which we still need to support on the
22  * wire. The table below shows the version and size for each field of the
23  * serialized NetworkGameInfo.
24  *
25  * Version: Bytes: Description:
26  * all 1 the version of this packet's structure
27  *
28  * 4+ 1 number of GRFs attached (n)
29  * 4+ n * 20 unique identifier for GRF files. Consists of:
30  * - one 4 byte variable with the GRF ID
31  * - 16 bytes (sent sequentially) for the MD5 checksum
32  * of the GRF
33  *
34  * 3+ 4 current game date in days since 1-1-0 (DMY)
35  * 3+ 4 game introduction date in days since 1-1-0 (DMY)
36  *
37  * 2+ 1 maximum number of companies allowed on the server
38  * 2+ 1 number of companies on the server
39  * 2+ 1 maximum number of spectators allowed on the server
40  *
41  * 1+ var string with the name of the server
42  * 1+ var string with the revision of the server
43  * 1+ 1 the language run on the server
44  * (0 = any, 1 = English, 2 = German, 3 = French)
45  * 1+ 1 whether the server uses a password (0 = no, 1 = yes)
46  * 1+ 1 maximum number of clients allowed on the server
47  * 1+ 1 number of clients on the server
48  * 1+ 1 number of spectators on the server
49  * 1 & 2 2 current game date in days since 1-1-1920 (DMY)
50  * 1 & 2 2 game introduction date in days since 1-1-1920 (DMY)
51  * 1+ var string with the name of the map
52  * 1+ 2 width of the map in tiles
53  * 1+ 2 height of the map in tiles
54  * 1+ 1 type of map:
55  * (0 = temperate, 1 = arctic, 2 = desert, 3 = toyland)
56  * 1+ 1 whether the server is dedicated (0 = no, 1 = yes)
57  */
58 
65  byte clients_on;
66 };
67 
75  uint16 map_width;
76  uint16 map_height;
80  bool dedicated;
82  bool compatible;
83  bool use_password;
85  byte server_lang;
86  byte clients_max;
87  byte companies_on;
91  byte map_set;
92 };
93 
95 
96 const char *GetNetworkRevisionString();
97 bool IsNetworkCompatibleVersion(const char *other);
98 
100 
102 void SerializeGRFIdentifier(Packet *p, const GRFIdentifier *grf);
103 
105 void SerializeNetworkGameInfo(Packet *p, const NetworkGameInfo *info);
106 
107 #endif /* NETWORK_CORE_GAME_INFO_H */
DeserializeGRFIdentifier
void DeserializeGRFIdentifier(Packet *p, GRFIdentifier *grf)
Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet.
Definition: game_info.cpp:319
NetworkGameInfo
The game information that is sent from the server to the clients.
Definition: game_info.h:71
NetworkGameInfo::companies_max
byte companies_max
Max companies allowed on server.
Definition: game_info.h:88
NETWORK_NAME_LENGTH
static const uint NETWORK_NAME_LENGTH
The maximum length of the server name and map name, in bytes including '\0'.
Definition: config.h:40
NetworkServerGameInfo::map_name
char map_name[NETWORK_NAME_LENGTH]
Map which is played ["random" for a randomized map].
Definition: game_info.h:64
NetworkGameInfo::use_password
bool use_password
Is this server passworded?
Definition: game_info.h:83
NetworkServerGameInfo
The game information that is not generated on-the-fly and has to be sent to the clients.
Definition: game_info.h:63
NetworkGameInfo::hostname
char hostname[NETWORK_HOSTNAME_LENGTH]
Hostname of the server (if any)
Definition: game_info.h:78
NetworkGameInfo::game_info_version
byte game_info_version
Version of the game info.
Definition: game_info.h:84
NetworkGameInfo::map_width
uint16 map_width
Map width.
Definition: game_info.h:75
SerializeGRFIdentifier
void SerializeGRFIdentifier(Packet *p, const GRFIdentifier *grf)
Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet.
Definition: game_info.cpp:305
NetworkGameInfo::version_compatible
bool version_compatible
Can we connect to this server or not? (based on server_revision)
Definition: game_info.h:81
SerializeNetworkGameInfo
void SerializeNetworkGameInfo(Packet *p, const NetworkGameInfo *info)
Serializes the NetworkGameInfo struct to the packet.
Definition: game_info.cpp:169
GRFIdentifier
Basic data to distinguish a GRF.
Definition: newgrf_config.h:83
NetworkGameInfo::start_date
Date start_date
When the game started.
Definition: game_info.h:73
NetworkGameInfo::server_lang
byte server_lang
Language of the server (we should make a nice table for this)
Definition: game_info.h:85
GRFConfig
Information about GRF, used in the game and (part of it) in savegames.
Definition: newgrf_config.h:152
NetworkGameInfo::companies_on
byte companies_on
How many started companies do we have.
Definition: game_info.h:87
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:14
FillNetworkGameInfo
void FillNetworkGameInfo(NetworkGameInfo &ngi)
Fill a NetworkGameInfo structure with the latest information of the server.
Definition: game_info.cpp:113
GetNetworkRevisionString
const char * GetNetworkRevisionString()
Get the network version string used by this build.
Definition: game_info.cpp:41
Packet
Internal entity of a packet.
Definition: packet.h:40
NetworkGameInfo::server_name
char server_name[NETWORK_NAME_LENGTH]
Server name.
Definition: game_info.h:77
NETWORK_REVISION_LENGTH
static const uint NETWORK_REVISION_LENGTH
The maximum length of the revision, in bytes including '\0'.
Definition: config.h:44
DeserializeNetworkGameInfo
void DeserializeNetworkGameInfo(Packet *p, NetworkGameInfo *info)
Deserializes the NetworkGameInfo struct from the packet.
Definition: game_info.cpp:231
IsNetworkCompatibleVersion
bool IsNetworkCompatibleVersion(const char *other)
Checks whether the given version string is compatible with our version.
Definition: game_info.cpp:95
NetworkGameInfo::clients_max
byte clients_max
Max clients allowed on server.
Definition: game_info.h:86
NetworkGameInfo::game_date
Date game_date
Current date.
Definition: game_info.h:74
core.h
NetworkGameInfo::server_revision
char server_revision[NETWORK_REVISION_LENGTH]
The version number the server is using (e.g.: 'r304' or 0.5.0)
Definition: game_info.h:79
config.h
NETWORK_HOSTNAME_LENGTH
static const uint NETWORK_HOSTNAME_LENGTH
The maximum length of the host name, in bytes including '\0'.
Definition: config.h:42
NetworkGameInfo::spectators_on
byte spectators_on
How many spectators do we have?
Definition: game_info.h:89
NetworkGameInfo::map_height
uint16 map_height
Map height.
Definition: game_info.h:76
NetworkServerGameInfo::clients_on
byte clients_on
Current count of clients on server.
Definition: game_info.h:65
NetworkGameInfo::grfconfig
GRFConfig * grfconfig
List of NewGRF files used.
Definition: game_info.h:72
_network_game_info
NetworkServerGameInfo _network_game_info
Information about our game.
Definition: game_info.cpp:35
NetworkGameInfo::compatible
bool compatible
Can we connect to this server or not? (based on server_revision and grf_match.
Definition: game_info.h:82
NetworkGameInfo::dedicated
bool dedicated
Is this a dedicated server?
Definition: game_info.h:80
NetworkGameInfo::spectators_max
byte spectators_max
Max spectators allowed on server.
Definition: game_info.h:90
NetworkGameInfo::map_set
byte map_set
Graphical set.
Definition: game_info.h:91