mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-14 18:47:39 +01:00
commit
57dcfa63a2
@ -573,27 +573,40 @@ static STREAMFILE *open_mapfile_pair(STREAMFILE *streamFile, int track, int num_
|
|||||||
for (i = 0; i < pair_count; i++) {
|
for (i = 0; i < pair_count; i++) {
|
||||||
const char *map_name = mapfile_pairs[i][0];
|
const char *map_name = mapfile_pairs[i][0];
|
||||||
const char *mus_name = mapfile_pairs[i][1];
|
const char *mus_name = mapfile_pairs[i][1];
|
||||||
char buf[PATH_LIMIT] = {0};
|
char buf[PATH_LIMIT] = { 0 };
|
||||||
char *pch;
|
char *pch;
|
||||||
|
int use_mask = 0;
|
||||||
map_len = strlen(map_name);
|
map_len = strlen(map_name);
|
||||||
|
|
||||||
/* replace map_name with expected mus_name */
|
/* replace map_name with expected mus_name */
|
||||||
if (file_len < map_len)
|
if (file_len < map_len)
|
||||||
continue;
|
continue;
|
||||||
if (strncasecmp(file_name + (file_len - map_len), map_name, map_len) != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
strncpy(buf, mus_name, map_len);
|
if (map_name[0] == '*') {
|
||||||
|
use_mask = 1;
|
||||||
|
map_name++;
|
||||||
|
map_len--;
|
||||||
|
|
||||||
|
if (strncmp(file_name + (file_len - map_len), map_name, map_len) != 0)
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
if (strcmp(file_name, map_name) != 0)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(buf, mus_name, PATH_LIMIT);
|
||||||
pch = strtok(buf, ","); //TODO: not thread safe in std C
|
pch = strtok(buf, ","); //TODO: not thread safe in std C
|
||||||
for (j = 0; j < track && pch; j++) {
|
for (j = 0; j < track && pch; j++) {
|
||||||
pch = strtok(NULL, ",");
|
pch = strtok(NULL, ",");
|
||||||
}
|
}
|
||||||
|
if (!pch) continue; /* invalid track */
|
||||||
|
|
||||||
if (!pch)
|
if (use_mask) {
|
||||||
continue;
|
file_name[file_len - map_len] = '\0';
|
||||||
|
strncat(file_name, pch + 1, PATH_LIMIT);
|
||||||
file_name[file_len - map_len] = '\0';
|
} else {
|
||||||
strcat(file_name, pch);
|
strncpy(file_name, pch, PATH_LIMIT);
|
||||||
|
}
|
||||||
|
|
||||||
musFile = open_streamfile_by_filename(streamFile, file_name);
|
musFile = open_streamfile_by_filename(streamFile, file_name);
|
||||||
if (musFile) return musFile;
|
if (musFile) return musFile;
|
||||||
|
@ -626,7 +626,8 @@ fail:
|
|||||||
static STREAMFILE* open_mapfile_pair(STREAMFILE *streamFile, int track, int num_tracks) {
|
static STREAMFILE* open_mapfile_pair(STREAMFILE *streamFile, int track, int num_tracks) {
|
||||||
static const char *const mapfile_pairs[][2] = {
|
static const char *const mapfile_pairs[][2] = {
|
||||||
/* standard cases, replace map part with mus part (from the end to preserve prefixes) */
|
/* standard cases, replace map part with mus part (from the end to preserve prefixes) */
|
||||||
{"mus_ctrl.mpf", "mus_str.mus"}, /* GoldenEye - Rogue Agent */
|
{"MUS_CTRL.MPF", "MUS_STR.MUS"}, /* GoldenEye - Rogue Agent (PS2) */
|
||||||
|
{"mus_ctrl.mpf", "mus_str.mus"}, /* GoldenEye - Rogue Agent (others) */
|
||||||
{"AKA_Mus.mpf", "Track.mus"}, /* Boogie */
|
{"AKA_Mus.mpf", "Track.mus"}, /* Boogie */
|
||||||
{"SSX4.mpf", "moments0.mus,main.mus,load_loop0.mus"}, /* SSX Blur */
|
{"SSX4.mpf", "moments0.mus,main.mus,load_loop0.mus"}, /* SSX Blur */
|
||||||
{"willow.mpf", "willow.mus,willow_o.mus"}, /* Harry Potter and the Chamber of Secrets */
|
{"willow.mpf", "willow.mus,willow_o.mus"}, /* Harry Potter and the Chamber of Secrets */
|
||||||
@ -634,16 +635,17 @@ static STREAMFILE* open_mapfile_pair(STREAMFILE *streamFile, int track, int num_
|
|||||||
{"Peak1Amb.mpf", "Peak1_Strm.mus,Peak1_Ovr0.mus"}, /* SSX 3 */
|
{"Peak1Amb.mpf", "Peak1_Strm.mus,Peak1_Ovr0.mus"}, /* SSX 3 */
|
||||||
{"Peak2Amb.mpf", "Peak2_Strm.mus,Peak2_Ovr0.mus"},
|
{"Peak2Amb.mpf", "Peak2_Strm.mus,Peak2_Ovr0.mus"},
|
||||||
{"Peak3Amb.mpf", "Peak3_Strm.mus,Peak3_Ovr0.mus"},
|
{"Peak3Amb.mpf", "Peak3_Strm.mus,Peak3_Ovr0.mus"},
|
||||||
{".mpf", "_main.mus"}, /* 007 - Everything or Nothing */
|
{"*.mpf", "*_main.mus"}, /* 007 - Everything or Nothing */
|
||||||
//TODO: improve pairs (needs better wildcard support)
|
/* TODO: need better wildcard support
|
||||||
//NSF2:
|
* NSF2:
|
||||||
/* ZTRxxROK.MAP > ZTRxx.TRJ */
|
* ZTRxxROK.MAP > ZTRxx.TRJ
|
||||||
/* ZTRxxTEC.MAP > ZTRxx.TRM */
|
* ZTRxxTEC.MAP > ZTRxx.TRM
|
||||||
/* ZZSHOW.MAP and ZZSHOW2.MAP > ZZSHOW.MUS */
|
* ZZSHOW.MAP and ZZSHOW2.MAP > ZZSHOW.MUS
|
||||||
//NSF3:
|
* NSF3:
|
||||||
/* ZTRxxROK.MAP > ZZZTRxxA.TRJ */
|
* ZTRxxROK.MAP > ZZZTRxxA.TRJ
|
||||||
/* ZTRxxTEC.MAP > ZZZTRxxB.TRM */
|
* ZTRxxTEC.MAP > ZZZTRxxB.TRM
|
||||||
/* other extra files that may need the hack below */
|
* ZTR00R0A.MAP and ZTR00R0B.MAP > ZZZTR00A.TRJ
|
||||||
|
* other extra files that may need the hack below */
|
||||||
};
|
};
|
||||||
STREAMFILE *musFile = NULL;
|
STREAMFILE *musFile = NULL;
|
||||||
char file_name[PATH_LIMIT];
|
char file_name[PATH_LIMIT];
|
||||||
@ -665,25 +667,38 @@ static STREAMFILE* open_mapfile_pair(STREAMFILE *streamFile, int track, int num_
|
|||||||
const char *mus_name = mapfile_pairs[i][1];
|
const char *mus_name = mapfile_pairs[i][1];
|
||||||
char buf[PATH_LIMIT] = {0};
|
char buf[PATH_LIMIT] = {0};
|
||||||
char *pch;
|
char *pch;
|
||||||
|
int use_mask = 0;
|
||||||
map_len = strlen(map_name);
|
map_len = strlen(map_name);
|
||||||
|
|
||||||
/* replace map_name with expected mus_name */
|
/* replace map_name with expected mus_name */
|
||||||
if (file_len < map_len)
|
if (file_len < map_len)
|
||||||
continue;
|
continue;
|
||||||
if (strncasecmp(file_name + (file_len - map_len), map_name, map_len) != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
strncpy(buf, mus_name, map_len);
|
if (map_name[0] == '*') {
|
||||||
|
use_mask = 1;
|
||||||
|
map_name++;
|
||||||
|
map_len--;
|
||||||
|
|
||||||
|
if (strcmp(file_name + (file_len - map_len), map_name) != 0)
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
if (strcmp(file_name, map_name) != 0)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(buf, mus_name, PATH_LIMIT);
|
||||||
pch = strtok(buf, ","); //TODO: not thread safe in std C
|
pch = strtok(buf, ","); //TODO: not thread safe in std C
|
||||||
for (j = 0; j < track && pch; j++) {
|
for (j = 0; j < track && pch; j++) {
|
||||||
pch = strtok(NULL, ",");
|
pch = strtok(NULL, ",");
|
||||||
}
|
}
|
||||||
|
if (!pch) continue; /* invalid track */
|
||||||
|
|
||||||
if (!pch)
|
if (use_mask) {
|
||||||
continue;
|
file_name[file_len - map_len] = '\0';
|
||||||
|
strncat(file_name, pch + 1, PATH_LIMIT);
|
||||||
file_name[file_len - map_len] = '\0';
|
} else {
|
||||||
strcat(file_name, pch);
|
strncpy(file_name, pch, PATH_LIMIT);
|
||||||
|
}
|
||||||
|
|
||||||
musFile = open_streamfile_by_filename(streamFile, file_name);
|
musFile = open_streamfile_by_filename(streamFile, file_name);
|
||||||
if (musFile) return musFile;
|
if (musFile) return musFile;
|
||||||
|
Loading…
Reference in New Issue
Block a user