Further changes to musicdef based on discussion with Gunla

- Add "author" and "originalcomposers" fields
    - "author" is for remixes and original compositions, can be ommitted
    - "originalcomposers" will not be visible mid-game, but will be visible in music test. Stores original sound team info
- Store all strings as Zone memory instead of static arrays, since not every field will be relevant for every track
This commit is contained in:
toaster 2022-12-17 17:36:44 +00:00
parent 81fec17bb4
commit ac423b3461
2 changed files with 67 additions and 10 deletions

View file

@ -1476,14 +1476,32 @@ ReadMusicDefFields
textline = value;
/* based ignored lumps */
if (!stricmp(stoken, "title")) {
STRBUFCPY(def->title, textline);
} else if (!stricmp(stoken, "source")) {
STRBUFCPY(def->source, textline);
} else if (!stricmp(stoken, "volume")) {
if (!stricmp(stoken, "title"))
{
Z_Free(def->title);
def->title = Z_StrDup(textline);
}
else if (!stricmp(stoken, "author"))
{
Z_Free(def->author);
def->author = Z_StrDup(textline);
}
else if (!stricmp(stoken, "source"))
{
Z_Free(def->source);
def->source = Z_StrDup(textline);
}
else if (!stricmp(stoken, "originalcomposers"))
{
Z_Free(def->composers);
def->composers = Z_StrDup(textline);
}
else if (!stricmp(stoken, "volume"))
{
def->volume = atoi(textline);
} else {
}
else
{
MusicDefError(CONS_WARNING,
"Unknown field '%s'.",
stoken, lumpnum, line);
@ -1606,9 +1624,46 @@ void S_ShowMusicCredit(void)
{
if (!stricmp(def->name, music_name))
{
char credittext[128] = "";
char *work = NULL;
size_t len = 128, worklen;
if (!def->title)
{
return;
}
work = va("\x1F %s", def->title);
worklen = strlen(work);
if (worklen <= len)
{
strncat(credittext, work, len);
len -= worklen;
#define MUSICCREDITAPPEND(field)\
if (field)\
{\
work = va(" - %s", field);\
worklen = strlen(work);\
if (worklen <= len)\
{\
strncat(credittext, work, len);\
len -= worklen;\
}\
}
MUSICCREDITAPPEND(def->author);
MUSICCREDITAPPEND(def->source);
#undef MUSICCREDITAPPEND
}
if (credittext[0] == '\0')
return;
cursongcredit.def = def;
Z_Free(cursongcredit.text);
cursongcredit.text = Z_StrDup(va("\x1F"" %s - %s", def->title, def->source));
cursongcredit.text = Z_StrDup(credittext);
cursongcredit.anim = 5*TICRATE;
cursongcredit.x = cursongcredit.old_x = 0;
cursongcredit.trans = NUMTRANSMAPS;

View file

@ -173,8 +173,10 @@ boolean S_SpeedMusic(float speed);
struct musicdef_t
{
char name[7];
char title[256];
char source[256];
char *title;
char *author;
char *source;
char *composers;
int volume;
musicdef_t *next;
};