OpenTTD Source  20241108-master-g80f628063a
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. More...
 
#define INSTANTIATE_BASE_MEDIA_METHODS(repl_type, set_type)
 Force instantiation of methods so we don't get linker errors. More...
 

Functions

void CheckExternalFiles ()
 Checks whether the MD5 checksums of the files are correct. More...
 
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. More...
 

Detailed Description

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

Note
You should never include this file due to the SET_TYPE define.

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_TYPE "set detail loading: {} field missing.", name); \
Debug(grf, 0, " Is {} readable for the user running OpenTTD?", full_filename); \
return false; \
}
#define SET_TYPE
The type of set we're replacing.
Definition: music.cpp:15

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 25 of file base_media_func.h.

◆ INSTANTIATE_BASE_MEDIA_METHODS

#define INSTANTIATE_BASE_MEDIA_METHODS (   repl_type,
  set_type 
)
Value:
template const char *repl_type::GetExtension(); \
template bool repl_type::AddFile(const std::string &filename, size_t pathlength, const std::string &tar_filename); \
template bool repl_type::HasSet(const struct ContentInfo *ci, bool md5sum); \
template bool repl_type::SetSet(const set_type *set); \
template bool repl_type::SetSetByName(const std::string &name); \
template bool repl_type::SetSetByShortname(uint32_t shortname); \
template void repl_type::GetSetsList(std::back_insert_iterator<std::string> &output_iterator); \
template int repl_type::GetNumSets(); \
template int repl_type::GetIndexOfUsedSet(); \
template const set_type *repl_type::GetSet(int index); \
template const set_type *repl_type::GetUsedSet(); \
template bool repl_type::DetermineBestSet(); \
template set_type *repl_type::GetAvailableSets(); \
template const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const set_type *s);
const char * TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s)
Check whether there's a base set matching some information.
Container for all important information about a piece of content.

Force instantiation of methods so we don't get linker errors.

Parameters
repl_typethe type of the BaseMedia to instantiate
set_typethe type of the BaseSet to instantiate

Definition at line 414 of file base_media_func.h.

Function Documentation

◆ CheckExternalFiles()

◆ 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 319 of file base_media_func.h.

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

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