From 7b62c14a8efcbc8fd90db0b6c8f2196dbdfadc67 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Oct 2024 12:42:04 +0200 Subject: [PATCH] Revert "add global maptitle string calced at mapload" This reverts commit 401597d309ba7da6bbaa31dcc00bf5a5e5904482. --- src/d_netcmd.c | 2 +- src/discord.c | 4 +++- src/doomstat.h | 1 - src/g_game.c | 22 +++++++++++++--------- src/hu_stuff.c | 4 ++-- src/s_sound.c | 2 +- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 96de8ed95..1322c4c5b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3141,7 +3141,7 @@ static void Command_ReplayMarker(void) demo.savemode = DSM_WILLAUTOSAVE; if (adjustedleveltime < 0) adjustedleveltime = 0; - snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", maptitle, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); + snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", G_BuildMapTitle(gamemap), G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); CONS_Printf("Replay will be saved!\n"); } } diff --git a/src/discord.c b/src/discord.c index 17b8ea836..cd7dafa8f 100644 --- a/src/discord.c +++ b/src/discord.c @@ -570,8 +570,10 @@ void DRPC_UpdatePresence(void) else { // Map name on tool tip - snprintf(mapname, 48, "Map: %s", maptitle); + char *title = G_BuildMapTitle(gamemap); + snprintf(mapname, 48, "Map: %s", title); discordPresence.largeImageText = mapname; + Z_Free(title); } if (gamestate == GS_LEVEL && Playing()) diff --git a/src/doomstat.h b/src/doomstat.h index f69402f25..fad4d4521 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -31,7 +31,6 @@ // Selected by user. extern INT16 gamemap; -extern char *maptitle; extern char mapmusname[7]; extern UINT16 mapmusflags; extern UINT32 mapmusposition; diff --git a/src/g_game.c b/src/g_game.c index 1c964473c..cd3030566 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -91,7 +91,6 @@ UINT32 mapmusposition; // Position to jump to UINT32 mapmusresume; INT16 gamemap = 1; -char *maptitle = {0}; INT16 maptol; UINT8 globalweather = 0; INT32 curWeather = PRECIP_NONE; @@ -4249,10 +4248,6 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool gamemap = (INT16)M_MapNumber(mapname[3], mapname[4]); // get xx out of MAPxx - if (maptitle) - Z_Free(maptitle); - maptitle = G_BuildMapTitle(gamemap); - // gamemap changed; we assume that its map header is always valid, // so make it so if(!mapheaderinfo[gamemap-1]) @@ -4278,9 +4273,14 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool if (netgame) { + char *title = G_BuildMapTitle(gamemap); + CON_LogMessage(va(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap))); - if (maptitle) - CON_LogMessage(va(": %s", maptitle)); + if (title) + { + CON_LogMessage(va(": %s", title)); + Z_Free(title); + } CON_LogMessage("\"\n"); } } @@ -4429,7 +4429,8 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, break; } } - else if (apromapnum == 0 || wanttable) + else + if (apromapnum == 0 || wanttable) { /* LEVEL 1--match keywords verbatim */ if (( aprop = strcasestr(realmapname, mapname) )) @@ -6261,7 +6262,7 @@ void G_BeginRecording(void) demoflags |= DF_ENCORE; if (!modeattacking && gL) // Ghosts don't read luavars, and you shouldn't ever need to save Lua in replays, you doof! - // SERIOUSLY THOUGH WHY WOULD YOU LOAD HOSTMOD AND RECORD A GHOST WITH IT !???? + // SERIOUSLY THOUGH WHY WOULD YOU LOAD HOSTMOD AND RECORD A GHOST WITH IT !???? demoflags |= DF_LUAVARS; // Setup header. @@ -6283,6 +6284,9 @@ void G_BeginRecording(void) // This will indirectly assign to demo.titlename too M_TextInputSetString(&demo.titlenameinput, demotitlename); + char *title = G_BuildMapTitle(gamemap); + snprintf(demo.titlename, 64, "%s - %s", title, modeattacking ? "Time Attack" : connectedservername); + Z_Free(title); } // demo checksum diff --git a/src/hu_stuff.c b/src/hu_stuff.c index d3ceb3aa0..9f96e31c1 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2630,10 +2630,10 @@ static void HU_DrawRankings(void) //V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, gametype_cons_t[gametype].strvalue); // draw the current map in the lower right if theres none just say its unknown - if (!maptitle) + if (!G_BuildMapTitle(gamemap)) V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, "UNKNOWN"); else - V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, maptitle); + V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, G_BuildMapTitle(gamemap)); if (!G_RaceGametype()) { diff --git a/src/s_sound.c b/src/s_sound.c index f222b35f1..1a3e310ae 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2041,7 +2041,7 @@ void S_CheckMap(void) // void S_InitMapMusic(void) { - skipintromus = cv_skipintromusic.value && stricmp(maptitle, "Wandering Falls") != 0; // thanks diggle! + skipintromus = cv_skipintromusic.value && stricmp(G_BuildMapTitle(gamemap), "Wandering Falls") != 0; // thanks diggle! if (mapmusflags & MUSIC_RELOADRESET) {