12 #ifndef BASE_MEDIA_BASE_H 13 #define BASE_MEDIA_BASE_H 49 template <
class T,
size_t Tnum_files,
bool Tsearch_in_tars>
54 static const size_t NUM_FILES = Tnum_files;
57 static const bool SEARCH_IN_TARS = Tsearch_in_tars;
84 for (uint i = 0; i < NUM_FILES; i++) {
98 return Tnum_files - this->found_files;
108 return Tnum_files - this->valid_files;
111 bool FillSetDetails(
IniFile *ini,
const char *path,
const char *full_filename,
bool allow_empty_filename =
true);
123 if (isocode != NULL) {
126 if (strcmp(iter->first, isocode) == 0)
return iter->second;
130 if (strncmp(iter->first, isocode, 2) == 0)
return iter->second;
134 return this->description.
Begin()->second;
148 return file->
CheckMD5(subdir, SIZE_MAX);
158 for (uint i = 0; i < NUM_FILES; i++) {
160 if (textfile != NULL) {
172 template <
class Tbase_set>
179 bool AddFile(
const char *
filename,
size_t basepath_length,
const char *tar_filename);
185 static const char *GetExtension();
195 static bool DetermineBestSet();
203 return num + fs.
Scan(GetExtension(),
BASESET_DIR, Tbase_set::SEARCH_IN_TARS);
206 static Tbase_set *GetAvailableSets();
208 static bool SetSet(
const char *name);
209 static char *GetSetsList(
char *p,
const char *last);
210 static int GetNumSets();
211 static int GetIndexOfUsedSet();
212 static const Tbase_set *GetSet(
int index);
213 static const Tbase_set *GetUsedSet();
221 static bool HasSet(
const ContentInfo *ci,
bool md5sum);
236 template <
class Tbase_set>
261 bool FillSetDetails(
struct IniFile *ini,
const char *path,
const char *full_filename);
318 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.
const T * Begin() const
Get the pointer to the first item (const)
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.
const T * End() const
Get the pointer behind the last valid item (const)
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 * GetDescription(const char *isocode=NULL) const
Get the description for the given ISO code.
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.
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.