OpenTTD
Data Structures | Macros | Typedefs | Functions | Variables
network_content.cpp File Reference

Content sending/receiving part of the network protocol. More...

#include "../stdafx.h"
#include "../rev.h"
#include "../ai/ai.hpp"
#include "../game/game.hpp"
#include "../window_func.h"
#include "../error.h"
#include "../base_media_base.h"
#include "../settings_type.h"
#include "network_content.h"
#include "table/strings.h"
#include <zlib.h>
#include "../safeguards.h"

Go to the source code of this file.

Data Structures

class  NetworkContentConnecter
 Connect to the content server. More...
 

Macros

#define check_not_null(p)   { if ((p) == NULL) { this->OnFailure(); return; } }
 
#define check_and_terminate(p)   { check_not_null(p); *(p) = '\0'; }
 

Typedefs

typedef bool(* HasProc) (const ContentInfo *ci, bool md5sum)
 Check whether a function piece of content is locally known. More...
 

Functions

bool HasScenario (const ContentInfo *ci, bool md5sum)
 Check whether we've got a given scenario based on its unique ID. More...
 
static bool HasGRFConfig (const ContentInfo *ci, bool md5sum)
 Wrapper function for the HasProc.
 
static char * GetFullFilename (const ContentInfo *ci, bool compressed)
 Determine the full filename of a piece of content information. More...
 
static bool GunzipFile (const ContentInfo *ci)
 Gunzip a given file and remove the .gz if successful. More...
 

Variables

ClientNetworkContentSocketHandler _network_content_client
 The client we use to connect to the server. More...
 

Detailed Description

Content sending/receiving part of the network protocol.

Definition in file network_content.cpp.

Typedef Documentation

◆ HasProc

typedef bool(* HasProc) (const ContentInfo *ci, bool md5sum)

Check whether a function piece of content is locally known.

Matches on the unique ID and possibly the MD5 checksum.

Parameters
cithe content info to search for
md5sumalso match the MD5 checksum?
Returns
true iff it's known

Definition at line 50 of file network_content.cpp.

Function Documentation

◆ GetFullFilename()

static char* GetFullFilename ( const ContentInfo ci,
bool  compressed 
)
static

Determine the full filename of a piece of content information.

Parameters
cithe information to get the filename from
compressedshould the filename end with .gz?
Returns
a statically allocated buffer with the filename or NULL when no filename could be made.

Definition at line 386 of file network_content.cpp.

References PacketReader::buf, GetContentInfoSubDir(), NO_DIRECTORY, and ContentInfo::type.

Referenced by ClientNetworkContentSocketHandler::AfterDownload(), and ClientNetworkContentSocketHandler::BeforeDownload().

◆ GunzipFile()

static bool GunzipFile ( const ContentInfo ci)
static

Gunzip a given file and remove the .gz if successful.

Parameters
cicontainer with filename
Returns
true if the gunzip completed

Definition at line 403 of file network_content.cpp.

Referenced by ClientNetworkContentSocketHandler::AfterDownload().

◆ HasScenario()

bool HasScenario ( const ContentInfo ci,
bool  md5sum 
)

Check whether we've got a given scenario based on its unique ID.

Parameters
ciThe content info to compare it to.
md5sumWhether to look at the md5sum or the id.
Returns
True iff we've got the scenario.

Definition at line 766 of file fios.cpp.

References FindScenario().

Referenced by ClientNetworkContentSocketHandler::Receive_SERVER_INFO().

Variable Documentation

◆ _network_content_client

ClientNetworkContentSocketHandler _network_content_client