# 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 "../window_func.h"`
`#include "../gui.h"`
`#include "../variables.h"`
`#include "../base_media_base.h"`
`#include "../settings_type.h"`
`#include "network_content.h"`
`#include "table/strings.h"`
`#include <zlib.h>`

Go to the source code of this file.

## Data Structures
class | NetworkContentConnecter
## Defines
#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.
## Functions
bool | HasScenario (const ContentInfo *ci, bool md5sum)
| Check whether we've got a given scenario based on it's unique ID.
static bool | HasGRFConfig (const ContentInfo *ci, bool md5sum)
| Wrapper function for the HasProc.
| DEF_CONTENT_RECEIVE_COMMAND (Client, PACKET_CONTENT_SERVER_INFO)
static char * | GetFullFilename (const ContentInfo *ci, bool compressed)
| Determine the full filename of a piece of content information.
static bool | GunzipFile (const ContentInfo *ci)
| Gunzip a given file and remove the .gz if successful.
| DEF_CONTENT_RECEIVE_COMMAND (Client, PACKET_CONTENT_SERVER_CONTENT)
## Variables
ClientNetworkContentSocketHandler | _network_content_client

## Detailed Description

Content sending/receiving part of the network protocol.

Definition in file network_content.cpp.

## Typedef Documentation

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:

  | ci | the content info to search for
  | md5sum | also match the MD5 checksum?

Returns:
  true iff it's known

Definition at line 46 of file network_content.cpp.

## Function Documentation

static char* GetFullFilename | ( | const ContentInfo * | ci,
|  | bool | compressed |
| ) |  |  | `[static]`

Determine the full filename of a piece of content information.

Parameters:

  | ci | the information to get the filename from
  | compressed | should the filename end with .gz?

Returns:
  a statically allocated buffer with the filename or NULL when no filename could be made.

Definition at line 338 of file network_content.cpp.

References AI_DIR, AI_LIBRARY_DIR, CONTENT_TYPE_AI, CONTENT_TYPE_AI_LIBRARY, CONTENT_TYPE_BASE_GRAPHICS, CONTENT_TYPE_BASE_MUSIC, CONTENT_TYPE_BASE_SOUNDS, CONTENT_TYPE_HEIGHTMAP, CONTENT_TYPE_NEWGRF, CONTENT_TYPE_SCENARIO, DATA_DIR, ContentInfo::filename, GM_DIR, HEIGHTMAP_DIR, lastof, lengthof, SCENARIO_DIR, SP_AUTODOWNLOAD_DIR, strecat(), and ContentInfo::type.

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

static bool GunzipFile | ( | const ContentInfo * | ci | ) | `[static]`

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

Parameters:

  | ci | container with filename

Returns:
  true if the gunzip completed

Definition at line 365 of file network_content.cpp.

References GetFullFilename().

Referenced by ClientNetworkContentSocketHandler::AfterDownload().

bool HasScenario | ( | const ContentInfo * | ci,
|  | bool | md5sum |
| ) |  |  |

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

Parameters:

  | ci | the content info to compare it to
  | md5sum | whether to look at the md5sum or the id

Returns:
  true if we've got the scenario

Definition at line 617 of file fios.cpp.

References SmallVector< T, S >::Begin(), SmallVector< T, S >::End(), ContentInfo::md5sum, ScenarioScanner::Scan(), and ContentInfo::unique_id.