OpenTTD Source 20260108-master-g8ba1860eaa
network_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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
72#ifndef NETWORK_CORE_GAME_INFO_H
73#define NETWORK_CORE_GAME_INFO_H
74
75#include "config.h"
76#include "core.h"
77#include "../../newgrf_config.h"
78#include "../../timer/timer_game_calendar.h"
79#include "../../timer/timer_game_tick.h"
80#include "../../landscape_type.h"
81
82#include <unordered_map>
83
91
115
124
134typedef std::unordered_map<uint32_t, NamedGRFIdentifier> GameInfoNewGRFLookupTable;
135
137
138std::string_view GetNetworkRevisionString();
139bool IsNetworkCompatibleVersion(std::string_view other);
141
144
147void SerializeGRFIdentifier(Packet &p, const GRFIdentifier &grf);
148
149void DeserializeNetworkGameInfo(Packet &p, NetworkGameInfo &info, const GameInfoNewGRFLookupTable *newgrf_lookup_table = nullptr);
150void SerializeNetworkGameInfo(Packet &p, const NetworkServerGameInfo &info, bool send_newgrf_names = true);
151
152#endif /* NETWORK_CORE_GAME_INFO_H */
uint64_t TickCounter
The type that the tick counter is stored in.
Configuration options of the network stuff.
Base for all network types (UDP and TCP).
LandscapeType
Landscape types.
std::string_view GetNetworkRevisionString()
Get the network version string used by this build.
void CheckGameCompatibility(NetworkGameInfo &ngi)
Check if an game entry is compatible with our client.
void DeserializeGRFIdentifier(Packet &p, GRFIdentifier &grf)
Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet.
void SerializeNetworkGameInfo(Packet &p, const NetworkServerGameInfo &info, bool send_newgrf_names=true)
Serializes the NetworkGameInfo struct to the packet.
std::unordered_map< uint32_t, NamedGRFIdentifier > GameInfoNewGRFLookupTable
Lookup table for the GameInfo in case of NST_LOOKUP_ID.
const NetworkServerGameInfo & GetCurrentNetworkServerGameInfo()
Get the NetworkServerGameInfo structure with the latest information of the server.
void SerializeGRFIdentifier(Packet &p, const GRFIdentifier &grf)
Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet.
void FillStaticNetworkServerGameInfo()
Fill a NetworkServerGameInfo structure with the static content, or things that are so static they can...
void DeserializeNetworkGameInfo(Packet &p, NetworkGameInfo &info, const GameInfoNewGRFLookupTable *newgrf_lookup_table=nullptr)
Deserializes the NetworkGameInfo struct from the packet.
NewGRFSerializationType
The different types/ways a NewGRF can be serialized in the GameInfo since version 6.
@ NST_LOOKUP_ID
Unique ID into a lookup table that is sent before.
@ NST_END
The end of the list (period).
@ NST_GRFID_MD5_NAME
Unique GRF ID, MD5 checksum and name.
@ NST_GRFID_MD5
Unique GRF ID and MD5 checksum.
void DeserializeGRFIdentifierWithName(Packet &p, NamedGRFIdentifier &grf)
Deserializes the NamedGRFIdentifier (GRF ID, MD5 checksum and name) from the packet.
NetworkServerGameInfo _network_game_info
Information about our game.
bool IsNetworkCompatibleVersion(std::string_view other)
Checks whether the given version string is compatible with our version.
Basic data to distinguish a GRF.
Container to hold the GRF identifier (GRF ID + MD5 checksum) and the name associated with that NewGRF...
std::string name
The name of the NewGRF.
GRFIdentifier ident
The unique identifier of the NewGRF.
The game information that is sent from the server to the clients with extra information only required...
bool version_compatible
Can we connect to this server or not? (based on server_revision)
bool compatible
Can we connect to this server or not? (based on server_revision and grf_match.
The game information that is sent from the server to the client.
TimerGameCalendar::Date calendar_start
When the game started.
bool dedicated
Is this a dedicated server?
std::string server_revision
The version number the server is using (e.g.: 'r304' or 0.5.0)
bool use_password
Is this server passworded?
uint8_t clients_max
Max clients allowed on server.
uint8_t spectators_on
How many spectators do we have?
GRFConfigList grfconfig
List of NewGRF files used.
uint16_t map_height
Map height.
std::string server_name
Server name.
uint16_t map_width
Map width.
TimerGameTick::TickCounter ticks_playing
Amount of ticks the game has been running unpaused.
LandscapeType landscape
The used landscape.
uint8_t companies_max
Max companies allowed on server.
std::string gamescript_name
Name of the gamescript.
TimerGameCalendar::Date calendar_date
Current calendar date.
int gamescript_version
Version of the gamescript.
uint8_t companies_on
How many started companies do we have.
uint8_t clients_on
Current count of clients on server.
Internal entity of a packet.
Definition packet.h:41
Templated helper to make a type-safe 'typedef' representing a single POD value.