Merge branch 'master' of https://git.do.srb2.org/KartKrew/Kart into cheats-streamline

This commit is contained in:
toaster 2022-09-26 17:07:02 +01:00
commit 4d9f19200b
5 changed files with 56 additions and 62 deletions

View file

@ -2553,10 +2553,8 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
if (!FIL_ReadFile(pdemo->filepath, &infobuffer)) if (!FIL_ReadFile(pdemo->filepath, &infobuffer))
{ {
CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), pdemo->filepath); CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), pdemo->filepath);
pdemo->type = MD_INVALID; infobuffer = NULL;
sprintf(pdemo->title, "INVALID REPLAY"); goto badreplay;
return;
} }
info_p = infobuffer; info_p = infobuffer;
@ -2564,10 +2562,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
if (memcmp(info_p, DEMOHEADER, 12)) if (memcmp(info_p, DEMOHEADER, 12))
{ {
CONS_Alert(CONS_ERROR, M_GetText("%s is not a Ring Racers replay file.\n"), pdemo->filepath); CONS_Alert(CONS_ERROR, M_GetText("%s is not a Ring Racers replay file.\n"), pdemo->filepath);
pdemo->type = MD_INVALID; goto badreplay;
sprintf(pdemo->title, "INVALID REPLAY");
Z_Free(infobuffer);
return;
} }
pdemo->type = MD_LOADED; pdemo->type = MD_LOADED;
@ -2589,10 +2584,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
// too old, cannot support. // too old, cannot support.
default: default:
CONS_Alert(CONS_ERROR, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemo->filepath); CONS_Alert(CONS_ERROR, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemo->filepath);
pdemo->type = MD_INVALID; goto badreplay;
sprintf(pdemo->title, "INVALID REPLAY");
Z_Free(infobuffer);
return;
} }
if (version != VERSION || subversion != SUBVERSION) if (version != VERSION || subversion != SUBVERSION)
@ -2602,10 +2594,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
if (memcmp(info_p, "PLAY", 4)) if (memcmp(info_p, "PLAY", 4))
{ {
CONS_Alert(CONS_ERROR, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemo->filepath); CONS_Alert(CONS_ERROR, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemo->filepath);
pdemo->type = MD_INVALID; goto badreplay;
sprintf(pdemo->title, "INVALID REPLAY");
Z_Free(infobuffer);
return;
} }
info_p += 4; // "PLAY" info_p += 4; // "PLAY"
READSTRINGN(info_p, mapname, sizeof(mapname)); READSTRINGN(info_p, mapname, sizeof(mapname));
@ -2704,6 +2693,12 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
// I think that's everything we need? // I think that's everything we need?
Z_Free(infobuffer); Z_Free(infobuffer);
return;
badreplay:
pdemo->type = MD_INVALID;
sprintf(pdemo->title, "INVALID REPLAY");
Z_Free(infobuffer);
} }
// //

View file

@ -575,6 +575,7 @@ char sprnames[NUMSPRITES + 1][5] =
"FLMP", // Flame Shield paper sprites "FLMP", // Flame Shield paper sprites
"FLML", // Flame Shield speed lines "FLML", // Flame Shield speed lines
"FLMF", // Flame Shield flash "FLMF", // Flame Shield flash
"GTOP", // Marble Garden Zone Spinning Top
"HYUU", // Hyudoro "HYUU", // Hyudoro
"GRWP", // Grow "GRWP", // Grow
"POHB", // Shrink Poh-Bee "POHB", // Shrink Poh-Bee

View file

@ -1119,6 +1119,7 @@ typedef enum sprite
SPR_FLMP, // Flame Shield paper sprites SPR_FLMP, // Flame Shield paper sprites
SPR_FLML, // Flame Shield speed lines SPR_FLML, // Flame Shield speed lines
SPR_FLMF, // Flame Shield flash SPR_FLMF, // Flame Shield flash
SPR_GTOP, // Marble Garden Zone Spinning Top
SPR_HYUU, // Hyudoro SPR_HYUU, // Hyudoro
SPR_GRWP, // Grow SPR_GRWP, // Grow
SPR_POHB, // Shrink Poh-Bee SPR_POHB, // Shrink Poh-Bee

