Realname for Cups

Permits prefixing them like maps AND giving them spaces instead of underscores, fixing the "RECYCLE_A" issue.
This commit is contained in:
toaster 2023-08-08 12:01:41 +01:00
parent 92b8ef33f6
commit b669f8484f
6 changed files with 34 additions and 6 deletions

View file

@ -3496,6 +3496,11 @@ void readcupheader(MYFILE *f, cupheader_t *cup)
else
cup->monitor = (word2[0] - 'A') + 10;
}
else if (fastcmp(word, "REALNAME"))
{
deh_strlcpy(cup->realname, word2,
sizeof(cup->realname), va("%s Cup: realname", cup->name));
}
else if (fastcmp(word, "ICON"))
{
deh_strlcpy(cup->icon, word2,

View file

@ -495,6 +495,15 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile)
sizeof(cup->name), va("Cup header %s: name", word2));
cup->namehash = hash;
char *start = strchr(word2, '_');
if (start)
start++;
else
start = word2;
deh_strlcpy(cup->realname, start,
sizeof(cup->realname), va("%s Cup: realname (default)", cup->name));
// Check to see if we have any custom cup record data that we could substitute in.
unloaded_cupheader_t *unloadedcup, *unloadedprev = NULL;
for (unloadedcup = unloadedcupheaders; unloadedcup; unloadedprev = unloadedcup, unloadedcup = unloadedcup->next)

View file

@ -396,6 +396,8 @@ struct cupheader_t
char name[MAXCUPNAME]; ///< Cup title
UINT32 namehash; ///< Cup title hash
char realname[MAXCUPNAME]; ///< Cup nomme de gurre
char icon[9]; ///< Name of the icon patch
char *levellist[CUPCACHE_MAX]; ///< List of levels that belong to this cup
INT16 cachedlevels[CUPCACHE_MAX]; ///< IDs in levellist, bonusgame, and specialstage

View file

@ -4742,7 +4742,7 @@ void G_LoadGameSettings(void)
}
#define GD_VERSIONCHECK 0xBA5ED123 // Change every major version, as usual
#define GD_VERSIONMINOR 4 // Change every format update
#define GD_VERSIONMINOR 5 // Change every format update
typedef enum
{
@ -5127,7 +5127,19 @@ void G_LoadGameData(void)
cupwindata_t dummywindata[4];
// Find the relevant cup.
READSTRINGL(save.p, cupname, sizeof(cupname));
if (versionMinor < 5)
{
// Before this version cups were called things like RING.
// Now that example cup would be called RR_RING instead.
cupname[0] = cupname[1] = 'R';
cupname[2] = '_';
READSTRINGL(save.p, (cupname + 3), sizeof(cupname) - 3);
}
else
{
READSTRINGL(save.p, cupname, sizeof(cupname));
}
UINT32 hash = quickncasehash(cupname, MAXCUPNAME);
for (cup = kartcupheaders; cup; cup = cup->next)
{

View file

@ -2397,7 +2397,7 @@ static void M_DrawCupTitle(INT16 y, levelsearch_t *levelsearch)
boolean unlocked = (M_GetFirstLevelInList(&temp, levelsearch) != NEXTMAP_INVALID);
UINT8 *colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_GREY, GTC_MENUCACHE);
patch_t *icon = W_CachePatchName(levelsearch->cup->icon, PU_CACHE);
const char *str = (unlocked ? va("%s Cup", levelsearch->cup->name) : "???");
const char *str = (unlocked ? va("%s Cup", levelsearch->cup->realname) : "???");
INT16 offset = V_LSTitleLowStringWidth(str, 0) / 2;
V_DrawLSTitleLowString(BASEVIDWIDTH/2 - offset, y+6, 0, str);
@ -6165,7 +6165,7 @@ static void M_DrawStatsMaps(void)
const char *str;
if (mapheaderinfo[mnum]->cup)
str = va("%s CUP", mapheaderinfo[mnum]->cup->name);
str = va("%s CUP", mapheaderinfo[mnum]->cup->realname);
else
str = "LOST AND FOUND";
@ -6435,7 +6435,7 @@ static void M_DrawStatsGP(void)
V_DrawScaledPatch(24-1, y, 0, W_CachePatchName(cup->icon, PU_CACHE));
V_DrawScaledPatch(24-1, y, 0, W_CachePatchName("CUPBOX", PU_CACHE));
V_DrawThinString(24+21+2, y + 7, 0, cup->name);
V_DrawThinString(24+21+2, y + 7, 0, cup->realname);
x = 7 + BASEVIDWIDTH - 20 - width;
for (j = endj; j >= KARTSPEED_EASY; j--)

View file

@ -1432,7 +1432,7 @@ static const char *M_GetConditionString(condition_t *cn)
continue;
return va("%s%s %s CUP",
completetype, orbetter,
(M_CupLocked(cup) ? "???" : cup->name)
(M_CupLocked(cup) ? "???" : cup->realname)
);
}
return va("INVALID CUP CONDITION \"%d:%d\"", cn->type, cn->requirement);