10 #ifndef BASE_MEDIA_BASE_H 11 #define BASE_MEDIA_BASE_H 47 template <
class T,
size_t Tnum_files,
bool Tsearch_in_tars>
52 static const size_t NUM_FILES = Tnum_files;
55 static const bool SEARCH_IN_TARS = Tsearch_in_tars;
77 for (
auto &pair : this->description) {
82 for (uint i = 0; i < NUM_FILES; i++) {
96 return Tnum_files - this->found_files;
106 return Tnum_files - this->valid_files;
109 bool FillSetDetails(
IniFile *ini,
const char *path,
const char *full_filename,
bool allow_empty_filename =
true);
121 if (isocode !=
nullptr) {
123 for (
const auto &pair : this->description) {
124 if (strcmp(pair.first, isocode) == 0)
return pair.second;
127 for (
const auto &pair : this->description) {
128 if (strncmp(pair.first, isocode, 2) == 0)
return pair.second;
132 return this->description.front().second;
146 return file->
CheckMD5(subdir, SIZE_MAX);
156 for (uint i = 0; i < NUM_FILES; i++) {
158 if (textfile !=
nullptr) {
170 template <
class Tbase_set>
177 bool AddFile(
const char *
filename,
size_t basepath_length,
const char *tar_filename)
override;
183 static const char *GetExtension();
193 static bool DetermineBestSet();
201 return num + fs.
Scan(GetExtension(),
BASESET_DIR, Tbase_set::SEARCH_IN_TARS);
204 static Tbase_set *GetAvailableSets();
206 static bool SetSet(
const char *name);
207 static char *GetSetsList(
char *p,
const char *last);
208 static int GetNumSets();
209 static int GetIndexOfUsedSet();
210 static const Tbase_set *GetSet(
int index);
211 static const Tbase_set *GetUsedSet();
219 static bool HasSet(
const ContentInfo *ci,
bool md5sum);
234 template <
class Tbase_set>
259 bool FillSetDetails(
struct IniFile *ini,
const char *path,
const char *full_filename);
316 bool FillSetDetails(
struct IniFile *ini,
const char *path,
const char *full_filename);
int override_end
MIDI tick to end the song at (0 if no override)
Metadata about a music track.
Old subdirectory for the music.
uint32 shortname
Four letter short variant of the name.
ChecksumResult check_result
cached result of md5 check
Subdirectory
The different kinds of subdirectories OpenTTD uses.
static const char *const * file_names
Internal names of the files in this set.
Structure holding filename and MD5 information about a single file.
int GetNumInvalid() const
Get the number of invalid files.
uint Scan(const char *extension, Subdirectory sd, bool tars=true, bool recursive=true)
Scan for files with the given extension in the given search path.
int override_start
MIDI ticks to skip over in beginning.
PaletteType palette
Palette of this graphics set.
Functions for Standard In/Out file operations.
TranslatedStrings description
Description of the base set.
All data/functions related with replacing the base sounds.
Subdirectory for all base data (base sets, intro game)
int GetNumMissing() const
Get the number of missing files.
The file did exist, just the md5 checksum did not match.
~BaseSet()
Free everything we allocated.
const char * missing_warning
warning when this file is missing
Helper for scanning for files with a given name.
Simple mapping class targeted for small sets of data.
const char * filename
filename
const char * name
The name of the base set.
All data/functions related with replacing the base graphics.
const char * filename
file on disk containing song (when used in MusicSet class, this pointer is owned by MD5File object fo...
TextfileType
Additional text files accompanying Tar archives.
BlitterType blitter
Blitter of this graphics set.
All data/functions related with replacing the base music.
uint32 version
The version of this base set.
ChecksumResult CheckMD5(Subdirectory subdir, size_t max_size) const
Calculate and check the MD5 hash of the supplied filename.
bool fallback
This set is a fallback set, i.e. it should be used only as last resort.
const char * GetDescription(const char *isocode=nullptr) const
Get the description for the given ISO code.
uint found_files
Number of the files that could be found.
Ini file that supports both loading and saving.
byte tracknr
track number of song displayed in UI
const char * GetTextfile(TextfileType type) const
Search a textfile file next to this base media.
uint valid_files
Number of the files that could be found and are valid.
The file did exist and the md5 checksum did match.
All data of a sounds set.
All data of a graphics set.
bool loop
song should play in a tight loop if possible, never ending
ChecksumResult
The result of a checksum check.
PaletteType
Palettes OpenTTD supports.
Information about a single base set.
int cat_index
entry index in CAT file, for filetype==MTT_MPSMIDI
The file has not been checked yet.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
static MD5File::ChecksumResult CheckMD5(const MD5File *file, Subdirectory subdir)
Calculate and check the MD5 hash of the supplied file.
MusicTrackType filetype
decoder required for song file
const char * GetTextfile(TextfileType type, Subdirectory dir, const char *filename)
Search a textfile file next to the given content.
byte num_available
Number of valid songs in set.
Types related to textfiles.
Container for all important information about a piece of content.
Types related to the graphics and/or input devices.
uint8 hash[16]
md5 sum of the file
Old subdirectory for the data.
GUI functions related to textfiles.