View file

@ -1062,7 +1062,6 @@ void M_DrawExtrasMovingButton(void);
void M_DrawExtras(void); void M_DrawExtras(void);
void M_DrawReplayHut(void); void M_DrawReplayHut(void);
void M_DrawReplayStartMenu(void); void M_DrawReplayStartMenu(void);
void M_DrawReplayHutReplayInfo(void);
// Misc menus: // Misc menus:
#define LOCATIONSTRING1 "Visit \x83SRB2.ORG/MODS\x80 to get & make addons!" #define LOCATIONSTRING1 "Visit \x83SRB2.ORG/MODS\x80 to get & make addons!"

View file

@ -3807,13 +3807,13 @@ void M_DrawPlaybackMenu(void)
#define SCALEDVIEWWIDTH (vid.width/vid.dupx) #define SCALEDVIEWWIDTH (vid.width/vid.dupx)
#define SCALEDVIEWHEIGHT (vid.height/vid.dupy) #define SCALEDVIEWHEIGHT (vid.height/vid.dupy)
void M_DrawReplayHutReplayInfo(void) static void M_DrawReplayHutReplayInfo(menudemo_t *demoref)
{ {
patch_t *patch = NULL; patch_t *patch = NULL;
UINT8 *colormap; UINT8 *colormap;
INT32 x, y, w, h; INT32 x, y, w, h;
switch (extrasmenu.demolist[dir_on[menudepthleft]].type) switch (demoref->type)
{ {
case MD_NOTLOADED: case MD_NOTLOADED:
V_DrawCenteredString(160, 40, V_SNAPTOTOP, "Loading replay information..."); V_DrawCenteredString(160, 40, V_SNAPTOTOP, "Loading replay information...");
@ -3834,22 +3834,20 @@ void M_DrawReplayHutReplayInfo(void)
x = 15; y = 15; x = 15; y = 15;
// A 160x100 image of the level as entry MAPxxP // A 160x100 image of the level as entry MAPxxP
//CONS_Printf("%d %s\n", extrasmenu.demolist[dir_on[menudepthleft]].map, G_BuildMapName(extrasmenu.demolist[dir_on[menudepthleft]].map)); if (demoref->map < nummapheaders && mapheaderinfo[demoref->map])
if (mapheaderinfo[extrasmenu.demolist[dir_on[menudepthleft]].map])
{ {
patch = mapheaderinfo[extrasmenu.demolist[dir_on[menudepthleft]].map]->thumbnailPic; patch = mapheaderinfo[demoref->map]->thumbnailPic;
if (!patch) if (!patch)
{ {
patch = blanklvl; patch = blanklvl;
} }
} }
else if (!patch) else
{ {
patch = W_CachePatchName("M_NOLVL", PU_CACHE); patch = W_CachePatchName("M_NOLVL", PU_CACHE);
} }
if (!(extrasmenu.demolist[dir_on[menudepthleft]].kartspeed & DF_ENCORE)) if (!(demoref->kartspeed & DF_ENCORE))
V_DrawSmallScaledPatch(x, y, V_SNAPTOTOP, patch); V_DrawSmallScaledPatch(x, y, V_SNAPTOTOP, patch);
else else
{ {
@ -3867,43 +3865,42 @@ void M_DrawReplayHutReplayInfo(void)
x += 85; x += 85;
if (mapheaderinfo[extrasmenu.demolist[dir_on[menudepthleft]].map-1]) if (demoref->map < nummapheaders && mapheaderinfo[demoref->map])
V_DrawString(x, y, V_SNAPTOTOP, G_BuildMapTitle(extrasmenu.demolist[dir_on[menudepthleft]].map)); V_DrawString(x, y, V_SNAPTOTOP, G_BuildMapTitle(demoref->map+1));
else else
V_DrawString(x, y, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT, "Level is not loaded."); V_DrawString(x, y, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT, "Level is not loaded.");
if (extrasmenu.demolist[dir_on[menudepthleft]].numlaps) if (demoref->numlaps)
V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("(%d laps)", extrasmenu.demolist[dir_on[menudepthleft]].numlaps)); V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("(%d laps)", demoref->numlaps));
V_DrawString(x, y+20, V_SNAPTOTOP|V_ALLOWLOWERCASE, extrasmenu.demolist[dir_on[menudepthleft]].gametype == GT_RACE ? V_DrawString(x, y+20, V_SNAPTOTOP|V_ALLOWLOWERCASE, demoref->gametype == GT_RACE ?
va("Race (%s speed)", kartspeed_cons_t[(extrasmenu.demolist[dir_on[menudepthleft]].kartspeed & ~DF_ENCORE) + 1].strvalue) : va("Race (%s speed)", kartspeed_cons_t[(demoref->kartspeed & ~DF_ENCORE) + 1].strvalue) :
"Battle Mode"); "Battle Mode");
if (!extrasmenu.demolist[dir_on[menudepthleft]].standings[0].ranking) if (!demoref->standings[0].ranking)
{ {
// No standings were loaded! // No standings were loaded!
V_DrawString(x, y+39, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT, "No standings available."); V_DrawString(x, y+39, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT, "No standings available.");
break; break;
} }
V_DrawThinString(x, y+29, V_SNAPTOTOP|highlightflags, "WINNER"); V_DrawThinString(x, y+29, V_SNAPTOTOP|highlightflags, "WINNER");
V_DrawString(x+38, y+30, V_SNAPTOTOP|V_ALLOWLOWERCASE, extrasmenu.demolist[dir_on[menudepthleft]].standings[0].name); V_DrawString(x+38, y+30, V_SNAPTOTOP|V_ALLOWLOWERCASE, demoref->standings[0].name);
if (extrasmenu.demolist[dir_on[menudepthleft]].gametype == GT_RACE) if (demoref->gametype == GT_RACE)
{ {
V_DrawThinString(x, y+39, V_SNAPTOTOP|highlightflags, "TIME"); V_DrawThinString(x, y+39, V_SNAPTOTOP|highlightflags, "TIME");
V_DrawRightAlignedString(x+84, y+40, V_SNAPTOTOP, va("%d'%02d\"%02d", V_DrawRightAlignedString(x+84, y+40, V_SNAPTOTOP, va("%d'%02d\"%02d",
G_TicsToMinutes(extrasmenu.demolist[dir_on[menudepthleft]].standings[0].timeorscore, true), G_TicsToMinutes(demoref->standings[0].timeorscore, true),
G_TicsToSeconds(extrasmenu.demolist[dir_on[menudepthleft]].standings[0].timeorscore), G_TicsToSeconds(demoref->standings[0].timeorscore),
G_TicsToCentiseconds(extrasmenu.demolist[dir_on[menudepthleft]].standings[0].timeorscore) G_TicsToCentiseconds(demoref->standings[0].timeorscore)
)); ));
} }
else else
{ {
V_DrawThinString(x, y+39, V_SNAPTOTOP|highlightflags, "SCORE"); V_DrawThinString(x, y+39, V_SNAPTOTOP|highlightflags, "SCORE");
V_DrawString(x+32, y+40, V_SNAPTOTOP, va("%d", extrasmenu.demolist[dir_on[menudepthleft]].standings[0].timeorscore)); V_DrawString(x+32, y+40, V_SNAPTOTOP, va("%d", demoref->standings[0].timeorscore));
} }
// Character face! // Character face!
@ -3911,12 +3908,12 @@ void M_DrawReplayHutReplayInfo(void)
// Lat: 08/06/2020: For some reason missing skins have their value set to 255 (don't even ask me why I didn't write this) // Lat: 08/06/2020: For some reason missing skins have their value set to 255 (don't even ask me why I didn't write this)
// and for an even STRANGER reason this passes the first check below, so we're going to make sure that the skin here ISN'T 255 before we do anything stupid. // and for an even STRANGER reason this passes the first check below, so we're going to make sure that the skin here ISN'T 255 before we do anything stupid.
if (extrasmenu.demolist[dir_on[menudepthleft]].standings[0].skin != 0xFF) if (demoref->standings[0].skin != 0xFF)
{ {
patch = faceprefix[extrasmenu.demolist[dir_on[menudepthleft]].standings[0].skin][FACE_WANTED]; patch = faceprefix[demoref->standings[0].skin][FACE_WANTED];
colormap = R_GetTranslationColormap( colormap = R_GetTranslationColormap(
extrasmenu.demolist[dir_on[menudepthleft]].standings[0].skin, demoref->standings[0].skin,
extrasmenu.demolist[dir_on[menudepthleft]].standings[0].color, demoref->standings[0].color,
GTC_MENUCACHE); GTC_MENUCACHE);
} }
else else
@ -3924,7 +3921,7 @@ void M_DrawReplayHutReplayInfo(void)
patch = W_CachePatchName("M_NOWANT", PU_CACHE); patch = W_CachePatchName("M_NOWANT", PU_CACHE);
colormap = R_GetTranslationColormap( colormap = R_GetTranslationColormap(
TC_RAINBOW, TC_RAINBOW,
extrasmenu.demolist[dir_on[menudepthleft]].standings[0].color, demoref->standings[0].color,
GTC_MENUCACHE); GTC_MENUCACHE);
} }
@ -4073,7 +4070,7 @@ void M_DrawReplayHut(void)
if (itemOn == replaylistitem) if (itemOn == replaylistitem)
{ {
M_DrawReplayHutReplayInfo(); M_DrawReplayHutReplayInfo(&extrasmenu.demolist[dir_on[menudepthleft]]);
} }
} }
@ -4081,42 +4078,43 @@ void M_DrawReplayStartMenu(void)
{ {
const char *warning; const char *warning;
UINT8 i; UINT8 i;
menudemo_t *demoref = &extrasmenu.demolist[dir_on[menudepthleft]];
M_DrawEggaChannel(); M_DrawEggaChannel();
M_DrawGenericMenu(); M_DrawGenericMenu();
#define STARTY 62-(extrasmenu.replayScrollTitle>>1) #define STARTY 62-(extrasmenu.replayScrollTitle>>1)
// Draw rankings beyond first // Draw rankings beyond first
for (i = 1; i < MAXPLAYERS && extrasmenu.demolist[dir_on[menudepthleft]].standings[i].ranking; i++) for (i = 1; i < MAXPLAYERS && demoref->standings[i].ranking; i++)
{ {
patch_t *patch; patch_t *patch;
UINT8 *colormap; UINT8 *colormap;
V_DrawRightAlignedString(BASEVIDWIDTH-100, STARTY + i*20, V_SNAPTOTOP|highlightflags, va("%2d", extrasmenu.demolist[dir_on[menudepthleft]].standings[i].ranking)); V_DrawRightAlignedString(BASEVIDWIDTH-100, STARTY + i*20, V_SNAPTOTOP|highlightflags, va("%2d", demoref->standings[i].ranking));
V_DrawThinString(BASEVIDWIDTH-96, STARTY + i*20, V_SNAPTOTOP|V_ALLOWLOWERCASE, extrasmenu.demolist[dir_on[menudepthleft]].standings[i].name); V_DrawThinString(BASEVIDWIDTH-96, STARTY + i*20, V_SNAPTOTOP|V_ALLOWLOWERCASE, demoref->standings[i].name);
if (extrasmenu.demolist[dir_on[menudepthleft]].standings[i].timeorscore == UINT32_MAX-1) if (demoref->standings[i].timeorscore == UINT32_MAX-1)
V_DrawThinString(BASEVIDWIDTH-92, STARTY + i*20 + 9, V_SNAPTOTOP, "NO CONTEST"); V_DrawThinString(BASEVIDWIDTH-92, STARTY + i*20 + 9, V_SNAPTOTOP, "NO CONTEST");
else if (extrasmenu.demolist[dir_on[menudepthleft]].gametype == GT_RACE) else if (demoref->gametype == GT_RACE)
V_DrawRightAlignedString(BASEVIDWIDTH-40, STARTY + i*20 + 9, V_SNAPTOTOP, va("%d'%02d\"%02d", V_DrawRightAlignedString(BASEVIDWIDTH-40, STARTY + i*20 + 9, V_SNAPTOTOP, va("%d'%02d\"%02d",
G_TicsToMinutes(extrasmenu.demolist[dir_on[menudepthleft]].standings[i].timeorscore, true), G_TicsToMinutes(demoref->standings[i].timeorscore, true),
G_TicsToSeconds(extrasmenu.demolist[dir_on[menudepthleft]].standings[i].timeorscore), G_TicsToSeconds(demoref->standings[i].timeorscore),
G_TicsToCentiseconds(extrasmenu.demolist[dir_on[menudepthleft]].standings[i].timeorscore) G_TicsToCentiseconds(demoref->standings[i].timeorscore)
)); ));
else else
V_DrawString(BASEVIDWIDTH-92, STARTY + i*20 + 9, V_SNAPTOTOP, va("%d", extrasmenu.demolist[dir_on[menudepthleft]].standings[i].timeorscore)); V_DrawString(BASEVIDWIDTH-92, STARTY + i*20 + 9, V_SNAPTOTOP, va("%d", demoref->standings[i].timeorscore));
// Character face! // Character face!
// Lat: 08/06/2020: For some reason missing skins have their value set to 255 (don't even ask me why I didn't write this) // Lat: 08/06/2020: For some reason missing skins have their value set to 255 (don't even ask me why I didn't write this)
// and for an even STRANGER reason this passes the first check below, so we're going to make sure that the skin here ISN'T 255 before we do anything stupid. // and for an even STRANGER reason this passes the first check below, so we're going to make sure that the skin here ISN'T 255 before we do anything stupid.
if (extrasmenu.demolist[dir_on[menudepthleft]].standings[i].skin != 0xFF) if (demoref->standings[i].skin != 0xFF)
{ {
patch = faceprefix[extrasmenu.demolist[dir_on[menudepthleft]].standings[i].skin][FACE_RANK]; patch = faceprefix[demoref->standings[i].skin][FACE_RANK];
colormap = R_GetTranslationColormap( colormap = R_GetTranslationColormap(
extrasmenu.demolist[dir_on[menudepthleft]].standings[i].skin, demoref->standings[i].skin,
extrasmenu.demolist[dir_on[menudepthleft]].standings[i].color, demoref->standings[i].color,
GTC_MENUCACHE); GTC_MENUCACHE);
} }
else else
@ -4124,7 +4122,7 @@ void M_DrawReplayStartMenu(void)
patch = W_CachePatchName("M_NORANK", PU_CACHE); patch = W_CachePatchName("M_NORANK", PU_CACHE);
colormap = R_GetTranslationColormap( colormap = R_GetTranslationColormap(
TC_RAINBOW, TC_RAINBOW,
extrasmenu.demolist[dir_on[menudepthleft]].standings[i].color, demoref->standings[i].color,
GTC_MENUCACHE); GTC_MENUCACHE);
} }
@ -4157,12 +4155,12 @@ void M_DrawReplayStartMenu(void)
} }
V_DrawFill(10, 10, 300, 60, V_SNAPTOTOP|159); V_DrawFill(10, 10, 300, 60, V_SNAPTOTOP|159);
M_DrawReplayHutReplayInfo(); M_DrawReplayHutReplayInfo(demoref);
V_DrawString(10, 72, V_SNAPTOTOP|highlightflags|V_ALLOWLOWERCASE, extrasmenu.demolist[dir_on[menudepthleft]].title); V_DrawString(10, 72, V_SNAPTOTOP|highlightflags|V_ALLOWLOWERCASE, demoref->title);
// Draw a warning prompt if needed // Draw a warning prompt if needed
switch (extrasmenu.demolist[dir_on[menudepthleft]].addonstatus) switch (demoref->addonstatus)
{ {
case DFILE_ERROR_CANNOTLOAD: case DFILE_ERROR_CANNOTLOAD:
warning = "Some addons in this replay cannot be loaded.\nYou can watch anyway, but desyncs may occur."; warning = "Some addons in this replay cannot be loaded.\nYou can watch anyway, but desyncs may occur.";