31 size_t entry_count = ofs / 8;
32 if (entrynum >= entry_count)
return std::nullopt;
34 file.
SeekTo(entrynum * 8, SEEK_SET);
38 std::string name(namelen,
'\0');
55 size_t entry_count = ofs / 8;
56 if (entrynum >= entry_count)
return std::nullopt;
58 file.
SeekTo(entrynum * 8, SEEK_SET);
61 file.
SeekTo(entrypos, SEEK_SET);
64 std::vector<uint8_t> data(entrylen);
72 "old_0",
"old_1",
"old_2",
"old_3",
"old_4",
"old_5",
"old_6",
"old_7",
"old_8",
"old_9",
73 "new_0",
"new_1",
"new_2",
"new_3",
"new_4",
"new_5",
"new_6",
"new_7",
"new_8",
"new_9",
74 "ezy_0",
"ezy_1",
"ezy_2",
"ezy_3",
"ezy_4",
"ezy_5",
"ezy_6",
"ezy_7",
"ezy_8",
"ezy_9",
98 if (c->GetNumMissing() != 0)
continue;
100 if (best ==
nullptr ||
115bool MusicSet::FillSetDetails(
const IniFile &ini,
const std::string &path,
const std::string &full_filename)
125 const std::string &filename = this->
files[i].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,...)
Output 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)
std::optional< std::string > GetMusicCatEntryName(const std::string &filename, size_t entrynum)
Read the name of a music CAT file entry.
static const std::string_view _music_file_names[]
Names corresponding to the music set's files.
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.
std::array< MD5File, BaseSet< MusicSet >::NUM_FILES > files
All files part of this set.
uint32_t version
The version of this base set.
uint valid_files
Number of the files that could be found and are valid.
static std::span< const std::string_view > GetFilenames()
Get the internal names of the files in this set.
bool fallback
This set is a fallback set, i.e. it should be used only as last resort.
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.
uint32_t shortname
Four letter short variant of the name.
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.
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)