15 #define SET_TYPE "music"
34 size_t entry_count = ofs / 8;
35 if (entrynum >= entry_count)
return std::nullopt;
37 file.
SeekTo(entrynum * 8, SEEK_SET);
41 std::string name(namelen,
'\0');
58 size_t entry_count = ofs / 8;
59 if (entrynum >= entry_count)
return std::nullopt;
61 file.
SeekTo(entrynum * 8, SEEK_SET);
64 file.
SeekTo(entrypos, SEEK_SET);
67 std::vector<uint8_t> data(entrylen);
77 "old_0",
"old_1",
"old_2",
"old_3",
"old_4",
"old_5",
"old_6",
"old_7",
"old_8",
"old_9",
78 "new_0",
"new_1",
"new_2",
"new_3",
"new_4",
"new_5",
"new_6",
"new_7",
"new_8",
"new_9",
79 "ezy_0",
"ezy_1",
"ezy_2",
"ezy_3",
"ezy_4",
"ezy_5",
"ezy_6",
"ezy_7",
"ezy_8",
"ezy_9",
84 template <
class T,
size_t Tnum_files,
bool Tsearch_in_tars>
87 template <
class Tbase_set>
93 template <
class Tbase_set>
98 const Tbase_set *best =
nullptr;
100 if (c->GetNumMissing() != 0)
continue;
102 if (best ==
nullptr ||
103 (best->fallback && !c->fallback) ||
104 best->valid_files < c->valid_files ||
105 (best->valid_files == c->valid_files &&
106 (best->shortname == c->shortname && best->version < c->version))) {
115 bool MusicSet::FillSetDetails(
const IniFile &ini,
const std::string &path,
const std::string &full_filename)
133 if (item !=
nullptr && item->
value.has_value() && !item->
value->empty()) {
138 if (!songname.has_value()) {
139 Debug(grf, 0,
"Base music set song missing from CAT file: {}/{}", filename, this->
songinfo[i].cat_index);
147 const char *trimmed_filename = filename.c_str();
151 for (; trimmed_filename !=
nullptr; trimmed_filename = strchr(trimmed_filename, PATHSEPCHAR)) {
154 while (*trimmed_filename == PATHSEPCHAR) trimmed_filename++;
156 item = names !=
nullptr ? names->
GetItem(trimmed_filename) :
nullptr;
157 if (item !=
nullptr && item->
value.has_value() && !item->
value->empty())
break;
161 if (item !=
nullptr && item->
value.has_value() && !item->
value->empty()) {
164 Debug(grf, 0,
"Base music set song name missing: {}", filename);
177 item = trimmed_filename !=
nullptr && timingtrim !=
nullptr ? timingtrim->
GetItem(trimmed_filename) :
nullptr;
178 if (item !=
nullptr && item->
value.has_value() && !item->
value->empty()) {
179 auto endpos = item->
value->find(
':');
180 if (endpos != std::string::npos) {
A file from which bytes, words and double words are read in (potentially) a random order.
void ReadBlock(void *ptr, size_t size)
Read a block.
void SeekTo(size_t pos, int mode)
Seek in the current file.
uint8_t ReadByte()
Read a byte from the file.
uint32_t ReadDword()
Read a double word (32 bits) from the file (in low endian format).
void SkipBytes(size_t n)
Skip n bytes ahead in the file.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
bool FioCheckFileExists(const std::string &filename, Subdirectory subdir)
Check whether the given file exists.
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
static const char *const _music_file_names[]
Names corresponding to the music set's files.
std::optional< std::string > GetMusicCatEntryName(const std::string &filename, size_t entrynum)
Read the name of a music CAT file entry.
std::optional< std::vector< uint8_t > > GetMusicCatEntryData(const std::string &filename, size_t entrynum)
Read the full data of a music CAT file entry.
Class related to random access to files.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
static void StrMakeValid(T &dst, const char *str, const char *last, StringValidationSettings settings)
Copies the valid (UTF-8) characters from str up to last to the dst.
Functions related to low-level strings.
Information about a single base set.
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.
MD5File files[NUM_FILES]
All files part of this set.
Ini file that supports both loading and saving.
A group within an ini file.
const IniItem * GetItem(std::string_view name) const
Get the item with the given name.
A single "line" in an ini file.
std::optional< std::string > value
The value of this item.
const IniGroup * GetGroup(std::string_view name) const
Get the group with the given name.
@ CR_NO_FILE
The file did not exist.
ChecksumResult check_result
cached result of md5 check
std::string filename
filename
MusicSongInfo songinfo[NUM_SONGS_AVAILABLE]
Data about individual songs in set.
uint8_t num_available
Number of valid songs in set.
MusicTrackType filetype
decoder required for song file
std::string songname
name of song displayed in UI
uint8_t tracknr
track number of song displayed in UI
std::string filename
file on disk containing song (when used in MusicSet class)
int override_start
MIDI ticks to skip over in beginning.
int cat_index
entry index in CAT file, for filetype==MTT_MPSMIDI
int override_end
MIDI tick to end the song at (0 if no override)