K_drawKartTimestamp: Do not update visible emblems on level completion unless you got more than one on completion

TODO: this code relies heavily on static variables. It has always done so, but the extent to which they're currently employed is worth a fresh look
This commit is contained in:
toaster 2023-02-05 00:35:22 +00:00
parent 2207115424
commit ac2255572a

View file

@ -1471,6 +1471,9 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI
// TIME_X = BASEVIDWIDTH-124; // 196 // TIME_X = BASEVIDWIDTH-124; // 196
// TIME_Y = 6; // 6 // TIME_Y = 6; // 6
static UINT8 prevmode = UINT8_MAX;
static emblem_t *maxemblem = NULL;
tic_t worktime; tic_t worktime;
INT32 jitter = 0; INT32 jitter = 0;
@ -1510,6 +1513,10 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI
} }
} }
if (mode != prevmode)
maxemblem = NULL;
prevmode = mode;
V_DrawScaledPatch(TX, TY, splitflags, ((mode == 2) ? kp_lapstickerwide : kp_timestickerwide)); V_DrawScaledPatch(TX, TY, splitflags, ((mode == 2) ? kp_lapstickerwide : kp_timestickerwide));
TX += 33; TX += 33;
@ -1558,10 +1565,13 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI
UINT8 *emblemcol[3] = {NULL, NULL, NULL}; UINT8 *emblemcol[3] = {NULL, NULL, NULL};
emblem_t *emblem = M_GetLevelEmblems(emblemmap); emblem_t *emblem = M_GetLevelEmblems(emblemmap);
while (emblem) while (emblem)
{ {
char targettext[9]; char targettext[9];
emblem_t *nextemblem = M_GetLevelEmblems(-1);
switch (emblem->type) switch (emblem->type)
{ {
case ET_TIME: case ET_TIME:
@ -1573,11 +1583,20 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI
{ {
emblempic[curemb] = W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_CACHE); emblempic[curemb] = W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_CACHE);
emblemcol[curemb] = R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE); emblemcol[curemb] = R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE);
if (++curemb == 3) curemb++;
break;
if (emblem == maxemblem
&& nextemblem != NULL
&& nextemblem->type == emblem->type
&& gamedata->collected[(nextemblem-emblemlocations)])
maxemblem = NULL;
if (emblem != maxemblem)
goto bademblem; goto bademblem;
} }
maxemblem = emblem;
if (emblem->tag > 0) if (emblem->tag > 0)
{ {
if (emblem->tag > mapheaderinfo[emblemmap-1]->ghostCount if (emblem->tag > mapheaderinfo[emblemmap-1]->ghostCount
@ -1616,13 +1635,19 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI
workx -= V_ThinStringWidth(targettext, splitflags|V_6WIDTHSPACE); workx -= V_ThinStringWidth(targettext, splitflags|V_6WIDTHSPACE);
V_DrawThinString(workx, worky, splitflags|V_6WIDTHSPACE, targettext); V_DrawThinString(workx, worky, splitflags|V_6WIDTHSPACE, targettext);
workx -= 11;
V_DrawSmallScaledPatch(workx, worky, splitflags, W_CachePatchName("NEEDIT", PU_CACHE)); if (emblem != maxemblem || !gamedata->collected[(emblem-emblemlocations)])
{
emblempic[curemb] = W_CachePatchName("NEEDIT", PU_CACHE);
curemb++;
}
break; break;
bademblem: bademblem:
emblem = M_GetLevelEmblems(-1); if (emblem == maxemblem || curemb == 3)
break;
emblem = nextemblem;
} }
if (!mode) if (!mode)