diff --git a/src/s_sound.c b/src/s_sound.c index 29c3bb6d4..96211d653 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -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; diff --git a/src/s_sound.h b/src/s_sound.h index 0b1148964..c9a86a2f5 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -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; };