From 723164152fec2e5c1fb129489ac8027092e627e6 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Mon, 17 Feb 2025 21:43:12 +0100 Subject: [PATCH] Salvage the remaining parts of 8f68a21 I'm keeping the screenshot mapname tho :^) --- src/d_main.cpp | 5 +---- src/discord.c | 13 ------------- src/g_game.c | 4 ++-- src/m_menu.c | 6 +++--- src/m_misc.cpp | 4 ++-- src/p_setup.c | 4 ++-- 6 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 15d5729c9..ede869228 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1893,14 +1893,11 @@ void D_SRB2Main(void) if (server && !M_CheckParm("+map")) { - // Prevent warping to nonexistent levels - if (W_CheckNumForName(G_BuildMapName(pstartmap)) == LUMPERROR) - I_Error("Could not warp to %s (map not found)\n", G_BuildMapName(pstartmap)); // Prevent warping to locked levels // ... unless you're in a dedicated server. Yes, technically this means you can view any level by // running a dedicated server and joining it yourself, but that's better than making dedicated server's // lives hell. - else if (!dedicated && M_MapLocked(pstartmap)) + if (!dedicated && M_MapLocked(pstartmap)) I_Error("You need to unlock this level before you can warp to it!\n"); else { diff --git a/src/discord.c b/src/discord.c index 590446227..4e8af70eb 100644 --- a/src/discord.c +++ b/src/discord.c @@ -442,9 +442,6 @@ void DRPC_UpdatePresence(void) char detailstr[48+1]; -#ifdef USEMAPIMG - char mapimg[8+1]; -#endif char mapname[5+21+21+2+1]; char charimg[4+SKINNAMESIZE+1]; @@ -547,16 +544,6 @@ void DRPC_UpdatePresence(void) if ((gamestate == GS_LEVEL || gamestate == GS_INTERMISSION) // Map info && !(demo.playback && demo.title)) { -#ifdef USEMAPIMG - if ((gamemap >= 1 && gamemap <= 60) // supported race maps - || (gamemap >= 136 && gamemap <= 164)) // supported battle maps - { - snprintf(mapimg, 8, "%s", G_BuildMapName(gamemap)); - strlwr(mapimg); - discordPresence.largeImageKey = mapimg; // Map image - } - else -#endif if (mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) { // Hell map, use the method that got you here :P diff --git a/src/g_game.c b/src/g_game.c index 250d6823c..3b4670eb4 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1354,7 +1354,7 @@ void G_DoLoadLevel(boolean resetplayer) // cleanup if (titlemapinaction == TITLEMAP_LOADING) { - if (W_CheckNumForName(G_BuildMapName(gamemap)) == LUMPERROR) + if (gamemap < 1 || gamemap > nummapheaders) { titlemap = 0; // let's not infinite recursion ok Command_ExitGame_f(); @@ -3606,7 +3606,7 @@ tryagain: break; } - if (vLump == NULL && ((l = W_CheckNumForName(va("%sS01",mapheaderinfo[ix+1]->lumpname))) == LUMPERROR)) + if (vLump == NULL && ((l = W_CheckNumForLongName(va("%sS01",mapheaderinfo[ix+1]->lumpname))) == LUMPERROR)) { vres_Free(vRes); continue; diff --git a/src/m_menu.c b/src/m_menu.c index ae509484f..3d9985ced 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2281,7 +2281,7 @@ static void Dummystaff_OnChange(void) dummystaffname[0] = '\0'; // TODO: Use map header to determine lump name - if ((l = W_CheckNumForName(va("%sS01",G_BuildMapName(cv_nextmap.value)))) == LUMPERROR) + if ((l = W_CheckNumForLongName(va("%sS01",G_BuildMapName(cv_nextmap.value)))) == LUMPERROR) { CV_StealthSetValue(&cv_dummystaff, 0); return; @@ -2290,7 +2290,7 @@ static void Dummystaff_OnChange(void) { char *temp = dummystaffname; UINT8 numstaff = 1; - while (numstaff < 99 && (l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(cv_nextmap.value),numstaff+1))) != LUMPERROR) + while (numstaff < 99 && (l = W_CheckNumForLongName(va("%sS%02u",G_BuildMapName(cv_nextmap.value),numstaff+1))) != LUMPERROR) numstaff++; if (cv_dummystaff.value < 1) @@ -2298,7 +2298,7 @@ static void Dummystaff_OnChange(void) else if (cv_dummystaff.value > numstaff) CV_StealthSetValue(&cv_dummystaff, 1); - if ((l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(cv_nextmap.value), cv_dummystaff.value))) == LUMPERROR) + if ((l = W_CheckNumForLongName(va("%sS%02u",G_BuildMapName(cv_nextmap.value), cv_dummystaff.value))) == LUMPERROR) return; // shouldn't happen but might as well check... G_UpdateStaffGhostName(l); diff --git a/src/m_misc.cpp b/src/m_misc.cpp index c0f1ba187..bbdb9efbd 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -793,7 +793,7 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png "Unknown"; #endif char rendermodetxt[9]; - char maptext[8]; + char maptext[MAXMAPLUMPNAME]; char lvlttltext[48]; char locationtxt[40]; char ctrevision[40]; @@ -814,7 +814,7 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png } if (gamestate == GS_LEVEL) - snprintf(maptext, 8, "%s", G_BuildMapName(gamemap)); + snprintf(maptext, MAXMAPLUMPNAME, "%s", G_BuildMapName(gamemap)); else snprintf(maptext, 8, "Unknown"); diff --git a/src/p_setup.c b/src/p_setup.c index 3a8661a08..dd6b453a5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -7849,7 +7849,7 @@ static void P_LoadRecordGhosts(void) lumpnum_t l; UINT8 j = 1; // TODO: Use map header to determine lump name - while (j <= 99 && (l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(gamemap),j))) != LUMPERROR) + while (j <= 99 && (l = W_CheckNumForLongName(va("%sS%02u",G_BuildMapName(gamemap),j))) != LUMPERROR) { G_AddGhost(va("%sS%02u",G_BuildMapName(gamemap),j)); j++; @@ -7991,7 +7991,7 @@ static void P_InitGametype(void) #else strcpy(ver, VERSIONSTRING); #endif - sprintf(buf, "%s"PATHSEP"media"PATHSEP"replay"PATHSEP"online"PATHSEP"%s"PATHSEP"%d-%s", + snprintf(buf, sizeof buf, "%s"PATHSEP"media"PATHSEP"replay"PATHSEP"online"PATHSEP"%s"PATHSEP"%d-%s", srb2home, ver, (int) (time(NULL)), G_BuildMapName(gamemap)); parts = M_PathParts(buf);