OpenTTD Source 20250520-master-gecadf1b322
|
Information about a single base set. More...
#include <base_media_base.h>
Public Types | |
typedef std::unordered_map< std::string, std::string, StringHash, std::equal_to<> > | TranslatedStrings |
Public Member Functions | |
~BaseSet () | |
Free everything we allocated. | |
int | GetNumMissing () const |
Get the number of missing files. | |
int | GetNumInvalid () const |
Get the number of invalid files. | |
void | LogError (std::string_view full_filename, std::string_view detail, int level=0) const |
Log error from reading basesets. | |
const IniItem * | GetMandatoryItem (std::string_view full_filename, const IniGroup &group, std::string_view name) const |
Try to read a single piece of metadata and return nullptr if it doesn't exist. | |
bool | FillSetDetails (const IniFile &ini, const std::string &path, const std::string &full_filename, bool allow_empty_filename=true) |
Read the set information from a loaded ini. | |
void | CopyCompatibleConfig (const T &src) |
const std::string & | GetDescription (std::string_view isocode) const |
Get the description for the given ISO code. | |
std::optional< std::string > | GetTextfile (TextfileType type) const |
Search a textfile file next to this base media. | |
Static Public Member Functions | |
static MD5File::ChecksumResult | CheckMD5 (const MD5File *file, Subdirectory subdir) |
Calculate and check the MD5 hash of the supplied file. | |
static std::span< const std::string_view > | GetFilenames () |
Get the internal names of the files in this set. | |
Data Fields | |
std::string | name |
The name of the base set. | |
std::string | url |
URL for information about the base set. | |
TranslatedStrings | description |
Description of the base set. | |
uint32_t | shortname = 0 |
Four letter short variant of the name. | |
std::vector< uint32_t > | version |
The version of this base set. | |
bool | fallback = false |
This set is a fallback set, i.e. it should be used only as last resort. | |
std::array< MD5File, BaseSet< T >::NUM_FILES > | files {} |
All files part of this set. | |
uint | found_files = 0 |
Number of the files that could be found. | |
uint | valid_files = 0 |
Number of the files that could be found and are valid. | |
T * | next = nullptr |
The next base set in this list. | |
Static Public Attributes | |
static constexpr size_t | NUM_FILES = BaseSetTraits<T>::num_files |
Number of files in this set. | |
static constexpr bool | SEARCH_IN_TARS = BaseSetTraits<T>::search_in_tars |
Whether to search in the tars or not. | |
static constexpr std::string_view | SET_TYPE = BaseSetTraits<T>::set_type |
BaseSet type name. | |
Information about a single base set.
T | the real class we're going to be |
Definition at line 50 of file base_media_base.h.
typedef std::unordered_map<std::string, std::string, StringHash, std::equal_to<> > BaseSet< T >::TranslatedStrings |
Definition at line 51 of file base_media_base.h.
Free everything we allocated.
Definition at line 76 of file base_media_base.h.
References BaseSet< T >::next.
|
inlinestatic |
Calculate and check the MD5 hash of the supplied file.
file | The file get the hash of. |
subdir | The sub directory to get the files from. |
Definition at line 138 of file base_media_base.h.
References MD5File::CheckMD5().
|
inline |
Definition at line 104 of file base_media_base.h.
bool BaseSet< T >::FillSetDetails | ( | const IniFile & | ini, |
const std::string & | path, | ||
const std::string & | full_filename, | ||
bool | allow_empty_filename = true |
||
) |
Read the set information from a loaded ini.
ini | the ini to read from |
path | the path to this ini file (for filenames) |
full_filename | the full filename of the loaded file (for error reporting purposes) |
allow_empty_filename | empty filenames are valid |
Definition at line 60 of file base_media_func.h.
References IniLoadFile::GetGroup(), IniGroup::GetItem(), IniGroup::items, and IniItem::value.
|
inline |
Get the description for the given ISO code.
It falls back to the first two characters of the ISO code in case no match could be made with the full ISO code. If even then the matching fails the default is returned.
isocode | the isocode to search for |
Definition at line 114 of file base_media_base.h.
|
static |
Get the internal names of the files in this set.
const IniItem * BaseSet< T >::GetMandatoryItem | ( | std::string_view | full_filename, |
const IniGroup & | group, | ||
std::string_view | name | ||
) | const |
Try to read a single piece of metadata and return nullptr if it doesn't exist.
Log error, if the data is missing.
full_filename | the full filename of the loaded file (for error reporting purposes) |
group | ini group to read from |
name | the name of the item to fetch. |
Definition at line 43 of file base_media_func.h.
References IniGroup::GetItem(), and IniGroup::name.
|
inline |
Get the number of invalid files.
Definition at line 95 of file base_media_base.h.
References BaseSet< T >::valid_files.
Referenced by CheckExternalFiles().
|
inline |
Get the number of missing files.
Definition at line 85 of file base_media_base.h.
References BaseSet< T >::found_files.
|
inline |
Search a textfile file next to this base media.
type | The type of the textfile to search for. |
Definition at line 148 of file base_media_base.h.
References BASESET_DIR, BaseSet< T >::files, and BaseSet< T >::GetTextfile().
Referenced by BaseSet< T >::GetTextfile().
void BaseSet< T >::LogError | ( | std::string_view | full_filename, |
std::string_view | detail, | ||
int | level = 0 |
||
) | const |
Log error from reading basesets.
full_filename | the full filename of the loaded file |
detail | detail log message |
level | debug level |
Definition at line 29 of file base_media_func.h.
References Debug.
TranslatedStrings BaseSet< T >::description |
Description of the base set.
Definition at line 64 of file base_media_base.h.
bool BaseSet< T >::fallback = false |
This set is a fallback set, i.e. it should be used only as last resort.
Definition at line 67 of file base_media_base.h.
std::array<MD5File, BaseSet<T>::NUM_FILES> BaseSet< T >::files {} |
All files part of this set.
Definition at line 69 of file base_media_base.h.
Referenced by CheckExternalFiles(), BaseSet< T >::GetTextfile(), and LoadSpriteTables().
uint BaseSet< T >::found_files = 0 |
Number of the files that could be found.
Definition at line 70 of file base_media_base.h.
Referenced by BaseSet< T >::GetNumMissing().
std::string BaseSet< T >::name |
The name of the base set.
Definition at line 62 of file base_media_base.h.
Referenced by CheckExternalFiles(), and GraphicsSetSaveConfig().
T* BaseSet< T >::next = nullptr |
The next base set in this list.
Definition at line 73 of file base_media_base.h.
Referenced by BaseSet< T >::~BaseSet().
|
staticconstexpr |
Number of files in this set.
Definition at line 54 of file base_media_base.h.
|
staticconstexpr |
Whether to search in the tars or not.
Definition at line 57 of file base_media_base.h.
|
staticconstexpr |
BaseSet type name.
Definition at line 60 of file base_media_base.h.
uint32_t BaseSet< T >::shortname = 0 |
Four letter short variant of the name.
Definition at line 65 of file base_media_base.h.
Referenced by GraphicsSetSaveConfig().
std::string BaseSet< T >::url |
URL for information about the base set.
Definition at line 63 of file base_media_base.h.
uint BaseSet< T >::valid_files = 0 |
Number of the files that could be found and are valid.
Definition at line 71 of file base_media_base.h.
Referenced by BaseSet< T >::GetNumInvalid().
std::vector<uint32_t> BaseSet< T >::version |
The version of this base set.
Definition at line 66 of file base_media_base.h.