diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 8473f5ce1..39ccfbb21 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -883,7 +883,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) void HU_TickSongCredits(void) { - if (cursongcredit.def == NULL) // No def + if (cursongcredit.text == NULL) // No def { cursongcredit.x = cursongcredit.old_x = 0; cursongcredit.anim = 0; @@ -1991,7 +1991,7 @@ static void HU_DrawDemoInfo(void) // void HU_DrawSongCredits(void) { - if (!cursongcredit.def || cursongcredit.trans >= NUMTRANSMAPS) // No def + if (!cursongcredit.text || cursongcredit.trans >= NUMTRANSMAPS) // No def { return; } diff --git a/src/music_manager.cpp b/src/music_manager.cpp index abf71fbb6..2233bdb97 100644 --- a/src/music_manager.cpp +++ b/src/music_manager.cpp @@ -60,6 +60,7 @@ void TuneManager::tick() // Only stop the music credit if the song actually // changed. S_StopMusicCredit(); + S_UnloadMusicCredit(); } stop_credit_ = false; @@ -91,6 +92,8 @@ void TuneManager::tick() adjust_volume(); I_SetSongSpeed(tune->speed()); + S_LoadMusicCredit(); + if (tune->credit && !tune->resume) { S_ShowMusicCredit(); diff --git a/src/p_setup.cpp b/src/p_setup.cpp index d5d33f861..42f596ff8 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -7629,8 +7629,7 @@ static void P_InitLevelSettings(void) g_quakes = NULL; // song credit init - Z_Free(cursongcredit.text); - memset(&cursongcredit,0,sizeof(struct cursongcredit)); + S_StopMusicCredit(); cursongcredit.trans = NUMTRANSMAPS; for (i = 0; i < MAXPLAYERS; i++) diff --git a/src/s_sound.c b/src/s_sound.c index 78d5f618b..eb5f8b020 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1244,6 +1244,7 @@ void S_AttemptToRestoreMusic(void) musicdef_t *musicdefstart = NULL; struct cursongcredit cursongcredit; // Currently displayed song credit info +char *g_realsongcredit; struct soundtest soundtest; // Sound Test (sound test) static void S_InsertMusicAtSoundTestSequenceTail(const char *musname, UINT16 map, UINT8 altref, musicdef_t ***tail) @@ -2093,11 +2094,11 @@ void S_InitMusicDefs(void) } // -// S_ShowMusicCredit +// S_LoadMusicCredit // -// Display current song's credit on screen +// Load the current song's credit into memory // -void S_ShowMusicCredit(void) +void S_LoadMusicCredit(void) { UINT8 i = 0; musicdef_t *def = S_FindMusicDef(Music_CurrentSong(), &i); @@ -2107,18 +2108,13 @@ void S_ShowMusicCredit(void) size_t len = 128, worklen; INT32 widthused = (3*BASEVIDWIDTH/4) - 7, workwidth; - if (!cv_songcredits.value) - return; + S_UnloadMusicCredit(); if (!def) // No definitions return; if (!def->title) - { - // Like showing a blank credit. - S_StopMusicCredit(); return; - } work = va("\x1F %s", def->title); worklen = strlen(work); @@ -2166,9 +2162,34 @@ void S_ShowMusicCredit(void) if (credittext[0] == '\0') return; - cursongcredit.def = def; + g_realsongcredit = Z_StrDup(credittext); +} + +void S_UnloadMusicCredit(void) +{ + Z_Free(g_realsongcredit); + g_realsongcredit = NULL; +} + +// +// S_ShowMusicCredit +// +// Display current song's credit on screen +// +void S_ShowMusicCredit(void) +{ + if (!cv_songcredits.value) + return; + + if (!g_realsongcredit) + { + // Like showing a blank credit. + S_StopMusicCredit(); + return; + } + Z_Free(cursongcredit.text); - cursongcredit.text = Z_StrDup(credittext); + cursongcredit.text = Z_StrDup(g_realsongcredit); cursongcredit.anim = 5*TICRATE; cursongcredit.x = cursongcredit.old_x = 0; cursongcredit.trans = NUMTRANSMAPS; @@ -2176,7 +2197,8 @@ void S_ShowMusicCredit(void) void S_StopMusicCredit(void) { - cursongcredit.def = NULL; + Z_Free(cursongcredit.text); + memset(&cursongcredit,0,sizeof(struct cursongcredit)); } /// ------------------------ diff --git a/src/s_sound.h b/src/s_sound.h index 94dc4935a..9cf67dde0 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -174,9 +174,9 @@ struct musicdef_t soundtestsequence_t sequence; }; +// For HUD, doesn't always appear extern struct cursongcredit { - musicdef_t *def; char *text; UINT16 anim; UINT8 trans; @@ -184,6 +184,9 @@ extern struct cursongcredit fixed_t old_x; } cursongcredit; +// For menu, always appears +extern char *g_realsongcredit; + extern struct soundtest { UINT8 tune; // Tune used for music system @@ -216,6 +219,8 @@ extern musicdef_t *musicdefstart; void S_LoadMusicDefs(UINT16 wadnum); void S_InitMusicDefs(void); musicdef_t *S_FindMusicDef(const char *name, UINT8 *i); +void S_LoadMusicCredit(void); +void S_UnloadMusicCredit(void); void S_ShowMusicCredit(void); void S_StopMusicCredit(void);