OpenTTD Source  12.0-beta2
game_info.h File Reference
#include "config.h"
#include "core.h"
#include "../../newgrf_config.h"
#include "../../date_type.h"
#include <unordered_map>

Go to the source code of this file.

Data Structures

struct  NetworkServerGameInfo
 The game information that is sent from the server to the client. More...
 
struct  NetworkGameInfo
 The game information that is sent from the server to the clients with extra information only required at the client side. More...
 
struct  NamedGRFIdentifier
 Container to hold the GRF identifier (GRF ID + MD5 checksum) and the name associated with that NewGRF. More...
 

Typedefs

typedef std::unordered_map< uint32, NamedGRFIdentifierGameInfoNewGRFLookupTable
 Lookup table for the GameInfo in case of NST_LOOKUP_ID.
 

Enumerations

enum  NewGRFSerializationType { NST_GRFID_MD5 = 0, NST_GRFID_MD5_NAME = 1, NST_LOOKUP_ID = 2, NST_END }
 The different types/ways a NewGRF can be serialized in the GameInfo since version 6. More...
 

Functions

std::string_view GetNetworkRevisionString ()
 Get the network version string used by this build. More...
 
bool IsNetworkCompatibleVersion (std::string_view other)
 Checks whether the given version string is compatible with our version. More...
 
void CheckGameCompatibility (NetworkGameInfo &ngi)
 Check if an game entry is compatible with our client.
 
void FillStaticNetworkServerGameInfo ()
 Fill a NetworkServerGameInfo structure with the static content, or things that are so static they can be updated on request from a settings change.
 
const NetworkServerGameInfoGetCurrentNetworkServerGameInfo ()
 Get the NetworkServerGameInfo structure with the latest information of the server. More...
 
void DeserializeGRFIdentifier (Packet *p, GRFIdentifier *grf)
 Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet. More...
 
void DeserializeGRFIdentifierWithName (Packet *p, NamedGRFIdentifier *grf)
 Deserializes the NamedGRFIdentifier (GRF ID, MD5 checksum and name) from the packet. More...
 
void SerializeGRFIdentifier (Packet *p, const GRFIdentifier *grf)
 Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet. More...
 
void DeserializeNetworkGameInfo (Packet *p, NetworkGameInfo *info, const GameInfoNewGRFLookupTable *newgrf_lookup_table=nullptr)
 Deserializes the NetworkGameInfo struct from the packet. More...
 
void SerializeNetworkGameInfo (Packet *p, const NetworkServerGameInfo *info, bool send_newgrf_names=true)
 Serializes the NetworkGameInfo struct to the packet. More...
 

Variables

NetworkServerGameInfo _network_game_info
 Information about our game.
 

Detailed Description

Convert NetworkGameInfo to Packet and back.

Definition in file game_info.h.

Enumeration Type Documentation

◆ NewGRFSerializationType

The different types/ways a NewGRF can be serialized in the GameInfo since version 6.

Enumerator
NST_GRFID_MD5 

Unique GRF ID and MD5 checksum.

NST_GRFID_MD5_NAME 

Unique GRF ID, MD5 checksum and name.

NST_LOOKUP_ID 

Unique ID into a lookup table that is sent before.

NST_END 

The end of the list (period).

Definition at line 83 of file game_info.h.

Function Documentation

◆ DeserializeGRFIdentifier()

void DeserializeGRFIdentifier ( Packet p,
GRFIdentifier grf 
)

Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet.

Parameters
pthe packet to read the data from.
grfthe GRFIdentifier to deserialize.

Definition at line 377 of file game_info.cpp.

References GRFIdentifier::grfid, GRFIdentifier::md5sum, Packet::Recv_uint32(), and Packet::Recv_uint8().

Referenced by DeserializeGRFIdentifierWithName(), DeserializeNetworkGameInfo(), and ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS().

◆ DeserializeGRFIdentifierWithName()

void DeserializeGRFIdentifierWithName ( Packet p,
NamedGRFIdentifier grf 
)

Deserializes the NamedGRFIdentifier (GRF ID, MD5 checksum and name) from the packet.

Parameters
pthe packet to read the data from.
grfthe NamedGRFIdentifier to deserialize.

Definition at line 391 of file game_info.cpp.

References DeserializeGRFIdentifier(), NamedGRFIdentifier::ident, NamedGRFIdentifier::name, NETWORK_GRF_NAME_LENGTH, and Packet::Recv_string().

Referenced by DeserializeNetworkGameInfo(), and ClientNetworkCoordinatorSocketHandler::Receive_GC_NEWGRF_LOOKUP().

◆ DeserializeNetworkGameInfo()

◆ GetCurrentNetworkServerGameInfo()

const NetworkServerGameInfo* GetCurrentNetworkServerGameInfo ( )

Get the NetworkServerGameInfo structure with the latest information of the server.

Returns
The current NetworkServerGameInfo.

Definition at line 143 of file game_info.cpp.

References _network_game_info, and NetworkServerGameInfo::companies_on.

Referenced by ServerNetworkGameSocketHandler::SendGameInfo(), and ClientNetworkCoordinatorSocketHandler::SendServerUpdate().

◆ GetNetworkRevisionString()

std::string_view GetNetworkRevisionString ( )

Get the network version string used by this build.

The returned string is guaranteed to be at most NETWORK_REVISON_LENGTH bytes including '\0' terminator.

Definition at line 43 of file game_info.cpp.

Referenced by FillStaticNetworkServerGameInfo(), IsNetworkCompatibleVersion(), NetworkHTTPSocketHandler::NetworkHTTPSocketHandler(), and ServerNetworkAdminSocketHandler::SendWelcome().

◆ IsNetworkCompatibleVersion()

bool IsNetworkCompatibleVersion ( std::string_view  other)

Checks whether the given version string is compatible with our version.

First tries to match the full string, if that fails, attempts to compare just git hashes.

Parameters
otherthe version string to compare to

Definition at line 90 of file game_info.cpp.

References GetNetworkRevisionString().

Referenced by CheckGameCompatibility().

◆ SerializeGRFIdentifier()

void SerializeGRFIdentifier ( Packet p,
const GRFIdentifier grf 
)

Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet.

Parameters
pthe packet to write the data to.
grfthe GRFIdentifier to serialize.

Definition at line 363 of file game_info.cpp.

References GRFIdentifier::grfid, GRFIdentifier::md5sum, Packet::Send_uint32(), and Packet::Send_uint8().

Referenced by ServerNetworkGameSocketHandler::SendNewGRFCheck(), and SerializeNetworkGameInfo().

◆ SerializeNetworkGameInfo()