OpenTTD Source 20241224-master-gf74b0cf984
BaseSet< T, Tnum_files, Tsearch_in_tars > Struct Template Reference

Information about a single base set. More...

#include <base_media_base.h>

Public Types

typedef std::unordered_map< std::string, std::string > 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.
 
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 (const std::string &isocode) const
 Get the description for the given ISO code.
 
std::string GetListLabel () const
 Get string to use when listing this set in the settings window.
 
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.
 

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
 Four letter short variant of the name.
 
uint32_t version
 The version of this base set.
 
bool fallback
 This set is a fallback set, i.e. it should be used only as last resort.
 
MD5File files [NUM_FILES]
 All files part of this set.
 
uint found_files
 Number of the files that could be found.
 
uint valid_files
 Number of the files that could be found and are valid.
 
T * next
 The next base set in this list.
 

Static Public Attributes

static const size_t NUM_FILES = Tnum_files
 Number of files in this set.
 
static const bool SEARCH_IN_TARS = Tsearch_in_tars
 Whether to search in the tars or not.
 
static const char *const * file_names = _graphics_file_names
 Internal names of the files in this set.
 

Detailed Description

template<class T, size_t Tnum_files, bool Tsearch_in_tars>
struct BaseSet< T, Tnum_files, Tsearch_in_tars >

Information about a single base set.

Template Parameters
Tthe real class we're going to be
Tnum_filesthe number of files in the set
Tsearch_in_tarswhether to search in the tars or not

Definition at line 49 of file base_media_base.h.

Member Typedef Documentation

◆ TranslatedStrings

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
typedef std::unordered_map<std::string, std::string> BaseSet< T, Tnum_files, Tsearch_in_tars >::TranslatedStrings

Definition at line 50 of file base_media_base.h.

Constructor & Destructor Documentation

◆ ~BaseSet()

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
BaseSet< T, Tnum_files, Tsearch_in_tars >::~BaseSet ( )
inline

Free everything we allocated.

Definition at line 75 of file base_media_base.h.

References BaseSet< T, Tnum_files, Tsearch_in_tars >::next.

Member Function Documentation

◆ CheckMD5()

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
static MD5File::ChecksumResult BaseSet< T, Tnum_files, Tsearch_in_tars >::CheckMD5 ( const MD5File file,
Subdirectory  subdir 
)
inlinestatic

Calculate and check the MD5 hash of the supplied file.

Parameters
fileThe file get the hash of.
subdirThe sub directory to get the files from.
Returns
  • #CR_MATCH if the MD5 hash matches
  • #CR_MISMATCH if the MD5 does not match
  • #CR_NO_FILE if the file misses

Definition at line 149 of file base_media_base.h.

References MD5File::CheckMD5().

◆ CopyCompatibleConfig()

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
void BaseSet< T, Tnum_files, Tsearch_in_tars >::CopyCompatibleConfig ( const T &  src)
inline

Definition at line 100 of file base_media_base.h.

◆ FillSetDetails()

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
bool BaseSet< T, Tnum_files, Tsearch_in_tars >::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.

Parameters
inithe ini to read from
paththe path to this ini file (for filenames)
full_filenamethe full filename of the loaded file (for error reporting purposes)
allow_empty_filenameempty filenames are valid
Returns
true if loading was successful.

Definition at line 42 of file base_media_func.h.

References Debug, fetch_metadata, MD5File::filename, IniLoadFile::GetGroup(), IniGroup::GetItem(), IniGroup::items, and IniItem::value.

◆ GetDescription()

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
const std::string & BaseSet< T, Tnum_files, Tsearch_in_tars >::GetDescription ( const std::string &  isocode) const
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.

Parameters
isocodethe isocode to search for
Returns
the description

Definition at line 110 of file base_media_base.h.

◆ GetListLabel()

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
std::string BaseSet< T, Tnum_files, Tsearch_in_tars >::GetListLabel ( ) const
inline

Get string to use when listing this set in the settings window.

If there are no invalid files, then this is just the set name, otherwise a string is formatted including the number of invalid files.

Returns
the string to display.

Definition at line 131 of file base_media_base.h.

References BaseSet< T, Tnum_files, Tsearch_in_tars >::GetNumInvalid(), GetString(), BaseSet< T, Tnum_files, Tsearch_in_tars >::name, SetDParam(), and SetDParamStr().

◆ GetNumInvalid()

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
int BaseSet< T, Tnum_files, Tsearch_in_tars >::GetNumInvalid ( ) const
inline

Get the number of invalid files.

Note
a missing file is invalid too!
Returns
the number

