OpenTTD Source: src/network/core/network_game_info.cpp Source File

OpenTTD Source 15.0-RC2

network_game_info.cpp
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
12#include "../../stdafx.h"
13#include "network_game_info.h"
14#include "../../company_base.h"
15#include "../../timer/timer_game_calendar.h"
16#include "../../timer/timer_game_tick.h"
17#include "../../debug.h"
18#include "../../map_func.h"
19#include "../../game/game.hpp"
20#include "../../game/game_info.hpp"
21#include "../../settings_type.h"
22#include "../../string_func.h"
23#include "../../rev.h"
24#include "../network_func.h"
25#include "../network.h"
26#include "../network_internal.h"
27#include "packet.h"
28
29#include "table/strings.h"
30
31#include "../../safeguards.h"
32
33
38static const uint GITHASH_SUFFIX_LEN = 12;
39
40 NetworkServerGameInfo _network_game_info;
41
46std::string_view GetNetworkRevisionString()
47{
48 static std::string network_revision;
49
50 if (network_revision.empty()) {
51#if not defined(NETWORK_INTERNAL_H)
52# error("network_internal.h must be included, otherwise the debug related preprocessor tokens won't be picked up correctly.")
53#elif not defined(ENABLE_NETWORK_SYNC_EVERY_FRAME)
54 /* Just a standard build. */
55 network_revision = _openttd_revision;
56#elif defined(NETWORK_SEND_DOUBLE_SEED)
57 /* Build for debugging that sends both parts of the seeds and by doing that practically syncs every frame. */
58 network_revision = fmt::format("dbg_seed-{}", _openttd_revision);
59#else
60 /* Build for debugging that sends the first part of the seed every frame, practically syncing every frame. */
61 network_revision = fmt::format("dbg_sync-{}", _openttd_revision);
62#endif
63 if (_openttd_revision_tagged) {
64 /* Tagged; do not mangle further, though ensure it's not too long. */
65 if (network_revision.size() >= NETWORK_REVISION_LENGTH) network_revision.resize(NETWORK_REVISION_LENGTH - 1);
66 } else {
67 /* Not tagged; add the githash suffix while ensuring the string does not become too long. */
68 assert(_openttd_revision_modified < 3);
69 std::string githash_suffix = fmt::format("-{}{}", "gum"[_openttd_revision_modified], _openttd_revision_hash);
70 if (githash_suffix.size() > GITHASH_SUFFIX_LEN) githash_suffix.resize(GITHASH_SUFFIX_LEN);
71
72 /* Where did the hash start in the original string? Overwrite from that position, unless that would create a too long string. */
73 size_t hash_end = network_revision.find_last_of('-');
74 if (hash_end == std::string::npos) hash_end = network_revision.size();
75 if (hash_end + githash_suffix.size() >= NETWORK_REVISION_LENGTH) hash_end = NETWORK_REVISION_LENGTH - githash_suffix.size() - 1;
76
77 /* Replace the git hash in revision string. */
78 network_revision.replace(hash_end, std::string::npos, githash_suffix);
79 }
80 assert(network_revision.size() < NETWORK_REVISION_LENGTH); // size does not include terminator, constant does, hence strictly less than
81 Debug(net, 3, "Network revision name: {}", network_revision);
82 }
83
84 return network_revision;
85}
86
92static std::string_view ExtractNetworkRevisionHash(std::string_view revision_string)
93{
94 size_t index = revision_string.find_last_of('-');
95 if (index == std::string::npos) return {};
96 return revision_string.substr(index);
97}
98
104bool IsNetworkCompatibleVersion(std::string_view other)
105{
106 std::string_view our_revision = GetNetworkRevisionString();
107 if (our_revision == other) return true;
108
109 /* If this version is tagged, then the revision string must be a complete match,
110 * since there is no git hash suffix in it.
111 * This is needed to avoid situations like "1.9.0-beta1" comparing equal to "2.0.0-beta1". */
112 if (_openttd_revision_tagged) return false;
113
114 /* One of the versions is for some sort of debugging, but not both. */
115 if (other.starts_with("dbg_seed") != our_revision.starts_with("dbg_seed")) return false;
116 if (other.starts_with("dbg_sync") != our_revision.starts_with("dbg_sync")) return false;
117
118 std::string_view hash1 = ExtractNetworkRevisionHash(our_revision);
119 std::string_view hash2 = ExtractNetworkRevisionHash(other);
120 return hash1 == hash2;
121}
122
126void CheckGameCompatibility(NetworkGameInfo &ngi)
127{
128 /* Check if we are allowed on this server based on the revision-check. */
129 ngi.version_compatible = IsNetworkCompatibleVersion(ngi.server_revision);
130 ngi.compatible = ngi.version_compatible;
131
132 /* Check if we have all the GRFs on the client-system too. */
133 for (const auto &c : ngi.grfconfig) {
134 if (c->status == GCS_NOT_FOUND) ngi.compatible = false;
135 }
136}
137
142void FillStaticNetworkServerGameInfo()
143{
144 _network_game_info.use_password = !_settings_client.network.server_password.empty();
145 _network_game_info.calendar_start = TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1);
146 _network_game_info.clients_max = _settings_client.network.max_clients;
147 _network_game_info.companies_max = _settings_client.network.max_companies;
148 _network_game_info.map_width = Map::SizeX();
149 _network_game_info.map_height = Map::SizeY();
150 _network_game_info.landscape = _settings_game.game_creation.landscape;
151 _network_game_info.dedicated = _network_dedicated;
152 CopyGRFConfigList(_network_game_info.grfconfig, _grfconfig, false);
153
154 _network_game_info.server_name = _settings_client.network.server_name;
155 _network_game_info.server_revision = GetNetworkRevisionString();
156}
157
162const NetworkServerGameInfo &GetCurrentNetworkServerGameInfo()
163{
164 /* These variables are updated inside _network_game_info as if they are global variables:
165 * - clients_on
166 * - invite_code
167 * These don't need to be updated manually here.
168 */
169 _network_game_info.companies_on = (uint8_t)Company::GetNumItems();
170 _network_game_info.spectators_on = NetworkSpectatorCount();
171 _network_game_info.calendar_date = TimerGameCalendar::date;
172 _network_game_info.ticks_playing = TimerGameTick::counter;
173 return _network_game_info;
174}
175
184static void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig &config, std::string_view name)
185{
186 /* Find the matching GRF file */
187 const GRFConfig *f = FindGRFConfig(config.ident.grfid, FGCM_EXACT, &config.ident.md5sum);
188 if (f == nullptr) {
189 AddGRFTextToList(config.name, name.empty() ? GetString(STR_CONFIG_ERROR_INVALID_GRF_UNKNOWN) : name);
190 config.status = GCS_NOT_FOUND;
191 } else {
192 config.filename = f->filename;
193 config.name = f->name;
194 config.info = f->info;
195 config.url = f->url;
196 }
197 config.flags.Set(GRFConfigFlag::Copy);
198}
199
205void SerializeNetworkGameInfo(Packet &p, const NetworkServerGameInfo &info, bool send_newgrf_names)
206{
207 p.Send_uint8 (NETWORK_GAME_INFO_VERSION);
208
209 /*
210 * Please observe the order.
211 * The parts must be read in the same order as they are sent!
212 */
213
214 /* Update the documentation in game_info.h on changes
215 * to the NetworkGameInfo wire-protocol! */
216
217 /* NETWORK_GAME_INFO_VERSION = 7 */
218 p.Send_uint64(info.ticks_playing);
219
220 /* NETWORK_GAME_INFO_VERSION = 6 */
221 p.Send_uint8(send_newgrf_names ? NST_GRFID_MD5_NAME : NST_GRFID_MD5);
222
223 /* NETWORK_GAME_INFO_VERSION = 5 */
224 GameInfo *game_info = Game::GetInfo();
225 p.Send_uint32(game_info == nullptr ? -1 : (uint32_t)game_info->GetVersion());
226 p.Send_string(game_info == nullptr ? "" : game_info->GetName());
227
228 /* NETWORK_GAME_INFO_VERSION = 4 */
229 {
230 /* Only send the GRF Identification (GRF_ID and MD5 checksum) of
231 * the GRFs that are needed, i.e. the ones that the server has
232 * selected in the NewGRF GUI and not the ones that are used due
233 * to the fact that they are in [newgrf-static] in openttd.cfg */
234 uint count = std::ranges::count_if(info.grfconfig, [](const auto &c) { return !c->flags.Test(GRFConfigFlag::Static); });
235 p.Send_uint8 (count); // Send number of GRFs
236
237 /* Send actual GRF Identifications */
238 for (const auto &c : info.grfconfig) {
239 if (c->flags.Test(GRFConfigFlag::Static)) continue;
240
241 SerializeGRFIdentifier(p, c->ident);
242 if (send_newgrf_names) p.Send_string(c->GetName());
243 }
244 }
245
246 /* NETWORK_GAME_INFO_VERSION = 3 */
247 p.Send_uint32(info.calendar_date.base());
248 p.Send_uint32(info.calendar_start.base());
249
250 /* NETWORK_GAME_INFO_VERSION = 2 */
251 p.Send_uint8 (info.companies_max);
252 p.Send_uint8 (info.companies_on);
253 p.Send_uint8 (info.clients_max); // Used to be max-spectators
254
255 /* NETWORK_GAME_INFO_VERSION = 1 */
256 p.Send_string(info.server_name);
257 p.Send_string(info.server_revision);
258 p.Send_bool (info.use_password);
259 p.Send_uint8 (info.clients_max);
260 p.Send_uint8 (info.clients_on);
261 p.Send_uint8 (info.spectators_on);
262 p.Send_uint16(info.map_width);
263 p.Send_uint16(info.map_height);
264 p.Send_uint8 (to_underlying(info.landscape));
265 p.Send_bool (info.dedicated);
266}
267
273void DeserializeNetworkGameInfo(Packet &p, NetworkGameInfo &info, const GameInfoNewGRFLookupTable *newgrf_lookup_table)
274{
275 uint8_t game_info_version = p.Recv_uint8();
276 NewGRFSerializationType newgrf_serialisation = NST_GRFID_MD5;
277
278 /*
279 * Please observe the order.
280 * The parts must be read in the same order as they are sent!
281 */
282
283 /* Update the documentation in game_info.h on changes
284 * to the NetworkGameInfo wire-protocol! */
285
286 switch (game_info_version) {
287 case 7:
288 info.ticks_playing = p.Recv_uint64();
289 [[fallthrough]];
290
291 case 6:
292 newgrf_serialisation = (NewGRFSerializationType)p.Recv_uint8();
293 if (newgrf_serialisation >= NST_END) return;
294 [[fallthrough]];
295
296 case 5: {
297 info.gamescript_version = (int)p.Recv_uint32();
298 info.gamescript_name = p.Recv_string(NETWORK_NAME_LENGTH);
299 [[fallthrough]];
300 }
301
302 case 4: {
303 /* Ensure that the maximum number of NewGRFs and the field in the network
304 * protocol are matched to each other. If that is not the case anymore a
305 * check must be added to ensure the received data is still valid. */
306 static_assert(std::numeric_limits<uint8_t>::max() == NETWORK_MAX_GRF_COUNT);
307 uint num_grfs = p.Recv_uint8();
308
309 GRFConfigList &dst = info.grfconfig;
310 for (uint i = 0; i < num_grfs; i++) {
311 NamedGRFIdentifier grf;
312 switch (newgrf_serialisation) {
313 case NST_GRFID_MD5:
314 DeserializeGRFIdentifier(p, grf.ident);
315 break;
316
317 case NST_GRFID_MD5_NAME:
318 DeserializeGRFIdentifierWithName(p, grf);
319 break;
320
321 case NST_LOOKUP_ID: {
322 if (newgrf_lookup_table == nullptr) return;
323 auto it = newgrf_lookup_table->find(p.Recv_uint32());
324 if (it == newgrf_lookup_table->end()) return;
325 grf = it->second;
326 break;
327 }
328
329 default:
330 NOT_REACHED();
331 }
332
333 auto c = std::make_unique<GRFConfig>();
334 c->ident = grf.ident;
335 HandleIncomingNetworkGameInfoGRFConfig(*c, grf.name);
336
337 /* Append GRFConfig to the list */
338 dst.push_back(std::move(c));
339 }
340 [[fallthrough]];
341 }
342
343 case 3:
344 info.calendar_date = TimerGameCalendar::Date{Clamp(p.Recv_uint32(), 0, CalendarTime::MAX_DATE.base())};
345 info.calendar_start = TimerGameCalendar::Date{Clamp(p.Recv_uint32(), 0, CalendarTime::MAX_DATE.base())};
346 [[fallthrough]];
347
348 case 2:
349 info.companies_max = p.Recv_uint8 ();
350 info.companies_on = p.Recv_uint8 ();
351 p.Recv_uint8(); // Used to contain max-spectators.
352 [[fallthrough]];
353
354 case 1:
355 info.server_name = p.Recv_string(NETWORK_NAME_LENGTH);
356 info.server_revision = p.Recv_string(NETWORK_REVISION_LENGTH);
357 if (game_info_version < 6) p.Recv_uint8 (); // Used to contain server-lang.
358 info.use_password = p.Recv_bool ();
359 info.clients_max = p.Recv_uint8 ();
360 info.clients_on = p.Recv_uint8 ();
361 info.spectators_on = p.Recv_uint8 ();
362 if (game_info_version < 3) { // 16 bits dates got scrapped and are read earlier
363 info.calendar_date = CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + p.Recv_uint16();
364 info.calendar_start = CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + p.Recv_uint16();
365 }
366 if (game_info_version < 6) while (p.Recv_uint8() != 0) {} // Used to contain the map-name.
367 info.map_width = p.Recv_uint16();
368 info.map_height = p.Recv_uint16();
369 info.landscape = LandscapeType{p.Recv_uint8()};
370 info.dedicated = p.Recv_bool ();
371
372 if (to_underlying(info.landscape) >= NUM_LANDSCAPE) info.landscape = LandscapeType::Temperate;
373 }
374
375 /* For older servers, estimate the ticks running based on the calendar date. */
376 if (game_info_version < 7) {
377 info.ticks_playing = static_cast<uint64_t>(std::max(0, info.calendar_date.base() - info.calendar_start.base())) * Ticks::DAY_TICKS;
378 }
379}
380
386void SerializeGRFIdentifier(Packet &p, const GRFIdentifier &grf)
387{
388 p.Send_uint32(grf.grfid);
389 p.Send_bytes(grf.md5sum);
390}
391
397void DeserializeGRFIdentifier(Packet &p, GRFIdentifier &grf)
398{
399 grf.grfid = p.Recv_uint32();
400 p.Recv_bytes(grf.md5sum);
401}
402
408void DeserializeGRFIdentifierWithName(Packet &p, NamedGRFIdentifier &grf)
409{
410 DeserializeGRFIdentifier(p, grf.ident);
411 grf.name = p.Recv_string(NETWORK_GRF_NAME_LENGTH);
412}
BaseBitSet::Set
constexpr Timpl & Set()
Set all bits.
Definition base_bitset_type.hpp:40
GameInfo
All static information from an Game like name, version, etc.
Definition game_info.hpp:16
Game::GetInfo
static class GameInfo * GetInfo()
Get the current GameInfo.
Definition game.hpp:70
Ticks::DAY_TICKS
static constexpr TimerGameTick::Ticks DAY_TICKS
1 day is 74 ticks; TimerGameCalendar::date_fract used to be uint16_t and incremented by 885.
Definition timer_game_tick.h:75
TimerGameCalendar::ConvertYMDToDate
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition timer_game_calendar.cpp:55
TimerGameCalendar::date
static Date date
Current date in days (day counter).
Definition timer_game_calendar.h:33
TimerGameConst< struct Calendar >::MAX_DATE
static constexpr TimerGame< struct Calendar >::Date MAX_DATE
The date of the last day of the max year.
Definition timer_game_common.h:187
TimerGameConst< struct Calendar >::DAYS_TILL_ORIGINAL_BASE_YEAR
static constexpr TimerGame< struct Calendar >::Date DAYS_TILL_ORIGINAL_BASE_YEAR
The date of the first day of the original base year.
Definition timer_game_common.h:184
TimerGameTick::counter
static TickCounter counter
Monotonic counter, in ticks, since start of game.
Definition timer_game_tick.h:60
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:53
NETWORK_GRF_NAME_LENGTH
static const uint NETWORK_GRF_NAME_LENGTH
Maximum length of the name of a GRF.
Definition config.h:73
NETWORK_MAX_GRF_COUNT
static const uint NETWORK_MAX_GRF_COUNT
Maximum number of GRFs that can be sent.
Definition config.h:90
NETWORK_REVISION_LENGTH
static const uint NETWORK_REVISION_LENGTH
The maximum length of the revision, in bytes including '\0'.
Definition config.h:56
NETWORK_GAME_INFO_VERSION
static const uint8_t NETWORK_GAME_INFO_VERSION
What version of game-info do we use?
Definition config.h:49
Debug
#define Debug(category, level, format_string,...)
Output a line of debugging information.
Definition debug.h:37
to_underlying
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
Definition enum_type.hpp:17
LandscapeType
LandscapeType
Landscape types.
Definition landscape_type.h:16
Clamp
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition math_func.hpp:79
_network_dedicated
bool _network_dedicated
are we a dedicated server?
Definition network.cpp:69
_grfconfig
GRFConfigList _grfconfig
First item in list of current GRF set up.
Definition newgrf_config.cpp:154
CopyGRFConfigList
void CopyGRFConfigList(GRFConfigList &dst, const GRFConfigList &src, bool init_only)
Copy a GRF Config list.
Definition newgrf_config.cpp:353
FindGRFConfig
const GRFConfig * FindGRFConfig(uint32_t grfid, FindGRFConfigMode mode, const MD5Hash *md5sum, uint32_t desired_version)
Find a NewGRF in the scanned list.
Definition newgrf_config.cpp:596
GCS_NOT_FOUND
@ GCS_NOT_FOUND
GRF file was not found in the local cache.
Definition newgrf_config.h:36
Copy
@ Copy
The data is copied from a grf in _all_grfs.
Definition newgrf_config.h:25
Static
@ Static
GRF file is used statically (can be used in any MP game)
Definition newgrf_config.h:23
FGCM_EXACT
@ FGCM_EXACT
Only find Grfs matching md5sum.
Definition newgrf_config.h:208
AddGRFTextToList
static void AddGRFTextToList(GRFTextList &list, uint8_t langid, std::string_view text_to_add)
Add a new text to a GRFText list.
Definition newgrf_text.cpp:478
packet.h
Basic functions to create, fill and read packets.
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:424
ClientSettings::network
NetworkSettings network
settings related to the network
Definition settings_type.h:651
GRFConfig
Information about GRF, used in the game and (part of it) in savegames.
Definition newgrf_config.h:158
GRFConfig::url
GRFTextWrapper url
NOSAVE: URL belonging to this GRF.
Definition newgrf_config.h:173
GRFConfig::info
GRFTextWrapper info
NOSAVE: GRF info (author, copyright, ...) (Action 0x08)
Definition newgrf_config.h:172
GRFConfig::name
GRFTextWrapper name
NOSAVE: GRF name (Action 0x08)
Definition newgrf_config.h:171
GRFConfig::status
GRFStatus status
NOSAVE: GRFStatus, enum.
Definition newgrf_config.h:179
GRFConfig::flags
GRFConfigFlags flags
NOSAVE: GCF_Flags, bitset.
Definition newgrf_config.h:178
GRFConfig::filename
std::string filename
Filename - either with or without full path.
Definition newgrf_config.h:170
GRFConfig::ident
GRFIdentifier ident
grfid and md5sum to uniquely identify newgrfs
Definition newgrf_config.h:168
GRFIdentifier
Basic data to distinguish a GRF.
Definition newgrf_config.h:83
GRFIdentifier::grfid
uint32_t grfid
GRF ID (defined by Action 0x08)
Definition newgrf_config.h:84
GRFIdentifier::md5sum
MD5Hash md5sum
MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF)
Definition newgrf_config.h:85
GameCreationSettings::landscape
LandscapeType landscape
the landscape we're currently in
Definition settings_type.h:395
GameCreationSettings::starting_year
TimerGameCalendar::Year starting_year
starting date
Definition settings_type.h:380
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition settings_type.h:634
Map::SizeX
static uint SizeX()
Get the size of the map along the X.
Definition map_func.h:272
Map::SizeY
static uint SizeY()
Get the size of the map along the Y.
Definition map_func.h:281
NamedGRFIdentifier
Container to hold the GRF identifier (GRF ID + MD5 checksum) and the name associated with that NewGRF...
Definition network_game_info.h:131
NamedGRFIdentifier::name
std::string name
The name of the NewGRF.
Definition network_game_info.h:133
NamedGRFIdentifier::ident
GRFIdentifier ident
The unique identifier of the NewGRF.
Definition network_game_info.h:132
NetworkGameInfo
The game information that is sent from the server to the clients with extra information only required...
Definition network_game_info.h:122
NetworkGameInfo::version_compatible
bool version_compatible
Can we connect to this server or not? (based on server_revision)
Definition network_game_info.h:123
NetworkGameInfo::compatible
bool compatible
Can we connect to this server or not? (based on server_revision and grf_match.
Definition network_game_info.h:124
NetworkServerGameInfo
The game information that is sent from the server to the client.
Definition network_game_info.h:97
NetworkServerGameInfo::calendar_start
TimerGameCalendar::Date calendar_start
When the game started.
Definition network_game_info.h:99
NetworkServerGameInfo::dedicated
bool dedicated
Is this a dedicated server?
Definition network_game_info.h:106
NetworkServerGameInfo::server_revision
std::string server_revision
The version number the server is using (e.g.: 'r304' or 0.5.0)
Definition network_game_info.h:105
NetworkServerGameInfo::use_password
bool use_password
Is this server passworded?
Definition network_game_info.h:107
NetworkServerGameInfo::clients_max
uint8_t clients_max
Max clients allowed on server.
Definition network_game_info.h:109
NetworkServerGameInfo::spectators_on
uint8_t spectators_on
How many spectators do we have?
Definition network_game_info.h:112
NetworkServerGameInfo::grfconfig
GRFConfigList grfconfig
List of NewGRF files used.
Definition network_game_info.h:98
NetworkServerGameInfo::map_height
uint16_t map_height
Map height.
Definition network_game_info.h:103
NetworkServerGameInfo::server_name
std::string server_name
Server name.
Definition network_game_info.h:104
NetworkServerGameInfo::map_width
uint16_t map_width
Map width.
Definition network_game_info.h:102
NetworkServerGameInfo::ticks_playing
TimerGameTick::TickCounter ticks_playing
Amount of ticks the game has been running unpaused.
Definition network_game_info.h:101
NetworkServerGameInfo::landscape
LandscapeType landscape
The used landscape.
Definition network_game_info.h:113
NetworkServerGameInfo::companies_max
uint8_t companies_max
Max companies allowed on server.
Definition network_game_info.h:111
NetworkServerGameInfo::gamescript_name
std::string gamescript_name
Name of the gamescript.
Definition network_game_info.h:115
NetworkServerGameInfo::calendar_date
TimerGameCalendar::Date calendar_date
Current calendar date.
Definition network_game_info.h:100
NetworkServerGameInfo::gamescript_version
int gamescript_version
Version of the gamescript.
Definition network_game_info.h:114
NetworkServerGameInfo::companies_on
uint8_t companies_on
How many started companies do we have.
Definition network_game_info.h:110
NetworkServerGameInfo::clients_on
uint8_t clients_on
Current count of clients on server.
Definition network_game_info.h:108
NetworkSettings::max_clients
uint8_t max_clients
maximum amount of clients
Definition settings_type.h:365
NetworkSettings::max_companies
uint8_t max_companies
maximum amount of companies
Definition settings_type.h:364
NetworkSettings::server_name
std::string server_name
name of the server
Definition settings_type.h:349
NetworkSettings::server_password
std::string server_password
password for joining this server
Definition settings_type.h:350
Packet
Internal entity of a packet.
Definition packet.h:43
Packet::Recv_uint16
uint16_t Recv_uint16()
Read a 16 bits integer from the packet.
Definition packet.cpp:332
Packet::Recv_bytes
size_t Recv_bytes(std::span< uint8_t > span)
Extract at most the length of the span bytes from the packet into the span.
Definition packet.cpp:403
Packet::Recv_uint64
uint64_t Recv_uint64()
Read a 64 bits integer from the packet.
Definition packet.cpp:364
Packet::Recv_bool
bool Recv_bool()
Read a boolean from the packet.
Definition packet.cpp:309
Packet::Recv_uint32
uint32_t Recv_uint32()
Read a 32 bits integer from the packet.
Definition packet.cpp:347
Packet::Send_string
void Send_string(std::string_view data)
Sends a string over the network.
Definition packet.cpp:172
Packet::Recv_string
std::string Recv_string(size_t length, StringValidationSettings settings=StringValidationSetting::ReplaceWithQuestionMark)
Reads characters (bytes) from the packet until it finds a '\0', or reaches a maximum of length charac...
Definition packet.cpp:425
Packet::Send_bool
void Send_bool(bool data)
Package a boolean in the packet.
Definition packet.cpp:111
Packet::Send_bytes
std::span< const uint8_t > Send_bytes(const std::span< const uint8_t > span)
Send as many of the bytes as possible in the packet.
Definition packet.cpp:197
Packet::Recv_uint8
uint8_t Recv_uint8()
Read a 8 bits integer from the packet.
Definition packet.cpp:318
Packet::Send_uint8
void Send_uint8(uint8_t data)
Package a 8 bits integer in the packet.
Definition packet.cpp:120
Packet::Send_uint32
void Send_uint32(uint32_t data)
Package a 32 bits integer in the packet.
Definition packet.cpp:141
Packet::Send_uint16
void Send_uint16(uint16_t data)
Package a 16 bits integer in the packet.
Definition packet.cpp:130
Packet::Send_uint64
void Send_uint64(uint64_t data)
Package a 64 bits integer in the packet.
Definition packet.cpp:154
Pool::PoolItem<&_company_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition pool_type.hpp:417
StrongType::Typedef
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition strong_typedef_type.hpp:130