OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #ifndef BASE_MEDIA_BASE_H
11 #define BASE_MEDIA_BASE_H
18 #include <unordered_map>
48 template <
class T,
size_t Tnum_files,
bool Tsearch_in_tars>
50 typedef std::unordered_map<std::string, std::string> TranslatedStrings;
77 free(this->files[i].filename);
78 free(this->files[i].missing_warning);
103 bool FillSetDetails(
IniFile *ini,
const char *path,
const char *full_filename,
bool allow_empty_filename =
true);
115 if (!isocode.empty()) {
117 auto desc = this->description.find(isocode);
118 if (desc != this->description.end())
return desc->second.c_str();
121 desc = this->description.find(isocode.substr(0, 2));
122 if (desc != this->description.end())
return desc->second.c_str();
125 return this->description.at(std::string{}).c_str();
139 return file->
CheckMD5(subdir, SIZE_MAX);
151 if (textfile !=
nullptr) {
163 template <
class Tbase_set>
170 bool AddFile(
const std::string &filename,
size_t basepath_length,
const std::string &tar_filename)
override;
199 static bool SetSet(
const std::string &name);
200 static char *
GetSetsList(
char *p,
const char *last);
203 static const Tbase_set *
GetSet(
int index);
227 template <
class Tbase_set>
252 bool FillSetDetails(
struct IniFile *ini,
const char *path,
const char *full_filename);
309 bool FillSetDetails(
struct IniFile *ini,
const char *path,
const char *full_filename);
const char * GetTextfile(TextfileType type) const
Search a textfile file next to this base media.
byte tracknr
track number of song displayed in UI
All data of a sounds set.
T * next
The next base set in this list.
const char * GetDescription(const std::string &isocode) const
Get the description for the given ISO code.
@ CR_MISMATCH
The file did exist, just the md5 checksum did not match.
ChecksumResult
The result of a checksum check.
uint32 shortname
Four letter short variant of the name.
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
std::string name
The name of the base set.
int override_start
MIDI ticks to skip over in beginning.
static const size_t NUM_FILES
Number of files in this set.
PaletteType
Palettes OpenTTD supports.
TranslatedStrings description
Description of the base set.
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.
bool loop
song should play in a tight loop if possible, never ending
uint found_files
Number of the files that could be found.
uint32 version
The version of this base set.
ChecksumResult check_result
cached result of md5 check
All data/functions related with replacing the base graphics.
@ OLD_GM_DIR
Old subdirectory for the music.
int override_end
MIDI tick to end the song at (0 if no override)
@ CR_MATCH
The file did exist and the md5 checksum did match.
bool fallback
This set is a fallback set, i.e. it should be used only as last resort.
const char * missing_warning
warning when this file is missing
uint8 hash[16]
md5 sum of the file
static const char *const * file_names
Internal names of the files in this set.
char songname[32]
name of song displayed in UI
Container for all important information about a piece of content.
Metadata about a music track.
ChecksumResult CheckMD5(Subdirectory subdir, size_t max_size) const
Calculate and check the MD5 hash of the supplied filename.
MusicSongInfo songinfo[NUM_SONGS_AVAILABLE]
Data about individual songs in set.
BlitterType blitter
Blitter of this graphics set.
uint valid_files
Number of the files that could be found and are valid.
int GetNumMissing() const
Get the number of missing files.
Ini file that supports both loading and saving.
Structure holding filename and MD5 information about a single file.
static MD5File::ChecksumResult CheckMD5(const MD5File *file, Subdirectory subdir)
Calculate and check the MD5 hash of the supplied GRF.
PaletteType palette
Palette of this graphics set.
All data/functions related with replacing the base music.
Information about a single base set.
@ CR_NO_FILE
The file did not exist.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
~BaseSet()
Free everything we allocated.
@ CR_UNKNOWN
The file has not been checked yet.
const char * filename
filename
const char * filename
file on disk containing song (when used in MusicSet class, this pointer is owned by MD5File object fo...
static const bool SEARCH_IN_TARS
Whether to search in the tars or not.
Helper for scanning for files with a given name.
TextfileType
Additional text files accompanying Tar archives.
byte num_available
Number of valid songs in set.
All data/functions related with replacing the base sounds.
@ OLD_DATA_DIR
Old subdirectory for the data.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
int GetNumInvalid() const
Get the number of invalid files.
static MD5File::ChecksumResult CheckMD5(const MD5File *file, Subdirectory subdir)
Calculate and check the MD5 hash of the supplied file.
bool FillSetDetails(IniFile *ini, const char *path, const char *full_filename, bool allow_empty_filename=true)
Read the set information from a loaded ini.
All data of a graphics set.
int cat_index
entry index in CAT file, for filetype==MTT_MPSMIDI
MD5File files[NUM_FILES]
All files part of this set.
MusicTrackType filetype
decoder required for song file