Definition at line 94 of file base_media_base.h.

References BaseSet< T, Tnum_files, Tsearch_in_tars >::valid_files.

Referenced by CheckExternalFiles(), and BaseSet< T, Tnum_files, Tsearch_in_tars >::GetListLabel().

◆ GetNumMissing()

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
int BaseSet< T, Tnum_files, Tsearch_in_tars >::GetNumMissing ( ) const
inline

Get the number of missing files.

Returns
the number

Definition at line 84 of file base_media_base.h.

References BaseSet< T, Tnum_files, Tsearch_in_tars >::found_files.

◆ GetTextfile()

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
std::optional< std::string > BaseSet< T, Tnum_files, Tsearch_in_tars >::GetTextfile ( TextfileType  type) const
inline

Search a textfile file next to this base media.

Parameters
typeThe type of the textfile to search for.
Returns
The filename for the textfile.

Definition at line 159 of file base_media_base.h.

References BASESET_DIR, BaseSet< T, Tnum_files, Tsearch_in_tars >::files, and BaseSet< T, Tnum_files, Tsearch_in_tars >::GetTextfile().

Referenced by BaseSet< T, Tnum_files, Tsearch_in_tars >::GetTextfile().

Field Documentation

◆ description

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
TranslatedStrings BaseSet< T, Tnum_files, Tsearch_in_tars >::description

Description of the base set.

Definition at line 63 of file base_media_base.h.

◆ fallback

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
bool BaseSet< T, Tnum_files, Tsearch_in_tars >::fallback

This set is a fallback set, i.e. it should be used only as last resort.

Definition at line 66 of file base_media_base.h.

◆ file_names

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
const char *const * BaseSet< T, Tnum_files, Tsearch_in_tars >::file_names = _graphics_file_names
static

Internal names of the files in this set.

Make sure we aren't messing things up.

Implementation.

Definition at line 59 of file base_media_base.h.

◆ files

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
MD5File BaseSet< T, Tnum_files, Tsearch_in_tars >::files[NUM_FILES]

All files part of this set.

Definition at line 68 of file base_media_base.h.

Referenced by CheckExternalFiles(), BaseSet< T, Tnum_files, Tsearch_in_tars >::GetTextfile(), and LoadSpriteTables().

◆ found_files

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
uint BaseSet< T, Tnum_files, Tsearch_in_tars >::found_files

Number of the files that could be found.

Definition at line 69 of file base_media_base.h.

Referenced by BaseSet< T, Tnum_files, Tsearch_in_tars >::GetNumMissing().

◆ name

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
std::string BaseSet< T, Tnum_files, Tsearch_in_tars >::name

The name of the base set.

Definition at line 61 of file base_media_base.h.

Referenced by CheckExternalFiles(), BaseSet< T, Tnum_files, Tsearch_in_tars >::GetListLabel(), and GraphicsSetSaveConfig().

◆ next

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
T* BaseSet< T, Tnum_files, Tsearch_in_tars >::next

The next base set in this list.

Definition at line 72 of file base_media_base.h.

Referenced by BaseSet< T, Tnum_files, Tsearch_in_tars >::~BaseSet().

◆ NUM_FILES

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
const size_t BaseSet< T, Tnum_files, Tsearch_in_tars >::NUM_FILES = Tnum_files
static

Number of files in this set.

Definition at line 53 of file base_media_base.h.

◆ SEARCH_IN_TARS

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
const bool BaseSet< T, Tnum_files, Tsearch_in_tars >::SEARCH_IN_TARS = Tsearch_in_tars
static

Whether to search in the tars or not.

Definition at line 56 of file base_media_base.h.

◆ shortname

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
uint32_t BaseSet< T, Tnum_files, Tsearch_in_tars >::shortname

Four letter short variant of the name.

Definition at line 64 of file base_media_base.h.

Referenced by GraphicsSetSaveConfig().

◆ url

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
std::string BaseSet< T, Tnum_files, Tsearch_in_tars >::url

URL for information about the base set.

Definition at line 62 of file base_media_base.h.

◆ valid_files

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
uint BaseSet< T, Tnum_files, Tsearch_in_tars >::valid_files

Number of the files that could be found and are valid.

Definition at line 70 of file base_media_base.h.

Referenced by BaseSet< T, Tnum_files, Tsearch_in_tars >::GetNumInvalid().

◆ version

template<class T , size_t Tnum_files, bool Tsearch_in_tars>
uint32_t BaseSet< T, Tnum_files, Tsearch_in_tars >::version

The version of this base set.

Definition at line 65 of file base_media_base.h.


The documentation for this struct was generated from the following files: