- better handling for maps without names.

Use the file's base part as name if that happens.
This commit is contained in:
Christoph Oelckers 2019-12-10 17:35:28 +01:00
parent db29fc1a01
commit 4cc22e155f
6 changed files with 18 additions and 17 deletions

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "gstrings.h" #include "gstrings.h"
#include "cmdlib.h"
// Localization capable replacement of the game specific solutions. // Localization capable replacement of the game specific solutions.
@ -15,6 +16,7 @@ struct MapRecord
int parTime; int parTime;
int designerTime; int designerTime;
FString fileName; FString fileName;
FString labelName;
FString name; FString name;
FString music; FString music;
int cdSongId; int cdSongId;
@ -28,6 +30,7 @@ struct MapRecord
const char *DisplayName() const char *DisplayName()
{ {
if (name.IsEmpty()) return labelName;
return GStrings.localize(name); return GStrings.localize(name);
} }
void SetName(const char *n) void SetName(const char *n)
@ -35,6 +38,12 @@ struct MapRecord
name = n; name = n;
MakeStringLocalizable(name); MakeStringLocalizable(name);
} }
void SetFileName(const char* n)
{
fileName = n;
labelName = ExtractFileBase(n);
}
}; };
extern MapRecord mapList[512]; extern MapRecord mapList[512];

View file

@ -5172,7 +5172,7 @@ repeatcase:
Bcorrectfilename(tempbuf,0); Bcorrectfilename(tempbuf,0);
mapList[j * MAXLEVELS + k].fileName = tempbuf; mapList[j * MAXLEVELS + k].SetFileName(tempbuf);
C_SkipComments(); C_SkipComments();

View file

@ -1819,7 +1819,7 @@ int G_EnterLevel(int gameMode)
if (VOLUMEONE || !Menu_HaveUserMap()) 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); OSD_Printf(OSDTEXT_RED "Map E%dL%d not defined!\n", ud.volume_number+1, ud.level_number+1);
return 1; return 1;

View file

@ -1871,7 +1871,7 @@ static int32_t C_ParseCommand(int32_t loop)
Bcorrectfilename(tempbuf,0); Bcorrectfilename(tempbuf,0);
mapList[j *MAXLEVELS+k].fileName = tempbuf; mapList[j *MAXLEVELS+k].SetFileName(tempbuf);
C_SkipComments(); C_SkipComments();

View file

@ -2340,7 +2340,7 @@ int G_EnterLevel(int gameMode)
mii = (ud.volume_number*MAXLEVELS)+ud.level_number; mii = (ud.volume_number*MAXLEVELS)+ud.level_number;
auto &mi = mapList[mii]; auto &mi = mapList[mii];
if ( mi.name.IsEmpty() || mi.fileName.IsEmpty()) if (mi.fileName.IsEmpty())
{ {
if (RR && g_lastLevel) if (RR && g_lastLevel)
{ {

View file

@ -1025,16 +1025,12 @@ void G_DisplayRest(int32_t smoothratio)
else if (g_levelTextTime < 5) else if (g_levelTextTime < 5)
o |= 1; o |= 1;
if (mapList[(ud.volume_number*MAXLEVELS) + ud.level_number].name.IsNotEmpty())
{
char const * const fn = currentboardfilename[0] != 0 && char const * const fn = currentboardfilename[0] != 0 &&
ud.volume_number == 0 && ud.level_number == 7 ud.volume_number == 0 && ud.level_number == 7
? currentboardfilename ? currentboardfilename
: mapList[(ud.volume_number*MAXLEVELS) + ud.level_number].DisplayName(); : mapList[(ud.volume_number*MAXLEVELS) + ud.level_number].DisplayName();
menutext_(160<<16, (90+16+8)<<16, -g_levelTextTime+22/*quotepulseshade*/, fn, o, TEXT_XCENTER); 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) 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 else
{ {
lastmapname = mapList[G_LastMapInfoIndex()].DisplayName(); 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) if (RR)
@ -2625,8 +2619,6 @@ void G_BonusScreenRRRA(int32_t bonusonly)
else else
{ {
lastmapname = mapList[G_LastMapInfoIndex()].DisplayName(); 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) if ((g_lastLevel && ud.volume_number == 2) || g_vixenLevel)