OpenTTD Source 15.0-beta2
base_media_func.h File Reference

Generic function implementations for base data (graphics, sounds). More...

#include "base_media_base.h"
#include "debug.h"
#include "ini_type.h"
#include "string_func.h"
#include "error_func.h"
#include "network/core/tcp_content_type.h"

Go to the source code of this file.

Macros

#define fetch_metadata(name)
 Try to read a single piece of metadata and return false if it doesn't exist.
 

Functions

void CheckExternalFiles ()
 Checks whether the MD5 checksums of the files are correct.
 
template<class Tbase_set >
const char * TryGetBaseSetFile (const ContentInfo &ci, bool md5sum, const Tbase_set *s)
 Check whether there's a base set matching some information.
 

Detailed Description

Generic function implementations for base data (graphics, sounds).

Definition in file base_media_func.h.

Macro Definition Documentation

◆ fetch_metadata

#define fetch_metadata (   name)
Value:
item = metadata->GetItem(name); \
if (item == nullptr || !item->value.has_value() || item->value->empty()) { \
Debug(grf, 0, "Base {}set detail loading: {} field missing.", BaseSet::SET_TYPE, name); \
Debug(grf, 0, " Is {} readable for the user running OpenTTD?", full_filename); \
return false; \
}
static constexpr std::string_view SET_TYPE
BaseSet type name.

Try to read a single piece of metadata and return false if it doesn't exist.

Parameters
namethe name of the item to fetch.

Definition at line 24 of file base_media_func.h.

Function Documentation

◆ CheckExternalFiles()

void CheckExternalFiles ( )
extern

Checks whether the MD5 checksums of the files are correct.

Note
Also checks sample.cat and other required non-NewGRF GRFs for corruption.

Definition at line 113 of file gfxinit.cpp.

References BASESET_DIR, BaseSet< SoundsSet >::CheckMD5(), GraphicsSet::CheckMD5(), MD5File::CR_MATCH, MD5File::CR_MISMATCH, Debug, BaseSet< T >::files, BaseSet< T >::GetNumInvalid(), BaseMedia< SoundsSet >::GetUsedSet(), BaseMedia< GraphicsSet >::GetUsedSet(), BaseSet< T >::name, and BaseSet< SoundsSet >::NUM_FILES.

Referenced by BaseMedia< Tbase_set >::SetSet().

◆ TryGetBaseSetFile()

template<class Tbase_set >
const char * TryGetBaseSetFile ( const ContentInfo &  ci,
bool  md5sum,
const Tbase_set *  s 
)

Check whether there's a base set matching some information.

Parameters
ciThe content info to compare it to.
md5sumShould the MD5 checksum be tested as well?
sThe list with sets.
Returns
The filename of the first file of the base set, or nullptr if there is no match.

Definition at line 322 of file base_media_func.h.

References MD5File::hash, ContentInfo::md5sum, and ContentInfo::unique_id.

Referenced by ContentInfo::GetTextfile(), and BaseMedia< Tbase_set >::HasSet().