OpenTTD Source 20241224-master-gee860a5c8e
|
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 "../fileio_func.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) == nullptr) { 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 its unique ID. | |
static bool | HasGRFConfig (const ContentInfo *ci, bool md5sum) |
Wrapper function for the HasProc. | |
static std::string | 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. | |
static ssize_t | TransferOutFWrite (std::optional< FileHandle > &file, const char *buffer, size_t amount) |
Simple wrapper around fwrite to be able to pass it to Packet's TransferOut. | |
Variables | |
ClientNetworkContentSocketHandler | _network_content_client |
The client we use to connect to the server. | |
Content sending/receiving part of the network protocol.
Definition in file network_content.cpp.
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.
ci | the content info to search for |
md5sum | also match the MD5 checksum? |
Definition at line 51 of file network_content.cpp.
|
static |
Determine the full filename of a piece of content information.
ci | the information to get the filename from |
compressed | should the filename end with .gz? |
Definition at line 384 of file network_content.cpp.
References ContentInfo::filename, GetContentInfoSubDir(), NO_DIRECTORY, SP_AUTODOWNLOAD_DIR, and ContentInfo::type.
Referenced by ClientNetworkContentSocketHandler::AfterDownload(), ClientNetworkContentSocketHandler::BeforeDownload(), and GunzipFile().
|
static |
Gunzip a given file and remove the .gz if successful.
ci | container with filename |
Definition at line 401 of file network_content.cpp.
References GetFullFilename(), and FileHandle::Open().
Referenced by ClientNetworkContentSocketHandler::AfterDownload().
|
static |
Wrapper function for the HasProc.
Definition at line 39 of file network_content.cpp.
References BSWAP32(), FGCM_ANY, FGCM_EXACT, FindGRFConfig(), ContentInfo::md5sum, and ContentInfo::unique_id.
Referenced by ClientNetworkContentSocketHandler::Receive_SERVER_INFO().
|
extern |
Check whether we've got a given scenario based on its unique ID.
ci | The content info to compare it to. |
md5sum | Whether to look at the md5sum or the id. |
Definition at line 710 of file fios.cpp.
References FindScenario().
Referenced by ClientNetworkContentSocketHandler::Receive_SERVER_INFO().
|
inlinestatic |
Simple wrapper around fwrite to be able to pass it to Packet's TransferOut.
file | The file to write data to. |
buffer | The buffer to write to the file. |
amount | The number of bytes to write. |
Definition at line 470 of file network_content.cpp.
Referenced by ClientNetworkContentSocketHandler::Receive_SERVER_CONTENT().
ClientNetworkContentSocketHandler _network_content_client |
The client we use to connect to the server.
Definition at line 36 of file network_content.cpp.
Referenced by BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow(), BootstrapAskForDownloadWindow::BootstrapAskForDownloadWindow(), NetworkContentListWindow::BuildContentList(), BootstrapAskForDownloadWindow::Close(), NetworkContentListWindow::Close(), BaseNetworkContentDownloadStatusWindow::Close(), NetworkContentListWindow::DrawDetails(), NetworkBackgroundLoop(), NetworkContentListWindow::NetworkContentListWindow(), BootstrapAskForDownloadWindow::OnClick(), NetworkContentDownloadStatusWindow::OnClick(), NetworkContentListWindow::OnClick(), BootstrapAskForDownloadWindow::OnConnect(), NetworkContentConnecter::OnConnect(), NetworkContentConnecter::OnFailure(), NetworkContentListWindow::OnKeyPress(), BootstrapAskForDownloadWindow::OnReceiveContentInfo(), NetworkContentListWindow::OnReceiveContentInfo(), and ShowNetworkContentListWindow().