From 4cc22e155f54920dec378f576a2b04c7df7bf12d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Dec 2019 17:35:28 +0100 Subject: [PATCH] - better handling for maps without names. Use the file's base part as name if that happens. --- source/common/mapinfo.h | 9 +++++++++ source/duke3d/src/gamedef.cpp | 2 +- source/duke3d/src/premap.cpp | 2 +- source/rr/src/gamedef.cpp | 2 +- source/rr/src/premap.cpp | 2 +- source/rr/src/screens.cpp | 18 +++++------------- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/source/common/mapinfo.h b/source/common/mapinfo.h index 8ff323376..c7baaa79f 100644 --- a/source/common/mapinfo.h +++ b/source/common/mapinfo.h @@ -1,6 +1,7 @@ #pragma once #include "gstrings.h" +#include "cmdlib.h" // Localization capable replacement of the game specific solutions. @@ -15,6 +16,7 @@ struct MapRecord int parTime; int designerTime; FString fileName; + FString labelName; FString name; FString music; int cdSongId; @@ -28,6 +30,7 @@ struct MapRecord const char *DisplayName() { + if (name.IsEmpty()) return labelName; return GStrings.localize(name); } void SetName(const char *n) @@ -35,6 +38,12 @@ struct MapRecord name = n; MakeStringLocalizable(name); } + void SetFileName(const char* n) + { + fileName = n; + labelName = ExtractFileBase(n); + } + }; extern MapRecord mapList[512]; diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 512dbb955..fd6134b90 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -5172,7 +5172,7 @@ repeatcase: Bcorrectfilename(tempbuf,0); - mapList[j * MAXLEVELS + k].fileName = tempbuf; + mapList[j * MAXLEVELS + k].SetFileName(tempbuf); C_SkipComments(); diff --git a/source/duke3d/src/premap.cpp b/source/duke3d/src/premap.cpp index 84a9ece65..a8a0a9339 100644 --- a/source/duke3d/src/premap.cpp +++ b/source/duke3d/src/premap.cpp @@ -1819,7 +1819,7 @@ int G_EnterLevel(int gameMode) if (VOLUMEONE || !Menu_HaveUserMap()) { - if (mm.name.IsEmpty() || mm.fileName.IsEmpty()) + if (mm.fileName.IsEmpty()) { OSD_Printf(OSDTEXT_RED "Map E%dL%d not defined!\n", ud.volume_number+1, ud.level_number+1); return 1; diff --git a/source/rr/src/gamedef.cpp b/source/rr/src/gamedef.cpp index 582bdc011..6ca7bd465 100644 --- a/source/rr/src/gamedef.cpp +++ b/source/rr/src/gamedef.cpp @@ -1871,7 +1871,7 @@ static int32_t C_ParseCommand(int32_t loop) Bcorrectfilename(tempbuf,0); - mapList[j *MAXLEVELS+k].fileName = tempbuf; + mapList[j *MAXLEVELS+k].SetFileName(tempbuf); C_SkipComments(); diff --git a/source/rr/src/premap.cpp b/source/rr/src/premap.cpp index 2edc60e0c..19b37b88e 100644 --- a/source/rr/src/premap.cpp +++ b/source/rr/src/premap.cpp @@ -2340,7 +2340,7 @@ int G_EnterLevel(int gameMode) mii = (ud.volume_number*MAXLEVELS)+ud.level_number; auto &mi = mapList[mii]; - if ( mi.name.IsEmpty() || mi.fileName.IsEmpty()) + if (mi.fileName.IsEmpty()) { if (RR && g_lastLevel) { diff --git a/source/rr/src/screens.cpp b/source/rr/src/screens.cpp index 0685b1468..cb4c93e07 100644 --- a/source/rr/src/screens.cpp +++ b/source/rr/src/screens.cpp @@ -1025,15 +1025,11 @@ void G_DisplayRest(int32_t smoothratio) else if (g_levelTextTime < 5) o |= 1; - if (mapList[(ud.volume_number*MAXLEVELS) + ud.level_number].name.IsNotEmpty()) - { - char const * const fn = currentboardfilename[0] != 0 && - ud.volume_number == 0 && ud.level_number == 7 - ? currentboardfilename - : mapList[(ud.volume_number*MAXLEVELS) + ud.level_number].DisplayName(); - - menutext_(160<<16, (90+16+8)<<16, -g_levelTextTime+22/*quotepulseshade*/, fn, o, TEXT_XCENTER); - } + char const * const fn = currentboardfilename[0] != 0 && + ud.volume_number == 0 && ud.level_number == 7 + ? currentboardfilename + : mapList[(ud.volume_number*MAXLEVELS) + ud.level_number].DisplayName(); + menutext_(160<<16, (90+16+8)<<16, -g_levelTextTime+22/*quotepulseshade*/, fn, o, TEXT_XCENTER); } if (g_player[myconnectindex].ps->newowner == -1 && ud.overhead_on == 0 && cl_crosshair && ud.camerasprite == -1) @@ -2045,8 +2041,6 @@ void G_BonusScreen(int32_t bonusonly) else { lastmapname = mapList[G_LastMapInfoIndex()].DisplayName(); - if (!lastmapname || !*lastmapname) // this isn't right but it's better than no name at all - lastmapname = mapList[G_LastMapInfoIndex()].fileName; } if (RR) @@ -2625,8 +2619,6 @@ void G_BonusScreenRRRA(int32_t bonusonly) else { lastmapname = mapList[G_LastMapInfoIndex()].DisplayName(); - if (!lastmapname || !*lastmapname) // this isn't right but it's better than no name at all - lastmapname = mapList[G_LastMapInfoIndex()].fileName; } if ((g_lastLevel && ud.volume_number == 2) || g_vixenLevel)