16 #define SET_TYPE "music" 36 size_t entry_count = ofs / 8;
37 if (entrynum < entry_count) {
41 char *name = MallocT<char>(namelen + 1);
64 size_t entry_count = ofs / 8;
65 if (entrynum < entry_count) {
71 byte *data = MallocT<byte>(entrylen);
83 "old_0",
"old_1",
"old_2",
"old_3",
"old_4",
"old_5",
"old_6",
"old_7",
"old_8",
"old_9",
84 "new_0",
"new_1",
"new_2",
"new_3",
"new_4",
"new_5",
"new_6",
"new_7",
"new_8",
"new_9",
85 "ezy_0",
"ezy_1",
"ezy_2",
"ezy_3",
"ezy_4",
"ezy_5",
"ezy_6",
"ezy_7",
"ezy_8",
"ezy_9",
90 template <
class T,
size_t Tnum_files,
bool Tsearch_in_tars>
93 template <
class Tbase_set>
99 template <
class Tbase_set>
104 const Tbase_set *best = NULL;
106 if (c->GetNumMissing() != 0)
continue;
109 (best->fallback && !c->fallback) ||
110 best->valid_files < c->valid_files ||
111 (best->valid_files == c->valid_files &&
112 (best->shortname == c->shortname && best->version < c->version))) {
121 bool MusicSet::FillSetDetails(
IniFile *ini,
const char *path,
const char *full_filename)
145 if (songname == NULL) {
146 DEBUG(grf, 0,
"Base music set song missing from CAT file: %s/%d", filename, this->
songinfo[i].cat_index);
156 const char *trimmed_filename = filename;
160 for (; trimmed_filename != NULL; trimmed_filename = strchr(trimmed_filename, PATHSEPCHAR)) {
163 while (*trimmed_filename == PATHSEPCHAR) trimmed_filename++;
165 item = names->
GetItem(trimmed_filename,
false);
173 DEBUG(grf, 0,
"Base music set song name missing: %s", filename);
186 item = timingtrim->
GetItem(trimmed_filename,
false);
188 const char *endpos = strchr(item->
value,
':');
189 if (endpos != NULL) {
int override_end
MIDI tick to end the song at (0 if no override)
A group within an ini file.
MusicSongInfo songinfo[NUM_SONGS_AVAILABLE]
Data about individual songs in set.
ChecksumResult check_result
cached result of md5 check
char * GetMusicCatEntryName(const char *filename, size_t entrynum)
Read the name of a music CAT file entry.
static const char *const _music_file_names[]
Names corresponding to the music set's files.
int override_start
MIDI ticks to skip over in beginning.
#define lastof(x)
Get the last element of an fixed size array.
byte * GetMusicCatEntryData(const char *filename, size_t entrynum, size_t &entrylen)
Read the full data of a music CAT file entry.
IniGroup * GetGroup(const char *name, size_t len=0, bool create_new=true)
Get the group with the given name.
char songname[32]
name of song displayed in UI
Slot used for the GRF scanning and such.
MD5File files[NUM_FILES]
All files part of this set.
Subdirectory for all base data (base sets, intro game)
byte FioReadByte()
Read a byte from the file.
A single "line" in an ini file.
const char * filename
filename
Definition of base types and functions in a cross-platform compatible way.
assert_compile(lengthof(_music_file_names)==NUM_SONGS_AVAILABLE)
Make sure we aren't messing things up.
A number of safeguards to prevent using unsafe methods.
void FioSeekTo(size_t pos, int mode)
Seek in the current file.
char * value
The value of this item.
const char * filename
file on disk containing song (when used in MusicSet class, this pointer is owned by MD5File object fo...
void FioReadBlock(void *ptr, size_t size)
Read a block.
#define lengthof(x)
Return the length of an fixed size array.
bool FioCheckFileExists(const char *filename, Subdirectory subdir)
Check whether the given file exists.
#define DEBUG(name, level,...)
Output a line of debugging information.
void FioOpenFile(int slot, const char *filename, Subdirectory subdir)
Open a slotted file.
uint32 FioReadDword()
Read a double word (32 bits) from the file (in low endian format).
Ini file that supports both loading and saving.
byte tracknr
track number of song displayed in UI
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Declarations for savegames operations.
void FioSkipBytes(int n)
Skip n bytes ahead in the 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.
IniItem * GetItem(const char *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.
Information about a single base set.
int cat_index
entry index in CAT file, for filetype==MTT_MPSMIDI
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
MusicTrackType filetype
decoder required for song file
byte num_available
Number of valid songs in set.