|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
14 #define SET_TYPE "music"
34 size_t entry_count = ofs / 8;
35 if (entrynum < entry_count) {
36 file.
SeekTo(entrynum * 8, SEEK_SET);
39 char *name = MallocT<char>(namelen + 1);
62 size_t entry_count = ofs / 8;
63 if (entrynum < entry_count) {
64 file.
SeekTo(entrynum * 8, SEEK_SET);
67 file.
SeekTo(entrypos, SEEK_SET);
69 byte *data = MallocT<byte>(entrylen);
81 "old_0",
"old_1",
"old_2",
"old_3",
"old_4",
"old_5",
"old_6",
"old_7",
"old_8",
"old_9",
82 "new_0",
"new_1",
"new_2",
"new_3",
"new_4",
"new_5",
"new_6",
"new_7",
"new_8",
"new_9",
83 "ezy_0",
"ezy_1",
"ezy_2",
"ezy_3",
"ezy_4",
"ezy_5",
"ezy_6",
"ezy_7",
"ezy_8",
"ezy_9",
88 template <
class T,
size_t Tnum_files,
bool Tsearch_in_tars>
91 template <
class Tbase_set>
97 template <
class Tbase_set>
102 const Tbase_set *best =
nullptr;
104 if (c->GetNumMissing() != 0)
continue;
106 if (best ==
nullptr ||
107 (best->fallback && !c->fallback) ||
108 best->valid_files < c->valid_files ||
109 (best->valid_files == c->valid_files &&
110 (best->shortname == c->shortname && best->version < c->version))) {
119 bool MusicSet::FillSetDetails(
const IniFile &ini,
const std::string &path,
const std::string &full_filename)
137 if (item !=
nullptr && item->
value.has_value() && !item->
value->empty()) {
142 if (songname ==
nullptr) {
143 Debug(grf, 0,
"Base music set song missing from CAT file: {}/{}", filename, this->
songinfo[i].cat_index);
152 const char *trimmed_filename = filename.c_str();
156 for (; trimmed_filename !=
nullptr; trimmed_filename = strchr(trimmed_filename, PATHSEPCHAR)) {
159 while (*trimmed_filename == PATHSEPCHAR) trimmed_filename++;
161 item = names !=
nullptr ? names->
GetItem(trimmed_filename) :
nullptr;
162 if (item !=
nullptr && item->
value.has_value() && !item->
value->empty())
break;
166 if (item !=
nullptr && item->
value.has_value() && !item->
value->empty()) {
169 Debug(grf, 0,
"Base music set song name missing: {}", filename);
182 item = trimmed_filename !=
nullptr && timingtrim !=
nullptr ? timingtrim->
GetItem(trimmed_filename) :
nullptr;
183 if (item !=
nullptr && item->
value.has_value() && !item->
value->empty()) {
184 auto endpos = item->
value->find(
':');
185 if (endpos != std::string::npos) {
byte tracknr
track number of song displayed in UI
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.
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
A single "line" in an ini file.
int override_start
MIDI ticks to skip over in beginning.
const IniItem * GetItem(const std::string &name) const
Get the item with the given name.
A group within an ini file.
static const char *const _music_file_names[]
Names corresponding to the music set's files.
ChecksumResult check_result
cached result of md5 check
void ReadBlock(void *ptr, size_t size)
Read a block.
int override_end
MIDI tick to end the song at (0 if no override)
byte ReadByte()
Read a byte from the file.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
std::string filename
file on disk containing song (when used in MusicSet class)
void free(const void *ptr)
Version of the standard free that accepts const pointers.
std::optional< std::string > value
The value of this item.
std::string filename
filename
MusicSongInfo songinfo[NUM_SONGS_AVAILABLE]
Data about individual songs in set.
const IniGroup * GetGroup(const std::string &name) const
Get the group with the given name.
std::string songname
name of song displayed in UI
byte * GetMusicCatEntryData(const std::string &filename, size_t entrynum, size_t &entrylen)
Read the full data of a music CAT file entry.
bool FioCheckFileExists(const std::string &filename, Subdirectory subdir)
Check whether the given file exists.
Ini file that supports both loading and saving.
void SkipBytes(size_t n)
Skip n bytes ahead in the file.
Information about a single base set.
@ CR_NO_FILE
The file did not exist.
void SeekTo(size_t pos, int mode)
Seek in the current file.
char * GetMusicCatEntryName(const std::string &filename, size_t entrynum)
Read the name of a music CAT file entry.
#define lengthof(x)
Return the length of an fixed size array.
uint32_t ReadDword()
Read a double word (32 bits) from the file (in low endian format).
byte num_available
Number of valid songs in 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
A file from which bytes, words and double words are read in (potentially) a random order.