diff --git a/src/hu_stuff.c b/src/hu_stuff.c index f0b8219e9..bad7be2e1 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -998,8 +998,7 @@ static void HU_TickSongCredits(void) if (cursongcredit.anim > 0) { - char *str = va("\x1F"" %s", cursongcredit.def->source); - INT32 len = V_ThinStringWidth(str, V_ALLOWLOWERCASE|V_6WIDTHSPACE); + INT32 len = V_ThinStringWidth(cursongcredit.text, V_ALLOWLOWERCASE|V_6WIDTHSPACE); fixed_t destx = (len+7) * FRACUNIT; if (cursongcredit.trans > 0) @@ -2094,29 +2093,28 @@ static void HU_DrawDemoInfo(void) // void HU_DrawSongCredits(void) { - char *str; fixed_t x; fixed_t y = (r_splitscreen ? (BASEVIDHEIGHT/2)-4 : 32) * FRACUNIT; INT32 bgt; - if (!cursongcredit.def) // No def + if (!cursongcredit.def || cursongcredit.trans >= NUMTRANSMAPS) // No def { return; } - str = va("\x1F"" %s", cursongcredit.def->source); bgt = (NUMTRANSMAPS/2) + (cursongcredit.trans / 2); x = R_InterpolateFixed(cursongcredit.old_x, cursongcredit.x); if (bgt < NUMTRANSMAPS) { - V_DrawFixedPatch(x, y - (2 * FRACUNIT), FRACUNIT, V_SNAPTOLEFT|(bgt<usage, textline); -#endif - } 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); @@ -1597,14 +1613,53 @@ 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(credittext); cursongcredit.anim = 5*TICRATE; - cursongcredit.x = cursongcredit.old_x =0; + cursongcredit.x = cursongcredit.old_x = 0; cursongcredit.trans = NUMTRANSMAPS; return; } - else - def = def->next; + + def = def->next; } } diff --git a/src/s_sound.h b/src/s_sound.h index 67011f4fe..03e1673cc 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -168,8 +168,10 @@ boolean S_SpeedMusic(float speed); typedef struct musicdef_s { char name[7]; - //char usage[256]; - char source[256]; + char *title; + char *author; + char *source; + char *composers; int volume; struct musicdef_s *next; } musicdef_t; @@ -177,6 +179,7 @@ typedef struct musicdef_s extern struct cursongcredit { musicdef_t *def; + char *text; UINT16 anim; UINT8 trans; fixed_t x;