1
0
Fork 0

Fix: Don't complain if CAT music files are missing entirely

Just complain if an index into a CAT file that exists is invalid.
pull/6825/head
Niels Martin Hansen 2018-06-07 21:34:24 +02:00 committed by Michael Lutz
parent a1b7812c7e
commit 5ab06ef8a3
3 changed files with 7 additions and 3 deletions

View File

@ -26,6 +26,7 @@ struct ContentInfo;
struct MD5File { struct MD5File {
/** The result of a checksum check */ /** The result of a checksum check */
enum ChecksumResult { enum ChecksumResult {
CR_UNKNOWN, ///< The file has not been checked yet
CR_MATCH, ///< The file did exist and the md5 checksum did match CR_MATCH, ///< The file did exist and the md5 checksum did match
CR_MISMATCH, ///< The file did exist, just the md5 checksum did not match CR_MISMATCH, ///< The file did exist, just the md5 checksum did not match
CR_NO_FILE, ///< The file did not exist CR_NO_FILE, ///< The file did not exist
@ -34,6 +35,7 @@ struct MD5File {
const char *filename; ///< filename const char *filename; ///< filename
uint8 hash[16]; ///< md5 sum of the file uint8 hash[16]; ///< md5 sum of the file
const char *missing_warning; ///< warning when this file is missing const char *missing_warning; ///< warning when this file is missing
ChecksumResult check_result; ///< cached result of md5 check
ChecksumResult CheckMD5(Subdirectory subdir, size_t max_size) const; ChecksumResult CheckMD5(Subdirectory subdir, size_t max_size) const;
}; };

View File

@ -129,7 +129,8 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
file->missing_warning = stredup(item->value); file->missing_warning = stredup(item->value);
} }
switch (T::CheckMD5(file, BASESET_DIR)) { file->check_result = T::CheckMD5(file, BASESET_DIR);
switch (file->check_result) {
case MD5File::CR_MATCH: case MD5File::CR_MATCH:
this->valid_files++; this->valid_files++;
this->found_files++; this->found_files++;

View File

@ -128,7 +128,7 @@ bool MusicSet::FillSetDetails(IniFile *ini, const char *path, const char *full_f
IniGroup *timingtrim = ini->GetGroup("timingtrim"); IniGroup *timingtrim = ini->GetGroup("timingtrim");
for (uint i = 0, j = 1; i < lengthof(this->songinfo); i++) { for (uint i = 0, j = 1; i < lengthof(this->songinfo); i++) {
const char *filename = this->files[i].filename; const char *filename = this->files[i].filename;
if (names == NULL || StrEmpty(filename)) { if (names == NULL || StrEmpty(filename) || this->files[i].check_result == MD5File::CR_NO_FILE) {
this->songinfo[i].songname[0] = '\0'; this->songinfo[i].songname[0] = '\0';
continue; continue;
} }
@ -143,7 +143,8 @@ bool MusicSet::FillSetDetails(IniFile *ini, const char *path, const char *full_f
char *songname = GetMusicCatEntryName(filename, this->songinfo[i].cat_index); char *songname = GetMusicCatEntryName(filename, this->songinfo[i].cat_index);
if (songname == NULL) { if (songname == NULL) {
DEBUG(grf, 0, "Base music set song missing from CAT file: %s/%d", filename, this->songinfo[i].cat_index); DEBUG(grf, 0, "Base music set song missing from CAT file: %s/%d", filename, this->songinfo[i].cat_index);
return false; this->songinfo[i].songname[0] = '\0';
continue;
} }
strecpy(this->songinfo[i].songname, songname, lastof(this->songinfo[i].songname)); strecpy(this->songinfo[i].songname, songname, lastof(this->songinfo[i].songname));
free(songname); free(songname);