OpenTTD Source
12.0-beta2
|
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(
IniFile *ini,
const char *path,
const char *full_filename)
138 if (item !=
nullptr && item->
value.has_value() && !item->
value->empty()) {
143 if (songname ==
nullptr) {
144 Debug(grf, 0,
"Base music set song missing from CAT file: {}/{}", filename, this->
songinfo[i].cat_index);
154 const char *trimmed_filename = filename;
158 for (; trimmed_filename !=
nullptr; trimmed_filename = strchr(trimmed_filename, PATHSEPCHAR)) {
161 while (*trimmed_filename == PATHSEPCHAR) trimmed_filename++;
163 item = names->
GetItem(trimmed_filename,
false);
164 if (item !=
nullptr && item->
value.has_value() && !item->
value->empty())
break;
168 if (item !=
nullptr && item->
value.has_value() && !item->
value->empty()) {
171 Debug(grf, 0,
"Base music set song name missing: {}", filename);
184 item = trimmed_filename !=
nullptr ? timingtrim->
GetItem(trimmed_filename,
false) :
nullptr;
185 if (item !=
nullptr && item->
value.has_value() && !item->
value->empty()) {
186 auto endpos = item->
value->find(
':');
187 if (endpos != std::string::npos) {
byte tracknr
track number of song displayed in UI
@ 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.
A group within an ini file.
static const char *const _music_file_names[]
Names corresponding to the music set's files.
char * GetMusicCatEntryName(const char *filename, size_t entrynum)
Read the name of a music CAT file entry.
ChecksumResult check_result
cached result of md5 check
byte * GetMusicCatEntryData(const char *filename, size_t entrynum, size_t &entrylen)
Read the full data of a music CAT file entry.
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.
void SkipBytes(int n)
Skip n bytes ahead in the file.
std::optional< std::string > value
The value of this item.
char songname[32]
name of song displayed in UI
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
MusicSongInfo songinfo[NUM_SONGS_AVAILABLE]
Data about individual songs in set.
uint32 ReadDword()
Read a double word (32 bits) from the file (in low endian format).
bool FioCheckFileExists(const std::string &filename, Subdirectory subdir)
Check whether the given file exists.
Ini file that supports both loading and saving.
Information about a single base set.
@ CR_NO_FILE
The file did not exist.
const char * filename
filename
void SeekTo(size_t pos, int mode)
Seek in the current file.
const char * filename
file on disk containing song (when used in MusicSet class, this pointer is owned by MD5File object fo...
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.
#define lengthof(x)
Return the length of an fixed size array.
byte num_available
Number of valid songs in set.
IniItem * GetItem(const std::string &name, bool create)
Get the item with the given name, and if it doesn't exist and create is true it creates a new item.
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
bool FillSetDetails(IniFile *ini, const char *path, const char *full_filename, bool allow_empty_filename=true)
Read the set information from a loaded ini.
#define lastof(x)
Get the last element of an fixed size array.
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.
IniGroup * GetGroup(const std::string &name, bool create_new=true)
Get the group with the given name.