OpenTTD Source  1.11.2
game_info.cpp File Reference
#include "../../stdafx.h"
#include "game_info.h"
#include "../../core/bitmath_func.hpp"
#include "../../company_base.h"
#include "../../date_func.h"
#include "../../debug.h"
#include "../../map_func.h"
#include "../../settings_type.h"
#include "../../string_func.h"
#include "../../rev.h"
#include "../network_func.h"
#include "../network.h"
#include "packet.h"
#include "../../safeguards.h"

Go to the source code of this file.

Functions

const char * GetNetworkRevisionString ()
 Get the network version string used by this build. More...
 
static const char * ExtractNetworkRevisionHash (const char *revstr)
 Extract the git hash from the revision string. More...
 
bool IsNetworkCompatibleVersion (const char *other)
 Checks whether the given version string is compatible with our version. More...
 
void FillNetworkGameInfo (NetworkGameInfo &ngi)
 Fill a NetworkGameInfo structure with the latest information of the server. More...
 
static void HandleIncomingNetworkGameInfoGRFConfig (GRFConfig *config)
 Function that is called for every GRFConfig that is read when receiving a NetworkGameInfo. More...
 
void SerializeNetworkGameInfo (Packet *p, const NetworkGameInfo *info)
 Serializes the NetworkGameInfo struct to the packet. More...
 
void DeserializeNetworkGameInfo (Packet *p, NetworkGameInfo *info)
 Deserializes the NetworkGameInfo struct from the packet. More...
 
void SerializeGRFIdentifier (Packet *p, const GRFIdentifier *grf)
 Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet. More...
 
void DeserializeGRFIdentifier (Packet *p, GRFIdentifier *grf)
 Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet. More...
 

Variables

static const uint GITHASH_SUFFIX_LEN = 12
 How many hex digits of the git hash to include in network revision string. More...
 
NetworkServerGameInfo _network_game_info
 Information about our game.
 

Detailed Description

Functions to convert NetworkGameInfo to Packet and back.

Definition in file game_info.cpp.

Function Documentation

◆ DeserializeGRFIdentifier()

void DeserializeGRFIdentifier ( Packet p,
GRFIdentifier grf 
)

◆ DeserializeNetworkGameInfo()

◆ ExtractNetworkRevisionHash()

static const char* ExtractNetworkRevisionHash ( const char *  revstr)
static

Extract the git hash from the revision string.

Parameters
revstrThe revision string (formatted as DATE-BRANCH-GITHASH).
Returns
The git has part of the revision.

Definition at line 85 of file game_info.cpp.

◆ FillNetworkGameInfo()

◆ GetNetworkRevisionString()

const char* GetNetworkRevisionString ( )

Get the network version string used by this build.

The returned string is guaranteed to be at most NETWORK_REVISON_LENGTH bytes.

Definition at line 41 of file game_info.cpp.

References stredup().

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

◆ HandleIncomingNetworkGameInfoGRFConfig()

static void HandleIncomingNetworkGameInfoGRFConfig ( GRFConfig config)
static

Function that is called for every GRFConfig that is read when receiving a NetworkGameInfo.

Only grfid and md5sum are set, the rest is zero. This function must set all appropriate fields. This GRF is later appended to the grfconfig list of the NetworkGameInfo.

Parameters
configthe GRF to handle.

Definition at line 145 of file game_info.cpp.

References FGCM_EXACT, GRFConfig::filename, FindGRFConfig(), FindUnknownGRFName(), GRFConfig::flags, GCF_COPY, GCS_NOT_FOUND, GRFIdentifier::grfid, GRFConfig::ident, GRFConfig::info, GRFIdentifier::md5sum, GRFConfig::name, SetBit(), GRFConfig::status, and GRFConfig::url.

Referenced by DeserializeNetworkGameInfo().

◆ IsNetworkCompatibleVersion()

bool IsNetworkCompatibleVersion ( const char *  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 95 of file game_info.cpp.

References GetNetworkRevisionString(), and NETWORK_REVISION_LENGTH.

Referenced by ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE().

◆ SerializeGRFIdentifier()

void SerializeGRFIdentifier ( Packet p,
const GRFIdentifier grf 
)

◆ SerializeNetworkGameInfo()

Variable Documentation

◆ GITHASH_SUFFIX_LEN

const uint GITHASH_SUFFIX_LEN = 12
static

How many hex digits of the git hash to include in network revision string.

Determined as 10 hex digits + 2 characters for -g/-u/-m prefix.

Definition at line 33 of file game_info.cpp.