mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
M_GetRecordMode
Simplifies a lot of copypasted "modeprefix" evaluations into one simple call. Only G_UpdateRecordReplays is seperate. Resolves two issues: - Guest replay ghosts have been broken for a while and nobody noticed (untracked) - Cannot watch back hivolt replays (#1656) In addition, makes it way easier to add new modeprefixes later.
This commit is contained in:
parent
19600c2589
commit
151b91f204
5 changed files with 29 additions and 74 deletions
|
|
@ -1008,7 +1008,7 @@ consvar_t cv_dummyprofilerumble = MenuDummy("dummyprofilerumble", "On").on_off()
|
|||
consvar_t cv_dummyscramble = MenuDummy("dummyscramble", "Random").values({{0, "Random"}, {1, "Points"}});
|
||||
|
||||
void CV_SPBAttackChanged(void);
|
||||
consvar_t cv_dummyspbattack = MenuDummy("dummyspbattack", "Off").on_off().onchange(CV_SPBAttackChanged);
|
||||
consvar_t cv_dummyspbattack = MenuDummy("dummyspbattack", "Off").on_off().onchange_noinit(CV_SPBAttackChanged);
|
||||
|
||||
consvar_t cv_dummyspectate = MenuDummy("dummyspectate", "Spectator").values({{0, "Spectator"}, {1, "Playing"}});
|
||||
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@ extern boolean imcontinuing; // Temporary flag while continuing
|
|||
#define ATTACKING_LAP (1<<1)
|
||||
#define ATTACKING_SPB (1<<2)
|
||||
extern UINT8 modeattacking;
|
||||
const char *M_GetRecordMode(void);
|
||||
|
||||
// menu demo things
|
||||
extern UINT8 numDemos;
|
||||
|
|
|
|||
|
|
@ -588,6 +588,7 @@ static void G_UpdateRecordReplays(void)
|
|||
char lastdemo[256], bestdemo[256];
|
||||
const char *modeprefix = "";
|
||||
|
||||
// See also M_GetRecordMode
|
||||
if (encoremode)
|
||||
{
|
||||
modeprefix = "spb-";
|
||||
|
|
|
|||
|
|
@ -266,6 +266,23 @@ menu_t PLAY_TAGhostsDef = {
|
|||
NULL
|
||||
};
|
||||
|
||||
// See also G_UpdateRecordReplays
|
||||
const char *M_GetRecordMode(void)
|
||||
{
|
||||
if (cv_dummyspbattack.value)
|
||||
{
|
||||
return "spb-";
|
||||
}
|
||||
|
||||
const INT32 skinid = R_SkinAvailableEx(cv_skin[0].string, false);
|
||||
if (skinid >= 0 && (skins[skinid]->flags & SF_HIVOLT))
|
||||
{
|
||||
return "hivolt-";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void CV_SPBAttackChanged(void);
|
||||
void CV_SPBAttackChanged(void)
|
||||
{
|
||||
|
|
@ -275,14 +292,12 @@ void CV_SPBAttackChanged(void)
|
|||
{
|
||||
// see also p_setup.c's P_LoadRecordGhosts
|
||||
char *gpath = Z_StrDup(va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(levellist.choosemap+1)));
|
||||
const char *modeprefix = "";
|
||||
const char *modeprefix = M_GetRecordMode();
|
||||
UINT8 active;
|
||||
|
||||
if (!gpath)
|
||||
return;
|
||||
|
||||
if (cv_dummyspbattack.value)
|
||||
modeprefix = "spb-";
|
||||
|
||||
active = false;
|
||||
PLAY_TimeAttack[ta_guest].status = IT_DISABLED;
|
||||
|
|
@ -458,20 +473,7 @@ void M_ReplayTimeAttack(INT32 choice)
|
|||
{
|
||||
menudemo_t menudemo = {0};
|
||||
const char *which = NULL;
|
||||
const char *modeprefix = "";
|
||||
|
||||
if (cv_dummyspbattack.value)
|
||||
{
|
||||
modeprefix = "spb-";
|
||||
}
|
||||
else
|
||||
{
|
||||
const INT32 skinid = R_SkinAvailableEx(cv_skin[0].string, false);
|
||||
if (skinid >= 0 && (skins[skinid]->flags & SF_HIVOLT))
|
||||
{
|
||||
modeprefix = "hivolt-";
|
||||
}
|
||||
}
|
||||
const char *modeprefix = M_GetRecordMode();
|
||||
|
||||
switch (choice)
|
||||
{
|
||||
|
|
@ -528,20 +530,7 @@ static void M_WriteGuestReplay(INT32 ch)
|
|||
|
||||
gpath = Z_StrDup(va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(levellist.choosemap+1)));
|
||||
|
||||
const char *modeprefix = "";
|
||||
|
||||
if (cv_dummyspbattack.value)
|
||||
{
|
||||
modeprefix = "spb-";
|
||||
}
|
||||
else
|
||||
{
|
||||
const INT32 skinid = R_SkinAvailableEx(cv_skin[0].string, false);
|
||||
if (skinid >= 0 && (skins[skinid]->flags & SF_HIVOLT))
|
||||
{
|
||||
modeprefix = "hivolt-";
|
||||
}
|
||||
}
|
||||
const char *modeprefix = M_GetRecordMode();
|
||||
|
||||
if (TA_GuestReplay_Str != NULL)
|
||||
{
|
||||
|
|
@ -597,20 +586,7 @@ void M_SetGuestReplay(INT32 choice)
|
|||
break;
|
||||
}
|
||||
|
||||
const char *modeprefix = "";
|
||||
|
||||
if (cv_dummyspbattack.value)
|
||||
{
|
||||
modeprefix = "spb-";
|
||||
}
|
||||
else
|
||||
{
|
||||
const INT32 skinid = R_SkinAvailableEx(cv_skin[0].string, false);
|
||||
if (skinid >= 0 && (skins[skinid]->flags & SF_HIVOLT))
|
||||
{
|
||||
modeprefix = "hivolt-";
|
||||
}
|
||||
}
|
||||
const char *modeprefix = M_GetRecordMode();
|
||||
|
||||
if (FIL_FileExists(va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%sguest.lmp", srb2home, timeattackfolder, G_BuildMapName(levellist.choosemap+1), modeprefix)))
|
||||
{
|
||||
|
|
@ -626,7 +602,7 @@ void M_StartTimeAttack(INT32 choice)
|
|||
{
|
||||
char *gpath;
|
||||
char nameofdemo[256];
|
||||
const char *modeprefix = "";
|
||||
const char *modeprefix = M_GetRecordMode();
|
||||
|
||||
(void)choice;
|
||||
|
||||
|
|
@ -649,16 +625,6 @@ void M_StartTimeAttack(INT32 choice)
|
|||
{
|
||||
encoremode = true; // guarantees short wipe
|
||||
}
|
||||
|
||||
modeprefix = "spb-";
|
||||
}
|
||||
else
|
||||
{
|
||||
const INT32 skinid = R_SkinAvailableEx(cv_skin[0].string, false);
|
||||
if (skinid >= 0 && (skins[skinid]->flags & SF_HIVOLT))
|
||||
{
|
||||
modeprefix = "hivolt-";
|
||||
}
|
||||
}
|
||||
|
||||
// DON'T SOFTLOCK
|
||||
|
|
|
|||
|
|
@ -7841,24 +7841,11 @@ static void P_LoadRecordGhosts(void)
|
|||
{
|
||||
// see also /menus/play-local-race-time-attack.c's M_PrepareTimeAttack
|
||||
char *gpath;
|
||||
const char *modeprefix = "";
|
||||
const char *modeprefix = M_GetRecordMode();
|
||||
INT32 i;
|
||||
|
||||
gpath = Z_StrDup(va("%s" PATHSEP "media" PATHSEP "replay" PATHSEP "%s" PATHSEP "%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)));
|
||||
|
||||
if (encoremode)
|
||||
{
|
||||
modeprefix = "-spb";
|
||||
}
|
||||
else
|
||||
{
|
||||
const INT32 skinid = R_SkinAvailableEx(cv_skin[0].string, false);
|
||||
if (skinid >= 0 && (skins[skinid]->flags & SF_HIVOLT))
|
||||
{
|
||||
modeprefix = "-hivolt";
|
||||
}
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
kTime = 1 << 0,
|
||||
|
|
@ -7883,7 +7870,7 @@ static void P_LoadRecordGhosts(void)
|
|||
|
||||
auto add_ghosts = [gpath](const srb2::String& base, UINT8 bits)
|
||||
{
|
||||
auto load = [base](const char* suffix) { P_TryAddExternalGhost(fmt::format("{}-{}.lmp", base, suffix).c_str()); };
|
||||
auto load = [base](const char* suffix) { P_TryAddExternalGhost(fmt::format("{}{}.lmp", base, suffix).c_str()); };
|
||||
|
||||
if (bits & kTime)
|
||||
load("time-best");
|
||||
|
|
@ -7901,7 +7888,7 @@ static void P_LoadRecordGhosts(void)
|
|||
if (allGhosts)
|
||||
{
|
||||
for (i = 0; i < numskins; ++i)
|
||||
add_ghosts(fmt::format("{}-{}{}", gpath, skins[i]->name, modeprefix), allGhosts);
|
||||
add_ghosts(fmt::format("{}-{}-{}", gpath, skins[i]->name, modeprefix), allGhosts);
|
||||
}
|
||||
|
||||
if (sameGhosts)
|
||||
|
|
@ -7909,7 +7896,7 @@ static void P_LoadRecordGhosts(void)
|
|||
INT32 skin = R_SkinAvailableEx(cv_skin[0].string, false);
|
||||
if (skin < 0 || !R_SkinUsable(-1, skin, false))
|
||||
skin = 0; // use default skin
|
||||
add_ghosts(fmt::format("{}-{}{}", gpath, skins[skin]->name, modeprefix), sameGhosts);
|
||||
add_ghosts(fmt::format("{}-{}-{}", gpath, skins[skin]->name, modeprefix), sameGhosts);
|
||||
}
|
||||
|
||||
// Guest ghost
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue