Show all .xsb names in .xwb instead of first

This commit is contained in:
bnnm 2019-08-10 17:26:44 +02:00
parent 35c471a9a9
commit 37af5c4166
2 changed files with 26 additions and 18 deletions

View File

@ -635,10 +635,11 @@ static int get_xsb_name(char * buf, size_t maxsize, int target_subsong, xwb_head
} }
//;VGM_LOG("XSB: name found=%i at %lx\n", xsb.parse_found, xsb.name_offset); //;VGM_LOG("XSB: name found=%i at %lx\n", xsb.parse_found, xsb.name_offset);
if (!xsb.parse_found || xsb.name_offset == 0) if (!xsb.parse_found || xsb.name[0] == '\0')
goto fail; goto fail;
read_string(buf,maxsize, xsb.name_offset,streamFile); /* null-terminated */ strncpy(buf,xsb.name,maxsize);
buf[maxsize-1] = '\0';
return 1; return 1;
fail: fail:
return 0; return 0;

View File

@ -1,5 +1,6 @@
#ifndef _XWB_XSB_H_ #ifndef _XWB_XSB_H_
#define _XWB_XSB_H_ #define _XWB_XSB_H_
#include "meta.h"
#define XSB_XACT1_0_MAX 5 /* Unreal Championship (Xbox) */ #define XSB_XACT1_0_MAX 5 /* Unreal Championship (Xbox) */
#define XSB_XACT1_1_MAX 8 /* Die Hard: Vendetta (Xbox) */ #define XSB_XACT1_1_MAX 8 /* Die Hard: Vendetta (Xbox) */
@ -30,9 +31,9 @@ typedef struct {
off_t cue_names_offset; off_t cue_names_offset;
/* output */ /* output */
int parse_found;
int parse_done; int parse_done;
off_t name_offset; char name[STREAM_NAME_SIZE];
int name_len;
} xsb_header; } xsb_header;
@ -41,24 +42,30 @@ static void xsb_check_stream(xsb_header * xsb, int stream_index, int wavebank_in
if (xsb->parse_done) if (xsb->parse_done)
return; return;
/* multiple names may correspond to a stream, so commenting parse_done /* multiple names may correspond to a stream (ex. Blue Dragon), so we concat all */
* will allow to search for other names instead of first only */
if (xsb->selected_stream == stream_index && if (xsb->selected_stream == stream_index &&
(xsb->selected_wavebank == wavebank_index || wavebank_index == -1 || wavebank_index == 255)) { (xsb->selected_wavebank == wavebank_index || wavebank_index == -1 || wavebank_index == 255)) {
xsb->name_offset = name_offset; char name[STREAM_NAME_SIZE];
xsb->parse_found = 1; size_t name_size;
xsb->parse_done = 1;
name_size = read_string(name,sizeof(name), name_offset,sf); /* null-terminated */
if (xsb->name_len) {
const char *cat = "; ";
int cat_len = 2;
if (xsb->name_len + cat_len + name_size + 1 < STREAM_NAME_SIZE) {
strcat(xsb->name + xsb->name_len, "; ");
strcat(xsb->name + xsb->name_len, name);
}
}
else {
strcpy(xsb->name, name);
}
xsb->name_len += name_size;
//xsb->parse_done = 1; /* uncomment this to stop reading after first name */
//;VGM_LOG("XSB: parse found stream=%i, wavebank=%i, name_offset=%lx\n", stream_index, wavebank_index, name_offset); //;VGM_LOG("XSB: parse found stream=%i, wavebank=%i, name_offset=%lx\n", stream_index, wavebank_index, name_offset);
} }
#if 0 // for debugging purposes
{
char stream_name[255];
read_string(stream_name,255, name_offset,sf); /* null-terminated */
;VGM_LOG("XSB: stream=%i, wavebank=%i, name=%lx=%s vs s=%i, w=%i\n", stream_index, wavebank_index, name_offset, stream_name, xsb->selected_stream, xsb->selected_wavebank);
xsb->parse_done = 0; /* keep parsing */
}
#endif
} }
/* old XACT1 is a bit different and much of it is unknown but this seems to work. /* old XACT1 is a bit different and much of it is unknown but this seems to work.